Page MenuHomec4science

No OneTemporary

File Metadata

Created
Tue, Aug 27, 18:22
This file is larger than 256 KB, so syntax highlighting was skipped.
diff --git a/.flake8 b/.flake8
new file mode 100644
index 000000000..2d44c0a5f
--- /dev/null
+++ b/.flake8
@@ -0,0 +1,4 @@
+[flake8]
+max-line-length = 99
+per-file-ignores =
+ py_engine.py:E201,E202,E203,E501
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index cfd7fe344..bb9d8955f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,194 +1,197 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jun 14 2010
# @date last modification: Fri Jan 22 2016
#
# @brief main configuration file
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#-------------------------------------------------------------------------------
# _ _
# | | | |
# __ _| | ____ _ _ __ | |_ _ _
# / _` | |/ / _` | '_ \| __| | | |
# | (_| | < (_| | | | | |_| |_| |
# \__,_|_|\_\__,_|_| |_|\__|\__,_|
#
#===============================================================================
#===============================================================================
# CMake Project
#===============================================================================
cmake_minimum_required(VERSION 3.1.3)
# add this options before PROJECT keyword
set(CMAKE_DISABLE_SOURCE_CHANGES ON)
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
project(Akantu)
enable_language(CXX)
#===============================================================================
# Misc. config for cmake
#===============================================================================
set(AKANTU_CMAKE_DIR "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules")
set(BUILD_SHARED_LIBS ON CACHE BOOL "Build shared libraries.")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL
"Enable/Disable output of compile commands during generation" FORCE)
mark_as_advanced(BUILD_SHARED_LIBS)
if(NOT AKANTU_TARGETS_EXPORT)
set(AKANTU_TARGETS_EXPORT AkantuTargets)
endif()
include(CMakeVersionGenerator)
include(CMakePackagesSystem)
include(CMakeFlagsHandling)
include(AkantuPackagesSystem)
include(AkantuMacros)
include(AkantuCleaning)
#cmake_activate_debug_message()
#===============================================================================
# Version Number
#===============================================================================
# AKANTU version number. An even minor number corresponds to releases.
set(AKANTU_MAJOR_VERSION 3)
set(AKANTU_MINOR_VERSION 1)
set(AKANTU_PATCH_VERSION 0)
define_project_version()
#===============================================================================
# Options
#===============================================================================
# Debug
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG -DAKANTU_NDEBUG"
CACHE STRING "Flags used by the compiler during release builds" FORCE)
#add_flags(cxx "-Wall -Wextra -pedantic -Werror")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_flags(cxx "-Wall -Wextra -pedantic") # -Weffc++
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG_INIT} -ggdb3"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT} -ggdb3"
CACHE STRING "Flags used by the compiler during debug builds" FORCE)
else()
add_flags(cxx "-Wall")
endif()
option(AKANTU_EXAMPLES "Activate examples" OFF)
option(AKANTU_TESTS "Activate tests" OFF)
set(AKANTU_PREFERRED_PYTHON_VERSION 3 CACHE STRING "Preferred version for python related things")
mark_as_advanced(AKANTU_PREFERRED_PYTHON_VERSION)
include(AkantuExtraCompilationProfiles)
#===============================================================================
# Dependencies
#===============================================================================
declare_akantu_types()
package_list_packages(${PROJECT_SOURCE_DIR}/packages
EXTRA_PACKAGES_FOLDER ${PROJECT_SOURCE_DIR}/extra_packages
NO_AUTO_COMPILE_FLAGS)
## meta option \todo better way to do it when multiple package give enable the
## same feature
if(AKANTU_SCOTCH)
set(AKANTU_PARTITIONER ON)
else()
set(AKANTU_PARTITIONER OFF)
endif()
if(AKANTU_MUMPS)
set(AKANTU_SOLVER ON)
else()
set(AKANTU_SOLVER OFF)
endif()
#===============================================================================
# Akantu library
#===============================================================================
add_subdirectory(src)
#===============================================================================
# Documentation
#===============================================================================
if(AKANTU_DOCUMENTATION_DOXYGEN OR AKANTU_DOCUMENTATION_MANUAL)
add_subdirectory(doc)
else()
set(AKANTU_DOC_EXCLUDE_FILES "${PROJECT_SOURCE_DIR}/doc/manual" CACHE INTERNAL "")
endif()
#===============================================================================
# Python interface
#===============================================================================
package_is_activated(python_interface _python_act)
if(_python_act)
if(IS_ABSOLUTE "${CMAKE_INSTALL_PREFIX}")
set(AKANTU_PYTHON_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
else()
set(AKANTU_PYTHON_INSTALL_PREFIX "${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_PREFIX}")
endif()
add_subdirectory(python)
endif()
#===============================================================================
# Examples and tests
#===============================================================================
include(AkantuTestsMacros)
include(AkantuExampleMacros)
if(AKANTU_TESTS)
option(AKANTU_BUILD_ALL_TESTS "Build all tests" ON)
find_package(GMSH REQUIRED)
endif()
+# tests
+add_test_tree(test)
+
if(AKANTU_EXAMPLES)
+ if(AKANTU_TESTS)
+ option(AKANTU_TEST_EXAMPLES "Run the examples" ON)
+ endif()
find_package(GMSH REQUIRED)
add_subdirectory(examples)
endif()
-# tests
-add_test_tree(test)
-
#===============================================================================
# Install and Packaging
#===============================================================================
include(AkantuInstall)
option(AKANTU_DISABLE_CPACK
"This option commands the generation of extra info for the \"make package\" target" ON)
mark_as_advanced(AKANTU_DISABLE_CPACK)
if(NOT AKANTU_DISABLE_CPACK)
include(AkantuCPack)
endif()
diff --git a/Jenkinsfile b/Jenkinsfile
index 8921bb666..408ee0ef9 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -1,185 +1,184 @@
pipeline {
parameters {string(defaultValue: '', description: 'api-token', name: 'API_TOKEN')
string(defaultValue: '', description: 'buildable phid', name: 'BUILD_TARGET_PHID')
string(defaultValue: '', description: 'Commit id', name: 'COMMIT_ID')
string(defaultValue: '', description: 'Diff id', name: 'DIFF_ID')
+ string(defaultValue: 'PHID-PROJ-5eqyu6ooyjktagbhf473', description: 'ID of the project', name: 'PROJECT_ID')
}
options {
disableConcurrentBuilds()
+ //skipDefaultCheckout(true)
}
environment {
PHABRICATOR_HOST = 'https://c4science.ch/api/'
PYTHONPATH = sh returnStdout: true, script: 'echo ${WORKSPACE}/test/ci/script/'
BLA_VENDOR = 'OpenBLAS'
OMPI_MCA_plm = 'isolated'
OMPI_MCA_btl = 'tcp,self'
}
agent {
dockerfile {
filename 'Dockerfile'
dir 'test/ci'
additionalBuildArgs '--tag akantu-environment'
}
}
stages {
+ stage('Checkout proper commit') {
+ steps {
+ checkout scm: [$class: 'GitSCM',
+ branches: [[name: "${COMMIT_ID}" ]]
+ ], changelog: true
+ }
+ }
+
stage('Lint') {
steps {
sh """
- arc lint --output json --rev ${GIT_PREVIOUS_COMMIT}^1 | jq . -srM | tee lint.json
+ arc lint --output json --rev HEAD^ | jq . -srM | tee lint.json
./test/ci/scripts/hbm send-arc-lint -f lint.json
"""
}
}
+
stage('Configure') {
steps {
sh """#!/bin/bash
set -o pipefail
mkdir -p build
cd build
cmake -DAKANTU_COHESIVE_ELEMENT:BOOL=TRUE \
-DAKANTU_IMPLICIT:BOOL=TRUE \
-DAKANTU_PARALLEL:BOOL=TRUE \
+ -DAKANTU_STRUCTURAL_MECHANICS:BOOL=TRUE \
+ -DAKANTU_HEAT_TRANSFER:BOOL=TRUE \
+ -DAKANTU_DAMAGE_NON_LOCAL:BOOL=TRUE \
-DAKANTU_PYTHON_INTERFACE:BOOL=TRUE \
+ -DAKANTU_EXAMPLES:BOOL=TRUE \
+ -DAKANTU_BUILD_ALL_EXAMPLES:BOOL=TRUE \
+ -DAKANTU_TEST_EXAMPLES:BOOL=FALSE \
-DAKANTU_TESTS:BOOL=TRUE .. | tee configure.txt
"""
}
post {
failure {
uploadArtifact('configure.txt', 'Configure')
deleteDir()
}
}
}
+
stage('Compile') {
steps {
sh '''#!/bin/bash
set -o pipefail
make -C build/src | tee compilation.txt
'''
}
post {
failure {
uploadArtifact('compilation.txt', 'Compilation')
}
}
}
stage ('Warnings gcc') {
steps {
warnings(consoleParsers: [[parserName: 'GNU Make + GNU C Compiler (gcc)']])
}
}
stage('Compile python') {
steps {
sh '''#!/bin/bash
set -o pipefail
+
make -C build/python | tee compilation_python.txt
'''
}
post {
failure {
uploadArtifact('compilation_python.txt', 'Compilation_Python')
}
}
}
stage('Compile tests') {
steps {
sh '''#!/bin/bash
set -o pipefail
+
make -C build/test | tee compilation_test.txt
'''
}
post {
failure {
uploadArtifact('compilation_test.txt', 'Compilation_Tests')
}
}
}
stage('Tests') {
steps {
sh '''
#rm -rf build/gtest_reports
cd build/
#source ./akantu_environement.sh
ctest -T test --no-compress-output || true
+ tag=$(head -n 1 < Testing/TAG)
+ if [ -e Testing/${tag}/Test.xml ]; then
+ cp Testing/${tag}/Test.xml ../CTestResults.xml
+ fi
'''
}
- post {
- always {
- script {
- def TAG = sh returnStdout: true, script: 'head -n 1 < build/Testing/TAG'
- def TAG_ = TAG.trim()
-
- if (fileExists("build/Testing/${TAG}/Test.xml")) {
- sh "cp build/Testing/${TAG}/Test.xml CTestResults.xml"
- }
- }
- }
- }
+ //post {
+ //failure {
+ //zip zipFile: 'build.zip', dir: 'build/', archive: true
+ //}
+ //}
}
}
-
post {
always {
createArtifact("./CTestResults.xml")
-
+
step([$class: 'XUnitBuilder',
thresholds: [
[$class: 'SkippedThreshold', failureThreshold: '0'],
[$class: 'FailedThreshold', failureThreshold: '0']],
tools: [
[$class: 'CTestType', pattern: 'CTestResults.xml', skipNoTestFiles: true]
]])
-
- // step([$class: 'XUnitBuilder',
- // thresholds: [
- // [$class: 'SkippedThreshold', failureThreshold: '100'],
- // [$class: 'FailedThreshold', failureThreshold: '0']],
- // tools: [
- // [$class: 'GoogleTestType', pattern: 'build/gtest_reports/**', skipNoTestFiles: true]
- // ]])
}
success {
passed()
}
failure {
- // emailext(
- // body: '''${SCRIPT, template="groovy-html.template"}''',
- // mimeType: 'text/html',
- // subject: "[Jenkins] ${currentBuild.fullDisplayName} Failed",
- // recipientProviders: [[$class: 'CulpritsRecipientProvider']],
- // to: 'akantu-admins@akantu.ch',
- // replyTo: 'akantu-admins@akantu.ch',
- // attachLog: true,
- // compressLog: false)
failed()
}
}
}
def failed() {
sh "./test/ci/scripts/hbm failed"
}
def passed() {
sh "./test/ci/scripts/hbm passed"
}
-def createArtifact(artifact) {
+def createArtifact(filename) {
sh "./test/ci/scripts/hbm send-uri -k 'Jenkins URI' -u ${BUILD_URL} -l 'View Jenkins result'"
- sh "./test/ci/scripts/hbm send-ctest-results -f ${artifact}"
+ sh "./test/ci/scripts/hbm send-ctest-results -f ${filename}"
}
def uploadArtifact(artifact, name) {
- sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v PHID-PROJ-5eqyu6ooyjktagbhf473"
+ sh "./test/ci/scripts/hbm upload-file -f ${artifact} -n \"${name}\" -v ${PROJECT_ID}"
}
diff --git a/cmake/AkantuExampleMacros.cmake b/cmake/AkantuExampleMacros.cmake
index 1cb3c59c4..be0a5322a 100644
--- a/cmake/AkantuExampleMacros.cmake
+++ b/cmake/AkantuExampleMacros.cmake
@@ -1,103 +1,141 @@
#===============================================================================
# @file AkantuExampleMacros.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jan 18 2016
# @date last modification: Fri Jan 22 2016
#
# @brief macros for examples
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#
#===============================================================================
include(AkantuSimulationMacros)
# ==============================================================================
function(register_example example_name)
_add_akantu_simulation(${example_name} ${ARGN} LIST_FILES _example_files)
if(DEFINED _add_examples_pkg)
package_add_to_variable(EXAMPLES_FILES ${_add_examples_pkg} ${_example_files})
endif()
+
+ if(AKANTU_TEST_EXAMPLES)
+ cmake_parse_arguments(_example
+ "PYTHON;PARALLEL"
+ ""
+ "SCRIPT"
+ ${ARGN}
+ )
+
+ if(_example_PARALLEL)
+ set(_exe ${MPIEXEC})
+ if(NOT _exe)
+ set(_exe ${MPIEXEC_EXECUTABLE})
+ endif()
+ set(_parallel_runner ${_exe} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} 2)
+ endif()
+
+ if(NOT _example_SCRIPT)
+ add_test(NAME ${example_name}-test
+ COMMAND ${_parallel_runner} $<TARGET_FILE:${example_name}>
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ elseif(_example_SCRIPT)
+ if(_example_PYTHON)
+ add_test(NAME ${example_name}-test
+ COMMAND ${_parallel_runner} ${PYTHON_EXECUTABLE} ${_example_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ else()
+ set(_python_path ENV{PYTHON_PATH})
+ if (NOT _python_path MATCHES ${PROJECT_BINARY_DIR}/python)
+ set(ENV{PYTHON_PATH} "${_python_path}:${PROJECT_BINARY_DIR}/python")
+ endif()
+ add_test(NAME ${example_name}-test
+ COMMAND ${_parallel_runner} ${_example_SCRIPT}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ endif()
+ endif()
+ endif()
endfunction()
# ==============================================================================
function(add_example et_name desc)
string(TOUPPER ${et_name} upper_name)
if(NOT _build_all_ex)
option(AKANTU_BUILD_ALL_EXAMPLES "Activate all examples" OFF)
set( _build_all_ex TRUE)
endif()
option(AKANTU_BUILD_EXAMPLES_${upper_name} ${desc} OFF)
if(AKANTU_BUILD_ALL_EXAMPLES)
mark_as_advanced(FORCE AKANTU_BUILD_EXAMPLES_${upper_name})
else()
mark_as_advanced(CLEAR AKANTU_BUILD_EXAMPLES_${upper_name})
endif()
if(AKANTU_BUILD_EXAMPLES_${upper_name} OR AKANTU_BUILD_ALL_EXAMPLES)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${et_name})
message(FATAL_ERROR "The folder ${CMAKE_CURRENT_SOURCE_DIR}/${et_name} "
"that you try to register as an example sub-folder, does not exists.")
endif()
cmake_parse_arguments(_manage_example
""
""
"PACKAGE"
${ARGN}
)
if(_manage_example_PACKAGE)
set(_act TRUE)
foreach(_pkg ${_manage_example_PACKAGE})
package_is_activated(${_pkg} _activated)
if(NOT _activated)
set(_act FALSE)
endif()
endforeach()
else()
message(SEND_ERROR "Examples should be associated to a package")
endif()
if(_act)
if(DEFINED _add_examples_pkg)
set(_save_add_examples_pkg ${_add_examples_pkg})
endif()
list(GET _manage_example_PACKAGE 0 _pkg)
set(_add_examples_pkg ${_pkg})
add_subdirectory(${et_name})
unset(_add_examples_pkg)
if(DEFINED _save_add_examples_pkg)
set(_add_examples_pkg ${_save_add_examples_pkg})
unset(_save_add_examples_pkg)
endif()
endif()
endif()
endfunction()
diff --git a/cmake/AkantuMacros.cmake b/cmake/AkantuMacros.cmake
index bb41eca95..1d0ca8b57 100644
--- a/cmake/AkantuMacros.cmake
+++ b/cmake/AkantuMacros.cmake
@@ -1,245 +1,268 @@
#===============================================================================
# @file AkantuMacros.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Fri Oct 22 2010
# @date last modification: Tue Jan 19 2016
#
# @brief Set of macros used by akantu cmake files
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
#===============================================================================
function(set_third_party_shared_libirary_name _var _lib)
set(${_var}
${PROJECT_BINARY_DIR}/third-party/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${_lib}${CMAKE_SHARED_LIBRARY_SUFFIX}
CACHE FILEPATH "" FORCE)
endfunction()
+# ==============================================================================
+function(_add_file_to_copy target file)
+ get_filename_component(_file_name_we ${file} NAME_WE)
+ get_filename_component(_file_name_ext ${file} EXT)
+ get_filename_component(_file_name ${file} NAME)
+ get_filename_component(_file_path ${file}
+ ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+
+ set(copy_target copy_${_file_name_we}_${_file_name_ext}_${target})
+ add_custom_target(${copy_target}
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file_name})
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_name}
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different
+ ${file}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${_file_path}
+ COMMENT "Copying file ${_file_name} for the target ${target}"
+ )
+ add_dependencies(${target} ${copy_target})
+endfunction()
+
# ==============================================================================
function(get_target_list_of_associated_files tgt files)
if(TARGET ${tgt})
get_target_property(_type ${tgt} TYPE)
else()
set(_type ${tgt}-NOTFOUND)
endif()
if(_type STREQUAL "SHARED_LIBRARY"
OR _type STREQUAL "STATIC_LIBRARY"
OR _type STREQUAL "MODULE_LIBRARY"
OR _type STREQUAL "EXECUTABLE")
get_target_property(_srcs ${tgt} SOURCES)
set(_dep_ressources)
foreach(_file ${_srcs})
list(APPEND _dep_ressources ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
endforeach()
elseif(_type)
get_target_property(_dep_ressources ${tgt} RESSOURCES)
endif()
set(${files} ${_dep_ressources} PARENT_SCOPE)
endfunction()
#===============================================================================
# Generate the list of currently loaded materials
function(generate_material_list)
message(STATUS "Determining the list of recognized materials...")
package_get_all_include_directories(
AKANTU_LIBRARY_INCLUDE_DIRS
)
package_get_all_external_informations(
PRIVATE_INCLUDE AKANTU_PRIVATE_EXTERNAL_INCLUDE_DIR
INTERFACE_INCLUDE AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR
LIBRARIES AKANTU_EXTERNAL_LIBRARIES
)
set(_include_dirs
${AKANTU_INCLUDE_DIRS}
${AKANTU_PRIVATE_EXTERNAL_INCLUDE_DIR}
${AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR}
)
try_run(_material_list_run _material_list_compile
${CMAKE_BINARY_DIR}
${PROJECT_SOURCE_DIR}/cmake/material_lister.cc
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${_include_dirs}" "-DCMAKE_CXX_STANDARD=14"
COMPILE_DEFINITIONS "-DAKANTU_CMAKE_LIST_MATERIALS"
COMPILE_OUTPUT_VARIABLE _compile_results
RUN_OUTPUT_VARIABLE _result_material_list)
if(_material_list_compile AND "${_material_list_run}" EQUAL 0)
message(STATUS "Materials included in Akantu:")
string(REPLACE "\n" ";" _material_list "${_result_material_list}")
foreach(_mat ${_material_list})
string(REPLACE ":" ";" _mat_key "${_mat}")
list(GET _mat_key 0 _key)
list(GET _mat_key 1 _class)
list(LENGTH _mat_key _l)
if("${_l}" GREATER 2)
list(REMOVE_AT _mat_key 0 1)
set(_opt " -- options: [")
foreach(_o ${_mat_key})
set(_opt "${_opt} ${_o}")
endforeach()
set(_opt "${_opt} ]")
else()
set(_opt "")
endif()
message(STATUS " ${_class} -- key: ${_key}${_opt}")
endforeach()
else()
message(STATUS "Could not determine the list of materials.")
message("${_compile_results}")
endif()
endfunction()
#===============================================================================
# Declare the options for the types and defines the approriate typedefs
function(declare_akantu_types)
set(AKANTU_TYPE_FLOAT "double (64bit)" CACHE STRING "Precision force floating point types")
mark_as_advanced(AKANTU_TYPE_FLOAT)
set_property(CACHE AKANTU_TYPE_FLOAT PROPERTY STRINGS
"quadruple (128bit)"
"double (64bit)"
"float (32bit)"
)
set(AKANTU_TYPE_INTEGER "int (32bit)" CACHE STRING "Size of the integer types")
mark_as_advanced(AKANTU_TYPE_INTEGER)
set_property(CACHE AKANTU_TYPE_INTEGER PROPERTY STRINGS
"int (32bit)"
"long int (64bit)"
)
include(CheckTypeSize)
# ----------------------------------------------------------------------------
# Floating point types
# ----------------------------------------------------------------------------
if(AKANTU_TYPE_FLOAT STREQUAL "float (32bit)")
set(AKANTU_FLOAT_TYPE "float" CACHE INTERNAL "")
set(AKANTU_FLOAT_SIZE 4 CACHE INTERNAL "")
elseif(AKANTU_TYPE_FLOAT STREQUAL "double (64bit)")
set(AKANTU_FLOAT_TYPE "double" CACHE INTERNAL "")
set(AKANTU_FLOAT_SIZE 8 CACHE INTERNAL "")
elseif(AKANTU_TYPE_FLOAT STREQUAL "quadruple (128bit)")
check_type_size("long double" LONG_DOUBLE)
if(HAVE_LONG_DOUBLE)
set(AKANTU_FLOAT_TYPE "long double" CACHE INTERNAL "")
set(AKANTU_FLOAT_SIZE 16 CACHE INTERNAL "")
message("This feature is not tested and will most probably not compile")
else()
message(FATAL_ERROR "The type long double is not defined on your system")
endif()
else()
message(FATAL_ERROR "The float type is not defined")
endif()
include(CheckIncludeFileCXX)
include(CheckCXXSourceCompiles)
# ----------------------------------------------------------------------------
# Integer types
# ----------------------------------------------------------------------------
check_include_file_cxx(cstdint HAVE_CSTDINT)
if(NOT HAVE_CSTDINT)
check_include_file_cxx(stdint.h HAVE_STDINT_H)
if(HAVE_STDINT_H)
list(APPEND _int_include stdint.h)
endif()
else()
list(APPEND _int_include cstdint)
endif()
check_include_file_cxx(cstddef HAVE_CSTDDEF)
if(NOT HAVE_CSTDINT)
check_include_file_cxx(stddef.h HAVE_STDDEF_H)
if(HAVE_STDINT_H)
list(APPEND _int_include stddef.h)
endif()
else()
list(APPEND _int_include cstddef)
endif()
if(AKANTU_TYPE_INTEGER STREQUAL "int (32bit)")
set(AKANTU_INTEGER_SIZE 4 CACHE INTERNAL "")
check_type_size("int" INT)
if(INT EQUAL 4)
set(AKANTU_SIGNED_INTEGER_TYPE "int" CACHE INTERNAL "")
set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned int" CACHE INTERNAL "")
else()
check_type_size("int32_t" INT32_T LANGUAGE CXX)
if(HAVE_INT32_T)
set(AKANTU_SIGNED_INTEGER_TYPE "int32_t" CACHE INTERNAL "")
set(AKANTU_UNSIGNED_INTEGER_TYPE "uint32_t" CACHE INTERNAL "")
list(APPEND _extra_includes ${_int_include})
endif()
endif()
elseif(AKANTU_TYPE_INTEGER STREQUAL "long int (64bit)")
set(AKANTU_INTEGER_SIZE 8 CACHE INTERNAL "")
check_type_size("long int" LONG_INT)
if(LONG_INT EQUAL 8)
set(AKANTU_SIGNED_INTEGER_TYPE "long int" CACHE INTERNAL "")
set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned long int" CACHE INTERNAL "")
else()
check_type_size("long long int" LONG_LONG_INT)
if(HAVE_LONG_LONG_INT AND LONG_LONG_INT EQUAL 8)
set(AKANTU_SIGNED_INTEGER_TYPE "long long int" CACHE INTERNAL "")
set(AKANTU_UNSIGNED_INTEGER_TYPE "unsigned long long int" CACHE INTERNAL "")
else()
check_type_size("int64_t" INT64_T)
if(HAVE_INT64_T)
set(AKANTU_SIGNED_INTEGER_TYPE "int64_t" CACHE INTERNAL "")
set(AKANTU_UNSIGNED_INTEGER_TYPE "uint64_t" CACHE INTERNAL "")
list(APPEND _extra_includes ${_int_include})
endif()
endif()
endif()
else()
message(FATAL_ERROR "The integer type is not defined")
endif()
# ----------------------------------------------------------------------------
# includes
# ----------------------------------------------------------------------------
foreach(_inc ${_extra_includes})
set(_incs "#include <${_inc}>\n${_incs}")
endforeach()
set(AKANTU_TYPES_EXTRA_INCLUDES ${_incs} CACHE INTERNAL "")
endfunction()
function(mask_package_options prefix)
get_property(_list DIRECTORY PROPERTY VARIABLES)
foreach(_var ${_list})
if("${_var}" MATCHES "^${prefix}.*")
mark_as_advanced(${_var})
endif()
endforeach()
endfunction()
diff --git a/cmake/AkantuSimulationMacros.cmake b/cmake/AkantuSimulationMacros.cmake
index f4711a0fd..3881b1fdf 100644
--- a/cmake/AkantuSimulationMacros.cmake
+++ b/cmake/AkantuSimulationMacros.cmake
@@ -1,176 +1,186 @@
#===============================================================================
# @file AkantuSimulationMacros.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jan 18 2016
# @date last modification: Wed Jan 20 2016
#
# @brief macros for examples
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#
#===============================================================================
if(__AKANTU_SIMULATION_MACROS)
return()
endif()
set(__AKANTU_SIMULATION_MACROS TRUE)
#===============================================================================
function(add_akantu_simulation simulation_name)
_add_akantu_simulation(${simulation_name} ${ARGN})
endfunction()
#===============================================================================
function(_add_akantu_simulation simulation_name)
set(multi_variables
SCRIPT
SOURCES
FILES_TO_COPY
DEPENDS
DIRECTORIES_TO_CREATE
COMPILE_OPTIONS
USE_PACKAGES
)
cmake_parse_arguments(_simulation
- ""
+ "PYTHON;PARALLEL"
"LIST_FILES"
"${multi_variables}"
${ARGN}
)
set(_deps_OK TRUE)
+ if(_simulation_PYTHON)
+ list(APPEND _simulation_USE_PACKAGES python_interface)
+ endif()
+
if(_simulation_USE_PACKAGES)
foreach(_pkg ${_simulation_USE_PACKAGES})
package_is_activated(${_pkg} _activated)
if(_activated)
package_get_include_dir(${_pkg} _inc_dir)
list(APPEND _simulation_INCLUDE_DIRS ${_inc_dir})
package_get_libraries(${_pkg} _libraries)
list(APPEND _simulation_LIBRARIES ${_libraries})
package_get_compile_flags(${_pkg} CXX _flags)
list(APPEND _simulation_COMPILE_FLAGS "${_flags}")
else()
message("${simulation_name} use ${_pkg} but Akantu "
" has been compiled without this package")
set(_deps_OK FALSE)
endif()
endforeach()
endif()
- package_is_activated(CORE_CXX11 _activated)
- if(_activated)
- package_get_compile_flags(CORE_CXX11 CXX _flags)
- list(APPEND _simulation_COMPILE_FLAGS "${_flags}")
- endif()
-
package_get_compile_flags(BOOST CXX _flags)
list(APPEND _simulation_COMPILE_FLAGS "${_flags}")
package_get_include_dir(BOOST _boost_include_dir)
string(REPLACE ";" " " _tmp_flags "${_simulation_COMPILE_FLAGS}")
string(REGEX REPLACE " +" " " _simulation_COMPILE_FLAGS "${_tmp_flags}")
if(_deps_OK)
if(_simulation_UNPARSED_ARGUMENTS OR _simulation_SOURCES)
add_executable(${simulation_name}
${_simulation_UNPARSED_ARGUMENTS} ${_simulation_SOURCES})
target_link_libraries(${simulation_name}
PRIVATE akantu ${_simulation_LIBRARIES})
target_include_directories(${simulation_name}
PRIVATE
${AKANTU_INCLUDE_DIRS}
${_boost_include_dir}
${_simulation_INCLUDE_DIRS})
if(_simulation_DEPENDS)
foreach(_deps ${_simulation_DEPENDS})
get_target_property(_type ${_deps} TYPE)
if(_type STREQUAL "SHARED_LIBRARY"
OR _type STREQUAL "STATIC_LIBRARY")
target_link_libraries(${simulation_name} PRIVATE ${_deps})
else()
add_dependencies(${simulation_name} ${_deps})
endif()
endforeach()
endif()
if(_simulation_COMPILE_OPTIONS)
set_target_properties(${simulation_name}
PROPERTIES COMPILE_DEFINITIONS "${_simulation_COMPILE_OPTIONS}")
endif()
if(_simulation_COMPILE_FLAGS)
set_target_properties(${simulation_name}
PROPERTIES COMPILE_FLAGS "${_simulation_COMPILE_FLAGS}")
endif()
endif()
if(_simulation_SCRIPT)
- file(COPY ${_simulation_SCRIPT} DESTINATION .)
+ add_custom_target(${simulation_name} ALL
+ COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_simulation_SCRIPT} ${CMAKE_CURRENT_BINARY_DIR}
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ BYPRODUCTS ${CMAKE_CURRENT_BINARY_DIR}/${_simulation_SCRIPT}
+ DEPENDS ${_simulation_SCRIPT}
+ )
+
+
+ if(_simulation_DEPENDS)
+ foreach(_deps ${_simulation_DEPENDS})
+ add_dependencies(${simulation_name} ${_deps})
+ endforeach()
+ endif()
endif()
# copy the needed files to the build folder
if(_simulation_FILES_TO_COPY)
file(COPY ${_simulation_FILES_TO_COPY} DESTINATION .)
endif()
# create the needed folders in the build folder
if(_simulation_DIRECTORIES_TO_CREATE)
foreach(_dir ${_simulation_DIRECTORIES_TO_CREATE})
if(IS_ABSOLUTE ${dir})
file(MAKE_DIRECTORY ${_dir})
else()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${_dir})
endif()
endforeach()
endif()
endif()
if(_simulation_LIST_FILES)
set(_simulation_files)
foreach(_file ${_simulation_SCRIPT} ${_simulation_SOURCES}
${_simulation_UNPARSED_ARGUMENTS} ${_simulation_FILES_TO_COPY})
list(APPEND _simulation_files ${CMAKE_CURRENT_SOURCE_DIR}/${_file})
endforeach()
foreach(_dep ${_simulation_DEPENDS})
get_target_list_of_associated_files(${_dep} _dep_ressources)
if(_dep_ressources)
list(APPEND _simulation_files "${_dep_ressources}")
endif()
endforeach()
set(${_simulation_LIST_FILES} ${_simulation_files} PARENT_SCOPE)
endif()
endfunction()
diff --git a/cmake/AkantuTestsMacros.cmake b/cmake/AkantuTestsMacros.cmake
index 250c6f430..520f40e38 100644
--- a/cmake/AkantuTestsMacros.cmake
+++ b/cmake/AkantuTestsMacros.cmake
@@ -1,667 +1,648 @@
#===============================================================================
# @file AkantuTestsMacros.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Fri Sep 03 2010
# @date last modification: Fri Jan 22 2016
#
# @brief macros for tests
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
#[=======================================================================[.rst:
AkantuTestsMacros
-----------------
This modules provides the functions to helper to declare tests and folders
containing tests in akantu
.. command:: add_test_tree
add_test_tree(<test_direcotry>)
``<test_directory>`` is the entry direcroty of the full structure of
subfolders containing tests
.. command:: add_akantu_test
add_akantu_test(<dir> <desc>)
This function add a subdirectory ``<dir>`` of tests that will be conditionnaly
activable and will be visible only if the parent folder as been activated An
option ``AKANTU_BUILD_TEST_<dir>`` will appear in ccmake with the description
``<desc>``. The compilation of all tests can be forced with the option
``AKANTU_BUILD_ALL_TESTS``
.. command:: register_test
register_test(<test_name>
SOURCES <sources>...
PACKAGE <akantu_packages>...
SCRIPT <scirpt>
[FILES_TO_COPY <filenames>...]
[DEPENDS <targets>...]
[DIRECTORIES_TO_CREATE <directories>...]
[COMPILE_OPTIONS <flags>...]
[EXTRA_FILES <filnames>...]
[LINK_LIBRARIES <libraries>...]
[INCLUDE_DIRECTORIES <include>...]
[UNSABLE]
[PARALLEL]
[PARALLEL_LEVEL <procs>...]
)
This function defines a test ``<test_name>_run`` this test could be of
different nature depending on the context. If Just sources are provided the
test consist of running the executable generated. If a file ``<test_name>.sh``
is present the test will execute the script. And if a ``<test_name>.verified``
exists the output of the test will be compared to this reference file
The options are:
``SOURCES <sources>...``
The list of source files to compile to generate the executable of the test
``PACKAGE <akantu_packages>...``
The list of package to which this test belongs. The test will be activable
only of all the packages listed are activated
``SCRIPT <script>``
The script to execute instead of the executable
``FILES_TO_COPY <filenames>...``
List of files to copy from the source directory to the build directory
``DEPENDS <targets>...``
List of targets the test depends on, for example if a mesh as to be generated
``DIRECTORIES_TO_CREATE <directories>...``
Obsolete. This specifies a list of directories that have to be created in
the build folder
``COMPILE_OPTIONS <flags>...``
List of extra compilations options to pass to the compiler
``EXTRA_FILES <filnames>...``
Files to consider when generating a package_source
``UNSABLE``
If this option is specified the test can be unacitivated by the glocal option
``AKANTU_BUILD_UNSTABLE_TESTS``, this is mainly intendeed to remove test
under developement from the continious integration
``PARALLEL``
This specifies that this test should be run in parallel. It will generate a
series of test for different number of processors. This automaticaly adds a
dependency to the package ``AKANTU_PARALLEL``
``PARALLEL_LEVEL``
This defines the different processor numbers to use, if not defined the
macro tries to determine it in a "clever" way
]=======================================================================]
set(AKANTU_DRIVER_SCRIPT ${AKANTU_CMAKE_DIR}/akantu_test_driver.sh)
-function(_add_file_to_copy target file)
- get_filename_component(_file_name_we ${file} NAME_WE)
- get_filename_component(_file_name ${file} NAME)
- get_filename_component(_file_path ${file}
- ABSOLUTE BASE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-
- set(copy_target copy_${_file_name_we}_${target})
- add_custom_target(${copy_target}
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_file_name})
- add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_file_name}
- COMMAND ${CMAKE_COMMAND} -E copy_if_different
- ${file}
- ${CMAKE_CURRENT_BINARY_DIR}
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${_file_path}
- COMMENT "Copying file ${_file_name} for the target ${target}"
- )
- add_dependencies(${target} ${copy_target})
-endfunction()
-
# ==============================================================================
macro(add_test_tree dir)
if(AKANTU_TESTS)
enable_testing()
include(CTest)
mark_as_advanced(BUILD_TESTING)
set(_akantu_current_parent_test ${dir} CACHE INTERNAL "Current test folder" FORCE)
set(_akantu_${dir}_tests_count 0 CACHE INTERNAL "" FORCE)
string(TOUPPER ${dir} _u_dir)
set(AKANTU_BUILD_${_u_dir} ON CACHE INTERNAL "${desc}" FORCE)
package_get_all_test_folders(_test_dirs)
foreach(_dir ${_test_dirs})
add_subdirectory(${_dir})
endforeach()
endif()
endmacro()
set(_test_flags
UNSTABLE
PARALLEL
PYTHON
GTEST
HEADER_ONLY
)
set(_test_one_variables
POSTPROCESS
SCRIPT
)
set(_test_multi_variables
SOURCES
FILES_TO_COPY
DEPENDS
DIRECTORIES_TO_CREATE
COMPILE_OPTIONS
EXTRA_FILES
LINK_LIBRARIES
INCLUDE_DIRECTORIES
PACKAGE
PARALLEL_LEVEL
)
# ==============================================================================
function(add_akantu_test dir desc)
if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${dir})
return()
endif()
set(_my_parent_dir ${_akantu_current_parent_test})
# initialize variables
set(_akantu_current_parent_test ${dir} CACHE INTERNAL "Current test folder" FORCE)
set(_akantu_${dir}_tests_count 0 CACHE INTERNAL "" FORCE)
# set the option for this directory
string(TOUPPER ${dir} _u_dir)
option(AKANTU_BUILD_${_u_dir} "${desc}")
mark_as_advanced(AKANTU_BUILD_${_u_dir})
# add the sub-directory
add_subdirectory(${dir})
# if no test can be activated make the option disappear
set(_force_deactivate_count FALSE)
if(${_akantu_${dir}_tests_count} EQUAL 0)
set(_force_deactivate_count TRUE)
endif()
# if parent off make the option disappear
set(_force_deactivate_parent FALSE)
string(TOUPPER ${_my_parent_dir} _u_parent_dir)
if(NOT AKANTU_BUILD_${_u_parent_dir})
set(_force_deactivate_parent TRUE)
endif()
if(_force_deactivate_parent OR _force_deactivate_count OR AKANTU_BUILD_ALL_TESTS)
if(NOT DEFINED _AKANTU_BUILD_${_u_dir}_SAVE)
set(_AKANTU_BUILD_${_u_dir}_SAVE ${AKANTU_BUILD_${_u_dir}} CACHE INTERNAL "" FORCE)
endif()
unset(AKANTU_BUILD_${_u_dir} CACHE)
if(AKANTU_BUILD_ALL_TESTS AND NOT _force_deactivate_count)
set(AKANTU_BUILD_${_u_dir} ON CACHE INTERNAL "${desc}" FORCE)
else()
set(AKANTU_BUILD_${_u_dir} OFF CACHE INTERNAL "${desc}" FORCE)
endif()
else()
if(DEFINED _AKANTU_BUILD_${_u_dir}_SAVE)
unset(AKANTU_BUILD_${_u_dir} CACHE)
set(AKANTU_BUILD_${_u_dir} ${_AKANTU_BUILD_${_u_dir}_SAVE} CACHE BOOL "${desc}")
unset(_AKANTU_BUILD_${_u_dir}_SAVE CACHE)
endif()
endif()
# adding up to the parent count
math(EXPR _tmp_parent_count "${_akantu_${dir}_tests_count} + ${_akantu_${_my_parent_dir}_tests_count}")
set(_akantu_${_my_parent_dir}_tests_count ${_tmp_parent_count} CACHE INTERNAL "" FORCE)
# restoring the parent current dir
set(_akantu_current_parent_test ${_my_parent_dir} CACHE INTERNAL "Current test folder" FORCE)
endfunction()
function(is_test_active is_active)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
if(NOT _register_test_PACKAGE)
message(FATAL_ERROR "No reference package was defined for the test"
" ${test_name} in folder ${CMAKE_CURRENT_SOURCE_DIR}")
endif()
if(_register_test_PYTHON)
list(APPEND _register_test_PACKAGE python_interface)
endif()
set(_test_act TRUE)
# Activate the test anly if all packages associated to the test are activated
foreach(_package ${_register_test_PACKAGE})
package_is_activated(${_package} _act)
if(NOT _act)
set(_test_act FALSE)
endif()
endforeach()
# check if the test is marked unstable and if the unstable test should be run
if(_register_test_UNSTABLE AND NOT AKANTU_BUILD_UNSTABLE_TESTS)
set(_test_act FALSE)
endif()
if(_test_act)
# todo this should be checked for the build package_sources since the file will not be listed.
math(EXPR _tmp_parent_count "${_akantu_${_akantu_current_parent_test}_tests_count} + 1")
set(_akantu_${_akantu_current_parent_test}_tests_count ${_tmp_parent_count} CACHE INTERNAL "" FORCE)
endif()
string(TOUPPER ${_akantu_current_parent_test} _u_parent)
if(NOT (AKANTU_BUILD_${_u_parent} OR AKANTU_BUILD_ALL_TESTS))
set(_test_act FALSE)
endif()
set(${is_active} ${_test_act} PARENT_SCOPE)
endfunction()
# ------------------------------------------------------------------------------
function(register_gtest_sources)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
is_test_active(_is_active ${ARGN})
register_test_files_to_package(${ARGN})
if(NOT _is_active)
return()
endif()
if(_register_test_PACKAGE)
set(_list ${_gtest_PACKAGE})
list(APPEND _list ${_register_test_PACKAGE})
list(REMOVE_DUPLICATES _list)
set(_gtest_PACKAGE ${_list} PARENT_SCOPE)
endif()
foreach (_var ${_test_flags})
if(_var STREQUAL "HEADER_ONLY")
if(NOT DEFINED_register_test_${_var})
set(_gtest_${_var} OFF PARENT_SCOPE)
elseif(NOT DEFINED _gtest_${_var})
set(_gtest_${_var} ON PARENT_SCOPE)
endif()
continue()
endif()
if(_register_test_${_var})
set(_gtest_${_var} ON PARENT_SCOPE)
else()
if(_gtest_${_var})
message("Another gtest file required ${_var} to be ON it will be globally set for this folder...")
endif()
endif()
endforeach()
if(_register_test_UNPARSED_ARGUMENTS)
list(APPEND _register_test_SOURCES ${_register_test_UNPARSED_ARGUMENTS})
endif()
foreach (_var ${_test_multi_variables})
if(_register_test_${_var})
set(_list ${_gtest_${_var}})
list(APPEND _list ${_register_test_${_var}})
list(REMOVE_DUPLICATES _list)
set(_gtest_${_var} ${_list} PARENT_SCOPE)
endif()
endforeach()
endfunction()
# ==============================================================================
function(akantu_pybind11_add_module target)
package_is_activated(pybind11 _pybind11_act)
if(_pybind11_act)
package_get_all_external_informations(
INTERFACE_INCLUDE AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR
)
pybind11_add_module(${target} ${ARGN})
+ target_link_libraries(${target} PRIVATE pyakantu)
target_include_directories(${target} SYSTEM PRIVATE ${PYBIND11_INCLUDE_DIR}
${AKANTU_INTERFACE_EXTERNAL_INCLUDE_DIR})
set_property(TARGET ${target} PROPERTY DEBUG_POSTFIX "")
endif()
endfunction()
# ==============================================================================
function(register_gtest_test test_name)
if(NOT _gtest_PACKAGE)
return()
endif()
set(_argn ${test_name}_gtest)
set(_link_libraries GTest::GTest GTest::Main)
list(FIND _gtest_PACKAGE python_interface _pos)
package_is_activated(python_interface _python_interface_act)
if(_python_interface_act AND (NOT _pos EQUAL -1))
list(APPEND _link_libraries pybind11::embed)
set(_compile_flags COMPILE_OPTIONS "AKANTU_TEST_USE_PYBIND11")
endif()
is_test_active(_is_active ${ARGN} PACKAGE ${_gtest_PACKAGE})
if(NOT _is_active)
return()
endif()
register_gtest_sources(${ARGN}
SOURCES ${PROJECT_SOURCE_DIR}/test/test_gtest_main.cc
LINK_LIBRARIES ${_link_libraries}
PACKAGE ${_gtest_PACKAGE}
${_compile_flags}
)
foreach (_var ${_test_flags})
if(_gtest_${_var})
list(APPEND _argn ${_var})
unset(_gtest_${_var})
endif()
endforeach()
foreach (_var ${_test_multi_variables})
if(_gtest_${_var})
list(APPEND _argn ${_var} ${_gtest_${_var}})
unset(_gtest_${_var})
endif()
endforeach()
register_test(${_argn} GTEST)
target_include_directories(${test_name}_gtest PRIVATE ${PROJECT_SOURCE_DIR}/test)
endfunction()
# ==============================================================================
function(register_test test_name)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
register_test_files_to_package(${ARGN})
is_test_active(_test_act ${ARGN})
if(NOT _test_act)
return()
endif()
set(_extra_args)
# check that the sources are files that need to be compiled
if(_register_test_SOURCES} OR _register_test_UNPARSED_ARGUMENTS)
set(_need_to_compile TRUE)
else()
set(_need_to_compile FALSE)
endif()
set(_compile_source)
foreach(_file ${_register_test_SOURCES} ${_register_test_UNPARSED_ARGUMENTS})
if(_file MATCHES "\\.cc$" OR _file MATCHES "\\.hh$")
list(APPEND _compile_source ${_file})
endif()
endforeach()
if(_compile_source)
# get the include directories for sources in activated directories
package_get_all_include_directories(
AKANTU_LIBRARY_INCLUDE_DIRS
)
# get the external packages compilation and linking informations
package_get_all_external_informations(
INTERFACE_INCLUDE AKANTU_EXTERNAL_INCLUDE_DIR
)
foreach(_pkg ${_register_test_PACKAGE})
package_get_nature(${_pkg} _nature)
if(_nature MATCHES "^external.*")
package_get_include_dir(${_pkg} _incl)
package_get_libraries(${_pkg} _libs)
list(APPEND _register_test_INCLUDE_DIRECTORIES ${_incl})
list(APPEND _register_test_LINK_LIBRARIES ${_libs})
endif()
endforeach()
# Register the executable to compile
add_executable(${test_name} ${_compile_source})
# set the proper includes to build most of the tests
target_include_directories(${test_name}
PRIVATE ${AKANTU_LIBRARY_INCLUDE_DIRS}
${AKANTU_EXTERNAL_INCLUDE_DIR}
${PROJECT_BINARY_DIR}/src
${_register_test_INCLUDE_DIRECTORIES})
if(NOT _register_test_HEADER_ONLY)
target_link_libraries(${test_name} PRIVATE akantu ${_register_test_LINK_LIBRARIES})
else()
get_target_property(_features akantu INTERFACE_COMPILE_FEATURES)
target_link_libraries(${test_name} ${_register_test_LINK_LIBRARIES})
target_compile_features(${test_name} PRIVATE ${_features})
endif()
# add the extra compilation options
if(_register_test_COMPILE_OPTIONS)
set_target_properties(${test_name}
PROPERTIES COMPILE_DEFINITIONS "${_register_test_COMPILE_OPTIONS}")
endif()
if(AKANTU_EXTRA_CXX_FLAGS)
set_target_properties(${test_name}
PROPERTIES COMPILE_FLAGS "${AKANTU_EXTRA_CXX_FLAGS}")
endif()
else()
add_custom_target(${test_name} ALL)
if(_register_test_UNPARSED_ARGUMENTS AND NOT _register_test_SCRIPT)
set(_register_test_SCRIPT ${_register_test_UNPARSED_ARGUMENTS})
endif()
endif()
if(_register_test_DEPENDS)
add_dependencies(${test_name} ${_register_test_DEPENDS})
endif()
# copy the needed files to the build folder
if(_register_test_FILES_TO_COPY)
foreach(_file ${_register_test_FILES_TO_COPY})
_add_file_to_copy(${test_name} "${_file}")
endforeach()
endif()
# create the needed folders in the build folder
if(_register_test_DIRECTORIES_TO_CREATE)
foreach(_dir ${_register_test_DIRECTORIES_TO_CREATE})
if(IS_ABSOLUTE ${dir})
file(MAKE_DIRECTORY "${_dir}")
else()
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_dir}")
endif()
endforeach()
endif()
# register the test for ctest
set(_arguments -n "${test_name}")
if(_register_test_SCRIPT)
_add_file_to_copy(${test_name} ${_register_test_SCRIPT})
if(_register_test_PYTHON)
if(NOT PYTHONINTERP_FOUND)
find_package(PythonInterp ${AKANTU_PREFERRED_PYTHON_VERSION} REQUIRED)
endif()
list(APPEND _arguments -e "${PYTHON_EXECUTABLE}")
list(APPEND _extra_args "${_register_test_SCRIPT}")
+ add_dependencies(${test_name} py11_akantu)
else()
list(APPEND _arguments -e "./${_register_test_SCRIPT}")
endif()
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.sh")
_add_file_to_copy(${test_name} ${test_name}.sh)
list(APPEND _arguments -e "./${test_name}.sh")
else()
list(APPEND _arguments -e "./${test_name}")
endif()
if(_register_test_GTEST)
list(APPEND _extra_args "--" "--gtest_output=xml:${PROJECT_BINARY_DIR}/gtest_reports/${test_name}.xml")
endif()
list(APPEND _arguments -E "${PROJECT_BINARY_DIR}/akantu_environement.sh")
package_is_activated(parallel _is_parallel)
if(_is_parallel AND AKANTU_TESTS_ALWAYS_USE_MPI AND NOT _register_test_PARALLEL)
set(_register_test_PARALLEL TRUE)
set(_register_test_PARALLEL_LEVEL 1)
endif()
if(_register_test_PARALLEL AND _is_parallel)
set(_exe ${MPIEXEC})
if(NOT _exe)
set(_exe ${MPIEXEC_EXECUTABLE})
endif()
list(APPEND _arguments -p "${_exe} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG}")
if(_register_test_PARALLEL_LEVEL)
set(_procs "${_register_test_PARALLEL_LEVEL}")
elseif(CMAKE_VERSION VERSION_GREATER "3.0")
set(_procs)
include(ProcessorCount)
ProcessorCount(N)
while(N GREATER 1)
list(APPEND _procs ${N})
math(EXPR N "${N} / 2")
endwhile()
list(APPEND _procs 1)
endif()
if(NOT _procs)
set(_procs 2)
endif()
endif()
if(_register_test_POSTPROCESS)
list(APPEND _arguments -s "${_register_test_POSTPROCESS}")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/${_register_test_POSTPROCESS}
FILE_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
endif()
list(APPEND _arguments -w "${CMAKE_CURRENT_BINARY_DIR}")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.verified")
list(APPEND _arguments -r "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.verified")
endif()
string(REPLACE ";" " " _command "${_arguments}")
# register them test
if(_procs)
foreach(p ${_procs})
add_test(NAME ${test_name}_${p} COMMAND ${AKANTU_DRIVER_SCRIPT} ${_arguments} -N ${p} ${_extra_args})
set_property(TEST ${test_name}_${p} PROPERTY PROCESSORS ${p})
endforeach()
else()
add_test(NAME ${test_name} COMMAND ${AKANTU_DRIVER_SCRIPT} ${_arguments} ${_extra_args})
set_property(TEST ${test_name} PROPERTY PROCESSORS 1)
endif()
endfunction()
function(register_test_files_to_package)
cmake_parse_arguments(_register_test
"${_test_flags}"
"${_test_one_variables}"
"${_test_multi_variables}"
${ARGN}
)
if(_register_test_PYTHON)
list(APPEND _register_test_PACKAGE python_interface)
endif()
set(_test_all_files)
# add the source files in the list of all files
foreach(_file ${_register_test_SOURCES} ${_register_test_UNPARSED_ARGUMENTS}
${_register_test_EXTRA_FILES} ${_register_test_SOURCES} ${_register_test_SCRIPT}
${_register_test_POSTPROCESS} ${_register_test_FILES_TO_COPY})
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${_file} OR EXISTS ${_file})
list(APPEND _test_all_files "${_file}")
else()
message("The file \"${_file}\" registred by the test \"${test_name}\" does not exists")
endif()
endforeach()
# add the different dependencies files (meshes, local libraries, ...)
foreach(_dep ${_register_test_DEPENDS})
get_target_list_of_associated_files(${_dep} _dep_ressources)
if(_dep_ressources)
list(APPEND _test_all_files "${_dep_ressources}")
endif()
endforeach()
# add extra files to the list of files referenced by a given test
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.sh")
list(APPEND _test_all_files "${test_name}.sh")
endif()
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${test_name}.verified")
list(APPEND _test_all_files "${test_name}.verified")
endif()
if(_register_test_SCRIPT)
list(APPEND _test_all_files "${_register_test_SCRIPT}")
endif()
# clean the list of all files for this test and add them in the total list
foreach(_file ${_test_all_files})
get_filename_component(_full ${_file} ABSOLUTE)
file(RELATIVE_PATH __file ${PROJECT_SOURCE_DIR} ${_full})
list(APPEND _tmp "${__file}")
endforeach()
foreach(_pkg ${_register_test_PACKAGE})
package_get_name(${_pkg} _pkg_name)
_package_add_to_variable(TESTS_FILES ${_pkg_name} ${_tmp})
endforeach()
endfunction()
diff --git a/cmake/Modules/FindGMSH.cmake b/cmake/Modules/FindGMSH.cmake
index 5f20554cf..4661bc8ac 100644
--- a/cmake/Modules/FindGMSH.cmake
+++ b/cmake/Modules/FindGMSH.cmake
@@ -1,102 +1,110 @@
#===============================================================================
# @file FindGMSH.cmake
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Dec 08 2014
# @date last modification: Tue Jan 19 2016
#
# @brief Find gmsh and delacre the add_mesh macro
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
find_program(GMSH gmsh
DOC "The mesh generetor gmsh")
mark_as_advanced(GMSH)
if (GMSH)
execute_process(COMMAND ${GMSH} --version
ERROR_VARIABLE GMSH_VERSION
ERROR_STRIP_TRAILING_WHITESPACE)
endif()
find_package(PackageHandleStandardArgs)
find_package_handle_standard_args(GMSH
REQUIRED_VARS GMSH
VERSION_VAR GMSH_VERSION)
#===============================================================================
function(ADD_MESH MESH_TARGET GEO_FILE)
if(NOT GMSH_FOUND)
return()
endif()
set(arguments
${MESH_TARGET} ${GEO_FILE}
${ARGN}
)
cmake_parse_arguments(_add_mesh
""
"OUTPUT;DIM;ORDER"
""
${arguments}
)
if(NOT _add_mesh_DIM AND NOT _add_mesh_ORDER)
list(GET _add_mesh_UNPARSED_ARGUMENTS 2 _add_mesh_DIM)
list(GET _add_mesh_UNPARSED_ARGUMENTS 3 _add_mesh_ORDER)
endif()
+ if(NOT _add_mesh_DIM)
+ set(_add_mesh_DIM 3)
+ endif()
+
+ if(NOT _add_mesh_ORDER)
+ set(_add_mesh_ORDER 1)
+ endif()
+
set(_geo_file ${CMAKE_CURRENT_SOURCE_DIR}/${GEO_FILE})
set(_r_geo_file "${GEO_FILE}")
if(_add_mesh_OUTPUT)
set(_msh_file ${CMAKE_CURRENT_BINARY_DIR}/${_add_mesh_OUTPUT})
set(_r_msh_file "${_add_mesh_OUTPUT}")
else(_add_mesh_OUTPUT)
get_filename_component(_msh_file "${GEO_FILE}" NAME_WE)
set(_r_msh_file "${_msh_file}.msh")
set(_msh_file ${CMAKE_CURRENT_BINARY_DIR}/${_msh_file}.msh)
endif(_add_mesh_OUTPUT)
if(GMSH_VERSION VERSION_LESS 3.0.0)
set(OPTIMIZE -optimize)
endif()
if(EXISTS ${_geo_file})
add_custom_command(
OUTPUT ${_msh_file}
DEPENDS ${_geo_file}
COMMAND ${GMSH}
ARGS -${_add_mesh_DIM} -order ${_add_mesh_ORDER} ${OPTIMIZE} -o ${_msh_file} ${_geo_file} 2>&1 > /dev/null
COMMENT "Generating the ${_add_mesh_DIM}D mesh ${_r_msh_file} (order ${_add_mesh_ORDER}) form the geometry ${_r_geo_file}"
)
add_custom_target(${MESH_TARGET}
DEPENDS ${_msh_file})
set_target_properties(${MESH_TARGET} PROPERTIES RESSOURCES ${_geo_file})
else(EXISTS ${_geo_file})
message(WARNING
"File ${_geo_file} not found for target ${MESH_TARGET}")
endif(EXISTS ${_geo_file})
endfunction()
diff --git a/cmake/libakantu/v3/printers.py b/cmake/libakantu/v3/printers.py
index b85a16fef..4ec724d58 100755
--- a/cmake/libakantu/v3/printers.py
+++ b/cmake/libakantu/v3/printers.py
@@ -1,384 +1,392 @@
#!/usr/bin/env python3
# encoding: utf-8
#
# Inspired from boost's pretty printers from
# Rüdiger Sonderfeld <ruediger@c-plusplus.de>
# and from Pretty-printers for libstc++ from Free Software Foundation, Inc.
#
import gdb
import re
import sys
import itertools
__use_gdb_pp__ = True
try:
import gdb.printing
except ImportError:
__use_gdb_pp__ = False
class AkantuPrinter(object):
regex = None
@classmethod
def supports(cls, typename):
- #print('{0} ~= {1}'.format(typename, cls.regex), file=sys.stderr)
+ # print('{0} ~= {1}'.format(typename, cls.regex), file=sys.stderr)
return cls.regex.search(typename)
@classmethod
def get_basic_type(cls, value):
""" Determines the type associated to a value"""
_type = value.type
# If it points to a reference, get the reference.
if _type.code == gdb.TYPE_CODE_REF:
_type = _type.target()
# Get the unqualified type, stripped of typedefs.
_type = _type.unqualified().strip_typedefs()
return _type.tag
+
if __use_gdb_pp__:
__akantu_pretty_printers__ = \
gdb.printing.RegexpCollectionPrettyPrinter("libakantu-v3")
else:
class AkantuPrettyPrinters(object):
def __init__(self, name):
super(AkantuPrettyPrinters, self).__init__()
self.name = name
self.printers = {}
@property
def enabled(self):
return True
def add_printer(self, name, regex, printer):
self.printers[name] = printer
def __call__(self, val):
typename = AkantuPrinter.get_basic_type(val)
if not typename:
return None
for name, printer in self.printers.items():
if(printer.supports(typename)):
return printer
return None
__akantu_pretty_printers__ = AkantuPrettyPrinters("libakantu-v3")
def register_pretty_printer(pretty_printer):
"Registers a Pretty Printer"
__akantu_pretty_printers__.add_printer(pretty_printer.name,
pretty_printer.regex,
pretty_printer)
return pretty_printer
+
@register_pretty_printer
class AkaArrayPrinter(AkantuPrinter):
"""Pretty printer for akantu::Array<T>"""
regex = re.compile('^akantu::Array<(.*?), (true|false)>$')
name = 'akantu::Array'
def __init__(self, value):
self.typename = self.get_basic_type(value)
self.value = value
self.ptr = self.value['values']
self.size = int(self.value['size_'])
self.nb_component = int(self.value['nb_component'])
def display_hint(self):
return 'array'
def to_string(self):
m = self.regex.search(self.typename)
return 'Array<{0}>({1}, {2}) stored at {3}'.format(
m.group(1), self.size, self.nb_component, self.ptr)
def children(self):
_ptr = self.ptr
for i in range(self.size):
_values = ["{0}".format((_ptr + j).dereference())
for j in range(self.nb_component)]
_ptr = _ptr + self.nb_component
yield ('[{0}]'.format(i),
('{0}' if self.nb_component == 1 else '[{0}]').format(
', '.join(_values)))
+
if sys.version_info[0] > 2:
- ### Python 3 stuff
+ # Python 3 stuff
Iterator = object
else:
- ### Python 2 stuff
+ # Python 2 stuff
class Iterator:
"""Compatibility mixin for iterators
Instead of writing next() methods for iterators, write
__next__() methods and use this mixin to make them work in
Python 2 as well as Python 3.
Idea stolen from the "six" documentation:
<http://pythonhosted.org/six/#six.Iterator>
"""
def next(self):
return self.__next__()
class RbtreeIterator(Iterator):
"""
Turn an RB-tree-based container (std::map, std::set etc.) into
a Python iterable object.
"""
def __init__(self, rbtree):
self.size = rbtree['_M_t']['_M_impl']['_M_node_count']
self.node = rbtree['_M_t']['_M_impl']['_M_header']['_M_left']
self.count = 0
def __iter__(self):
return self
def __len__(self):
- return int (self.size)
+ return int(self.size)
def __next__(self):
if self.count == self.size:
raise StopIteration
result = self.node
self.count = self.count + 1
if self.count < self.size:
# Compute the next node.
node = self.node
if node.dereference()['_M_right']:
node = node.dereference()['_M_right']
while node.dereference()['_M_left']:
node = node.dereference()['_M_left']
else:
parent = node.dereference()['_M_parent']
while node == parent.dereference()['_M_right']:
node = parent
parent = parent.dereference()['_M_parent']
if node.dereference()['_M_right'] != parent:
node = parent
self.node = node
return result
+
def get_value_from_aligned_membuf(buf, valtype):
"""Returns the value held in a __gnu_cxx::__aligned_membuf."""
return buf['_M_storage'].address.cast(valtype.pointer()).dereference()
+
def get_value_from_Rb_tree_node(node):
"""Returns the value held in an _Rb_tree_node<_Val>"""
try:
member = node.type.fields()[1].name
if member == '_M_value_field':
# C++03 implementation, node contains the value as a member
return node['_M_value_field']
elif member == '_M_storage':
# C++11 implementation, node stores value in __aligned_membuf
valtype = node.type.template_argument(0)
return get_value_from_aligned_membuf(node['_M_storage'], valtype)
- except:
+ except: # noqa: E722
pass
raise ValueError("Unsupported implementation for %s" % str(node.type))
+
def find_type(orig, name):
typ = orig.strip_typedefs()
while True:
# Strip cv-qualifiers. PR 67440.
search = '%s::%s' % (typ.unqualified(), name)
try:
return gdb.lookup_type(search)
except RuntimeError:
pass
# The type was not found, so try the superclass. We only need
# to check the first superclass, so we don't bother with
# anything fancier here.
field = typ.fields()[0]
if not field.is_base_class:
raise ValueError("Cannot find type %s::%s" % (str(orig), name))
typ = field.type
+
@register_pretty_printer
class AkaElementTypeMapArrayPrinter(AkantuPrinter):
"""Pretty printer for akantu::ElementTypeMap<Array<T>>"""
- regex = re.compile('^akantu::ElementTypeMap<akantu::Array<(.*?), (true|false)>\*, akantu::(.*?)>$')
+ regex = re.compile('^akantu::ElementTypeMap<akantu::Array<(.*?), (true|false)>\*, akantu::(.*?)>$') # noqa: E501,W605
name = 'akantu::ElementTypeMapArray'
# Turn an RbtreeIterator into a pretty-print iterator.
class _rb_iter(Iterator):
def __init__(self, rbiter, type, ghost_type):
self.rbiter = rbiter
self.count = 0
self.type = type
self.ghost_type = ghost_type
+
def __iter__(self):
return self
def __next__(self):
if self.count % 2 == 0:
n = next(self.rbiter)
n = n.cast(self.type).dereference()
n = get_value_from_Rb_tree_node(n)
self.pair = n
item = "{0}:{1}".format(n['first'], self.ghost_type)
else:
item = self.pair['second'].dereference()
result = ('[{0}]'.format(self.count), item)
self.count = self.count + 1
return result
def _iter(self, not_ghost, ghost, type):
iter_size = (len(not_ghost), len(ghost))
it = self._rb_iter(not_ghost, type, '_not_ghost')
for _ in range(iter_size[0] * 2):
yield next(it)
it = self._rb_iter(ghost, type, '_ghost')
for _ in range(iter_size[1] * 2):
yield next(it)
raise StopIteration
def __init__(self, value):
self.typename = self.get_basic_type(value)
self.value = value
self.data = self.value['data']
self.ghost_data = self.value['ghost_data']
def to_string(self):
m = self.regex.search(self.typename)
return 'ElementTypMapArray<{0}> with '\
'{1} _not_ghost and {2} _ghost'.format(
m.group(1), len(RbtreeIterator(self.data)),
len(RbtreeIterator(self.ghost_data)))
def children(self):
- m = self.regex.search(self.typename)
-
+ # m = self.regex.search(self.typename)
rep_type = find_type(self.data.type, '_Rep_type')
node = find_type(rep_type, '_Link_type')
node = node.strip_typedefs()
return itertools.chain(
self._rb_iter(RbtreeIterator(self.data), node, "_not_ghost"),
self._rb_iter(RbtreeIterator(self.ghost_data), node, "_ghost"))
def display_hint(self):
return 'map'
# @register_pretty_printer
class AkaTensorPrinter(AkantuPrinter):
"""Pretty printer for akantu::Tensor<T>"""
regex = re.compile('^akantu::Tensor<(.*), +(.*), +(.*)>$')
name = 'akantu::Tensor'
value = None
typename = ""
ptr = None
dims = []
ndims = 0
def pretty_print(self):
def ij2str(i, j, m):
return "{0}".format((self.ptr+m*j + i).dereference())
def line(i, m, n):
return "[{0}]".format(", ".join((ij2str(i, j, m) for j in
range(n))))
m = int(self.dims[0])
if (self.ndims == 1):
n = 1
else:
n = int(self.dims[1])
return "[{0}]".format(", ".join(line(i, m, n) for i in range(m)))
def __init__(self, value):
self.typename = self.get_basic_type(value)
self.value = value
self.ptr = self.value['values']
self.dims = self.value['n']
def children(self):
yield ('values', self.pretty_print())
yield ('wrapped', self.value['wrapped'])
+
@register_pretty_printer
class AkaVectorPrinter(AkaTensorPrinter):
"""Pretty printer for akantu::Vector<T>"""
regex = re.compile('^akantu::Vector<(.*)>$')
name = 'akantu::Vector'
n = 0
ptr = 0x0
def __init__(self, value):
super(AkaVectorPrinter, self).__init__(value)
self.ndims = 1
def to_string(self):
m = self.regex.search(self.typename)
return 'Vector<{0}>({1}) [{2}]'.format(m.group(1), int(self.dims[0]),
str(self.ptr))
@register_pretty_printer
class AkaMatrixPrinter(AkaTensorPrinter):
"""Pretty printer for akantu::Matrix<T>"""
regex = re.compile('^akantu::Matrix<(.*)>$')
name = 'akantu::Matrix'
def __init__(self, value):
super(AkaMatrixPrinter, self).__init__(value)
self.ndims = 2
def to_string(self):
m = self.regex.search(self.typename)
return 'Matrix<%s>(%d, %d) [%s]' % (m.group(1), int(self.dims[0]),
int(self.dims[1]),
str(self.ptr))
@register_pretty_printer
class AkaElementPrinter(AkantuPrinter):
"""Pretty printer for akantu::Element"""
regex = re.compile('^akantu::Element$')
name = 'akantu::Element'
def __init__(self, value):
self.typename = self.get_basic_type(value)
self.value = value
self.element = self.value['element']
self.eltype = self.value['type']
self.ghost_type = self.value['ghost_type']
self._ek_not_defined = gdb.parse_and_eval('akantu::_not_defined')
self._casper = gdb.parse_and_eval('akantu::_casper')
self._max_uint = gdb.parse_and_eval('(akantu::UInt) -1')
def to_string(self):
if (self.element == self._max_uint) and \
(self.eltype == self._ek_not_defined) and \
(self.ghost_type == self._casper):
return 'ElementNull'
return 'Element({0}, {1}, {2})'.format(self.element, self.eltype,
self.ghost_type)
def register_akantu_printers(obj):
"Register Akantu Pretty Printers."
if __use_gdb_pp__:
gdb.printing.register_pretty_printer(obj, __akantu_pretty_printers__)
else:
if obj is None:
obj = gdb
obj.pretty_printers.append(__akantu_pretty_printers__)
diff --git a/doc/manual/manual-solidmechanicsmodel.tex b/doc/manual/manual-solidmechanicsmodel.tex
index 3b078ac86..95e0d5692 100644
--- a/doc/manual/manual-solidmechanicsmodel.tex
+++ b/doc/manual/manual-solidmechanicsmodel.tex
@@ -1,1138 +1,1138 @@
\chapter{Solid Mechanics Model\index{SolidMechanicsModel}\label{sect:smm}}
The solid mechanics model is a specific implementation of the
\code{Model} interface dedicated to handle the equations of motion or
equations of equilibrium. The model is created for a given mesh. It
will create its own \code{FEEngine} object to compute the interpolation,
gradient, integration and assembly operations. A
\code{SolidMechanicsModel} object can simply be created like this:
\begin{cpp}
SolidMechanicsModel model(mesh);
\end{cpp}
where \code{mesh} is the mesh for which the equations are to be
solved. A second parameter called \code{spatial\_dimension} can be
added after \code{mesh} if the spatial dimension of the problem is
different than that of the mesh.
This model contains at least the following six \code{Arrays}:
\begin{description}
\item[blocked\_dofs] contains a Boolean value for each degree of
freedom specifying whether that degree is blocked or not. A
Dirichlet boundary condition can be prescribed by setting the
\textbf{blocked\_dofs} value of a degree of freedom to \code{true}.
A Neumann boundary condition can be applied by setting the
\textbf{blocked\_dofs} value of a degree of freedom to \code{false}.
The \textbf{displacement}, \textbf{velocity} and
\textbf{acceleration} are computed for all degrees of freedom for
which the \textbf{blocked\_dofs} value is set to \code{false}. For
the remaining degrees of freedom, the imposed values (zero by
default after initialization) are kept.
\item[displacement] contains the displacements of all degrees of
freedom. It can be either a computed displacement for free degrees
of freedom or an imposed displacement in case of blocked ones
($\vec{u}$ in the following).
\item[velocity] contains the velocities of all degrees of freedom. As
\textbf{displacement}, it contains computed or imposed velocities
depending on the nature of the degrees of freedom ($\dot{\vec{u}}$
in the following).
\item[acceleration] contains the accelerations of all degrees of
freedom. As \textbf{displacement}, it contains computed or imposed
accelerations depending on the nature of the degrees of freedom
($\ddot{\vec{u}}$ in the following).
\item[external\_force] contains the external forces applied on the nodes
($\vec{f}_{\st{ext}}$ in the following).
\item[internal\_force] contains the internal forces on the nodes
($\vec{f}_{\st{int}}$ in the following).
\end{description}
Some examples to help to understand how to use this model will be
presented in the next sections.
\section{Model Setup}
\subsection{Setting Initial Conditions \label{sect:smm:initial_condition}}
For a unique solution of the equations of motion, initial
displacements and velocities for all degrees of freedom must be
specified:
\begin{eqnarray}
\vec{u}(t=0) = \vec{u}_0\\
\dot{\vec u}(t=0) =\vec{v}_0
\end{eqnarray} The solid mechanics model can be initialized as
follows:
\begin{cpp}
model.initFull()
\end{cpp}
This function initializes the internal arrays and sets them to
zero. Initial displacements and velocities that are not equal to zero
can be prescribed by running a loop over the total number of
nodes. Here, the initial displacement in $x$-direction and the
initial velocity in $y$-direction for all nodes is set to $0.1$ and $1$,
respectively.
\begin{cpp}
auto & disp = model.getDisplacement();
auto & velo = model.getVelocity();
for (UInt node = 0; node < mesh.getNbNodes(); ++node) {
disp(node, 0) = 0.1;
velo(node, 1) = 1.;
}
\end{cpp}
\subsection{Setting Boundary Conditions\label{sect:smm:boundary}}
This section explains how to impose Dirichlet or Neumann boundary
conditions. A Dirichlet boundary condition specifies the values that
the displacement needs to take for every point $x$ at the boundary
($\Gamma_u$) of the problem domain (Fig.~\ref{fig:smm:boundaries}):
\begin{equation}
\vec{u} = \bar{\vec u} \quad \forall \vec{x}\in
\Gamma_{u}
\end{equation}
A Neumann boundary condition imposes the value of the gradient of the
solution at the boundary $\Gamma_t$ of the problem domain
(Fig.~\ref{fig:smm:boundaries}):
\begin{equation}
\vec{t} = \mat{\sigma} \vec{n} = \bar{\vec t} \quad
\forall \vec{x}\in \Gamma_{t}
\end{equation}
\begin{figure} \centering
\def\svgwidth{0.5\columnwidth}
\input{figures/problemDomain.pdf_tex}
\caption{Problem domain $\Omega$ with boundary in three
dimensions. The Dirchelet and the Neumann regions of the boundary
are denoted with $\Gamma_u$ and $\Gamma_t$,
respecitvely.\label{fig:smm:boundaries}}
\label{fig:problemDomain}
\end{figure}
Different ways of imposing these boundary conditions exist. A basic
way is to loop over nodes or elements at the boundary and apply local
values. A more advanced method consists of using the notion of the
boundary of the mesh. In the following both ways are presented.
Starting with the basic approach, as mentioned, the Dirichlet boundary
conditions can be applied by looping over the nodes and assigning the
required values. Figure~\ref{fig:smm:dirichlet_bc} shows a beam with a
fixed support on the left side. On the right end of the beam, a load
is applied. At the fixed support, the displacement has a given
value. For this example, the displacements in both the $x$ and the
$y$-direction are set to zero. Implementing this displacement boundary
condition is similar to the implementation of initial displacement
conditions described above. However, in order to impose a displacement
boundary condition for all time steps, the corresponding nodes need to
be marked as boundary nodes using the function \code{blocked}. While,
in order to impose a load on the right side, the nodes are not marked.
The detail codes are shown as follows:
\begin{cpp}
auto & blocked = model.getBlockedDOFs();
const auto & pos = mesh.getNodes();
UInt nb_nodes = mesh.getNbNodes();
for (UInt node = 0; node < nb_nodes; ++node) {
if(Math::are_float_equal(pos(node, _x), 0)) {
blocked(node, _x) = true; // block dof in x-direction
blocked(node, _y) = true; // block dof in y-direction
disp(node, _x) = 0.; // fixed displacement in x-direction
disp(node, _y) = 0.; // fixed displacement in y-direction
} else if (Math::are_float_equal(pos(node, _y), 0)) {
blocked(node, _x) = false; // unblock dof in x-direction
forces(node, _x) = 10.; // force in x-direction
}
}
\end{cpp}
\begin{figure}[!htb]
\centering
\includegraphics[scale=0.4]{figures/dirichlet}
\caption{Beam with fixed support and load.\label{fig:smm:dirichlet_bc}}
\end{figure}
For the more advanced approach, one needs the notion of a boundary in
the mesh. Therefore, the boundary should be created before boundary
condition functors can be applied. Generally the boundary can be
specified from the mesh file or the geometry. For the first case, the
function \code{createGroupsFromMeshData} is called. This function
can read any types of mesh data which are provided in the mesh
file. If the mesh file is created with Gmsh, the function takes one
input strings which is either \code{tag\_0}, \code{tag\_1} or
\code{physical\_names}. The first two tags are assigned by Gmsh to
each element which shows the physical group that they belong to. In
Gmsh, it is also possible to consider strings for different groups of
elements. These elements can be separated by giving a string
\code{physical\_names} to the function
\code{createGroupsFromMeshData}:
\begin{cpp}
mesh.createGroupsFromMeshData<std::string>("physical_names").
\end{cpp}
Boundary conditions support can also be
created from the geometry by calling
\code{createBoundaryGroupFromGeometry}. This function gathers all the
elements on the boundary of the geometry.
To apply the required boundary conditions, the function \code{applyBC}
needs to be called on a \code{SolidMechanicsModel}. This function
gets a Dirichlet or Neumann functor and a string which specifies the
desired boundary on which the boundary conditions is to be
applied. The functors specify the type of conditions to apply. Three
built-in functors for Dirichlet exist: \code{FlagOnly, FixedValue,}
and \code{IncrementValue}. The functor \code{FlagOnly} is used if a
point is fixed in a given direction. Therefore, the input parameter to
this functor is only the fixed direction. The \code{FixedValue}
functor is used when a displacement value is applied in a fixed
direction. The \code{IncrementValue} applies an increment to the
displacement in a given direction. The following code shows the
utilization of three functors for the top, bottom and side surface of
the mesh which were already defined in the Gmsh file:
\begin{cpp}
model.applyBC(BC::Dirichlet::FixedValue(13.0, _y), "Top");
model.applyBC(BC::Dirichlet::FlagOnly(_x), "Bottom");
model.applyBC(BC::Dirichlet::IncrementValue(13.0, _x), "Side");
\end{cpp}
To apply a Neumann boundary condition, the applied traction or stress
should be specified before. In case of specifying the traction on the
surface, the functor \code{FromTraction} of Neumann boundary
conditions is called. Otherwise, the functor \code{FromStress} should
be called which gets the stress tensor as an input parameter.
\begin{cpp}
Vector<Real> surface_traction = {0., 0., 1.};
auto surface_stress(3, 3) = Matrix<Real>::eye(3);
model.applyBC(BC::Neumann::FromTraction(surface_traction), "Bottom");
model.applyBC(BC::Neumann::FromStress(surface_stress), "Top");
\end{cpp}
If the boundary conditions need to be removed during the simulation, a
functor is called from the Neumann boundary condition to free those
boundary conditions from the desired boundary.
\begin{cpp}
model.applyBC(BC::Neumann::FreeBoundary(), "Side");
\end{cpp}
User specified functors can also be implemented. A full example for
setting both initial and boundary conditions can be found in
\shellcode{\examplesdir/boundary\_conditions.cc}. The problem solved
in this example is shown in Fig.~\ref{fig:smm:bc_and_ic}. It consists
of a plate that is fixed with movable supports on the left and bottom
side. On the right side, a traction, which increases linearly with the
number of time steps, is applied. The initial displacement and
velocity in $x$-direction at all free nodes is zero and two
respectively.
\begin{figure}[!htb]
\centering
\includegraphics[scale=0.8]{figures/bc_and_ic_example}
\caption{Plate on movable supports.\label{fig:smm:bc_and_ic}}
\end{figure}
As it is mentioned in Section \ref{sect:common:groups}, node and
element groups can be used to assign the boundary conditions. A
generic example is given below with a Dirichlet boundary condition.
\begin{cpp}
// create a node group
NodeGroup & node_group = mesh.createNodeGroup("nodes_fix");
/*
fill the node group with the nodes you want
*/
// create an element group using the existing node group
mesh.createElementGroupFromNodeGroup("el_fix", "nodes_fix", spatial_dimension-1);
// boundary condition can be applied using the element group name
model.applyBC(BC::Dirichlet::FixedValue(0.0, _x), "el_fix");
\end{cpp}
\subsection{Material Selector\label{sect:smm:materialselector}}
If the user wants to assign different materials to different
finite elements groups in \akantu, a material selector has to be
used. By default, \akantu assigns the first valid material in the
material file to all elements present in the model (regular continuum
materials are assigned to the regular elements and cohesive materials
are assigned to cohesive elements or element facets).
To assign different materials to specific elements, mesh data
information such as tag information or specified physical names can be
used. \code{MeshDataMaterialSelector} class uses this information to
assign different materials. With the proper physical name or tag name
and index, different materials can be assigned as demonstrated in the
examples below.
\begin{cpp}
auto mat_selector = std::make_shared<MeshDataMaterialSelector<std::string>>("physical_names", model);
model.setMaterialSelector(mat_selector);
\end{cpp}
In this example the physical names specified in a GMSH geometry file will by
used to match the material names in the input file.
Another example would be to use the first (\code{tag\_0}) or the second
(\code{tag\_1}) tag associated to each elements in the mesh:
\begin{cpp}
auto mat_selector = std::make_shared<MeshDataMaterialSelector<UInt>>(
"tag_1", model, first_index);
model.setMaterialSelector(*mat_selector);
\end{cpp}
where \code{first\_index} (default is 1) is the value of \code{tag\_1} that will
be associated to the first material in the material input file. The following
values of the tag will be associated with the following materials.
There are four different material selectors pre-defined in
\akantu. \code{MaterialSelector} and \code{DefaultMaterialSelector} is
used to assign a material to regular elements by default. For the
regular elements, as in the example above,
\code{MeshDataMaterialSelector} can be used to assign different
materials to different elements.
Apart from the \akantu's default material selectors, users can always
develop their own classes in the main code to tackle various
multi-material assignment situations.
% An application of \code{DefaultMaterialCohesiveSelector} and usage in
% a customly generated material selector class can be seen in
% \shellcode{\examplesdir/cohesive\_element/cohesive\_extrinsic\_IG\_TG/cohesive\_extrinsic\_IG\_TG.cc}.
\IfFileExists{manual-cohesive_elements_insertion.tex}{\input{manual-cohesive_elements_insertion}}{}
\section{Static Analysis\label{sect:smm:static}}
The \code{SolidMechanicsModel} class can handle different analysis
methods, the first one being presented is the static case. In this
case, the equation to solve is
\begin{equation}
\label{eqn:smm:static} \mat{K} \vec{u} =
\vec{f}_{\st{ext}}
\end{equation}
where $\mat{K}$ is the global stiffness matrix, $\vec{u}$ the
displacement vector and $\vec{f}_{\st{ext}}$ the vector of external
forces applied to the system.
To solve such a problem, the static solver of the
\code{SolidMechanicsModel}\index{SolidMechanicsModel} object is used.
First, a model has to be created and initialized. To create the
model, a mesh (which can be read from a file) is needed, as explained
in Section~\ref{sect:common:mesh}. Once an instance of a
\code{SolidMechanicsModel} is obtained, the easiest way to initialize
it is to use the \code{initFull}\index{SolidMechanicsModel!initFull}
method by giving the \code{SolidMechanicsModelOptions}. These options
specify the type of analysis to be performed and whether the materials
should be initialized with \code{initMaterials} or not.
\begin{cpp}
SolidMechanicsModel model(mesh);
model.initFull(_analysis_method = _static);
\end{cpp}
Here, a static analysis is chosen by passing the argument
\code{\_static} to the method. By default, the Boolean for no
initialization of the materials is set to false, so that they are
initialized during the \code{initFull}. The method \code{initFull}
also initializes all appropriate vectors to zero. Once the model is
created and initialized, the boundary conditions can be set as
explained in Section~\ref{sect:smm:boundary}. Boundary conditions
will prescribe the external forces for some free degrees of freedom
$\vec{f}_{\st{ext}}$ and displacements for some others. At this point
of the analysis, the function
\code{solveStep}\index{SolidMechanicsModel!solveStep} can be called:
\begin{cpp}
model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_residual>(1e-4, 1);
\end{cpp}
This function is templated by the solving method and the convergence
criterion and takes two arguments: the tolerance and the maximum
number of iterations (100 by default), which are $\num{1e-4}$ and $1$ for this example. The
modified Newton-Raphson method is chosen to solve the system. In this
method, the equilibrium equation (\ref{eqn:smm:static}) is modified in
order to apply a Newton-Raphson convergence algorithm:
\begin{align}\label{eqn:smm:static-newton-raphson}
\mat{K}^{i+1}\delta\vec{u}^{i+1} &= \vec{r} \\
&= \vec{f}_{\st{ext}} -\vec{f}_{\st{int}}\\
&= \vec{f}_{\st{ext}} - \mat{K}^{i} \vec{u}^{i}\\
\vec{u}^{i+1} &= \vec{u}^{i} + \delta\vec{u}^{i+1}~,\nonumber
\end{align}
where $\delta\vec{u}$ is the increment of displacement to be added
from one iteration to the other, and $i$ is the Newton-Raphson
iteration counter. By invoking the \code{solveStep} method in the
first step, the global stiffness matrix $\mat{K}$ from
Equation~(\ref{eqn:smm:static}) is automatically assembled. A
Newton-Raphson iteration is subsequently started, $\mat{K}$ is updated
according to the displacement computed at the previous iteration and
-one loops until the forces are balanced (\code{\SolveConvergenceCriteria::\_residual}), \ie
-$||\vec{r}|| < \mbox{\code{\SolveConvergenceCriteria::\_residual}}$. One can also iterate
-until the increment of displacement is zero (\code{\SolveConvergenceCriteria::\_increment})
+one loops until the forces are balanced (\code{SolveConvergenceCriteria::\_residual}), \ie
+$||\vec{r}|| < \mbox{\code{SolveConvergenceCriteria::\_residual}}$. One can also iterate
+until the increment of displacement is zero (\code{SolveConvergenceCriteria::\_increment})
which also means that the equilibrium is found. For a linear elastic
problem, the solution is obtained in one iteration and therefore the
maximum number of iterations can be set to one. But for a non-linear
case, one needs to iterate as long as the norm of the residual exceeds
the tolerance threshold and therefore the maximum number of iterations
has to be higher, e.g. $100$:
\begin{cpp}
model.solveStep<_scm_newton_raphson_tangent_modified,SolveConvergenceCriteria::_residual>(1e-4, 100)
\end{cpp}
At the end of the analysis, the final solution is stored in the
\textbf{displacement} vector. A full example of how to solve a static
problem is presented in the code \code{\examplesdir/static/static.cc}.
This example is composed of a 2D plate of steel, blocked with rollers
on the left and bottom sides as shown in Figure \ref{fig:smm:static}.
The nodes from the right side of the sample are displaced by $0.01\%$
of the length of the plate.
\begin{figure}[!htb]
\centering
\includegraphics[scale=1.05]{figures/static}
\caption{Numerical setup\label{fig:smm:static}}
\end{figure}
The results of this analysis is depicted in
Figure~\ref{fig:smm:implicit:static_solution}.
\begin{figure}[!htb]
\centering
\includegraphics[width=.7\linewidth]{figures/static_analysis}
\caption{Solution of the static analysis. Left: the initial
condition, right: the solution (deformation magnified 50 times)}
\label{fig:smm:implicit:static_solution}
\end{figure}
\subsection{Static implicit analysis with dynamic insertion of cohesive elements}
In order to solve problems with the extrinsic cohesive method in the
static implicit solution scheme, the function \code{solveStepCohesive}
has to be used:
\begin{cpp}
model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(1e-13, error, 25, false, 1e5, true);
\end{cpp}
in which the arguments are: tolerance, error, max\_iteration,
load\_reduction, tol\_increase\_factor, do\_not\_factorize. This
function, first applies the Newton-Raphson procedure to solve the
problem. Then, it calls the method \code{checkCohesiveStress} to
check if cohesive elements have to be inserted. Since the approach is
implicit, only one element is added, the most stressed one (see
Section \ref{extrinsic_insertion}). After insertion, the
Newton-Raphson procedure is applied again to solve the same
incremental loading step, with the new inserted cohesive element. The
procedure loops in this way since no new cohesive elements have to be
inserted. At that point, the solution is saved, and the simulation
can advance to the next incremental loading step. In case the
convergence is not reached, the obtained solution is not saved and the
simulation return to the main file with the error given by the
solution saved in the argument of the function \emph{error}. In this
way, the user can intervene in the simulation in order to find anyhow
convergence. A possibility is, for instance, to reduce the last
incremental loading step. The variable \emph{load\_reduction} can be
used to identify if the load has been already reduced or not. At the
same time, with the variable \emph{tol\_increase\_factor} it is
possible to increase the tolerance by a factor defined by the user in
the main file, in order to accept a solution even with an error bigger
than the tolerance set at the beginning. It is possible to increase
the tolerance only in the phase of loading reduction, i.e., when
load\_reduction = true. A not converged solution is never saved. In
case the convergence is not reached even after the loading reduction
procedure, the displacement field is not updated and remains the one
of the last converged incremental steps. Also, cohesive elements are
inserted only if convergence is reached. An example of the extrinsic
cohesive method in the static implicit solution scheme is presented in
\shellcode{\examplesdir/cohesive\_element/cohesive\_extrinsic\_implicit}.
\section{Dynamic Methods} \label{sect:smm:Dynamic_methods}
Different ways to solve the equations of motion are implemented in the
solid mechanics model. The complete equations that should be solved
are:
\begin{equation}
\label{eqn:equation-motion}
\mat{M}\ddot{\vec{u}} +
\mat{C}\dot{\vec{u}} + \mat{K}\vec{u} = \vec{f}_{\st{ext}}~,
\end{equation}
where $\mat{M}$, $\mat{C}$ and $\mat{K}$ are the mass,
damping and stiffness matrices, respectively.
In the previous section, it has already been discussed how to solve this
equation in the static case, where $\ddot{\vec{u}} = \dot{\vec{u}} = 0$. Here
the method to solve this equation in the general case will be presented. For
this purpose, a time discretization has to be specified. The most common
discretization method in solid mechanics is the Newmark-$\beta$ method, which is
also the default in \akantu.
For the Newmark-$\beta$ method, (\ref{eqn:equation-motion}) becomes a
system of three equations (see \cite{curnier92a} \cite{hughes-83a} for
more details):
\begin{align}
\mat{M} \ddot{\vec{u}}_{n+1} + \mat{C}\dot{\vec{u}}_{n+1} + \mat{K} \vec{u}_{n+1} &={\vec{f}_{\st{ext}}}_{\, n+1}
\label{eqn:equation-motion-discret} \\
\vec{u}_{n+1} &=\vec{u}_{n} + \left(1 - \alpha\right) \Delta t \dot{\vec{u}}_{n} +
\alpha \Delta t \dot{\vec{u}}_{n+1} + \left(\frac{1}{2} -
\alpha\right) \Delta t^2
\ddot{\vec{u}}_{n} \label{eqn:finite-difference-1}\\
\dot{\vec{u}}_{n+1} &= \dot{\vec{u}}_{n} + \left(1 - \beta\right)
\Delta t \ddot{\vec{u}}_{n} + \beta \Delta t
\ddot{\vec{u}}_{n+1} \label{eqn:finite-difference-2}
\end{align}
In these new equations, $\ddot{\vec{u}}_{n}$, $\dot{\vec{u}}_{n}$ and
$\vec{u}_{n}$ are the approximations of $\ddot{\vec{u}}(t_n)$,
$\dot{\vec{u}}(t_n)$ and $\vec{u}(t_n)$.
Equation~(\ref{eqn:equation-motion-discret}) is the equation of motion
discretized in space (finite-element discretization), and equations
(\ref{eqn:finite-difference-1}) and (\ref{eqn:finite-difference-2})
are discretized in both space and time (Newmark discretization). The
$\alpha$ and $\beta$ parameters determine the stability and the
accuracy of the algorithm. Classical values for $\alpha$ and $\beta$
are usually $\beta = 1/2$ for no numerical damping and $0 < \alpha <
1/2$.
\begin{center}
\begin{tabular}{cll}
\toprule
$\alpha$ & Method ($\beta = 1/2$) & Type\\
\midrule
$0$ & central difference & explicit\\
$1/6$ & Fox-Goodwin (royal road) &implicit\\
$1/3$ & Linear acceleration &implicit\\
$1/2$ & Average acceleration (trapezoidal rule)& implicit\\
\bottomrule
\end{tabular}
\end{center}
The solution of this system of equations,
(\ref{eqn:equation-motion-discret})-(\ref{eqn:finite-difference-2}) is
split into a predictor and a corrector system of equations. Moreover,
in the case of a non-linear equations, an iterative algorithm such as
the Newton-Raphson method is applied. The system of equations can be
written as:
\begin{enumerate}
\item \textit{Predictor:}
\begin{align}
\vec{u}_{n+1}^{0} &= \vec{u}_{n} + \Delta t
\dot{\vec{u}}_{n} + \frac{\Delta t^2}{2} \ddot{\vec{u}}_{n} \\
\dot{\vec{u}}_{n+1}^{0} &= \dot{\vec{u}}_{n} + \Delta t
\ddot{\vec{u}}_{n} \\
\ddot{\vec{u}}_{n+1}^{0} &= \ddot{\vec{u}}_{n}
\end{align}
\item \textit{Solve:}
\begin{align}
\left(c \mat{M} + d \mat{C} + e \mat{K}_{n+1}^i\right)
\vec{w} = {\vec{f}_{\st{ext}}}_{\,n+1} - {\vec{f}_{\st{int}}}_{\,n+1}^i -
\mat{C} \dot{\vec{u}}_{n+1}^i - \mat{M} \ddot{\vec{u}}_{n+1}^i = \vec{r}_{n+1}^i
\end{align}
\item \textit{Corrector:}
\begin{align}
\ddot{\vec{u}}_{n+1}^{i+1} &= \ddot{\vec{u}}_{n+1}^{i} +c \vec{w} \\
\dot{\vec{u}}_{n+1}^{i+1} &= \dot{\vec{u}}_{n+1}^{i} + d\vec{w} \\
\vec{u}_{n+1}^{i+1} &= \vec{u}_{n+1}^{i} + e \vec{w}
\end{align}
\end{enumerate}
where $i$ is the Newton-Raphson iteration counter and $c$, $d$ and $e$
are parameters depending on the method used to solve the equations
\begin{center}
\begin{tabular}{lcccc}
\toprule
& $\vec{w}$ & $e$ & $d$ & $c$\\
\midrule
in acceleration &$ \delta\ddot{\vec{u}}$ & $\alpha \beta\Delta t^2$ &$\beta \Delta t$ &$1$\\
in velocity & $ \delta\dot{\vec{u}}$& $\alpha\Delta t$ & $1$ & $\frac{1}{\beta \Delta t}$\\
in displacement &$\delta\vec{u}$ & $ 1$ & $\frac{1}{\alpha \Delta t}$ & $\frac{1}{\alpha \beta \Delta t^2}$\\
\bottomrule
\end{tabular}
\end{center}
% \note{If you want to use the implicit solver \akantu should be compiled at
% least with one sparse matrix solver such as Mumps\cite{mumps}.}
\subsection{Implicit Time Integration}
To solve a problem with an implicit time integration scheme, first a
\code{SolidMechanicsModel} object has to be created and initialized.
Then the initial and boundary conditions have to be set. Everything
is similar to the example in the static case
(Section~\ref{sect:smm:static}), however, in this case the implicit
dynamic scheme is selected at the initialization of the model.
\begin{cpp}
SolidMechanicsModel model(mesh);
model.initFull(_analysis_method = _implicit_dynamic);
/*Boundary conditions see Section ~ %\ref{sect:smm:boundary}% */
\end{cpp}
Because a dynamic simulation is conducted, an integration time step
$\Delta t$ has to be specified. In the case of implicit simulations,
\akantu implements a trapezoidal rule by default. That is to say
$\alpha = 1/2$ and $\beta = 1/2$ which is unconditionally
stable. Therefore the value of the time step can be chosen arbitrarily
within reason. \index{SolidMechanicsModel!setTimeStep}
\begin{cpp}
model.setTimeStep(time_step);
\end{cpp}
Since the system has to be solved for a given amount of time steps, the
method \code{solveStep()}, (which has already been used in the static
example in Section~\ref{sect:smm:static}), is called inside a time
loop:
\begin{cpp}
/// time loop
Real time = 0.;
auto & solver = model.getNonLinearSolver();
solver.set("max_iterations", 100);
solver.set("threshold", 1e-12);
solver.set("convergence_type", SolveConvergenceCriteria::_solution);
for (UInt s = 1; time <max_time; ++s, time += time_step) {
model.solveStep();
}
\end{cpp}
An example of solid mechanics with an implicit time integration scheme
is presented in
\shellcode{\examplesdir/implicit/implicit\_dynamic.cc}. This example
consists of a 3D beam of
$\SI{10}{\metre}\,\times\,\SI{1}{\metre}\,\times\,\SI{1}{\metre}$
blocked on one side and is on a roller on the other side. A constant
force of \SI{5}{\kilo\newton} is applied in its middle.
Figure~\ref{fig:smm:implicit:dynamic} presents the geometry of this
case. The material used is a fictitious linear elastic material with a
density of \SI{1000}{\kilo\gram\per\cubic\metre}, a Young's Modulus of
\SI{120}{\mega\pascal} and Poisson's ratio of $0.3$. These values
were chosen to simplify the analytical solution.
An approximation of the dynamic response of the middle point of the
beam is given by:
\begin{equation}
\label{eqn:smm:implicit}
u\left(\frac{L}{2}, t\right)
= \frac{1}{\pi^4} \left(1 - cos\left(\pi^2 t\right) +
\frac{1}{81}\left(1 - cos\left(3^2 \pi^2 t\right)\right) +
\frac{1}{625}\left(1 - cos\left(5^2 \pi^2 t\right)\right)\right)
\end{equation}
\begin{figure}[!htb]
\centering
\includegraphics[scale=.6]{figures/implicit_dynamic}
\caption{Numerical setup}
\label{fig:smm:implicit:dynamic}
\end{figure}
Figure \ref{fig:smm:implicit:dynamic_solution} presents the deformed
beam at 3 different times during the simulation: time steps 0, 1000 and
2000.
\begin{figure}[!htb]
\centering
\setlength{\unitlength}{0.1\textwidth}
\begin{tikzpicture}
\node[above right] (img) at (0,0)
{\includegraphics[width=.6\linewidth]{figures/dynamic_analysis}};
\node[left] at (0pt,20pt) {$0$}; \node[left] at (0pt,60pt) {$1000$};
\node[left] at (0pt,100pt) {$2000$};
\end{tikzpicture}
\caption{Deformed beam at 3 different times (displacement are
magnified by a factor 10).}
\label{fig:smm:implicit:dynamic_solution}
\end{figure}
\subsection{Explicit Time Integration}
\label{ssect:smm:expl-time-integr}
The explicit dynamic time integration scheme is based on the
Newmark-$\beta$ scheme with $\alpha=0$ (see equations
\ref{eqn:equation-motion-discret}-\ref{eqn:finite-difference-2}). In
\akantu, $\beta$ is defaults to $\beta=1/2$, see section
\ref{sect:smm:Dynamic_methods}.
The initialization of the simulation is similar to the static and
implicit dynamic version. The model is created from the
\code{SolidMechanicsModel} class. In the initialization, the explicit
scheme is selected using the \code{\_explicit\_lumped\_mass} constant.
\begin{cpp}
SolidMechanicsModel model(mesh);
model.initFull(_analysis_method = _explicit_lumped_mass);
\end{cpp}
\index{SolidMechanicsModel!initFull}
\note{Writing \code{model.initFull()} or \code{model.initFull();} is
equivalent to use the \code{\_explicit\_lumped\_mass} keyword, as this
is the default case.}
The explicit time integration scheme implemented in \akantu uses a
lumped mass matrix $\mat{M}$ (reducing the computational cost). This
matrix is assembled by distributing the mass of each element onto its
nodes. The resulting $\mat{M}$ is therefore a diagonal matrix stored
in the \textbf{mass} vector of the model.
The explicit integration scheme is conditionally stable. The time step
has to be smaller than the stable time step which is obtained in
\akantu as follows:
\begin{cpp}
critical_time_step = model.getStableTimeStep();
\end{cpp} \index{SolidMechanicsModel!StableTimeStep}
The stable time step corresponds to the time the fastest wave (the compressive
wave) needs to travel the characteristic length of the mesh:
\begin{equation}
\label{eqn:smm:explicit:stabletime}
\Delta t_{\st{crit}} = \frac{\Delta x}{c}
\end{equation}
where $\Delta x$ is a characteristic length (\eg the inradius in the case of
linear triangle element) and $c$ is the celerity of the fastest wave in the
material. It is generally the compressive wave of celerity
$c = \sqrt{\frac{2 \mu + \lambda}{\rho}}$, $\mu$ and $\lambda$ are the first and
second Lame's coefficients and $\rho$ is the density. However, it is recommended
to impose a time step that is smaller than the stable time step, for instance,
by multiplying the stable time step by a safety factor smaller than one.
\begin{cpp}
const Real safety_time_factor = 0.8;
Real applied_time_step = critical_time_step * safety_time_factor;
model.setTimeStep(applied_time_step);
\end{cpp}
\index{SolidMechanicsModel!setTimeStep} The initial displacement and
velocity fields are, by default, equal to zero if not given
specifically by the user (see \ref{sect:smm:initial_condition}).
Like in implicit dynamics, a time loop is used in which the
displacement, velocity and acceleration fields are updated at each
time step. The values of these fields are obtained from the
Newmark$-\beta$ equations with $\beta=1/2$ and $\alpha=0$. In \akantu
these computations at each time step are invoked by calling the
function \code{solveStep}:
\begin{cpp}
for (UInt s = 1; (s-1)*applied_time_step < total_time; ++s) {
model.solveStep();
}
\end{cpp} \index{SolidMechanicsModel!solveStep}
The method
\code{solveStep} wraps the four following functions:
\begin{itemize}
\item \code{model.explicitPred()} allows to compute the displacement
field at $t+1$ and a part of the velocity field at $t+1$, denoted by
$\vec{\dot{u}^{\st{p}}}_{n+1}$, which will be used later in the method
\code{model.explicitCorr()}. The equations are:
\begin{align}
\vec{u}_{n+1} &= \vec{u}_{n} + \Delta t
\vec{\dot{u}}_{n} + \frac{\Delta t^2}{2} \vec{\ddot{u}}_{n}\\
\vec{\dot{u}^{\st{p}}}_{n+1} &= \vec{\dot{u}}_{n} + \Delta t
\vec{\ddot{u}}_{n}
\label{eqn:smm:explicit:onehalfvelocity}
\end{align}
\item \code{model.updateResidual()} and
\code{model.updateAcceleration()} compute the acceleration increment
$\delta \vec{\ddot{u}}$:
\begin{equation}
\left(\mat{M} + \frac{1}{2} \Delta t \mat{C}\right)
\delta \vec{\ddot{u}} = \vec{f_{\st{ext}}} - \vec{f}_{\st{int}\, n+1}
- \mat{C} \vec{\dot{u}^{\st{p}}}_{n+1} - \mat{M} \vec{\ddot{u}}_{n}
\end{equation}
\note{The internal force $\vec{f}_{\st{int}\, n+1}$ is computed from
the displacement $\vec{u}_{n+1}$ based on the constitutive law.}
\item \code{model.explicitCorr()} computes the velocity and
acceleration fields at $t+1$:
\begin{align}
\vec{\dot{u}}_{n+1} &= \vec{\dot{u}^{\st{p}}}_{n+1} + \frac{\Delta t}{2}
\delta \vec{\ddot{u}} \\ \vec{\ddot{u}}_{n+1} &=
\vec{\ddot{u}}_{n} + \delta \vec{\ddot{u}}
\end{align}
\end{itemize}
The use of an explicit time integration scheme is illustrated by the
example:\par
\noindent \shellcode{\examplesdir/explicit/explicit\_dynamic.cc}\par
\noindent This example models the propagation of a wave in a steel beam. The
beam and the applied displacement in the $x$ direction are shown in
Figure~\ref{fig:smm:explicit}.
\begin{figure}[!htb] \centering
\begin{tikzpicture}
\coordinate (c) at (0,2);
\draw[shift={(c)},thick, color=blue] plot [id=x, domain=-5:5, samples=50] ({\x, {(40 * sin(0.1*pi*3*\x) * exp(- (0.1*pi*3*\x)*(0.1*pi*3*\x) / 4))}});
\draw[shift={(c)},-latex] (-6,0) -- (6,0) node[right, below] {$x$};
\draw[shift={(c)},-latex] (0,-0.7) -- (0,1) node[right] {$u$};
\draw[shift={(c)}] (-0.1,0.6) node[left] {$A$}-- (1.5,0.6);
\coordinate (l) at (0,0.6);
\draw[shift={(0,-0.7)}] (-5, 0) -- (5,0) -- (5, 1) -- (-5, 1) -- cycle;
\draw[shift={(l)}, latex-latex] (-5,0)-- (5,0) node [midway, above] {$L$};
\draw[shift={(l)}] (5,0.2)-- (5,-0.2);
\draw[shift={(l)}] (-5,0.2)-- (-5,-0.2);
\coordinate (h) at (5.3,-0.7);
\draw[shift={(h)}, latex-latex] (0,0)-- (0,1) node [midway, right] {$h$};
\draw[shift={(h)}] (-0.2,1)-- (0.2,1);
\draw[shift={(h)}] (-0.2,0)-- (0.2,0);
\end{tikzpicture}
\caption{Numerical setup \label{fig:smm:explicit}}
\end{figure}
The length and height of the beam are $L=\SI{10}{\metre}$ and
$h = \SI{1}{\metre}$, respectively. The material is linear elastic,
homogeneous and isotropic (density:
\SI{7800}{\kilo\gram\per\cubic\metre}, Young's modulus:
\SI{210}{\giga\pascal} and Poisson's ratio: $0.3$). The imposed
displacement follow a Gaussian function with a maximum amplitude of $A = \SI{0.01}{\meter}$. The
potential, kinetic and total energies are computed. The safety factor
is equal to $0.8$.
\input{manual-constitutive-laws}
\section{Adding a New Constitutive Law}\index{Material!create a new
material}
There are several constitutive laws in \akantu as described in the
previous Section~\ref{sect:smm:CL}. It is also possible to use a
user-defined material for the simulation. These materials are referred
to as local materials since they are local to the example of the user
and not part of the \akantu library. To define a new local material,
two files (\code {material\_XXX.hh} and \code{material\_XXX.cc}) have
to be provided where \code{XXX} is the name of the new material. The
header file \code {material\_XXX.hh} defines the interface of your
custom material. Its implementation is provided in the
\code{material\_XXX.cc}. The new law must inherit from the
\code{Material} class or any other existing material class. It is
therefore necessary to include the interface of the parent material
in the header file of your local material and indicate the inheritance
in the declaration of the class:
\begin{cpp}
/* ---------------------------------------------------------------------- */
#include "material.hh"
/* ---------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_XXX_HH__
#define __AKANTU_MATERIAL_XXX_HH__
namespace akantu {
class MaterialXXX : public Material {
/// declare here the interface of your material
};
\end{cpp}
In the header file the user also needs to declare all the members of the new
material. These include the parameters that a read from the
material input file, as well as any other material parameters that will be
computed during the simulation and internal variables.
In the following the example of adding a new damage material will be
presented. In this case the parameters in the material will consist of the
Young's modulus, the Poisson coefficient, the resistance to damage and the
damage threshold. The material will then from these values compute its Lam\'{e}
coefficients and its bulk modulus. Furthermore, the user has to add a new
internal variable \code{damage} in order to store the amount of damage at each
quadrature point in each step of the simulation. For this specific material the
member declaration inside the class will look as follows:
\begin{cpp}
class LocalMaterialDamage : public Material {
/// declare constructors/destructors here
/// declare methods and accessors here
/* -------------------------------------------------------------------- */
/* Class Members */
/* -------------------------------------------------------------------- */
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Damage, damage, Real);
private:
/// the young modulus
Real E;
/// Poisson coefficient
Real nu;
/// First Lame coefficient
Real lambda;
/// Second Lame coefficient (shear modulus)
Real mu;
/// resistance to damage
Real Yd;
/// damage threshold
Real Sd;
/// Bulk modulus
Real kpa;
/// damage internal variable
InternalField<Real> damage;
};
\end{cpp}
In order to enable to print the material parameters at any point in
the user's example file using the standard output stream by typing:
\begin{cpp}
for (UInt m = 0; m < model.getNbMaterials(); ++m)
std::cout << model.getMaterial(m) << std::endl;
\end{cpp}
the standard output stream operator has to be redefined. This should be done at the end of the header file:
\begin{cpp}
class LocalMaterialDamage : public Material {
/// declare here the interace of your material
}:
/* ---------------------------------------------------------------------- */
/* inline functions */
/* ---------------------------------------------------------------------- */
/// standard output stream operator
inline std::ostream & operator <<(std::ostream & stream, const LocalMaterialDamage & _this)
{
_this.printself(stream);
return stream;
}
\end{cpp}
However, the user still needs to register the material parameters that
should be printed out. The registration is done during the call of the
constructor. Like all definitions the implementation of the
constructor has to be written in the \code{material\_XXX.cc}
file. However, the declaration has to be provided in the
\code{material\_XXX.hh} file:
\begin{cpp}
class LocalMaterialDamage : public Material {
/* -------------------------------------------------------------------- */
/* Constructors/Destructors */
/* -------------------------------------------------------------------- */
public:
LocalMaterialDamage(SolidMechanicsModel & model, const ID & id = "");
};
\end{cpp}
The user can now define the implementation of the constructor in the
\code{material\_XXX.cc} file:
\begin{cpp}
/* ---------------------------------------------------------------------- */
#include "local_material_damage.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* ---------------------------------------------------------------------- */
LocalMaterialDamage::LocalMaterialDamage(SolidMechanicsModel & model,
const ID & id) :
Material(model, id),
damage("damage", *this) {
AKANTU_DEBUG_IN();
this->registerParam("E", E, 0., _pat_parsable, "Young's modulus");
this->registerParam("nu", nu, 0.5, _pat_parsable, "Poisson's ratio");
this->registerParam("lambda", lambda, _pat_readable, "First Lame coefficient");
this->registerParam("mu", mu, _pat_readable, "Second Lame coefficient");
this->registerParam("kapa", kpa, _pat_readable, "Bulk coefficient");
this->registerParam("Yd", Yd, 50., _pat_parsmod);
this->registerParam("Sd", Sd, 5000., _pat_parsmod);
damage.initialize(1);
AKANTU_DEBUG_OUT();
}
\end{cpp}
During the intializer list the reference to the model and the material id are
assigned and the constructor of the internal field is called. Inside the scope
of the constructor the internal values have to be initialized and the
parameters, that should be printed out, are registered with the function:
\code{registerParam}\index{Material!registerParam}:
\begin{cpp}
void registerParam(name of the parameter (key in the material file),
member variable,
default value (optional parameter),
access permissions,
description);
\end{cpp}
The available access permissions are as follows:
\begin{itemize}
\item \code{\_pat\_internal}: Parameter can only be output when the material is printed.
\item \code{\_pat\_writable}: User can write into the parameter. The parameter is output when the material is printed.
\item \code{\_pat\_readable}: User can read the parameter. The parameter is output when the material is printed.
\item \code{\_pat\_modifiable}: Parameter is writable and readable.
\item \code{\_pat\_parsable}: Parameter can be parsed, \textit{i.e.} read from the input file.
\item \code{\_pat\_parsmod}: Parameter is modifiable and parsable.
\end{itemize}
In order to implement the new constitutive law the user needs to
specify how the additional material parameters, that are not
defined in the input material file, should be calculated. Furthermore,
it has to be defined how stresses and the stable time step should be
computed for the new local material. In the case of implicit
simulations, in addition, the computation of the tangent stiffness needs
to be defined. Therefore, the user needs to redefine the following
functions of the parent material:
\begin{cpp}
void initMaterial();
// for explicit and implicit simulations void
computeStress(ElementType el_type, GhostType ghost_type = _not_ghost);
// for implicit simulations
void computeTangentStiffness(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost);
// for explicit and implicit simulations
Real getStableTimeStep(Real h, const Element & element);
\end{cpp}
In the following a detailed description of these functions is provided:
\begin{itemize}
\item \code{initMaterial}:~ This method is called after the material
file is fully read and the elements corresponding to each material
are assigned. Some of the frequently used constant parameters are
calculated in this method. For example, the Lam\'{e} constants of
elastic materials can be considered as such parameters.
\item \code{computeStress}:~ In this method, the stresses are
computed based on the constitutive law as a function of the strains of the
quadrature points. For example, the stresses for the elastic
material are calculated based on the following formula:
\begin{equation}
\label{eqn:smm:constitutive_elastic}
\mat{\sigma } =\lambda\mathrm{tr}(\mat{\varepsilon})\mat{I}+2 \mu \mat{\varepsilon}
\end{equation}
Therefore, this method contains a loop on all quadrature points
assigned to the material using the two macros:\par
\code{MATERIAL\_STRESS\_QUADRATURE\_POINT\_LOOP\_BEGIN}\par
\code{MATERIAL\_STRESS\_QUADRATURE\_POINT\_LOOP\_END}
\begin{cpp}
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(element_type);
// sigma <- f(grad_u)
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
\end{cpp}
\note{The strain vector in \akantu contains the values of $\nabla
\vec{u}$, i.e. it is really the \emph{displacement gradient},}
\item \code{computeTangentStiffness}:~ This method is called when
the tangent to the stress-strain curve is desired (see Fig \ref
{fig:smm:AL:K}). For example, it is called in the implicit solver
when the stiffness matrix for the regular elements is assembled
based on the following formula:
\begin{equation}
\label{eqn:smm:constitutive_elasc} \mat{K }
=\int{\mat{B^T}\mat{D(\varepsilon)}\mat{B}}
\end{equation}
Therefore, in this method, the \code{tangent} matrix (\mat{D}) is
computed for a given strain.
\note{ The \code{tangent} matrix is a $4^{th}$ order tensor which is
stored as a matrix in Voigt notation.}
\begin{figure}[!htb]
\begin{center}
\includegraphics[width=0.4\textwidth,keepaspectratio=true]{figures/tangent.pdf}
\caption{Tangent to the stress-strain curve.}
\label{fig:smm:AL:K}
\end{center}
\end{figure}
\item \code{getCelerity}:~The stability criterion of the explicit integration scheme depend on the fastest wave celerity~\eqref{eqn:smm:explicit:stabletime}. This celerity depend on the material, and therefore the value of this velocity should be defined in this method for each new material. By default, the fastest wave speed is the compressive wave whose celerity can be defined in~\code{getPushWaveSpeed}.
\end{itemize}
Once the declaration and implementation of the new material has been
completed, this material can be used in the user's example by including the header file:
\begin{cpp}
#include "material_XXX.hh"
\end{cpp}
For existing materials, as mentioned in Section~\ref{sect:smm:CL}, by
default, the materials are initialized inside the method
\code{initFull}. If a local material should be used instead, the
initialization of the material has to be postponed until the local
material is registered in the model. Therefore, the model is
initialized with the boolean for skipping the material initialization
equal to true:
\begin{cpp}
/// model initialization
model.initFull(_analysis_method = _explicit_lumped_mass);
\end{cpp}
Once the model has been initialized, the local material needs
to be registered in the model:
\begin{cpp}
model.registerNewCustomMaterials<XXX>("name_of_local_material");
\end{cpp}
Only at this point the material can be initialized:
\begin{cpp}
model.initMaterials();
\end{cpp}
A full example for adding a new damage law can be found in
\shellcode{\examplesdir/new\_material}.
\subsection{Adding a New Non-Local Constitutive Law}\index{Material!create a new non-local material}
In order to add a new non-local material we first have to add the local constitutive law in \akantu (see above). We can then add the non-local version of the constitutive law by adding the two files (\code{material\_XXX\_non\_local.hh} and \code{material\_XXX\_non\_local.cc}) where \code{XXX} is the name of the corresponding local material. The new law must inherit from the two classes, non-local parent class, such as the \code{MaterialNonLocal} class, and from the local version of the constitutive law, \textit{i.e.} \code{MaterialXXX}. It is therefore necessary to include the interface of those classes in the header file of your custom material and indicate the inheritance in the declaration of the class:
\begin{cpp}
/* ---------------------------------------------------------------------- */
#include "material_non_local.hh" // the non-local parent
#include "material_XXX.hh"
/* ---------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_XXX_HH__
#define __AKANTU_MATERIAL_XXX_HH__
namespace akantu {
class MaterialXXXNonLocal : public MaterialXXX,
public MaterialNonLocal {
/// declare here the interface of your material
};
\end{cpp}
As members of the class we only need to add the internal fields to store the non-local quantities, which are obtained from the averaging process:
\begin{cpp}
/* -------------------------------------------------------------------------- */
/* Class members */
/* -------------------------------------------------------------------------- *
protected:
InternalField<Real> grad_u_nl;
\end{cpp}
The following four functions need to be implemented in the non-local material:
\begin{cpp}
/// initialization of the material
void initMaterial();
/// loop over all element and invoke stress computation
virtual void computeNonLocalStresses(GhostType ghost_type);
/// compute stresses after local quantities have been averaged
virtual void computeNonLocalStress(ElementType el_type, GhostType ghost_type)
/// compute all local quantities
void computeStress(ElementType el_type, GhostType ghost_type);
\end{cpp}
In the intialization of the non-local material we need to register the local quantity for the averaging process. In our example the internal field \emph{grad\_u\_nl} is the non-local counterpart of the gradient of the displacement field (\emph{grad\_u\_nl}):
\begin{cpp}
void MaterialXXXNonLocal::initMaterial() {
MaterialXXX::initMaterial();
MaterialNonLocal::initMaterial();
/// register the non-local variable in the manager
this->model->getNonLocalManager().registerNonLocalVariable(this->grad_u.getName(), this->grad_u_nl.getName(), spatial_dimension * spatial_dimension);
}
\end{cpp}
The function to register the non-local variable takes as parameters the name of the local internal field, the name of the non-local counterpart and the number of components of the field we want to average.
In the \emph{computeStress} we now need to compute all the quantities we want to average. We can then write a loop for the stress computation in the function \emph{computeNonLocalStresses} and then provide the constitutive law on each integration point in the function \emph{computeNonLocalStress}.
%%% Local Variables: %%% mode: latex %%% TeX-master: "manual" %%% End:
diff --git a/examples/cohesive_element/cohesive_extrinsic/cohesive_extrinsic.cc b/examples/cohesive_element/cohesive_extrinsic/cohesive_extrinsic.cc
index df76899ae..6c0da65d8 100644
--- a/examples/cohesive_element/cohesive_extrinsic/cohesive_extrinsic.cc
+++ b/examples/cohesive_element/cohesive_extrinsic/cohesive_extrinsic.cc
@@ -1,126 +1,125 @@
/**
* @file cohesive_extrinsic.cc
*
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Mon Jan 18 2016
*
* @brief Test for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
const UInt spatial_dimension = 2;
const UInt max_steps = 1000;
Mesh mesh(spatial_dimension);
mesh.read("triangle.msh");
SolidMechanicsModelCohesive model(mesh);
/// model initialization
- model.initFull(
- _analysis_method = _explicit_lumped_mass,
- _is_extrinsic = true);
+ model.initFull(_analysis_method = _explicit_lumped_mass,
+ _is_extrinsic = true);
Real time_step = model.getStableTimeStep() * 0.05;
model.setTimeStep(time_step);
std::cout << "Time step: " << time_step << std::endl;
CohesiveElementInserter & inserter = model.getElementInserter();
inserter.setLimit(_y, 0.30, 0.20);
model.updateAutomaticInsertion();
Array<Real> & position = mesh.getNodes();
Array<Real> & velocity = model.getVelocity();
Array<bool> & boundary = model.getBlockedDOFs();
Array<Real> & displacement = model.getDisplacement();
UInt nb_nodes = mesh.getNbNodes();
/// boundary conditions
for (UInt n = 0; n < nb_nodes; ++n) {
if (position(n, 1) > 0.99 || position(n, 1) < -0.99)
boundary(n, 1) = true;
if (position(n, 0) > 0.99 || position(n, 0) < -0.99)
boundary(n, 0) = true;
}
model.setBaseName("extrinsic");
model.addDumpFieldVector("displacement");
model.addDumpField("velocity");
model.addDumpField("acceleration");
model.addDumpField("internal_force");
model.addDumpField("stress");
model.addDumpField("grad_u");
model.dump();
/// initial conditions
Real loading_rate = 0.5;
Real disp_update = loading_rate * time_step;
for (UInt n = 0; n < nb_nodes; ++n) {
velocity(n, 1) = loading_rate * position(n, 1);
}
/// Main loop
for (UInt s = 1; s <= max_steps; ++s) {
/// update displacement on extreme nodes
for (UInt n = 0; n < nb_nodes; ++n) {
if (position(n, 1) > 0.99 || position(n, 1) < -0.99)
displacement(n, 1) += disp_update * position(n, 1);
}
model.checkCohesiveStress();
model.solveStep();
if (s % 10 == 0) {
model.dump();
std::cout << "passing step " << s << "/" << max_steps << std::endl;
}
}
Real Ed = model.getEnergy("dissipated");
Real Edt = 200 * std::sqrt(2);
std::cout << Ed << " " << Edt << std::endl;
if (Ed < Edt * 0.999 || Ed > Edt * 1.001 || std::isnan(Ed)) {
std::cout << "The dissipated energy is incorrect" << std::endl;
return EXIT_FAILURE;
}
finalize();
return EXIT_SUCCESS;
}
diff --git a/examples/cohesive_element/cohesive_extrinsic_implicit/cohesive_extrinsic_implicit.cc b/examples/cohesive_element/cohesive_extrinsic_implicit/cohesive_extrinsic_implicit.cc
index e7bd04c0f..b44be75ef 100644
--- a/examples/cohesive_element/cohesive_extrinsic_implicit/cohesive_extrinsic_implicit.cc
+++ b/examples/cohesive_element/cohesive_extrinsic_implicit/cohesive_extrinsic_implicit.cc
@@ -1,171 +1,173 @@
/**
* @file cohesive_extrinsic_implicit.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jan 12 2016
* @date last modification: Mon Jan 18 2016
*
* @brief Example for extrinsic cohesive elements in implicit
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
debug::setDebugLevel(dblError);
const UInt spatial_dimension = 2;
const UInt max_steps = 20;
const Real final_opening = 1e-4;
Mesh mesh(spatial_dimension);
mesh.read("dcb_2d.msh");
SolidMechanicsModelCohesive model(mesh);
/// model initialization
model.initFull(SolidMechanicsModelCohesiveOptions(_static, true));
// CohesiveElementInserter inserter(mesh);
model.limitInsertion(_y, -0.000001, 0.000001);
model.updateAutomaticInsertion();
Real eps = 1e-11;
Array<bool> & boundary = model.getBlockedDOFs();
Array<Real> & position = mesh.getNodes();
Array<Real> & displacement = model.getDisplacement();
/// boundary conditions
const Vector<Real> & lower = mesh.getLowerBounds();
const Vector<Real> & upper = mesh.getUpperBounds();
const Real left = lower[0];
const Real right = upper[0];
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (std::abs(position(n, 0) - left) < eps) {
boundary(n, 1) = true;
boundary(n, 0) = true;
}
if (std::abs(position(n, 0) - right) < eps && position(n, 1) < 0.0)
boundary(n, 1) = true;
if (std::abs(position(n, 0) - right) < eps && position(n, 1) > 0.0)
boundary(n, 1) = true;
}
model.setBaseName("extr_impl");
model.addDumpFieldVector("displacement");
model.addDumpField("external_force");
model.addDumpField("internal_force");
model.addDumpField("stress");
model.addDumpField("partitions");
model.dump();
// Dumping cohesive elements
model.setBaseNameToDumper("cohesive elements", "cohe_elem_extr_impl");
model.addDumpFieldVectorToDumper("cohesive elements", "displacement");
model.addDumpFieldToDumper("cohesive elements", "damage");
model.dump("cohesive elements");
// model.updateResidual();
Real increment = final_opening / max_steps;
Real tolerance = 1e-13;
Real error;
bool load_reduction = false;
Real tol_increase_factor = 1.0e8;
/// Main loop
for (UInt nstep = 0; nstep < max_steps; ++nstep) {
std::cout << "step no. " << nstep << std::endl;
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (std::abs(position(n, 0) - right) < eps && position(n, 1) > 0.0)
displacement(n, 1) += increment;
if (std::abs(position(n, 0) - right) < eps && position(n, 1) < 0.0)
displacement(n, 1) -= increment;
}
- model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ model.solveStepCohesive<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
tolerance, error, 25, load_reduction, tol_increase_factor);
// If convergence has not been reached, the load is reduced and
// the incremental step is solved again.
while (!load_reduction && error > tolerance) {
load_reduction = true;
std::cout << "LOAD STEP REDUCTION" << std::endl;
increment = increment / 2.0;
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (std::abs(position(n, 0) - right) < eps && position(n, 1) > 0.0)
displacement(n, 1) -= increment;
if (std::abs(position(n, 0) - right) < eps && position(n, 1) < 0.0)
displacement(n, 1) += increment;
}
UInt nb_cohesive_elements =
mesh.getNbElement(spatial_dimension, _not_ghost, _ek_cohesive);
- model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ model.solveStepCohesive<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
tolerance, error, 25, load_reduction, tol_increase_factor);
UInt new_nb_cohesive_elements =
mesh.getNbElement(spatial_dimension, _not_ghost, _ek_cohesive);
UInt nb_cohe[2];
nb_cohe[0] = nb_cohesive_elements;
nb_cohe[1] = new_nb_cohesive_elements;
// Every time a new cohesive element is introduced, the variable
// load_reduction is set to false, so that it is possible to
// further iterate in the loop of load reduction. If no new
// cohesive elements are introduced, usually there is no gain in
// further reducing the load, even if convergence is not reached
if (nb_cohe[0] == nb_cohe[1])
load_reduction = true;
else
load_reduction = false;
}
model.dump();
model.dump("cohesive elements");
UInt nb_cohe_elems[1];
nb_cohe_elems[0] =
mesh.getNbElement(spatial_dimension, _not_ghost, _ek_cohesive);
std::cout << "No. of cohesive elements: " << nb_cohe_elems[0] << std::endl;
}
finalize();
return EXIT_SUCCESS;
}
diff --git a/examples/cohesive_element/cohesive_intrinsic/cohesive_intrinsic.cc b/examples/cohesive_element/cohesive_intrinsic/cohesive_intrinsic.cc
index 841c35d0f..ec276ee41 100644
--- a/examples/cohesive_element/cohesive_intrinsic/cohesive_intrinsic.cc
+++ b/examples/cohesive_element/cohesive_intrinsic/cohesive_intrinsic.cc
@@ -1,151 +1,136 @@
/**
* @file cohesive_intrinsic.cc
*
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Mon Jan 18 2016
*
* @brief Test for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
+#include "element_group.hh"
#include "mesh_iterators.hh"
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
-static void updateDisplacement(SolidMechanicsModelCohesive &, Array<UInt> &,
- ElementType, Real);
+static void updateDisplacement(SolidMechanicsModelCohesive &,
+ const ElementGroup &, Real);
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
const UInt spatial_dimension = 2;
const UInt max_steps = 350;
- const ElementType type = _triangle_6;
-
Mesh mesh(spatial_dimension);
mesh.read("triangle.msh");
SolidMechanicsModelCohesive model(mesh);
model.getElementInserter().setLimit(_x, -0.26, -0.24);
/// model initialization
- model.initFull();
+ model.initFull(_analysis_method = _explicit_lumped_mass,
+ _is_extrinsic = false);
Real time_step = model.getStableTimeStep() * 0.8;
model.setTimeStep(time_step);
std::cout << "Time step: " << time_step << std::endl;
Array<bool> & boundary = model.getBlockedDOFs();
UInt nb_nodes = mesh.getNbNodes();
/// boundary conditions
for (UInt dim = 0; dim < spatial_dimension; ++dim) {
for (UInt n = 0; n < nb_nodes; ++n) {
boundary(n, dim) = true;
}
}
model.setBaseName("intrinsic");
model.addDumpFieldVector("displacement");
model.addDumpField("velocity");
model.addDumpField("acceleration");
model.addDumpField("stress");
model.addDumpField("grad_u");
model.addDumpField("external_force");
model.addDumpField("internal_force");
model.dump();
/// update displacement
- Array<UInt> elements;
+ auto && elements = mesh.createElementGroup("diplacement");
Vector<Real> barycenter(spatial_dimension);
- for_each_element(mesh, [&](auto && el) {
- mesh.getBarycenter(el, barycenter);
- if (barycenter(_x) > -0.25)
- elements.push_back(el.element);
- });
+
+ for_each_element(mesh,
+ [&](auto && el) {
+ mesh.getBarycenter(el, barycenter);
+ if (barycenter(_x) > -0.25)
+ elements.add(el, true);
+ },
+ _element_kind = _ek_regular);
Real increment = 0.01;
- updateDisplacement(model, elements, type, increment);
+ updateDisplacement(model, elements, increment);
/// Main loop
for (UInt s = 1; s <= max_steps; ++s) {
model.solveStep();
- updateDisplacement(model, elements, type, increment);
-
+ updateDisplacement(model, elements, increment);
if (s % 1 == 0) {
model.dump();
std::cout << "passing step " << s << "/" << max_steps << std::endl;
}
}
Real Ed = model.getEnergy("dissipated");
-
Real Edt = 2 * sqrt(2);
std::cout << Ed << " " << Edt << std::endl;
if (Ed < Edt * 0.999 || Ed > Edt * 1.001 || std::isnan(Ed)) {
std::cout << "The dissipated energy is incorrect" << std::endl;
return EXIT_FAILURE;
}
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
static void updateDisplacement(SolidMechanicsModelCohesive & model,
- Array<UInt> & elements, ElementType type,
- Real increment) {
- Mesh & mesh = model.getMesh();
- UInt nb_element = elements.size();
- UInt nb_nodes = mesh.getNbNodes();
- UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
-
- const Array<UInt> & connectivity = mesh.getConnectivity(type);
+ const ElementGroup & group, Real increment) {
Array<Real> & displacement = model.getDisplacement();
- Array<bool> update(nb_nodes);
- update.clear();
-
- for (UInt el = 0; el < nb_element; ++el) {
- for (UInt n = 0; n < nb_nodes_per_element; ++n) {
- UInt node = connectivity(elements(el), n);
- if (!update(node)) {
- displacement(node, 0) -= increment;
- // displacement(node, 1) += increment;
- update(node) = true;
- }
- }
+
+ for (auto && node : group.getNodeGroup().getNodes()) {
+ displacement(node, 0) += increment;
}
}
diff --git a/examples/cohesive_element/cohesive_intrinsic/triangle.geo b/examples/cohesive_element/cohesive_intrinsic/triangle.geo
index cbe3dd7a7..9b4ba1410 100644
--- a/examples/cohesive_element/cohesive_intrinsic/triangle.geo
+++ b/examples/cohesive_element/cohesive_intrinsic/triangle.geo
@@ -1,15 +1,15 @@
-h = 1.;
+h = .1;
Point(1) = { 1, 1, 0, h};
Point(2) = {-1, 1, 0, h};
Point(3) = {-1,-1, 0, h};
Point(4) = { 1,-1, 0, h};
Line(1) = {1, 2};
Line(2) = {2, 3};
Line(3) = {3, 4};
Line(4) = {4, 1};
Line Loop(5) = {1, 2, 3, 4};
Plane Surface(6) = {5};
Physical Surface(7) = {6};
Transfinite Line {1, 2, 3, 4} = 3;
\ No newline at end of file
diff --git a/examples/explicit/explicit_dynamic.cc b/examples/explicit/explicit_dynamic.cc
index c03506e49..76b6d19e4 100644
--- a/examples/explicit/explicit_dynamic.cc
+++ b/examples/explicit/explicit_dynamic.cc
@@ -1,113 +1,107 @@
/**
* @file explicit_dynamic.cc
*
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
*
* @date creation: Sun Jul 12 2015
* @date last modification: Mon Jan 18 2016
*
* @brief This code refers to the explicit dynamic example from the user manual
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
const UInt spatial_dimension = 3;
const Real pulse_width = 2.;
const Real A = 0.01;
Real time_step;
Real time_factor = 0.8;
UInt max_steps = 1000;
Mesh mesh(spatial_dimension);
- if(Communicator::getStaticCommunicator().whoAmI() == 0)
+ if (Communicator::getStaticCommunicator().whoAmI() == 0)
mesh.read("bar.msh");
- mesh.distribute();
-
- mesh.makePeriodic(_x);
- mesh.makePeriodic(_y);
- mesh.makePeriodic(_z);
-
SolidMechanicsModel model(mesh);
/// model initialization
model.initFull(_analysis_method = _explicit_lumped_mass);
time_step = model.getStableTimeStep();
std::cout << "Time Step = " << time_step * time_factor << "s (" << time_step
<< "s)" << std::endl;
model.setTimeStep(time_step * time_factor);
/// boundary and initial conditions
Array<Real> & displacement = model.getDisplacement();
const Array<Real> & nodes = mesh.getNodes();
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
Real x = nodes(n) - 2;
// Sinus * Gaussian
Real L = pulse_width;
Real k = 0.1 * 2 * M_PI * 3 / L;
displacement(n) = A * sin(k * x) * exp(-(k * x) * (k * x) / (L * L));
}
std::ofstream energy;
energy.open("energy.csv");
energy << "id,rtime,epot,ekin,tot" << std::endl;
model.setBaseName("explicit_dynamic");
model.addDumpField("displacement");
model.addDumpField("velocity");
model.addDumpField("acceleration");
model.addDumpField("stress");
model.dump();
for (UInt s = 1; s <= max_steps; ++s) {
model.solveStep();
Real epot = model.getEnergy("potential");
Real ekin = model.getEnergy("kinetic");
energy << s << "," << s * time_step << "," << epot << "," << ekin << ","
<< epot + ekin << "," << std::endl;
if (s % 10 == 0)
std::cout << "passing step " << s << "/" << max_steps << std::endl;
model.dump();
}
energy.close();
finalize();
return EXIT_SUCCESS;
}
diff --git a/examples/heat_transfer/heat_transfer_static_2d.cc b/examples/heat_transfer/heat_transfer_static_2d.cc
index 63d25d308..70ce4d03a 100644
--- a/examples/heat_transfer/heat_transfer_static_2d.cc
+++ b/examples/heat_transfer/heat_transfer_static_2d.cc
@@ -1,94 +1,94 @@
/**
* @file test_heat_transfer_model_square2d_implicit.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sun May 01 2011
* @date last modification: Mon Jan 29 2018
*
* @brief test of the class HeatTransferModel on the 3d cube
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "heat_transfer_model.hh"
/* -------------------------------------------------------------------------- */
+#include <cmath>
#include <fstream>
#include <iostream>
#include <string>
-#include <cmath>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
UInt spatial_dimension = 2;
std::string base_name;
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
// create mesh
Mesh mesh(spatial_dimension);
mesh.read("square.msh");
HeatTransferModel model(mesh);
// initialize everything
model.initFull(_analysis_method = _static);
// boundary conditions
const Array<Real> & nodes = mesh.getNodes();
Array<bool> & blocked_dofs = model.getBlockedDOFs();
Array<Real> & temperature = model.getTemperature();
double length = 1.;
UInt nb_nodes = nodes.size();
for (UInt i = 0; i < nb_nodes; ++i) {
temperature(i) = 100.;
Real dx = nodes(i, 0);
Real dy = nodes(i, 1);
- Vector<Real> dX = {dx , dy};
+ Vector<Real> dX = {dx, dy};
dX -= length / 4.;
Real d = dX.norm();
if (d < 0.1) {
blocked_dofs(i) = true;
temperature(i) = 300.;
}
if (std::abs(dx) < 1e-4 || std::abs(dy) < 1e-4)
blocked_dofs(i) = true;
- if (std::abs(dx-length) < 1e-4 || std::abs(dy-length) < 1e-4)
+ if (std::abs(dx - length) < 1e-4 || std::abs(dy - length) < 1e-4)
blocked_dofs(i) = true;
}
model.setBaseName("heat_transfer_static_2d");
model.addDumpField("temperature");
model.addDumpField("internal_heat_rate");
model.addDumpField("conductivity");
model.addDumpField("blocked_dofs");
model.dump();
model.solveStep();
model.dump();
return 0;
}
diff --git a/examples/implicit/implicit_dynamic.cc b/examples/implicit/implicit_dynamic.cc
index 210be4f38..50de8e6e8 100644
--- a/examples/implicit/implicit_dynamic.cc
+++ b/examples/implicit/implicit_dynamic.cc
@@ -1,148 +1,149 @@
/**
* @file implicit_dynamic.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sun Oct 19 2014
*
* @brief This code refers to the implicit dynamic example from the user manual
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "non_linear_solver.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
const Real bar_length = 10.;
const Real bar_height = 1.;
const Real bar_depth = 1.;
const Real F = 5e3;
const Real L = bar_length;
const Real I = bar_depth * bar_height * bar_height * bar_height / 12.;
const Real E = 12e7;
const Real rho = 1000;
const Real m = rho * bar_height * bar_depth;
static Real w(UInt n) {
return n * n * M_PI * M_PI / (L * L) * sqrt(E * I / m);
}
static Real analytical_solution(Real time) {
return 2 * F * L * L * L / (pow(M_PI, 4) * E * I) *
((1. - cos(w(1) * time)) + (1. - cos(w(3) * time)) / 81. +
(1. - cos(w(5) * time)) / 625.);
}
const UInt spatial_dimension = 2;
const Real time_step = 1e-4;
const Real max_time = 0.62;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize("material_dynamic.dat", argc, argv);
Mesh mesh(spatial_dimension);
const auto & comm = Communicator::getStaticCommunicator();
Int prank = comm.whoAmI();
if (prank == 0)
mesh.read("beam.msh");
mesh.distribute();
SolidMechanicsModel model(mesh);
/// model initialization
model.initFull(_analysis_method = _implicit_dynamic);
Material & mat = model.getMaterial(0);
mat.setParam("E", E);
mat.setParam("rho", rho);
Array<Real> & force = model.getExternalForce();
Array<Real> & displacment = model.getDisplacement();
// boundary conditions
model.applyBC(BC::Dirichlet::FixedValue(0.0, _x), "blocked");
model.applyBC(BC::Dirichlet::FixedValue(0.0, _y), "blocked");
model.applyBC(BC::Dirichlet::FixedValue(0.0, _y), "roller");
- const Array<UInt> & trac_nodes = mesh.getElementGroup("traction").getNodes();
+ const Array<UInt> & trac_nodes =
+ mesh.getElementGroup("traction").getNodeGroup().getNodes();
bool dump_node = false;
if (trac_nodes.size() > 0 && mesh.isLocalOrMasterNode(trac_nodes(0))) {
force(trac_nodes(0), 1) = F;
dump_node = true;
}
// output setup
std::ofstream pos;
pos.open("position.csv");
if (!pos.good())
AKANTU_ERROR("Cannot open file \"position.csv\"");
pos << "id,time,position,solution" << std::endl;
model.setBaseName("dynamic");
model.addDumpFieldVector("displacement");
model.addDumpField("velocity");
model.addDumpField("acceleration");
model.addDumpField("external_force");
model.addDumpField("internal_force");
model.dump();
model.setTimeStep(time_step);
auto & solver = model.getNonLinearSolver();
solver.set("max_iterations", 100);
solver.set("threshold", 1e-12);
solver.set("convergence_type", SolveConvergenceCriteria::_solution);
/// time loop
Real time = 0.;
for (UInt s = 1; time < max_time; ++s, time += time_step) {
if (prank == 0)
std::cout << s << "\r" << std::flush;
model.solveStep();
if (dump_node)
pos << s << "," << time << "," << displacment(trac_nodes(0), 1) << ","
<< analytical_solution(s * time_step) << std::endl;
if (s % 100 == 0)
model.dump();
}
std::cout << std::endl;
pos.close();
finalize();
return EXIT_SUCCESS;
}
diff --git a/examples/io/dumper/CMakeLists.txt b/examples/io/dumper/CMakeLists.txt
index 16f1bdeaa..b8c2a4e1c 100644
--- a/examples/io/dumper/CMakeLists.txt
+++ b/examples/io/dumper/CMakeLists.txt
@@ -1,61 +1,63 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Fabian Barras <fabian.barras@epfl.ch>
#
# @date creation: Fri Sep 03 2010
# @date last modification: Wed Jan 20 2016
#
# @brief CMakeLists for DumperIOHelper examples
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#
#===============================================================================
add_mesh(swiss_train_mesh swiss_train.geo 2 1)
add_library(locomotive_tools
locomotive_tools.cc
locomotive_tools.hh
)
package_get_include_dir(BOOST _boost_include_dir)
target_link_libraries(locomotive_tools PRIVATE akantu)
target_include_directories(locomotive_tools PRIVATE ${AKANTU_INCLUDE_DIRS} ${_boost_include_dir})
if(AKANTU_EXTRA_CXX_FLAGS)
set_target_properties(locomotive_tools PROPERTIES COMPILE_FLAGS ${AKANTU_EXTRA_CXX_FLAGS})
endif()
register_example(dumper_low_level
SOURCES dumper_low_level.cc
USE_PACKAGES IOHelper
DEPENDS swiss_train_mesh locomotive_tools
+ DIRECTORIES_TO_CREATE paraview
)
register_example(dumpable_interface
SOURCES dumpable_interface.cc
USE_PACKAGES IOHelper
DEPENDS swiss_train_mesh locomotive_tools
+ DIRECTORIES_TO_CREATE paraview
)
diff --git a/examples/io/dumper/dumpable_interface.cc b/examples/io/dumper/dumpable_interface.cc
index fe3505088..8de5326de 100644
--- a/examples/io/dumper/dumpable_interface.cc
+++ b/examples/io/dumper/dumpable_interface.cc
@@ -1,186 +1,190 @@
/**
* @file dumpable_interface.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Aug 17 2015
* @date last modification: Mon Aug 31 2015
*
* @brief Example of dumper::Dumpable interface.
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_group.hh"
#include "group_manager_inline_impl.cc"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#include "dumpable_inline_impl.hh"
#include "dumper_iohelper_paraview.hh"
/* -------------------------------------------------------------------------- */
#include "locomotive_tools.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
/*
In this example, we present dumper::Dumpable which is an interface
for other classes who want to dump themselves.
Several classes of Akantu inheritate from Dumpable (Model, Mesh, ...).
In this example we reproduce the same tasks as example_dumper_low_level.cc
using this time Dumpable interface inherted by Mesh, NodeGroup and
ElementGroup.
It is then advised to read first example_dumper_low_level.cc.
*/
initialize(argc, argv);
// To start let us load the swiss train mesh and its mesh data information.
UInt spatial_dimension = 2;
Mesh mesh(spatial_dimension);
mesh.read("swiss_train.msh");
/*
swiss_train.msh has the following physical groups that can be viewed with
GMSH:
"$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
6
2 1 "red"
2 2 "white"
2 3 "lwheel_1"
2 4 "lwheel_2"
2 5 "rwheel_2"
2 6 "rwheel_1"
$EndPhysicalNames
..."
*/
// Grouping nodes and elements belonging to train wheels (=four mesh data).
ElementGroup & wheels_elements =
mesh.createElementGroup("wheels", spatial_dimension);
wheels_elements.append(mesh.getElementGroup("lwheel_1"));
wheels_elements.append(mesh.getElementGroup("lwheel_2"));
wheels_elements.append(mesh.getElementGroup("rwheel_1"));
wheels_elements.append(mesh.getElementGroup("rwheel_2"));
- const Array<UInt> & lnode_1 = (mesh.getElementGroup("lwheel_1")).getNodes();
- const Array<UInt> & lnode_2 = (mesh.getElementGroup("lwheel_2")).getNodes();
- const Array<UInt> & rnode_1 = (mesh.getElementGroup("rwheel_1")).getNodes();
- const Array<UInt> & rnode_2 = (mesh.getElementGroup("rwheel_2")).getNodes();
+ const Array<UInt> & lnode_1 =
+ (mesh.getElementGroup("lwheel_1")).getNodeGroup().getNodes();
+ const Array<UInt> & lnode_2 =
+ (mesh.getElementGroup("lwheel_2")).getNodeGroup().getNodes();
+ const Array<UInt> & rnode_1 =
+ (mesh.getElementGroup("rwheel_1")).getNodeGroup().getNodes();
+ const Array<UInt> & rnode_2 =
+ (mesh.getElementGroup("rwheel_2")).getNodeGroup().getNodes();
Array<Real> & node = mesh.getNodes();
UInt nb_nodes = mesh.getNbNodes();
// This time a 2D Array is created and a padding size of 3 is passed to
// NodalField in order to warp train deformation on Paraview.
Array<Real> displacement(nb_nodes, spatial_dimension);
// Create an ElementTypeMapArray for the colour
ElementTypeMapArray<UInt> colour("colour");
colour.initialize(mesh, _with_nb_element = true);
/* ------------------------------------------------------------------------ */
/* Creating dumpers */
/* ------------------------------------------------------------------------ */
// Create dumper for the complete mesh and register it as default dumper.
- DumperParaview dumper("train", "./paraview/dumpable", false);
+ auto && dumper = std::make_shared<DumperParaview>("train", "./paraview/dumpable", false);
mesh.registerExternalDumper(dumper, "train", true);
mesh.addDumpMesh(mesh);
// The dumper for the filtered mesh can be directly taken from the
// ElementGroup and then registered as "wheels_elements" dumper.
- DumperIOHelper & wheels = mesh.getGroupDumper("paraview_wheels", "wheels");
+ auto && wheels = mesh.getGroupDumper("paraview_wheels", "wheels");
- mesh.registerExternalDumper(wheels, "wheels");
+ mesh.registerExternalDumper(wheels.shared_from_this(), "wheels");
mesh.setDirectoryToDumper("wheels", "./paraview/dumpable");
// Arrays and ElementTypeMapArrays can be added as external fields directly
mesh.addDumpFieldExternal("displacement", displacement);
ElementTypeMapArrayFilter<UInt> filtered_colour(
colour, wheels_elements.getElements());
auto colour_field_wheel =
std::make_shared<dumper::ElementalField<UInt, Vector, true>>(
filtered_colour);
mesh.addDumpFieldExternal("color", colour_field_wheel);
mesh.addDumpFieldExternalToDumper("wheels", "displacement", displacement);
mesh.addDumpFieldExternalToDumper("wheels", "colour", colour);
// For some specific cases the Fields should be created, as when you want to
// pad an array
auto displacement_vector_field =
mesh.createNodalField(&displacement, "all", 3);
mesh.addDumpFieldExternal("displacement_as_paraview_vector",
displacement_vector_field);
mesh.addDumpFieldExternalToDumper("wheels", "displacement_as_paraview_vector",
displacement_vector_field);
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
// Fill the ElementTypeMapArray colour.
fillColour(mesh, colour);
/// Apply displacement and wheels rotation.
Real tot_displacement = 50.;
Real radius = 1.;
UInt nb_steps = 100;
Real theta = tot_displacement / radius;
Vector<Real> l_center(spatial_dimension);
Vector<Real> r_center(spatial_dimension);
for (UInt i = 0; i < spatial_dimension; ++i) {
l_center(i) = node(14, i);
r_center(i) = node(2, i);
}
for (UInt i = 0; i < nb_steps; ++i) {
displacement.clear();
Real step_ratio = Real(i) / Real(nb_steps);
Real angle = step_ratio * theta;
applyRotation(l_center, angle, node, displacement, lnode_1);
applyRotation(l_center, angle, node, displacement, lnode_2);
applyRotation(r_center, angle, node, displacement, rnode_1);
applyRotation(r_center, angle, node, displacement, rnode_2);
for (UInt j = 0; j < nb_nodes; ++j) {
displacement(j, _x) += step_ratio * tot_displacement;
}
/// Dump call is finally made through Dumpable interface.
mesh.dump();
mesh.dump("wheels");
}
finalize();
return 0;
}
diff --git a/examples/io/dumper/dumper_low_level.cc b/examples/io/dumper/dumper_low_level.cc
index 30ab30377..51eaa337b 100644
--- a/examples/io/dumper/dumper_low_level.cc
+++ b/examples/io/dumper/dumper_low_level.cc
@@ -1,194 +1,198 @@
/**
* @file dumper_low_level.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Aug 17 2015
*
* @brief Example of dumper::DumperIOHelper low-level methods.
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_group.hh"
#include "group_manager.hh"
#include "mesh.hh"
#include "dumper_elemental_field.hh"
#include "dumper_nodal_field.hh"
#include "dumper_iohelper_paraview.hh"
#include "locomotive_tools.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
/* This example aims at illustrating how to manipulate low-level methods of
DumperIOHelper.
The aims is to visualize a colorized moving train with Paraview */
initialize(argc, argv);
// To start let us load the swiss train mesh and its mesh data information.
// We aknowledge here a weel-known swiss industry for mesh donation.
UInt spatial_dimension = 2;
Mesh mesh(spatial_dimension);
mesh.read("swiss_train.msh");
Array<Real> & nodes = mesh.getNodes();
UInt nb_nodes = mesh.getNbNodes();
/* swiss_train.msh has the following physical groups that can be viewed with
GMSH:
"$MeshFormat
2.2 0 8
$EndMeshFormat
$PhysicalNames
6
2 1 "red"
2 2 "white"
2 3 "lwheel_1"
2 4 "lwheel_2"
2 5 "rwheel_2"
2 6 "rwheel_1"
$EndPhysicalNames
..."
*/
// Grouping nodes and elements belonging to train wheels (=four mesh data)
ElementGroup & wheels_elements =
mesh.createElementGroup("wheels", spatial_dimension);
wheels_elements.append(mesh.getElementGroup("lwheel_1"));
wheels_elements.append(mesh.getElementGroup("lwheel_2"));
wheels_elements.append(mesh.getElementGroup("rwheel_1"));
wheels_elements.append(mesh.getElementGroup("rwheel_2"));
- const Array<UInt> & lnode_1 = (mesh.getElementGroup("lwheel_1")).getNodes();
- const Array<UInt> & lnode_2 = (mesh.getElementGroup("lwheel_2")).getNodes();
- const Array<UInt> & rnode_1 = (mesh.getElementGroup("rwheel_1")).getNodes();
- const Array<UInt> & rnode_2 = (mesh.getElementGroup("rwheel_2")).getNodes();
+ const Array<UInt> & lnode_1 =
+ (mesh.getElementGroup("lwheel_1")).getNodeGroup().getNodes();
+ const Array<UInt> & lnode_2 =
+ (mesh.getElementGroup("lwheel_2")).getNodeGroup().getNodes();
+ const Array<UInt> & rnode_1 =
+ (mesh.getElementGroup("rwheel_1")).getNodeGroup().getNodes();
+ const Array<UInt> & rnode_2 =
+ (mesh.getElementGroup("rwheel_2")).getNodeGroup().getNodes();
/* Note this Array is constructed with three components in order to warp train
deformation on Paraview. A more appropriate way to do this is to set a
padding in the NodalField (See example_dumpable_interface.cc.) */
Array<Real> displacement(nb_nodes, 3);
// ElementalField are constructed with an ElementTypeMapArray.
ElementTypeMapArray<UInt> colour;
colour.initialize(mesh, _with_nb_element = true);
/* ------------------------------------------------------------------------ */
/* Dumper creation */
/* ------------------------------------------------------------------------ */
// Creation of two DumperParaview. One for full mesh, one for a filtered
// mesh.
DumperParaview dumper("train", "./paraview/dumper", false);
DumperParaview wheels("wheels", "./paraview/dumper", false);
// Register the full mesh
dumper.registerMesh(mesh);
// Register a filtered mesh limited to nodes and elements from wheels groups
wheels.registerFilteredMesh(mesh, wheels_elements.getElements(),
- wheels_elements.getNodes());
+ wheels_elements.getNodeGroup().getNodes());
// Generate an output file of the two mesh registered.
dumper.dump();
wheels.dump();
/* At this stage no fields are attached to the two dumpers. To do so, a
dumper::Field object has to be created. Several types of dumper::Field
exist. In this example we present two of them.
NodalField to describe nodal displacements of our train.
ElementalField handling the color of our different part.
*/
// NodalField are constructed with an Array.
auto displ_field = std::make_shared<dumper::NodalField<Real>>(displacement);
auto colour_field = std::make_shared<dumper::ElementalField<UInt>>(colour);
// Register the freshly created fields to our dumper.
dumper.registerField("displacement", displ_field);
dumper.registerField("colour", colour_field);
// For the dumper wheels, fields have to be filtered at registration.
// Filtered NodalField can be simply registered by adding an Array<UInt>
// listing the nodes.
auto displ_field_wheel = std::make_shared<dumper::NodalField<Real, true>>(
- displacement, 0, 0, &(wheels_elements.getNodes()));
+ displacement, 0, 0, &(wheels_elements.getNodeGroup().getNodes()));
wheels.registerField("displacement", displ_field_wheel);
// For the ElementalField, an ElementTypeMapArrayFilter has to be created.
ElementTypeMapArrayFilter<UInt> filtered_colour(
colour, wheels_elements.getElements());
auto colour_field_wheel =
std::make_shared<dumper::ElementalField<UInt, Vector, true>>(
filtered_colour);
wheels.registerField("colour", colour_field_wheel);
/* ------------------------------------------------------------------------ */
// Now that the dumpers are created and the fields are associated, let's
// paint and move the train!
// Fill the ElementTypeMapArray colour according to mesh data information.
fillColour(mesh, colour);
// Apply displacement and wheels rotation.
Real tot_displacement = 50.;
Real radius = 1.;
UInt nb_steps = 100;
Real theta = tot_displacement / radius;
Vector<Real> l_center(3);
Vector<Real> r_center(3);
for (UInt i = 0; i < spatial_dimension; ++i) {
l_center(i) = nodes(14, i);
r_center(i) = nodes(2, i);
}
for (UInt i = 0; i < nb_steps; ++i) {
displacement.clear();
Real angle = (Real)i / (Real)nb_steps * theta;
applyRotation(l_center, angle, nodes, displacement, lnode_1);
applyRotation(l_center, angle, nodes, displacement, lnode_2);
applyRotation(r_center, angle, nodes, displacement, rnode_1);
applyRotation(r_center, angle, nodes, displacement, rnode_2);
for (UInt j = 0; j < nb_nodes; ++j) {
displacement(j, 0) += (Real)i / (Real)nb_steps * tot_displacement;
}
// Output results after each moving steps for main and wheel dumpers.
dumper.dump();
wheels.dump();
}
finalize();
return 0;
}
diff --git a/examples/new_material/local_material_damage.cc b/examples/new_material/local_material_damage.cc
index 644b1a7fc..17807fd3c 100644
--- a/examples/new_material/local_material_damage.cc
+++ b/examples/new_material/local_material_damage.cc
@@ -1,110 +1,109 @@
/**
* @file local_material_damage.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jan 18 2016
*
* @brief Specialization of the material class for the damage material
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "local_material_damage.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
LocalMaterialDamage::LocalMaterialDamage(SolidMechanicsModel & model,
const ID & id)
: Material(model, id), damage("damage", *this) {
AKANTU_DEBUG_IN();
this->registerParam("E", E, 0., _pat_parsable, "Young's modulus");
this->registerParam("nu", nu, 0.5, _pat_parsable, "Poisson's ratio");
this->registerParam("lambda", lambda, _pat_readable,
"First Lamé coefficient");
this->registerParam("mu", mu, _pat_readable, "Second Lamé coefficient");
this->registerParam("kapa", kpa, _pat_readable, "Bulk coefficient");
this->registerParam("Yd", Yd, 50., _pat_parsmod);
this->registerParam("Sd", Sd, 5000., _pat_parsmod);
damage.initialize(1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void LocalMaterialDamage::initMaterial() {
AKANTU_DEBUG_IN();
Material::initMaterial();
lambda = nu * E / ((1 + nu) * (1 - 2 * nu));
mu = E / (2 * (1 + nu));
kpa = lambda + 2. / 3. * mu;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void LocalMaterialDamage::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Real * dam = damage(el_type, ghost_type).storage();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeStressOnQuad(grad_u, sigma, *dam);
++dam;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-void LocalMaterialDamage::computePotentialEnergy(ElementType el_type,
- GhostType ghost_type) {
+void LocalMaterialDamage::computePotentialEnergy(ElementType el_type) {
AKANTU_DEBUG_IN();
- if (ghost_type != _not_ghost)
- return;
Real * epot = potential_energy(el_type).storage();
- MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
+ MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
computePotentialEnergyOnQuad(grad_u, sigma, *epot);
epot++;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
static bool material_is_alocated_local_damage [[gnu::unused]] =
- MaterialFactory::getInstance().registerAllocator(
- "local_damage", [](UInt, const ID &, SolidMechanicsModel & model, const ID & id) -> std::unique_ptr<Material> {
- return std::make_unique<LocalMaterialDamage>(model, id);
- });
-
-} // akantu
+ MaterialFactory::getInstance().registerAllocator(
+ "local_damage",
+ [](UInt, const ID &, SolidMechanicsModel & model,
+ const ID & id) -> std::unique_ptr<Material> {
+ return std::make_unique<LocalMaterialDamage>(model, id);
+ });
+
+} // namespace akantu
diff --git a/examples/new_material/local_material_damage.hh b/examples/new_material/local_material_damage.hh
index 918fdf29e..f797529a3 100644
--- a/examples/new_material/local_material_damage.hh
+++ b/examples/new_material/local_material_damage.hh
@@ -1,125 +1,118 @@
/**
* @file local_material_damage.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Aug 10 2015
* @date last modification: Mon Jan 18 2016
*
* @brief Material isotropic elastic
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_LOCAL_MATERIAL_DAMAGE_HH__
#define __AKANTU_LOCAL_MATERIAL_DAMAGE_HH__
namespace akantu {
class LocalMaterialDamage : public Material {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
LocalMaterialDamage(SolidMechanicsModel & model, const ID & id = "");
virtual ~LocalMaterialDamage(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
- void initMaterial();
+ void initMaterial() override;
/// constitutive law for all element of a type
- void computeStress(ElementType el_type, GhostType ghost_type = _not_ghost);
+ void computeStress(ElementType el_type,
+ GhostType ghost_type = _not_ghost) override;
+ /// compute the potential energy for all elements
+ void computePotentialEnergy(ElementType el_type) override;
+
+protected:
/// constitutive law for a given quadrature point
inline void computeStressOnQuad(Matrix<Real> & grad_u, Matrix<Real> & sigma,
Real & damage);
- /// compute tangent stiffness
- virtual void computeTangentStiffness(__attribute__((unused))
- const ElementType & el_type,
- __attribute__((unused))
- Array<Real> & tangent_matrix,
- __attribute__((unused))
- GhostType ghost_type = _not_ghost){};
-
- /// compute the potential energy for all elements
- void computePotentialEnergy(ElementType el_type,
- GhostType ghost_type = _not_ghost);
-
/// compute the potential energy for on element
inline void computePotentialEnergyOnQuad(Matrix<Real> & grad_u,
Matrix<Real> & sigma, Real & epot);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// compute the celerity of the fastest wave in the material
- inline Real getCelerity(const Element & element) const;
+ inline Real getCelerity(const Element & element) const override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
-
+public:
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Damage, damage, Real);
private:
/// the young modulus
Real E;
/// Poisson coefficient
Real nu;
/// First Lamé coefficient
Real lambda;
/// Second Lamé coefficient (shear modulus)
Real mu;
/// resistance to damage
Real Yd;
/// damage threshold
Real Sd;
/// Bulk modulus
Real kpa;
/// damage internal variable
InternalField<Real> damage;
};
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "local_material_damage_inline_impl.hh"
#endif /* __AKANTU_LOCAL_MATERIAL_DAMAGE_HH__ */
diff --git a/examples/new_material/local_material_damage_inline_impl.hh b/examples/new_material/local_material_damage_inline_impl.hh
index 32700e042..df3256a42 100644
--- a/examples/new_material/local_material_damage_inline_impl.hh
+++ b/examples/new_material/local_material_damage_inline_impl.hh
@@ -1,91 +1,91 @@
/**
* @file local_material_damage_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Aug 10 2015
* @date last modification: Mon Jan 18 2016
*
* @brief Implementation of the inline functions of the material damage
*
* @section LICENSE
*
* Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
* (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_LOCAL_MATERIAL_DAMAGE_INLINE_IMPL_HH__
#define __AKANTU_LOCAL_MATERIAL_DAMAGE_INLINE_IMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline void LocalMaterialDamage::computeStressOnQuad(Matrix<Real> & grad_u,
Matrix<Real> & sigma,
Real & dam) {
Real trace = grad_u.trace();
/// \sigma_{ij} = \lambda * (\nabla u)_{kk} * \delta_{ij} + \mu * (\nabla
/// u_{ij} + \nabla u_{ji})
for (UInt i = 0; i < spatial_dimension; ++i) {
for (UInt j = 0; j < spatial_dimension; ++j) {
sigma(i, j) =
(i == j) * lambda * trace + mu * (grad_u(i, j) + grad_u(j, i));
}
}
Real Y = 0;
for (UInt i = 0; i < spatial_dimension; ++i) {
for (UInt j = 0; j < spatial_dimension; ++j) {
Y += sigma(i, j) * grad_u(i, j);
}
}
Y *= 0.5;
Real Fd = Y - Yd - Sd * dam;
if (Fd > 0)
dam = (Y - Yd) / Sd;
dam = std::min(dam, 1.);
sigma *= 1 - dam;
}
/* -------------------------------------------------------------------------- */
inline void LocalMaterialDamage::computePotentialEnergyOnQuad(
Matrix<Real> & grad_u, Matrix<Real> & sigma, Real & epot) {
epot = 0.;
for (UInt i = 0, t = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j, ++t)
epot += sigma(i, j) * (grad_u(i, j) - (i == j));
epot *= .5;
}
/* -------------------------------------------------------------------------- */
inline Real LocalMaterialDamage::getCelerity(__attribute__((unused))
const Element & element) const {
// Here the fastest celerity is the push wave speed
return (std::sqrt((2 * mu + lambda) / rho));
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_LOCAL_MATERIAL_DAMAGE_INLINE_IMPL_HH__ */
diff --git a/examples/new_material/viscoelastic_maxwell/material_viscoelastic_maxwell_energies.cc b/examples/new_material/viscoelastic_maxwell/material_viscoelastic_maxwell_energies.cc
index 79e7d170e..8a2b2ed74 100644
--- a/examples/new_material/viscoelastic_maxwell/material_viscoelastic_maxwell_energies.cc
+++ b/examples/new_material/viscoelastic_maxwell/material_viscoelastic_maxwell_energies.cc
@@ -1,180 +1,178 @@
/**
* @file material_viscoelastic_maxwell_energies.cc
*
* @author Emil Gallyamov <emil.gallyamov@epfl.ch>
*
* @date creation: Tue Nov 20 2018
* @date last modification:
*
* @brief Example of using viscoelastic material and computing energies
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <iostream>
#include <limits>
#include <sstream>
/* -------------------------------------------------------------------------- */
#include "material_viscoelastic_maxwell.hh"
#include "non_linear_solver.hh"
#include "solid_mechanics_model.hh"
#include "sparse_matrix.hh"
using namespace akantu;
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char * argv[]) {
akantu::initialize("material_viscoelastic_maxwell.dat", argc, argv);
// sim data
Real eps = 0.1;
const UInt dim = 2;
Real sim_time = 100.;
Real T = 10.;
Mesh mesh(dim);
mesh.read("material_viscoelastic_maxwell_mesh.msh");
SolidMechanicsModel model(mesh);
/* ------------------------------------------------------------------------ */
/* Initialization */
/* ------------------------------------------------------------------------ */
model.initFull(_analysis_method = _static);
std::cout << model.getMaterial(0) << std::endl;
std::stringstream filename_sstr;
filename_sstr << "material_viscoelastic_maxwell_output.out";
std::ofstream output_data;
output_data.open(filename_sstr.str().c_str());
- Material &mat = model.getMaterial(0);
+ Material & mat = model.getMaterial(0);
Real time_step = 0.1;
UInt nb_nodes = mesh.getNbNodes();
- const Array<Real> &coordinate = mesh.getNodes();
- Array<Real> &displacement = model.getDisplacement();
- Array<bool> &blocked = model.getBlockedDOFs();
+ const Array<Real> & coordinate = mesh.getNodes();
+ Array<Real> & displacement = model.getDisplacement();
+ Array<bool> & blocked = model.getBlockedDOFs();
/// Setting time step
model.setTimeStep(time_step);
model.setBaseName("dynamic");
model.addDumpFieldVector("displacement");
model.addDumpField("blocked_dofs");
model.addDumpField("external_force");
model.addDumpField("internal_force");
model.addDumpField("grad_u");
model.addDumpField("stress");
model.addDumpField("strain");
-
UInt max_steps = sim_time / time_step + 1;
Real time = 0.;
- auto &solver = model.getNonLinearSolver();
+ auto & solver = model.getNonLinearSolver();
solver.set("max_iterations", 10);
solver.set("threshold", 1e-7);
solver.set("convergence_type", SolveConvergenceCriteria::_residual);
/* ------------------------------------------------------------------------ */
/* Main loop */
/* ------------------------------------------------------------------------ */
for (UInt s = 0; s <= max_steps; ++s) {
std::cout << "Time Step = " << time_step << "s" << std::endl;
std::cout << "Time = " << time << std::endl;
// impose displacement
Real epsilon = 0;
if (time < T) {
epsilon = eps * time / T;
} else {
epsilon = eps;
}
for (UInt n = 0; n < nb_nodes; ++n) {
if (Math::are_float_equal(coordinate(n, 0), 0.0)) {
displacement(n, 0) = 0;
blocked(n, 0) = true;
displacement(n, 1) = epsilon * coordinate(n, 1);
blocked(n, 1) = true;
} else if (Math::are_float_equal(coordinate(n, 1), 0.0)) {
displacement(n, 0) = epsilon * coordinate(n, 0);
blocked(n, 0) = true;
displacement(n, 1) = 0;
blocked(n, 1) = true;
} else if (Math::are_float_equal(coordinate(n, 0), 0.001)) {
displacement(n, 0) = epsilon * coordinate(n, 0);
blocked(n, 0) = true;
displacement(n, 1) = epsilon * coordinate(n, 1);
blocked(n, 1) = true;
} else if (Math::are_float_equal(coordinate(n, 1), 0.001)) {
displacement(n, 0) = epsilon * coordinate(n, 0);
blocked(n, 0) = true;
displacement(n, 1) = epsilon * coordinate(n, 1);
blocked(n, 1) = true;
}
}
try {
model.solveStep();
- } catch (debug::Exception &e) {
+ } catch (debug::Exception & e) {
}
// for debugging
// auto int_force = model.getInternalForce();
// auto &K = model.getDOFManager().getMatrix("K");
// K.saveMatrix("K.mtx");
Int nb_iter = solver.get("nb_iterations");
Real error = solver.get("error");
bool converged = solver.get("converged");
if (converged) {
std::cout << "Converged in " << nb_iter << " iterations" << std::endl;
} else {
std::cout << "Didn't converge after " << nb_iter
<< " iterations. Error is " << error << std::endl;
return EXIT_FAILURE;
}
model.dump();
Real epot = mat.getEnergy("potential");
Real edis = mat.getEnergy("dissipated");
Real work = mat.getEnergy("work");
// data output
- output_data << s * time_step << " " << epsilon
- << " " << epot << " " << edis << " " << work << std::endl;
+ output_data << s * time_step << " " << epsilon << " " << epot << " " << edis
+ << " " << work << std::endl;
time += time_step;
-
}
output_data.close();
finalize();
}
diff --git a/examples/parallel/CMakeLists.txt b/examples/parallel/CMakeLists.txt
index 4a597eb76..dd5d27a29 100644
--- a/examples/parallel/CMakeLists.txt
+++ b/examples/parallel/CMakeLists.txt
@@ -1,39 +1,40 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Jan 18 2016
#
# @brief configuration for a parallel example
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#
#===============================================================================
#===============================================================================
add_mesh(parallel_2d_mesh square_2d.geo 2 1)
register_example(parallel_2d
SOURCES parallel_2d.cc
DEPENDS parallel_2d_mesh
- FILES_TO_COPY material.dat)
+ FILES_TO_COPY material.dat
+ PARALLEL)
diff --git a/examples/python/CMakeLists.txt b/examples/python/CMakeLists.txt
index c2e3d6d10..343e776e5 100644
--- a/examples/python/CMakeLists.txt
+++ b/examples/python/CMakeLists.txt
@@ -1,7 +1,9 @@
-add_subdirectory(plate-hole)
add_subdirectory(custom-material)
+add_subdirectory(dynamics)
+add_subdirectory(eigen_modes)
+add_subdirectory(plate-hole)
add_subdirectory(stiffness_matrix)
package_add_files_to_package(
examples/python/README.rst
)
diff --git a/examples/python/cohesive/CMakeLists.txt b/examples/python/cohesive/CMakeLists.txt
new file mode 100644
index 000000000..7c77b3046
--- /dev/null
+++ b/examples/python/cohesive/CMakeLists.txt
@@ -0,0 +1,8 @@
+add_mesh(plate plate.geo DIM 2)
+
+register_example(cohesive_python
+ SCRIPT cohesive.py
+ PYTHON
+ FILES_TO_COPY material.dat
+ DEPENDS plate
+ )
diff --git a/examples/python/cohesive/plate.py b/examples/python/cohesive/plate.py
index 3ac2db7e8..d8090a1cc 100644
--- a/examples/python/cohesive/plate.py
+++ b/examples/python/cohesive/plate.py
@@ -1,104 +1,84 @@
#!/usr/bin/env python3
-
-from __future__ import print_function
-
-import akantu
+import akantu as aka
import numpy as np
-################################################################
-
def solve(material_file, mesh_file, traction):
- akantu.parseInput(material_file)
+ aka.parseInput(material_file)
spatial_dimension = 2
- ################################################################
+ # -------------------------------------------------------------------------
# Initialization
- ################################################################
- mesh = akantu.Mesh(spatial_dimension)
+ # -------------------------------------------------------------------------
+ mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
- model = akantu.SolidMechanicsModelCohesive(mesh)
- model.initFull(akantu.SolidMechanicsModelCohesiveOptions(akantu._static,
- True))
+ model = aka.SolidMechanicsModelCohesive(mesh)
+ model.initFull(_analysis_method=aka._static,
+ _is_extrinsic=True)
- model.initNewSolver(akantu._explicit_lumped_mass)
+ model.initNewSolver(aka._explicit_lumped_mass)
model.setBaseName('plate')
model.addDumpFieldVector('displacement')
model.addDumpFieldVector('external_force')
model.addDumpField('strain')
model.addDumpField('stress')
model.addDumpField('blocked_dofs')
model.setBaseNameToDumper('cohesive elements', 'cohesive')
model.addDumpFieldVectorToDumper('cohesive elements', 'displacement')
model.addDumpFieldToDumper('cohesive elements', 'damage')
model.addDumpFieldVectorToDumper('cohesive elements', 'traction')
model.addDumpFieldVectorToDumper('cohesive elements', 'opening')
- ################################################################
+ # -------------------------------------------------------------------------
# Boundary conditions
- ################################################################
-
- model.applyBC(akantu.FixedValue(0.0, akantu._x), 'XBlocked')
- model.applyBC(akantu.FixedValue(0.0, akantu._y), 'YBlocked')
+ # -------------------------------------------------------------------------
+ model.applyBC(aka.FixedValue(0.0, aka._x), 'XBlocked')
+ model.applyBC(aka.FixedValue(0.0, aka._y), 'YBlocked')
trac = np.zeros(spatial_dimension)
- trac[int(akantu._y)] = traction
+ trac[int(aka._y)] = traction
print('Solve for traction ', traction)
model.getExternalForce()[:] = 0
- model.applyBC(akantu.FromTraction(trac), 'Traction')
+ model.applyBC(aka.FromTraction(trac), 'Traction')
solver = model.getNonLinearSolver('static')
solver.set('max_iterations', 100)
solver.set('threshold', 1e-10)
- solver.set('convergence_type', akantu._scc_residual)
+ solver.set('convergence_type', aka._scc_residual)
model.solveStep('static')
model.dump()
model.dump('cohesive elements')
model.setTimeStep(model.getStableTimeStep()*0.1)
maxsteps = 100
+
for i in range(0, maxsteps):
print('{0}/{1}'.format(i, maxsteps))
model.checkCohesiveStress()
model.solveStep('explicit_lumped')
if i % 10 == 0:
model.dump()
model.dump('cohesive elements')
- # if i < 200:
- # model.getVelocity()[:] *= .9
-
-################################################################
-# main
-################################################################
+# -----------------------------------------------------------------------------
+# main
+# -----------------------------------------------------------------------------
def main():
-
- import os
mesh_file = 'plate.msh'
-
- if not os.path.isfile(mesh_file):
- import subprocess
- ret = subprocess.call(
- 'gmsh -format msh2 -2 plate.geo {0}'.format(mesh_file),
- shell=True)
- if not ret == 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
-
material_file = 'material.dat'
traction = .095
solve(material_file, mesh_file, traction)
-################################################################
+# -----------------------------------------------------------------------------
if __name__ == '__main__':
main()
diff --git a/examples/python/custom-material/CMakeLists.txt b/examples/python/custom-material/CMakeLists.txt
index abaacb68f..ddcc31d6c 100644
--- a/examples/python/custom-material/CMakeLists.txt
+++ b/examples/python/custom-material/CMakeLists.txt
@@ -1,7 +1,13 @@
+add_mesh(square square.geo DIM 2)
register_example(bi-material
SCRIPT bi-material.py
- FILES_TO_COPY material.dat square.geo)
+ PYTHON
+ FILES_TO_COPY material.dat
+ DEPENDS square)
+add_mesh(bar bar.geo DIM 2)
register_example(custom-material
SCRIPT custom-material.py
- FILES_TO_COPY material.dat bar.geo)
+ PYTHON
+ FILES_TO_COPY material.dat
+ DEPENDS bar)
diff --git a/examples/python/custom-material/bi-material.py b/examples/python/custom-material/bi-material.py
index 7e302fcb2..d58c12058 100644
--- a/examples/python/custom-material/bi-material.py
+++ b/examples/python/custom-material/bi-material.py
@@ -1,193 +1,178 @@
import akantu as aka
-import subprocess
import numpy as np
-import time
-import os
-# ------------------------------------------------------------- #
+# ------------------------------------------------------------------------------
class LocalElastic(aka.Material):
-
def __init__(self, model, _id):
super().__init__(model, _id)
super().registerParamReal('E',
aka._pat_readable | aka._pat_parsable,
'Youngs modulus')
super().registerParamReal('nu',
aka._pat_readable | aka._pat_parsable,
'Poisson ratio')
# change it to have the initialize wrapped
super().registerInternal('factor', 1)
super().registerInternal('quad_coordinates', 2)
def initMaterial(self):
nu = self.getReal('nu')
E = self.getReal('E')
self.mu = E / (2 * (1 + nu))
self.lame_lambda = nu * E / (
(1. + nu) * (1. - 2. * nu))
# Second Lame coefficient (shear modulus)
self.lame_mu = E / (2. * (1. + nu))
super().initMaterial()
quad_coords = self.internals["quad_coordinates"]
factor = self.internals["factor"]
model = self.getModel()
model.getFEEngine().computeIntegrationPointsCoordinates(
quad_coords, self.element_filter)
for elem_type in factor.elementTypes():
factor = factor(elem_type)
coords = quad_coords(elem_type)
factor[:] = 1.
factor[coords[:, 1] < 0.5] = .5
# declares all the parameters that are needed
def getPushWaveSpeed(self, params):
return np.sqrt((self.lame_lambda + 2 * self.lame_mu) / self.rho)
# compute small deformation tensor
@staticmethod
def computeEpsilon(grad_u):
return 0.5 * (grad_u + np.einsum('aij->aji', grad_u))
# constitutive law
def computeStress(self, el_type, ghost_type):
grad_u = self.getGradU(el_type, ghost_type)
sigma = self.getStress(el_type, ghost_type)
n_quads = grad_u.shape[0]
grad_u = grad_u.reshape((n_quads, 2, 2))
factor = self.internals['factor'](el_type, ghost_type).reshape(n_quads)
epsilon = self.computeEpsilon(grad_u)
sigma = sigma.reshape((n_quads, 2, 2))
trace = np.einsum('aii->a', grad_u)
sigma[:, :, :] = (
np.einsum('a,ij->aij', trace,
self.lame_lambda * np.eye(2))
+ 2. * self.lame_mu * epsilon)
sigma[:, :, :] = np.einsum('aij, a->aij', sigma, factor)
# constitutive law tangent modulii
def computeTangentModuli(self, el_type, tangent_matrix, ghost_type):
n_quads = tangent_matrix.shape[0]
tangent = tangent_matrix.reshape(n_quads, 3, 3)
factor = self.internals['factor'](el_type, ghost_type).reshape(n_quads)
Miiii = self.lame_lambda + 2 * self.lame_mu
Miijj = self.lame_lambda
Mijij = self.lame_mu
tangent[:, 0, 0] = Miiii
tangent[:, 1, 1] = Miiii
tangent[:, 0, 1] = Miijj
tangent[:, 1, 0] = Miijj
tangent[:, 2, 2] = Mijij
tangent[:, :, :] = np.einsum('aij, a->aij', tangent, factor)
# computes the energy density
def computePotentialEnergy(self, el_type):
-
sigma = self.getStress(el_type)
grad_u = self.getGradU(el_type)
nquads = sigma.shape[0]
stress = sigma.reshape(nquads, 2, 2)
grad_u = grad_u.reshape((nquads, 2, 2))
epsilon = self.computeEpsilon(grad_u)
energy_density = self.getPotentialEnergy(el_type)
energy_density[:, 0] = 0.5 * np.einsum('aij,aij->a', stress, epsilon)
+# ------------------------------------------------------------------------------
# applies manually the boundary conditions
def applyBC(model):
nbNodes = model.getMesh().getNbNodes()
position = model.getMesh().getNodes()
displacement = model.getDisplacement()
blocked_dofs = model.getBlockedDOFs()
width = 1.
height = 1.
epsilon = 1e-8
for node in range(0, nbNodes):
if((np.abs(position[node, 0]) < epsilon) or # left side
(np.abs(position[node, 0] - width) < epsilon)): # right side
blocked_dofs[node, 0] = True
displacement[node, 0] = 0 * position[node, 0] + 0.
if(np.abs(position[node, 1]) < epsilon): # lower side
blocked_dofs[node, 1] = True
displacement[node, 1] = - 1.
if(np.abs(position[node, 1] - height) < epsilon): # upper side
blocked_dofs[node, 1] = True
displacement[node, 1] = 1.
+# register the material to the material factory
+def allocator(dim, option, model, id):
+ return LocalElastic(model, id)
+
+
+mat_factory = aka.MaterialFactory.getInstance()
+mat_factory.registerAllocator("local_elastic", allocator)
+
# main parameters
spatial_dimension = 2
mesh_file = 'square.msh'
-if not os.path.isfile(mesh_file):
- # call gmsh to generate the mesh
- ret = subprocess.call(
- 'gmsh -format msh2 -2 square.geo -optimize square.msh', shell=True)
- if ret != 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
-
-time.sleep(2)
-
# read mesh
mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
-mat_factory = aka.MaterialFactory.getInstance()
-
-
-def allocator(_dim, _unused, model, _id):
- return LocalElastic(model, _id)
-
-
-mat_factory.registerAllocator("local_elastic", allocator)
-
# parse input file
aka.parseInput('material.dat')
# init the SolidMechanicsModel
model = aka.SolidMechanicsModel(mesh)
model.initFull(_analysis_method=aka._static)
# configure the solver
solver = model.getNonLinearSolver()
solver.set("max_iterations", 2)
solver.set("threshold", 1e-3)
-solver.set("convergence_type", aka.SolveConvergenceCriteria__solution)
+solver.set("convergence_type", aka.SolveConvergenceCriteria.solution)
# prepare the dumper
model.setBaseName("bimaterial")
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("internal_force")
model.addDumpFieldVector("external_force")
model.addDumpField("strain")
model.addDumpField("stress")
# model.addDumpField("factor")
model.addDumpField("blocked_dofs")
# Boundary conditions
applyBC(model)
# solve the problem
model.solveStep()
# dump paraview files
model.dump()
epot = model.getEnergy('potential')
print('Potential energy: ' + str(epot))
diff --git a/examples/python/custom-material/custom-material.py b/examples/python/custom-material/custom-material.py
index 82a5bb708..8e25b2d5b 100644
--- a/examples/python/custom-material/custom-material.py
+++ b/examples/python/custom-material/custom-material.py
@@ -1,213 +1,177 @@
#!/usr/bin/env python3
-
-from __future__ import print_function
-################################################################
-import os
-import subprocess
import numpy as np
-import akantu
-################################################################
-
-
-class FixedValue(akantu.DirichletFunctor):
-
- def __init__(self, value, axis):
- super().__init__(axis)
- self.value = value
- self.axis = int(axis)
+import akantu as aka
- def __call__(self, node, flags, disp, coord):
- # sets the displacement to the desired value in the desired axis
- disp[self.axis] = self.value
- # sets the blocked dofs vector to true in the desired axis
- flags[self.axis] = True
-################################################################
-
-
-class LocalElastic(akantu.Material):
+# ------------------------------------------------------------------------------
+class LocalElastic(aka.Material):
def __init__(self, model, _id):
super().__init__(model, _id)
super().registerParamReal('E',
- akantu._pat_readable | akantu._pat_parsable,
+ aka._pat_readable | aka._pat_parsable,
'Youngs modulus')
super().registerParamReal('nu',
- akantu._pat_readable | akantu._pat_parsable,
+ aka._pat_readable | aka._pat_parsable,
'Poisson ratio')
def initMaterial(self):
nu = self.getReal('nu')
E = self.getReal('E')
self.mu = E / (2 * (1 + nu))
self.lame_lambda = nu * E / (
(1. + nu) * (1. - 2. * nu))
# Second Lame coefficient (shear modulus)
self.lame_mu = E / (2. * (1. + nu))
super().initMaterial()
# declares all the parameters that are needed
def getPushWaveSpeed(self, element):
rho = self.getReal('rho')
return np.sqrt((self.lame_lambda + 2 * self.lame_mu) / rho)
# compute small deformation tensor
@staticmethod
def computeEpsilon(grad_u):
return 0.5 * (grad_u + np.einsum('aij->aji', grad_u))
# constitutive law
def computeStress(self, el_type, ghost_type):
grad_u = self.getGradU(el_type, ghost_type)
sigma = self.getStress(el_type, ghost_type)
n_quads = grad_u.shape[0]
grad_u = grad_u.reshape((n_quads, 2, 2))
epsilon = self.computeEpsilon(grad_u)
sigma = sigma.reshape((n_quads, 2, 2))
trace = np.einsum('aii->a', grad_u)
sigma[:, :, :] = (
np.einsum('a,ij->aij', trace,
self.lame_lambda * np.eye(2))
+ 2. * self.lame_mu * epsilon)
# constitutive law tangent modulii
def computeTangentModuli(self, el_type, tangent_matrix, ghost_type):
n_quads = tangent_matrix.shape[0]
tangent = tangent_matrix.reshape(n_quads, 3, 3)
Miiii = self.lame_lambda + 2 * self.lame_mu
Miijj = self.lame_lambda
Mijij = self.lame_mu
tangent[:, 0, 0] = Miiii
tangent[:, 1, 1] = Miiii
tangent[:, 0, 1] = Miijj
tangent[:, 1, 0] = Miijj
tangent[:, 2, 2] = Mijij
# computes the energy density
def computePotentialEnergy(self, el_type):
sigma = self.getStress(el_type)
grad_u = self.getGradU(el_type)
nquads = sigma.shape[0]
stress = sigma.reshape(nquads, 2, 2)
grad_u = grad_u.reshape((nquads, 2, 2))
epsilon = self.computeEpsilon(grad_u)
energy_density = self.getPotentialEnergy(el_type)
energy_density[:, 0] = 0.5 * np.einsum('aij,aij->a', stress, epsilon)
-################################################################
-# main
-################################################################
+# register material to the MaterialFactory
+def allocator(_dim, unused, model, _id):
+ return LocalElastic(model, _id)
+
+mat_factory = aka.MaterialFactory.getInstance()
+mat_factory.registerAllocator("local_elastic", allocator)
+
+# ------------------------------------------------------------------------------
+# main
+# ------------------------------------------------------------------------------
spatial_dimension = 2
-akantu.parseInput('material.dat')
+aka.parseInput('material.dat')
mesh_file = 'bar.msh'
max_steps = 250
time_step = 1e-3
-# if mesh was not created the calls gmsh to generate it
-if not os.path.isfile(mesh_file):
- ret = subprocess.call('gmsh -format msh2 -2 bar.geo bar.msh', shell=True)
- if ret != 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
-
-################################################################
+# ------------------------------------------------------------------------------
# Initialization
-################################################################
-mesh = akantu.Mesh(spatial_dimension)
+# ------------------------------------------------------------------------------
+mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
-mat_factory = akantu.MaterialFactory.getInstance()
-
-
-def allocator(_dim, unused, model, _id):
- return LocalElastic(model, _id)
-
-
-mat_factory.registerAllocator("local_elastic", allocator)
-
# parse input file
-akantu.parseInput('material.dat')
-
-model = akantu.SolidMechanicsModel(mesh)
+aka.parseInput('material.dat')
-model.initFull(_analysis_method=akantu._explicit_lumped_mass)
-# model.initFull(_analysis_method=akantu._implicit_dynamic)
+model = aka.SolidMechanicsModel(mesh)
+model.initFull(_analysis_method=aka._explicit_lumped_mass)
model.setBaseName("waves")
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("acceleration")
model.addDumpFieldVector("velocity")
model.addDumpFieldVector("internal_force")
model.addDumpFieldVector("external_force")
model.addDumpField("strain")
model.addDumpField("stress")
model.addDumpField("blocked_dofs")
-################################################################
+# ------------------------------------------------------------------------------
# boundary conditions
-################################################################
+# ------------------------------------------------------------------------------
+model.applyBC(aka.FixedValue(0, aka._x), "XBlocked")
+model.applyBC(aka.FixedValue(0, aka._y), "YBlocked")
-model.applyBC(FixedValue(0, akantu._x), "XBlocked")
-model.applyBC(FixedValue(0, akantu._y), "YBlocked")
-
-################################################################
+# ------------------------------------------------------------------------------
# initial conditions
-################################################################
-
+# ------------------------------------------------------------------------------
displacement = model.getDisplacement()
nb_nodes = mesh.getNbNodes()
position = mesh.getNodes()
pulse_width = 1
A = 0.01
for i in range(0, nb_nodes):
# Sinus * Gaussian
x = position[i, 0] - 5.
L = pulse_width
k = 0.1 * 2 * np.pi * 3 / L
displacement[i, 0] = A * \
np.sin(k * x) * np.exp(-(k * x) * (k * x) / (L * L))
-################################################################
+# ------------------------------------------------------------------------------
# timestep value computation
-################################################################
+# ------------------------------------------------------------------------------
time_factor = 0.8
stable_time_step = model.getStableTimeStep() * time_factor
print("Stable Time Step = {0}".format(stable_time_step))
print("Required Time Step = {0}".format(time_step))
time_step = stable_time_step * time_factor
model.setTimeStep(time_step)
-################################################################
+# ------------------------------------------------------------------------------
# loop for evolution of motion dynamics
-################################################################
-model.assembleInternalForces()
-
+# ------------------------------------------------------------------------------
print("step,step * time_step,epot,ekin,epot + ekin")
for step in range(0, max_steps + 1):
model.solveStep()
if step % 10 == 0:
model.dump()
epot = model.getEnergy('potential')
ekin = model.getEnergy('kinetic')
# output energy calculation to screen
print("{0},{1},{2},{3},{4}".format(step, step * time_step,
epot, ekin,
(epot + ekin)))
diff --git a/examples/python/dynamics/CMakeLists.txt b/examples/python/dynamics/CMakeLists.txt
new file mode 100644
index 000000000..ebad09645
--- /dev/null
+++ b/examples/python/dynamics/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_mesh(bar_dynamics_mesh bar.geo DIM 2)
+register_example(dynamics-python
+ SCRIPT dynamics.py
+ PYTHON
+ FILES_TO_COPY material.dat
+ DEPENDS bar_dynamics_mesh)
diff --git a/examples/python/dynamics/dynamics.py b/examples/python/dynamics/dynamics.py
index 5b7e3ef84..d1c2f7690 100644
--- a/examples/python/dynamics/dynamics.py
+++ b/examples/python/dynamics/dynamics.py
@@ -1,131 +1,111 @@
#!/usr/bin/env python3
-
-from __future__ import print_function
-################################################################
-import os
-import subprocess
import numpy as np
-import akantu
-################################################################
-
+import akantu as aka
-class MyFixedValue(akantu.FixedValue):
+# -----------------------------------------------------------------------------
+class MyFixedValue(aka.FixedValue):
def __init__(self, value, axis):
super().__init__(value, axis)
self.value = value
self.axis = int(axis)
def __call__(self, node, flags, disp, coord):
# sets the displacement to the desired value in the desired axis
disp[self.axis] = self.value
# sets the blocked dofs vector to true in the desired axis
flags[self.axis] = True
-################################################################
-
+# -----------------------------------------------------------------------------
def main():
-
spatial_dimension = 2
-
- akantu.parseInput('material.dat')
-
mesh_file = 'bar.msh'
max_steps = 250
time_step = 1e-3
- # if mesh was not created the calls gmsh to generate it
- if not os.path.isfile(mesh_file):
- ret = subprocess.call('gmsh -format msh2 -2 bar.geo bar.msh', shell=True)
- if ret != 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
+ aka.parseInput('material.dat')
- ################################################################
+ # -------------------------------------------------------------------------
# Initialization
- ################################################################
- mesh = akantu.Mesh(spatial_dimension)
+ # -------------------------------------------------------------------------
+ mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
- model = akantu.SolidMechanicsModel(mesh)
+ model = aka.SolidMechanicsModel(mesh)
- model.initFull(_analysis_method=akantu._explicit_lumped_mass)
- # model.initFull(_analysis_method=akantu._implicit_dynamic)
+ model.initFull(_analysis_method=aka._explicit_lumped_mass)
+ # model.initFull(_analysis_method=aka._implicit_dynamic)
model.setBaseName("waves")
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("acceleration")
model.addDumpFieldVector("velocity")
model.addDumpFieldVector("internal_force")
model.addDumpFieldVector("external_force")
model.addDumpField("strain")
model.addDumpField("stress")
model.addDumpField("blocked_dofs")
- ################################################################
+ # -------------------------------------------------------------------------
# boundary conditions
- ################################################################
-
- model.applyBC(MyFixedValue(0, akantu._x), "XBlocked")
- model.applyBC(MyFixedValue(0, akantu._y), "YBlocked")
+ # -------------------------------------------------------------------------
+ model.applyBC(MyFixedValue(0, aka._x), "XBlocked")
+ model.applyBC(MyFixedValue(0, aka._y), "YBlocked")
- ################################################################
+ # -------------------------------------------------------------------------
# initial conditions
- ################################################################
-
+ # -------------------------------------------------------------------------
displacement = model.getDisplacement()
nb_nodes = mesh.getNbNodes()
position = mesh.getNodes()
pulse_width = 1
A = 0.01
for i in range(0, nb_nodes):
# Sinus * Gaussian
x = position[i, 0] - 5.
L = pulse_width
k = 0.1 * 2 * np.pi * 3 / L
displacement[i, 0] = A * \
np.sin(k * x) * np.exp(-(k * x) * (k * x) / (L * L))
displacement[i, 1] = 0
- ################################################################
+ # -------------------------------------------------------------------------
# timestep value computation
- ################################################################
+ # -------------------------------------------------------------------------
time_factor = 0.8
stable_time_step = model.getStableTimeStep() * time_factor
print("Stable Time Step = {0}".format(stable_time_step))
print("Required Time Step = {0}".format(time_step))
time_step = stable_time_step * time_factor
model.setTimeStep(time_step)
- ################################################################
+ # -------------------------------------------------------------------------
# loop for evolution of motion dynamics
- ################################################################
- model.assembleInternalForces()
-
+ # -------------------------------------------------------------------------
print("step,step * time_step,epot,ekin,epot + ekin")
for step in range(0, max_steps + 1):
model.solveStep()
if step % 10 == 0:
model.dump()
epot = model.getEnergy('potential')
ekin = model.getEnergy('kinetic')
# output energy calculation to screen
print("{0},{1},{2},{3},{4}".format(step, step * time_step,
epot, ekin,
(epot + ekin)))
return
-################################################################
+# -----------------------------------------------------------------------------
if __name__ == "__main__":
main()
diff --git a/examples/python/eigen_modes/CMakeLists.txt b/examples/python/eigen_modes/CMakeLists.txt
new file mode 100644
index 000000000..8ee96d530
--- /dev/null
+++ b/examples/python/eigen_modes/CMakeLists.txt
@@ -0,0 +1,5 @@
+register_example(eigen-modes
+ SCRIPT eigen_modes.py
+ FILES_TO_COPY material.dat image_saver.py
+ PYTHON
+ )
diff --git a/examples/python/eigen_modes/eigen_modes.py b/examples/python/eigen_modes/eigen_modes.py
index e11c4f3e3..9cab84653 100644
--- a/examples/python/eigen_modes/eigen_modes.py
+++ b/examples/python/eigen_modes/eigen_modes.py
@@ -1,263 +1,248 @@
import subprocess
import argparse
-import akantu
+import akantu as aka
import numpy as np
from image_saver import ImageSaver
import matplotlib.pyplot as plt
from scipy.sparse.linalg import eigsh
from scipy.sparse import csr_matrix
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# parser
-# ------------------------------------------------------------------------
-
-
+# -----------------------------------------------------------------------------
parser = argparse.ArgumentParser(description='Eigen mode exo')
-
parser.add_argument('-m', '--mode_number', type=int, required=True,
- help='precise the mode to study')
+ help='precise the mode to study', default=2)
parser.add_argument('-wL', '--wave_width', type=float,
help='precise the width of the wave for '
- 'the initial displacement')
+ 'the initial displacement', default=5)
parser.add_argument('-L', '--Lbar', type=float,
help='precise the length of the bar', default=10)
parser.add_argument('-t', '--time_step', type=float,
help='precise the timestep',
default=None)
parser.add_argument('-n', '--max_steps', type=int,
help='precise the number of timesteps',
default=500)
parser.add_argument('-mh', '--mesh_h', type=float,
help='characteristic mesh size',
default=.2)
-
args = parser.parse_args()
-print(args)
-
mode = args.mode_number
wave_width = args.wave_width
time_step = args.time_step
max_steps = args.max_steps
mesh_h = args.mesh_h
Lbar = args.Lbar
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Mesh Generation
-# ------------------------------------------------------------------------
-
+# -----------------------------------------------------------------------------
geo_content = """
// Mesh size
h = {0};
""".format(mesh_h)
geo_content += """
h1 = h;
h2 = h;
// Dimensions of the bar
Lx = 10;
Ly = 1;
// ------------------------------------------
// Geometry
// ------------------------------------------
Point(101) = { 0.0, -Ly/2, 0.0, h1};
Point(102) = { Lx, -Ly/2, 0.0, h2};
Point(103) = { Lx, 0., 0.0, h2};
Point(104) = { Lx, Ly/2., 0.0, h2};
Point(105) = { 0.0, Ly/2., 0.0, h1};
Point(106) = { 0.0, 0., 0.0, h1};
Line(101) = {101,102};
Line(102) = {102,103};
Line(103) = {103,104};
Line(104) = {104,105};
Line(105) = {105,106};
Line(106) = {106,101};
Line(107) = {106,103};
Line Loop(108) = {101, 102, -107, 106};
Plane Surface(109) = {108};
Line Loop(110) = {103, 104, 105, 107};
Plane Surface(111) = {110};
Physical Surface(112) = {109, 111};
Transfinite Surface "*";
Recombine Surface "*";
Physical Surface(113) = {111, 109};
Physical Line("XBlocked") = {103, 102};
Physical Line("ImposedVelocity") = {105, 106};
Physical Line("YBlocked") = {104, 101};
"""
mesh_file = 'bar'
with open(mesh_file + '.geo', 'w') as f:
f.write(geo_content)
-subprocess.call(['gmsh', '-format', 'msh2', '-2', mesh_file + '.geo'])
+subprocess.call(['gmsh', '-2', mesh_file + '.geo'])
mesh_file = mesh_file + '.msh'
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Initialization
-# ------------------------------------------------------------------------
-
+# -----------------------------------------------------------------------------
spatial_dimension = 2
-akantu.parseInput('material.dat')
+aka.parseInput('material.dat')
-mesh = akantu.Mesh(spatial_dimension)
+mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
-model = akantu.SolidMechanicsModel(mesh)
-model.initFull(akantu._implicit_dynamic)
+model = aka.SolidMechanicsModel(mesh)
+model.initFull(aka._implicit_dynamic)
model.setBaseName("waves-{0}".format(mode))
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("acceleration")
model.addDumpFieldVector("velocity")
model.addDumpField("blocked_dofs")
-
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# Boundary conditions
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
internal_force = model.getInternalForce()
displacement = model.getDisplacement()
acceleration = model.getAcceleration()
velocity = model.getVelocity()
blocked_dofs = model.getBlockedDOFs()
nbNodes = mesh.getNbNodes()
position = mesh.getNodes()
-model.applyBC(akantu.FixedValue(0.0, akantu._x), "XBlocked")
-model.applyBC(akantu.FixedValue(0.0, akantu._y), "YBlocked")
+model.applyBC(aka.FixedValue(0.0, aka._x), "XBlocked")
+model.applyBC(aka.FixedValue(0.0, aka._y), "YBlocked")
# ------------------------------------------------------------------------
# timestep value computation
# ------------------------------------------------------------------------
time_factor = 0.8
stable_time_step = model.getStableTimeStep() * time_factor
if time_step:
print("Required Time Step = {0}".format(time_step))
if stable_time_step * time_factor < time_step:
print("Stable Time Step = {0}".format(stable_time_step))
raise RuntimeError("required time_step too large")
print("Required Time Step = {0}".format(time_step))
else:
print("Stable Time Step = {0}".format(stable_time_step))
time_step = stable_time_step * time_factor
model.setTimeStep(time_step)
disp_sav = ImageSaver(mesh, displacement, 0, Lbar)
velo_sav = ImageSaver(mesh, velocity, 0, Lbar)
# ------------------------------------------------------------------------
# compute the eigen modes
# ------------------------------------------------------------------------
-
model.assembleStiffnessMatrix()
model.assembleMass()
stiff = model.getDOFManager().getMatrix('K')
-stiff = akantu.AkantuSparseMatrix(stiff).toarray()
+stiff = aka.AkantuSparseMatrix(stiff).toarray()
mass = model.getDOFManager().getMatrix('M')
-mass = akantu.AkantuSparseMatrix(mass).toarray()
+mass = aka.AkantuSparseMatrix(mass).toarray()
# select the non blocked DOFs by index in the mask
-mask = blocked_dofs.flatten() == False
+mask = np.equal(blocked_dofs.flatten(), False)
Mass_star = mass[mask, :]
Mass_star = csr_matrix(Mass_star[:, mask].copy())
K_star = stiff[mask, :]
K_star = csr_matrix(K_star[:, mask].copy())
print('getting the eigen values')
vals, vects = eigsh(K_star, M=Mass_star, which='SM', k=20)
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# import the initial conditions in displacement
-# ------------------------------------------------------------------------
-
+# -----------------------------------------------------------------------------
displacement.reshape(nbNodes*2)[mask] = vects[:, mode]
with open('modes.txt', 'a') as f:
f.write('{0} {1}\n'.format(mode, vals[mode]))
model.dump()
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# prepare the storage of the dynamical evolution
-# ------------------------------------------------------------------------
-
+# -----------------------------------------------------------------------------
e_p = np.zeros(max_steps + 1)
e_k = np.zeros(max_steps + 1)
e_t = np.zeros(max_steps + 1)
time = np.zeros(max_steps + 1)
norm = np.zeros(max_steps + 1)
epot = model.getEnergy('potential')
ekin = model.getEnergy('kinetic')
e_p[0] = epot
e_k[0] = ekin
e_t[0] = epot + ekin
time[0] = 0
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# loop for evolution of motion dynamics
-# ------------------------------------------------------------------------
-
+# -----------------------------------------------------------------------------
for step in range(1, max_steps + 1):
-
model.solveStep()
# outputs
epot = model.getEnergy('potential')
ekin = model.getEnergy('kinetic')
print(step, '/', max_steps, epot, ekin, epot + ekin)
e_p[step] = epot
e_k[step] = ekin
e_t[step] = epot + ekin
time[step] = (step + 1) * time_step
disp_sav.storeStep()
velo_sav.storeStep()
if step % 10 == 0:
model.dump()
-# ------------------------------------------------------------------------
+# -----------------------------------------------------------------------------
# plot figures for global evolution
-# ------------------------------------------------------------------------
-
+# -----------------------------------------------------------------------------
# energy norms
plt.figure(1)
plt.plot(time, e_t, 'r', time, e_p, 'b', time, e_k, 'g')
# space-time diagram for diplacements
plt.figure(2)
plt.imshow(disp_sav.getImage(), extent=(0, Lbar, max_steps * time_step, 0))
plt.xlabel("Space ")
plt.ylabel("Time ")
# space-time diagram for velocities
plt.figure(3)
plt.imshow(velo_sav.getImage(), extent=(0, Lbar, max_steps * time_step, 0))
plt.xlabel("Velocity")
plt.ylabel("Time")
plt.show()
diff --git a/examples/python/eigen_modes/image_saver.py b/examples/python/eigen_modes/image_saver.py
index 1eeaca3e6..41401ee1c 100644
--- a/examples/python/eigen_modes/image_saver.py
+++ b/examples/python/eigen_modes/image_saver.py
@@ -1,72 +1,68 @@
#!/usr/bin/env python3
-# -------------------------------------------------------------------------- */
import numpy as np
import matplotlib.pyplot as plt
-# -------------------------------------------------------------------------- */
+# -----------------------------------------------------------------------------
class ImageSaver:
- # ------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
# Constructors/Destructors
- # ------------------------------------------------------------------------
-
+ # -------------------------------------------------------------------------
def __init__(self, mesh, field, component, Lbar):
self.mesh = mesh
self.field_copy = None
self.field = field
self.component = component
self.max_value = 0
self.Lbar = Lbar
# compute the number of nodes in one direction
self.nb_nodes = 0
epsilon = 1e-8
nodes = mesh.getNodes()
for n in range(0, mesh.getNbNodes()):
if np.abs(nodes[n, 1]) < epsilon:
self.nb_nodes += 1
- # ------------------------------------------------------------------------
+ # -------------------------------------------------------------------------
# Methods
- # ------------------------------------------------------------------------
-
+ # -------------------------------------------------------------------------
def storeStep(self):
if self.field_copy is None:
current_size = 0
self.field_copy = np.zeros(self.nb_nodes)
else:
current_size = self.field_copy.shape[0]
self.field_copy.resize(current_size + self.nb_nodes)
epsilon = 1e-8
h = self.Lbar / (self.nb_nodes-1)
nodes = self.mesh.getNodes()
for n in range(0, self.mesh.getNbNodes()):
if np.abs(nodes[n, 1]) < epsilon:
normed_x = nodes[n, 0]/h + h/10.
index = int(normed_x)
self.field_copy[current_size +
index] = self.field[n, self.component]
if self.max_value < self.field[n, self.component]:
self.max_value = self.field[n, self.component]
def getImage(self):
-
width = int(self.nb_nodes)
height = int(self.field_copy.shape[0] / self.nb_nodes)
if np.abs(self.max_value) > 1e-8:
for n in range(0, self.field_copy.shape[0]):
self.field_copy[n] = 1 - self.field_copy[n] / self.max_value
img = self.field_copy.reshape((height, width))
return img
def saveImage(self, filename):
img = self.getImage()
plt.imshow(img)
plt.savefig(filename)
diff --git a/examples/python/plate-hole/CMakeLists.txt b/examples/python/plate-hole/CMakeLists.txt
index 4a933e0a3..64b2f0dec 100644
--- a/examples/python/plate-hole/CMakeLists.txt
+++ b/examples/python/plate-hole/CMakeLists.txt
@@ -1,3 +1,8 @@
+add_mesh(plate_hole_mesh plate.geo DIM 2 ORDER 1)
+
register_example(plate-hole
SCRIPT plate.py
- FILES_TO_COPY material.dat plate.geo)
+ FILES_TO_COPY material.dat
+ DEPENDS plate_hole_mesh
+ PYTHON
+ )
diff --git a/examples/python/plate-hole/plate-mpi.py b/examples/python/plate-hole/plate-mpi.py
deleted file mode 100644
index ad32def24..000000000
--- a/examples/python/plate-hole/plate-mpi.py
+++ /dev/null
@@ -1,120 +0,0 @@
-#!/usr/bin/env python3
-
-from mpi4py import MPI
-import akantu
-import numpy as np
-
-comm = MPI.COMM_WORLD
-rank = comm.Get_rank()
-
-################################################################
-# Dirichlet Boudary condition functor: fix the displacement
-################################################################
-
-
-class FixedValue(akantu.DirichletFunctor):
-
- def __init__(self, value, axis):
- super().__init__(axis)
- self.value = value
- self.axis = int(axis)
-
- def __call__(self, node, flags, disp, coord):
- # sets the displacement to the desired value in the desired axis
- disp[self.axis] = self.value
- # sets the blocked dofs vector to true in the desired axis
- flags[self.axis] = True
-
-################################################################
-# Neumann Boudary condition functor: impose a traction
-################################################################
-
-
-class FromTraction(akantu.NeumannFunctor):
-
- def __init__(self, traction):
- super().__init__()
- self.traction = traction
-
- def __call__(self, quad_point, force, coord, normals):
- # sets the force to the desired value in the desired axis
- force[:] = self.traction
-
-################################################################
-
-
-def solve(material_file, mesh_file, traction):
- akantu.parseInput(material_file)
- spatial_dimension = 2
-
- ################################################################
- # Initialization
- ################################################################
- mesh = akantu.Mesh(spatial_dimension)
- if rank == 0:
- mesh.read(mesh_file)
- mesh.distribute()
-
- model = akantu.SolidMechanicsModel(mesh)
- model.initFull(akantu.SolidMechanicsModelOptions(akantu._static))
-
- model.setBaseName("plate")
- model.addDumpFieldVector("displacement")
- model.addDumpFieldVector("external_force")
- model.addDumpField("strain")
- model.addDumpField("stress")
- model.addDumpField("blocked_dofs")
-
- ################################################################
- # Boundary conditions
- ################################################################
-
- model.applyBC(FixedValue(0.0, akantu._x), "XBlocked")
- model.applyBC(FixedValue(0.0, akantu._y), "YBlocked")
-
- trac = np.zeros(spatial_dimension)
- trac[1] = traction
-
- if rank == 0:
- print("Solve for traction ", traction)
-
- model.getExternalForce()[:] = 0
- model.applyBC(FromTraction(trac), "Traction")
-
- solver = model.getNonLinearSolver()
- solver.set("max_iterations", int(2))
- solver.set("threshold", 1e-10)
- solver.set("convergence_type", akantu._scc_residual)
-
- model.solveStep()
-
- model.dump()
-
-################################################################
-# main
-################################################################
-
-
-def main():
-
- import os
- mesh_file = 'plate.msh'
- # if mesh was not created the calls gmsh to generate it
- if rank == 0 and not os.path.isfile(mesh_file):
- import subprocess
- ret = subprocess.call(
- 'gmsh -format msh2 -2 plate.geo {0}'.format(mesh_file), shell=True)
- if not ret == 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
-
- comm.Barrier()
- material_file = 'material.dat'
-
- traction = 1.
- solve(material_file, mesh_file, traction)
-
-
-################################################################
-if __name__ == "__main__":
- main()
diff --git a/examples/python/plate-hole/plate.py b/examples/python/plate-hole/plate.py
index 141716bc6..efabe9628 100644
--- a/examples/python/plate-hole/plate.py
+++ b/examples/python/plate-hole/plate.py
@@ -1,114 +1,72 @@
#!/usr/bin/env python3
-
-from __future__ import print_function
-
-import akantu
+try:
+ from mpi4py import MPI
+ comm = MPI.COMM_WORLD
+ prank = comm.Get_rank()
+except ImportError:
+ prank = 0
+
+import akantu as aka
import numpy as np
-################################################################
-# Dirichlet Boudary condition functor: fix the displacement
-################################################################
-
-
-class FixedValue(akantu.DirichletFunctor):
-
- def __init__(self, value, axis):
- super().__init__(axis)
- self.value = value
- self.axis = int(axis)
-
- def __call__(self, node, flags, disp, coord):
- # sets the displacement to the desired value in the desired axis
- disp[self.axis] = self.value
- # sets the blocked dofs vector to true in the desired axis
- flags[self.axis] = True
-
-################################################################
-# Neumann Boudary condition functor: impose a traction
-################################################################
-
-
-class FromTraction(akantu.NeumannFunctor):
-
- def __init__(self, traction):
- super().__init__()
- self.traction = traction
-
- def __call__(self, quad_point, force, coord, normals):
- # sets the force to the desired value in the desired axis
- force[:] = self.traction
-
-################################################################
-
+# -----------------------------------------------------------------------------
def solve(material_file, mesh_file, traction):
- akantu.parseInput(material_file)
+ aka.parseInput(material_file)
spatial_dimension = 2
- ################################################################
+ # -------------------------------------------------------------------------
# Initialization
- ################################################################
- mesh = akantu.Mesh(spatial_dimension)
- mesh.read(mesh_file)
+ # -------------------------------------------------------------------------
+ mesh = aka.Mesh(spatial_dimension)
+ if prank == 0:
+ mesh.read(mesh_file)
+
+ mesh.distribute()
- model = akantu.SolidMechanicsModel(mesh)
- model.initFull(akantu.SolidMechanicsModelOptions(akantu._static))
+ model = aka.SolidMechanicsModel(mesh)
+ model.initFull(_analysis_method=aka._static)
model.setBaseName("plate")
model.addDumpFieldVector("displacement")
model.addDumpFieldVector("external_force")
model.addDumpField("strain")
model.addDumpField("stress")
model.addDumpField("blocked_dofs")
- ################################################################
+ # -------------------------------------------------------------------------
# Boundary conditions
- ################################################################
-
- model.applyBC(FixedValue(0.0, akantu._x), "XBlocked")
- model.applyBC(FixedValue(0.0, akantu._y), "YBlocked")
+ # -------------------------------------------------------------------------
+ model.applyBC(aka.FixedValue(0.0, aka._x), "XBlocked")
+ model.applyBC(aka.FixedValue(0.0, aka._y), "YBlocked")
+ model.getExternalForce()[:] = 0
trac = np.zeros(spatial_dimension)
trac[1] = traction
-
- print("Solve for traction ", traction)
-
- model.getExternalForce()[:] = 0
- model.applyBC(FromTraction(trac), "Traction")
+ model.applyBC(aka.FromTraction(trac), "Traction")
solver = model.getNonLinearSolver()
- solver.set("max_iterations", int(2))
+ solver.set("max_iterations", 2)
solver.set("threshold", 1e-10)
- solver.set("convergence_type", akantu.SolveConvergenceCriteria__residual)
+ solver.set("convergence_type", aka.SolveConvergenceCriteria.residual)
+ print("Solve for traction ", traction)
model.solveStep()
model.dump()
-################################################################
-# main
-################################################################
-
+# -----------------------------------------------------------------------------
+# main
+# -----------------------------------------------------------------------------
def main():
-
- import os
mesh_file = 'plate.msh'
- # if mesh was not created the calls gmsh to generate it
- if not os.path.isfile(mesh_file):
- import subprocess
- ret = subprocess.call(
- 'gmsh -format msh2 -2 plate.geo {0}'.format(mesh_file), shell=True)
- if not ret == 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
-
material_file = 'material.dat'
-
traction = 1.
+
solve(material_file, mesh_file, traction)
-################################################################
+# -----------------------------------------------------------------------------
if __name__ == "__main__":
main()
diff --git a/examples/python/stiffness_matrix/CMakeLists.txt b/examples/python/stiffness_matrix/CMakeLists.txt
index 1b507413b..bf55db522 100644
--- a/examples/python/stiffness_matrix/CMakeLists.txt
+++ b/examples/python/stiffness_matrix/CMakeLists.txt
@@ -1,3 +1,8 @@
+add_mesh(plate_stiffness_matrix plate.geo DIM 2)
+
register_example(stiffness_matrix
SCRIPT stiffness_matrix.py
- FILES_TO_COPY material.dat plate.geo)
+ FILES_TO_COPY material.dat
+ DEPENDS plate_stiffness_matrix
+ PYTHON
+ )
diff --git a/examples/python/stiffness_matrix/plate.msh b/examples/python/stiffness_matrix/plate.msh
index 5425a1257..0e2a8efc0 100644
--- a/examples/python/stiffness_matrix/plate.msh
+++ b/examples/python/stiffness_matrix/plate.msh
@@ -1,6237 +1,6267 @@
$MeshFormat
-2.2 0 8
+4 0 8
$EndMeshFormat
$PhysicalNames
5
0 12 "XBlocked"
0 13 "YBlocked"
1 9 "XBlocked"
1 10 "YBlocked"
1 11 "Traction"
$EndPhysicalNames
+$Entities
+6 5 1 0
+1 0 0 0 0 0 0 0
+2 4 0 0 4 0 0 0
+3 4 4 0 4 4 0 0
+4 0 4 0 0 4 0 0
+5 1 0 0 1 0 0 2 12 13
+6 0 1 0 0 1 0 0
+1 5.551115123125783e-17 0 0 1 1 0 0 2 5 -6
+2 0 1 0 0 4 0 1 9 2 6 -4
+3 0 4 0 4 4 0 1 11 2 4 -3
+4 4 0 0 4 4 0 0 2 3 -2
+5 1 0 0 4 0 0 1 10 2 2 -5
+7 0 0 0 4 4 0 1 8 5 -1 -5 -4 -3 -2
+$EndEntities
$Nodes
-2092
+11 2092
+2 0 0 1
1 4 0 0
+3 0 0 1
2 4 4 0
+4 0 0 1
3 0 4 0
+5 0 0 1
4 1 0 0
+6 0 0 1
5 0 1 0
+1 1 0 15
6 0.9951847266502585 0.09801714055230534 0
7 0.9807852803038259 0.1950903225158687 0
8 0.9569403355024331 0.2902846780119318 0
9 0.9238795320817892 0.3826834334019886 0
10 0.8819212636904032 0.4713967380569389 0
11 0.8314696113679687 0.5555702344182949 0
12 0.7730104520841969 0.6343932857215511 0
13 0.7071067795733449 0.7071067827997501 0
14 0.634393282646958 0.7730104546074502 0
15 0.5555702316245595 0.8314696132346829 0
16 0.471396735522105 0.8819212650453002 0
17 0.3826834312318057 0.9238795329807084 0
18 0.2902846763682919 0.9569403360010258 0
19 0.1950903214145686 0.980785280522888 0
20 0.0980171400302339 0.995184726701678 0
+2 1 0 29
21 0 1.099999999999506 0
22 0 1.199999999999012 0
23 0 1.299999999998518 0
24 0 1.399999999998024 0
25 0 1.499999999997529 0
26 0 1.599999999997035 0
27 0 1.699999999996541 0
28 0 1.799999999996047 0
29 0 1.899999999995552 0
30 0 1.999999999995116 0
31 0 2.099999999995333 0
32 0 2.199999999995579 0
33 0 2.299999999995825 0
34 0 2.399999999996071 0
35 0 2.499999999996318 0
36 0 2.599999999996564 0
37 0 2.699999999996809 0
38 0 2.799999999997055 0
39 0 2.8999999999973 0
40 0 2.999999999997546 0
41 0 3.099999999997791 0
42 0 3.199999999998036 0
43 0 3.299999999998282 0
44 0 3.399999999998528 0
45 0 3.499999999998773 0
46 0 3.599999999999018 0
47 0 3.699999999999264 0
48 0 3.79999999999951 0
49 0 3.899999999999755 0
+3 1 0 39
50 0.09999999999981146 4 0
51 0.1999999999995986 4 0
52 0.2999999999994113 4 0
53 0.3999999999992587 4 0
54 0.4999999999990951 4 0
55 0.5999999999988144 4 0
56 0.6999999999985229 4 0
57 0.7999999999982315 4 0
58 0.89999999999794 4 0
59 0.9999999999976484 4 0
60 1.099999999997357 4 0
61 1.199999999997066 4 0
62 1.299999999996774 4 0
63 1.399999999996483 4 0
64 1.499999999996191 4 0
65 1.5999999999959 4 0
66 1.699999999995608 4 0
67 1.799999999995317 4 0
68 1.899999999995025 4 0
69 1.999999999994777 4 0
70 2.099999999994997 4 0
71 2.19999999999526 4 0
72 2.299999999995524 4 0
73 2.399999999995787 4 0
74 2.49999999999605 4 0
75 2.599999999996314 4 0
76 2.699999999996577 4 0
77 2.79999999999684 4 0
78 2.899999999997104 4 0
79 2.999999999997367 4 0
80 3.09999999999763 4 0
81 3.199999999997893 4 0
82 3.299999999998157 4 0
83 3.39999999999842 4 0
84 3.499999999998683 4 0
85 3.599999999998947 4 0
86 3.69999999999921 4 0
87 3.799999999999474 4 0
88 3.899999999999737 4 0
+4 1 0 39
89 4 3.899999999999583 0
90 4 3.799999999999167 0
91 4 3.699999999998751 0
92 4 3.599999999998334 0
93 4 3.499999999998004 0
94 4 3.399999999998612 0
95 4 3.299999999999305 0
96 4 3.199999999999999 0
97 4 3.100000000000693 0
98 4 3.000000000001386 0
99 4 2.90000000000208 0
100 4 2.800000000002774 0
101 4 2.700000000003467 0
102 4 2.60000000000416 0
103 4 2.500000000004854 0
104 4 2.400000000005547 0
105 4 2.300000000006241 0
106 4 2.200000000006934 0
107 4 2.100000000007628 0
108 4 2.000000000008235 0
109 4 1.900000000007906 0
110 4 1.800000000007489 0
111 4 1.700000000007074 0
112 4 1.600000000006657 0
113 4 1.500000000006241 0
114 4 1.400000000005825 0
115 4 1.300000000005409 0
116 4 1.200000000004993 0
117 4 1.100000000004577 0
118 4 1.000000000004161 0
119 4 0.9000000000037449 0
120 4 0.8000000000033287 0
121 4 0.7000000000029125 0
122 4 0.6000000000024963 0
123 4 0.5000000000020806 0
124 4 0.4000000000016639 0
125 4 0.3000000000012486 0
126 4 0.200000000000832 0
127 4 0.1000000000004162 0
+5 1 0 29
128 3.900000000001324 0 0
129 3.800000000002422 0 0
130 3.700000000002307 0 0
131 3.60000000000252 0 0
132 3.500000000003786 0 0
133 3.400000000003746 0 0
134 3.300000000003589 0 0
135 3.200000000003433 0 0
136 3.100000000003276 0 0
137 3.000000000003119 0 0
138 2.900000000002963 0 0
139 2.800000000002806 0 0
140 2.70000000000265 0 0
141 2.600000000002494 0 0
142 2.500000000002337 0 0
143 2.400000000002181 0 0
144 2.300000000002025 0 0
145 2.200000000001869 0 0
146 2.100000000001713 0 0
147 2.000000000001557 0 0
148 1.900000000001402 0 0
149 1.800000000001246 0 0
150 1.70000000000109 0 0
151 1.600000000000934 0 0
152 1.500000000000778 0 0
153 1.400000000000623 0 0
154 1.300000000000467 0 0
155 1.200000000000311 0 0
156 1.100000000000156 0 0
+7 2 0 1936
157 2.059834627972047 2.071774407501231 0
158 1.179280626212892 2.824332137761062 0
159 2.821717920519497 1.181487301489158 0
160 2.870938197227737 2.862589013298715 0
161 1.761378395153983 1.074185380680933 0
162 1.035484802949141 1.795528417091771 0
163 3.102742231376358 2.001710484125938 0
164 2.015012089200159 3.111498742109454 0
165 2.342691263812367 0.6851327556972823 0
166 0.6872170268250173 3.312782973174925 0
167 3.312782973175087 0.6872170268250323 0
168 0.6739082941492394 2.406757063345106 0
169 3.332204160367965 3.329525279815482 0
170 2.237171745500607 1.445084285476748 0
171 1.13899392508689 1.141146650770716 0
172 1.484218361160645 2.247347889035101 0
173 1.457886491409792 3.376365688120475 0
174 3.387364630303134 1.46154719733819 0
175 1.631308858990636 1.657056642292305 0
176 3.379085752096072 2.556282456602916 0
177 2.563355365756499 3.383482555865657 0
178 2.3317382890251 2.614947874529122 0
179 0.5717547177498667 1.464626073045153 0
180 1.455405182348013 0.5659811143906933 0
181 2.583354504629948 1.898951587349129 0
182 2.827383607678683 0.5144880702972171 0
183 1.821837563867549 2.635878027794323 0
184 0.5026107168072008 2.843301296015982 0
185 2.777314918780683 2.382404323221444 0
186 0.492241060473887 1.913773319495745 0
187 1.917393548985615 0.4776808319217449 0
188 1.866680055451452 3.548209232193982 0
189 3.53113793330113 1.879339311000612 0
190 2.927202178455239 1.608307152495156 0
191 1.052217083126269 3.561121849162911 0
192 3.563724772669571 1.056047184525339 0
193 3.545336529523794 2.961461455573517 0
194 2.953852897388042 3.556204885139878 0
195 1.562860310508591 2.971810856634471 0
196 1.054892758104844 2.208690050120225 0
197 2.172093552538404 1.059286661229019 0
198 2.489142698551071 2.990975546615491 0
199 3.61433970795542 0.3895760791093845 0
200 0.4025590449029198 3.597440955097092 0
201 1.135552600278538 0.791727815712713 0
202 3.612699217763244 3.612699217763224 0
203 2.395548413661271 2.245692637967394 0
204 3.623066073997228 2.268966480746184 0
205 2.268966480745472 3.623066073995068 0
206 0.7733992919148471 1.13866827770248 0
207 1.046458714038827 3.187634184523169 0
208 3.171591349738888 1.055518966283827 0
209 1.474312788273057 1.293764999033996 0
210 1.990120795289137 1.705225795902449 0
211 2.68577987344284 0.8565112689566434 0
212 1.720978341687657 2.005466972306212 0
213 0.8357033652419018 2.69652523332488 0
214 3.154165813951709 0.3711737959388691 0
215 2.487450590830798 0.3685732849922235 0
216 3.187132605141837 3.00225913027513 0
217 0.9280601470672928 1.459358833449071 0
218 0.3583130920826133 3.165173658664609 0
219 1.474898283587542 2.61842238457653 0
220 1.369194161187577 1.923742820454392 0
221 0.3423053607095761 2.515577518116112 0
222 2.610797378315194 1.45012679644447 0
223 2.855862450576572 3.238288358082068 0
224 1.912702044559522 1.360680046777973 0
225 1.41298968388584 0.9838813227792947 0
226 3.033982948505735 2.577475400758868 0
227 1.319878445711294 1.600532130010072 0
228 2.048689277592323 2.414163926588466 0
229 0.7321832434003049 3.665055177461772 0
230 3.665055177461519 0.7321832434001063 0
231 2.498751912297174 1.129893961421254 0
232 3.666697543819277 3.280823248254657 0
233 3.277822869100524 3.666915351882116 0
234 1.957309923060282 0.8040736926546496 0
235 0.7985684815523527 2.023170400249038 0
236 1.573502726814574 3.675628650731362 0
237 3.67709582378063 1.5835195167348 0
238 0.3234045513543287 1.275563970784248 0
239 1.259558737202446 0.3155193572049318 0
240 0.3204798939025587 1.651703698491485 0
241 2.972583691341996 0.7876889875643716 0
242 1.177586337115621 2.509860260997754 0
243 0.7797651899086815 3.008855274687577 0
244 1.648509895738948 0.3129293938507431 0
245 0.3223524611193754 2.220163695183995 0
246 2.088412779243467 2.804647359007034 0
247 3.684817001808269 2.676894969583816 0
248 2.67245088468384 3.686928371454458 0
249 2.260501749569738 1.843434389774715 0
250 3.099697544640006 1.323845570551229 0
251 3.218059876235646 1.7216153179124 0
252 2.182604004369282 0.3106432090262924 0
253 3.301271669725211 2.265861849347764 0
254 2.258753072355335 3.299955498890597 0
255 2.643102078402434 2.665401682304939 0
256 1.742547197029971 3.259126165188637 0
257 1.773543862352646 2.306085510407776 0
258 0.7568463992276776 1.715336072589943 0
259 2.80862265446359 2.082080337698757 0
260 1.674023845327693 0.7842551502146167 0
261 1.297598363586556 3.71196989899947 0
262 3.711969898999516 1.297598363586833 0
263 1.312004134495224 3.118940753599327 0
264 3.033493504208013 2.27882147750712 0
265 0.9069134788155497 0.8929476437510191 0
266 1.836882454649946 2.905376447741898 0
267 2.74619966855217 0.2615749641392818 0
268 0.2580304911749545 2.931266187083996 0
269 1.142226567742575 0.5214613259019345 0
270 2.462057489028428 1.672172253988223 0
271 0.9193947663696417 2.450591799519246 0
272 2.579324886520474 0.6017848732173925 0
273 3.392128227738654 0.2519862423505305 0
274 2.031773760493745 3.748177463331111 0
275 3.748177463330362 2.031773760494034 0
276 3.35880145404556 2.799498392044847 0
277 0.5804319054520376 2.615832795588139 0
278 3.093888556952874 3.348418956169651 0
279 0.2498735122629235 3.399958073184745 0
280 0.5147604603040064 1.131713299283271 0
281 2.841622645764675 1.828975287970894 0
282 1.20670443664021 3.379898906519365 0
283 3.375762564506549 1.221485062606774 0
284 2.234050343077273 3.001689371253065 0
285 2.357191138255083 0.9089790920358494 0
286 2.541419218029784 2.438914692101256 0
287 0.2479914286883235 1.948323191545799 0
288 0.565349458734029 2.160695311288353 0
289 2.018136610736282 3.368965287127441 0
290 3.362289936450845 2.020362848989265 0
291 3.742071444512653 2.446427953816554 0
292 2.442735672760505 3.726704176943481 0
293 2.108988677248498 0.5891863199461874 0
294 1.884149777427906 0.2381899141158837 0
295 2.706753702586548 3.045237537058853 0
296 3.762121509717302 0.2376674659586799 0
297 0.2352688827835619 3.750804041991312 0
298 1.692924662024964 1.426512378855439 0
299 1.715649574224005 0.5297955599286037 0
300 0.9428409098550121 3.769022638040231 0
301 3.769022638039702 0.9428409098541822 0
302 3.101352584701159 0.582129665375014 0
303 1.169249497942303 1.397451048679616 0
304 1.794213320099831 3.765040622063467 0
305 3.767911372083121 1.794675211084742 0
306 0.9117849323506159 3.375122471940709 0
307 3.367946888625958 0.9108978927636622 0
308 3.769140274698623 3.068436834916203 0
309 3.068436834915941 3.769140274698342 0
310 1.275733323371447 2.134637451424288 0
311 3.440326402403763 1.678297414855112 0
312 2.832448872593704 1.40472897314227 0
313 3.092953256311199 2.806671683026898 0
314 2.971179854689692 0.230891645751323 0
315 3.758170817193186 3.773551046495502 0
316 3.384728092476857 3.127634068384491 0
317 0.5474133810259891 3.064603500117769 0
318 0.227474261627206 2.704006141458169 0
319 1.973457841414909 1.146411547935172 0
320 2.777581733168567 3.430889707439454 0
321 1.648984965995719 2.492757736068411 0
322 0.5348237167661489 3.77614966830608 0
323 3.775778105279163 0.5348207345937327 0
324 0.4930921247327604 3.387723883970225 0
325 1.010588472652612 2.950906805844175 0
326 1.638205751263605 2.762111278299866 0
327 1.39238280159913 2.82411801530613 0
328 2.298169795178504 1.238496080803737 0
329 2.656249048009742 2.207728473884726 0
330 2.692670968964814 1.651694850547039 0
331 3.381796307190958 0.5019020412356975 0
332 3.78102686140263 3.476014673190904 0
333 3.471597477764715 3.762535415186073 0
334 1.657894936289693 3.468702951049163 0
335 1.37161479481024 0.7518757206540253 0
336 2.295144253171705 2.063798416815118 0
337 1.910511578684842 1.916754473063199 0
338 0.5206949925417212 1.726677412237421 0
339 0.2150534933837839 1.464603154685763 0
340 2.441675536893859 3.217859709642753 0
341 0.8588579449862448 2.219931130424579 0
342 2.968022078671691 1.008261429786912 0
343 2.182423694506801 0.8322834837091798 0
344 2.992023422283888 3.051607302919298 0
345 1.455953775996943 0.2147565716401785 0
346 1.106517393740884 2.013702130291513 0
347 2.279746251341666 2.400322367712852 0
348 2.352987129440272 2.812885705464612 0
349 1.545157381461528 3.186457697388496 0
350 2.838406726760743 2.589625092076281 0
351 3.78947991566244 2.855172053082031 0
352 2.856211107627051 3.791175128384409 0
353 3.227813685865641 2.443849888798401 0
354 1.221827063312749 0.9795691505220536 0
355 1.56745818300293 1.872825624426246 0
356 0.9443599954363798 1.250518016918117 0
357 0.7491189856141806 1.33838303155936 0
358 2.326457535638262 0.4828693372981284 0
359 1.821137400712481 1.585922173466009 0
360 3.033705298479149 1.82070787895002 0
361 1.320543229452085 1.160254870337756 0
362 1.527500510240728 2.067279592334253 0
363 1.058279798566907 1.585027999096453 0
364 2.128437622435213 2.602581882368729 0
365 2.04773825482977 1.507360141184439 0
366 1.363150893879319 2.442617217833059 0
367 1.047268241070969 2.669297943049992 0
368 2.362077009574105 0.1972146386831222 0
369 0.4792638061715729 2.338380170071132 0
370 0.2048037627547484 2.379339023944357 0
371 3.531490820144457 3.429699021115271 0
372 1.561392992539696 1.116908430680444 0
373 1.893807547821784 2.141773965236879 0
374 3.120123303097877 1.543050392001625 0
375 1.487717100837181 1.518629941443007 0
376 0.9559163333688548 0.7112372685199755 0
377 3.562143040610156 2.445548357697457 0
378 2.461658824426795 3.540253367341872 0
379 3.181470686403084 0.8408132719301035 0
380 2.084057597793002 1.334073687789064 0
381 2.672393360245708 1.044629142222181 0
382 1.249700229966213 1.750415871300841 0
383 2.625531871453455 2.841751316713368 0
384 2.198055273499019 1.640218240141193 0
385 0.7122773696376163 0.9412858094959899 0
386 1.736821831005247 1.827174787622758 0
387 2.628484296650622 1.256746613116387 0
388 2.192638202149752 2.216862573136349 0
389 3.525597745665366 2.068949590958754 0
390 2.068949590958981 3.525597745663776 0
391 0.8482648701230362 3.187715700669532 0
392 3.583906467041797 0.1870855363973309 0
393 3.228127529281009 2.670909634964932 0
394 2.667490200599336 3.234499393832801 0
395 2.804473069211954 0.728454785188305 0
396 0.6991078725154467 2.837404608106253 0
397 0.6318655152214488 3.498854370616963 0
398 1.785913412173669 1.253496650392086 0
399 2.426950300350325 1.376701758184164 0
400 1.129126119358137 3.815582931416936 0
401 3.815582931415531 1.129126119358637 0
402 1.714428585068926 3.060299746153868 0
403 1.21724056163091 2.317636418714232 0
404 3.492160150273963 0.6459372598903914 0
405 1.317580079363991 3.518005674838809 0
406 3.516902277564004 1.318781968961099 0
407 1.291553134127144 2.661938807511112 0
408 2.48103497268005 2.054986699317706 0
409 3.189133147918144 3.194834907331018 0
410 3.815316035912248 2.269909899289583 0
411 2.269909899281465 3.815316035913397 0
412 3.230767971162939 3.493792596021344 0
413 1.453977049994229 1.710035024346884 0
414 0.1835010023883578 3.574009241398438 0
415 1.888468166470664 2.452074655938097 0
416 1.860987523194935 0.6405254759153309 0
417 0.6719715478350933 1.863019046955623 0
418 1.454659059138316 3.837419142767541 0
419 3.837419142768367 1.454659059138927 0
420 2.565352982008434 0.1865280092313415 0
421 2.054805932922362 0.1828544331136762 0
422 0.9873070428828996 1.058230967350739 0
423 1.175812784835197 3.012670162042959 0
424 2.099166490873588 1.888440182176859 0
425 3.21692866429548 0.1848624435649664 0
426 0.1855020467660105 3.102013628664847 0
427 2.49776153078304 0.7887185570769714 0
428 0.7606288522037205 1.53549404501676 0
429 2.992070859390117 0.4027768888971235 0
430 1.924283655580719 0.9739907309840322 0
431 0.1700346142617001 1.151464375851993 0
432 1.611173483600221 0.9535185580776246 0
433 1.34133914440125 1.423267647921739 0
434 1.150863656483822 0.1708489366271618 0
435 3.358744955132912 1.837073371837715 0
436 1.433019975600422 0.3915967022687767 0
437 0.1802356857833756 1.777202584223009 0
438 0.3980202063862963 1.424673087889608 0
439 3.506529295977527 2.696674774842824 0
440 2.669432460982581 0.4257032711143908 0
441 0.8561819268411557 1.843277289328229 0
442 0.9006711031900096 1.633473490381253 0
443 0.8848084450409309 3.552697611269749 0
444 3.556214500256146 0.8714652513856758 0
445 2.958191729711847 2.438261967307575 0
446 3.054731806848779 1.158060854348299 0
447 0.4175160163356187 2.693193246955799 0
448 3.448226156222159 3.592608922325167 0
449 0.7746015872888905 2.527228916193465 0
450 1.651789231265723 2.166555723093964 0
451 2.014425852177011 2.237885753964746 0
452 1.291221903162731 0.6013980021795415 0
453 0.5934165414762637 1.280209180688178 0
454 2.843464528172957 0.8834244415457141 0
455 0.1714036742665409 2.106136654022946 0
456 3.572658534121014 3.129982292050098 0
457 2.933446365595081 1.958137261760317 0
458 2.474755204791245 2.705226550485325 0
459 0.1653741663522051 2.546555444225318 0
460 0.7985817657307593 3.840452367420107 0
461 3.840452367419745 0.7985817657300047 0
462 3.845447726293479 3.205343607134695 0
463 3.224039702080563 3.828834640206977 0
464 1.109002126473783 0.3635871137324646 0
465 0.9578484389051235 2.084752477835057 0
466 1.645384991087739 3.830901546221694 0
467 3.836536721105117 1.643571038324591 0
468 2.943744979110507 2.721823410803916 0
469 0.3519505371116962 1.839005412731398 0
470 3.253712830261891 1.342437716252702 0
471 2.176697398495803 3.160650654090192 0
472 0.8620760462684842 2.862036654221911 0
473 2.871023764706943 2.242734370789131 0
474 2.089339404971878 0.4445808268705499 0
475 0.3530933982380186 1.110867456680898 0
476 2.654490168168414 2.044637562790233 0
477 1.919802624826116 2.774318497630564 0
478 0.5408274909237663 3.230621404562402 0
479 1.982129957823278 2.935356942930343 0
480 3.167828582168225 2.158044948624643 0
481 1.724357664006089 0.1647087102023513 0
482 3.836388375341087 2.58838482537443 0
483 2.59529920471189 3.834018537280368 0
484 3.411025394276466 2.386562394986903 0
485 2.382016690465396 3.402055379378732 0
486 1.494552971863298 3.534009901620554 0
487 3.542435664100062 1.487673344221009 0
488 2.521401366199022 0.9529700238565812 0
489 1.519293493102087 0.7247957467091809 0
490 1.063141715062176 2.375810411251471 0
491 0.3833176500063405 3.836206570771334 0
492 3.836206570771298 0.3833176500061273 0
493 0.4219904273129147 2.977118300777086 0
494 1.047280189367525 0.9131755667005498 0
495 1.910641465772125 3.232874190550187 0
496 3.841723686040489 3.611951781911646 0
497 3.616379533437431 3.83668801407894 0
498 0.1619674331178227 3.272724209387151 0
499 0.3725630497884945 2.051742951666508 0
500 2.332645744284949 1.083433497940692 0
501 1.611874126654288 2.31966850093356 0
502 2.989690045834238 2.129680695302295 0
503 1.793953813188203 0.8887882468464816 0
504 3.115142241701744 3.61342160603712 0
505 3.59662190566537 1.724650626497505 0
506 2.426268374595524 1.813923204620897 0
507 1.850787876761274 3.387114938516668 0
508 3.481825130201853 3.263807907464889 0
509 2.636694135190061 3.530359228765468 0
510 2.801423056270832 3.590817752953383 0
511 1.734297555845727 3.618286151821405 0
512 0.1537501562230263 1.610865205364459 0
513 3.203765882101414 1.882473550676482 0
514 2.925040118052554 3.37664889056016 0
515 2.782349594886054 2.736019415251163 0
516 0.6909647909698883 3.153957725201881 0
517 3.468890837353488 2.232119788465666 0
518 2.232119788465419 3.468890837351501 0
519 2.947224902051028 0.6154998116680466 0
520 1.795224519794395 0.3753248591878189 0
521 2.951657909643901 1.282377832431224 0
522 2.97911629859309 1.458536086808604 0
523 3.359479699675572 2.965968707880403 0
524 1.411071911522405 2.991520130241402 0
525 3.275597667982976 1.573918021946387 0
526 0.1570195461136941 1.317639393721025 0
527 3.617580271766343 2.81821208789993 0
528 2.692256612865069 2.507223859567237 0
529 3.231360099453441 0.4989258517814038 0
530 1.971862478739484 2.589071801407324 0
531 2.22112031204417 0.15538055409286 0
532 0.4644071945663256 1.573697980554958 0
533 2.223587733438285 2.726425851906205 0
534 3.022758576933321 3.206571067778175 0
535 0.7081928719109518 2.147218288772624 0
536 1.188208128842623 3.218782587501654 0
537 1.336138515357571 3.279825180760635 0
538 1.316479679647896 0.1616465602323707 0
539 1.236489264226976 1.277501817418631 0
540 2.57126190459388 3.11461442823519 0
541 2.400715703397181 1.527531275115869 0
542 2.07419073973068 0.9410948038852622 0
543 1.578722339984011 0.4488399790123233 0
544 0.6259685467225118 1.612737368631532 0
545 3.205988225782758 1.193090422428567 0
546 1.063550177807407 3.334861890599807 0
547 3.344614268129882 1.056194646022858 0
548 3.628541478077315 0.5562273215613819 0
549 1.605002972938738 3.32619157627361 0
550 2.787940272409521 1.540253540990276 0
551 1.998614701167213 0.3234100367865851 0
552 2.843251410110152 0.1452161489873671 0
553 0.5568903368296736 3.630510534217226 0
554 0.7731214060522043 3.43292483945681 0
555 3.436470536147741 0.7738182618699557 0
556 1.924149709836608 3.844102633070397 0
557 3.844102633069999 1.924149709838499 0
558 1.19232754761791 3.61101751729255 0
559 3.610906544501012 1.192620778445465 0
560 2.360472925506892 3.081723577395516 0
561 0.6184525479869795 2.028196598243418 0
562 1.003468018659819 2.814779719283176 0
563 2.436343289289312 0.5724860222832083 0
564 0.1442518231236271 2.831394262462602 0
565 0.5009755860060475 2.496172610915493 0
566 1.886250120957764 3.043210505896673 0
567 1.511780057265402 2.459729336614024 0
568 0.9920690837567985 0.5659913796199709 0
569 0.5630467014473601 0.9890701418421604 0
570 3.051872095623048 1.659075843353325 0
571 1.636564162927949 1.254390158237335 0
572 3.849373099469633 1.283912557706584 0
573 1.283912557704733 3.849373099469684 0
574 3.226046719715106 2.859533463818221 0
575 2.402329941802018 2.478508099414592 0
576 1.309386518881663 0.4580408771075242 0
577 2.851723085145537 3.014429637170567 0
578 0.1366469595097899 2.251270127804502 0
579 1.235136241352968 1.935715333704102 0
580 0.8157605811377111 0.779638354601389 0
581 1.699007933238032 2.912279413897355 0
582 2.839970433953512 0.3709613693333687 0
583 1.764633446080337 2.763300201845539 0
584 0.3524370590986902 2.835743783409123 0
585 2.815097951345079 1.030288764573291 0
586 0.9811105260138233 1.937446580950801 0
587 2.488564392569297 2.847518083570912 0
588 1.578408447782779 0.1517967458057528 0
589 3.307972838836815 0.3615736520863292 0
590 1.430412665357608 3.663950599920594 0
591 3.663950599921208 1.430412665358237 0
592 2.569376581324827 1.759998366636501 0
593 1.284039558541333 2.914534253231311 0
594 3.850783664981963 2.727521898998043 0
595 2.740169962698114 3.865191357535297 0
596 3.088479271139525 0.1429333464336701 0
597 0.6475263881885183 3.8617345672802 0
598 3.861734567280001 0.6475263881886852 0
599 3.859981508061885 2.099301142334977 0
600 2.099301142329858 3.859981508064915 0
601 1.681882647731223 2.62896671985644 0
602 2.375045964975701 1.947843744177729 0
603 2.334055747428737 1.70943079109034 0
604 2.111167022290734 1.185064147368108 0
605 3.864388848641295 0.1356111513580877 0
606 0.1356111513585576 3.864388848641594 0
607 0.8498549813594372 1.034023878833271 0
608 3.498385356761835 2.836982167160684 0
609 1.909427992103722 3.681512490262065 0
610 3.668984275139455 1.921559830418843 0
611 2.328937703531009 0.3372684604745972 0
612 3.450157182936054 0.130148725615795 0
613 2.213351479972778 2.864645524663026 0
614 2.52963266000397 2.578077111735796 0
615 0.3490462491303749 3.304431916131806 0
616 1.02971725710109 2.521358165224487 0
617 2.723726390560445 1.936171224810097 0
618 0.4244846109411758 1.246509875408939 0
619 3.071803410098677 3.456069282457725 0
620 2.818870941533197 1.693810890225884 0
621 3.169342614441207 2.312074192982024 0
622 1.076215597504916 1.305139697547695 0
623 0.813494274205938 2.363999807266379 0
624 2.711839235684585 0.5878870799500234 0
625 3.106177250741949 0.7254573713245184 0
626 2.547535807521222 2.299696956134432 0
627 3.867310569608187 3.359126145271152 0
628 3.348781779180769 3.862398027576236 0
629 0.930944733855932 3.080602007708188 0
630 3.088676578280559 0.942294374434417 0
631 0.6441277408673993 2.950067266137776 0
632 3.555615330085912 2.582027822500113 0
633 1.09420764563601 0.6606825678367939 0
634 3.865896454748271 2.971226006412794 0
635 2.971226006412384 3.865896454747645 0
636 3.000645185514544 2.911776292410107 0
637 1.910157449444207 2.317816021288716 0
638 3.344319204824967 3.477372908568264 0
639 2.575746740951411 1.583924194273709 0
640 2.532202196439062 3.670789701085769 0
641 2.520417963827912 1.281076490822677 0
642 1.965669921145465 0.6470530468159443 0
643 3.46870437858362 0.3618452692371316 0
644 2.119239535875724 1.754839582638957 0
645 0.3137607663152027 2.337498702695499 0
646 1.503423306043588 2.751320603724252 0
647 0.1352975942078409 3.465628037200451 0
648 1.510924406195453 0.8579426463939276 0
649 1.055486891754392 3.696463336480772 0
650 3.696463336480399 1.055486891753652 0
651 1.26032044104648 0.8690264030668138 0
652 2.697672807564673 0.1352784325327088 0
653 3.053053525861448 2.416352955341754 0
654 0.3645926345303707 3.463909803110229 0
655 3.69423061295148 2.947515368521779 0
656 2.951122523928955 3.69342407391153 0
657 0.9371906954550685 2.321264567242178 0
658 2.248827940483389 0.5884709149842313 0
659 1.400994411241642 2.132908502925462 0
660 0.6996789915726234 2.676138514582281 0
661 3.851868227727428 3.872404728364453 0
662 3.655911475298683 3.4094143459592 0
663 0.136203172010892 2.989578230564493 0
664 1.856658168102082 1.713773251106967 0
665 1.340488362999639 2.269891249881114 0
666 3.118785571851425 3.10146805784659 0
667 0.9084434586035267 2.583399120223163 0
668 2.245692355302648 0.9488992586775881 0
669 1.588569067269883 0.6077155580620593 0
670 1.839195905632046 0.7769228036425019 0
671 3.708232277211016 2.169454107202549 0
672 2.169454107200237 3.708232277209763 0
673 2.175004893156951 2.479692354117571 0
674 1.950385536504743 1.515514388917687 0
675 2.344090525578449 3.866421270938012 0
676 3.866421270937897 2.34409052558638 0
677 2.751942304734239 2.909988215220346 0
678 0.6439528785246064 1.095751679162562 0
679 2.323661800340515 0.8201106550155342 0
680 2.653040297852881 0.7219674465827419 0
681 2.363072037599515 2.948606457132676 0
682 2.175336547002597 1.99362187670956 0
683 1.110072298487518 1.051122944554837 0
684 2.67016473952873 2.367212384340949 0
685 2.132027117479319 3.008574059205901 0
686 3.698813697472334 0.1372043130692251 0
687 2.703642686666393 1.791465218579397 0
688 2.072481040873647 3.211213543741023 0
689 1.962740070473541 0.1325319143384608 0
690 0.28778788971596 3.048559609829127 0
691 0.5731969575451714 2.733302272720804 0
692 2.629805072575449 0.3064286428439933 0
693 3.23053513330016 2.064035302774734 0
694 3.222416841888281 1.449848896607668 0
695 0.1275514480269877 3.701907099767871 0
696 1.029604888859055 3.859040599290314 0
697 3.859040599289789 1.02960488885971 0
698 2.098900992226946 0.7327999282963764 0
699 2.558628480972842 0.4762831804609204 0
700 1.820056607657098 1.419446061940366 0
701 3.357008295805735 2.678842524502579 0
702 1.556001106726741 1.394980747592653 0
703 0.4936744060291087 3.5154137963555 0
704 1.1616189992882 2.113572072059807 0
705 0.4305544319432842 2.220441678691854 0
706 1.636823679360315 1.533060985890237 0
707 1.207488604159484 1.522829511981371 0
708 1.760580237838161 2.43232809631827 0
709 3.207409853037337 3.317726394207158 0
710 1.187204618323247 1.666227821188116 0
711 1.158586825012992 3.474733219536652 0
712 3.466445458089074 1.167970835270685 0
713 2.686015474907243 1.383781773333556 0
714 0.5725003882563956 2.29397495802805 0
715 3.724375190918975 0.3425009281561815 0
716 0.3507356426735739 3.713422775291573 0
717 1.365595972915481 1.792589451469577 0
718 2.482953733564715 0.1125698389859868 0
719 0.6271624407610082 2.486358869544424 0
720 2.324649322572025 3.20745916156955 0
721 2.954220444739076 1.755154470611206 0
722 3.516214415366508 0.4938579119194795 0
723 1.732332915705652 0.662886537355258 0
724 2.001265540944815 1.268331089285761 0
725 0.8694906649027745 3.682089702224257 0
726 3.682560437168644 0.8680926422394425 0
727 3.405019272824062 1.340929328993928 0
728 0.1255387431604453 1.880751897099578 0
729 1.034254171592147 1.472048349955207 0
730 3.675870227546043 2.361767255069084 0
731 2.359947519497267 3.673017503185682 0
732 2.233415635395458 0.7179024104851641 0
733 0.4545437023338759 1.041110447065015 0
734 1.244250080103297 0.7016611550356662 0
735 3.365328070185063 2.13021194894757 0
736 2.136407834371334 3.365550384772809 0
737 3.319315114134596 0.1219016691523186 0
738 1.173393333078459 2.634159065551659 0
739 1.346497489948633 2.560393846176899 0
740 2.780996041634777 3.325753653567214 0
741 3.270016773702787 0.9457241324188101 0
742 0.8204826593899186 1.262020261959596 0
743 3.298726967593386 0.8074060149556935 0
744 2.324023690708454 3.517598453848059 0
745 3.515819254248615 2.322887039283115 0
746 1.843871750064776 1.162511244830963 0
747 2.601571042006285 2.985133102763348 0
748 1.455884246745562 3.098395290399886 0
749 1.462071370227847 1.100873805069356 0
750 2.782235801401006 2.197611319470296 0
751 2.543929142422488 3.268375165020156 0
752 0.468065980404113 2.072003800359245 0
753 2.30894209608736 2.181311767800101 0
754 1.987025539132512 3.460944092892067 0
755 3.462697795297729 1.976111438902177 0
756 0.3137892682750516 1.537261026248144 0
757 1.026425943264419 0.4418832957462677 0
758 3.883456525254723 1.758250817119708 0
759 1.748477596947679 3.896644057201927 0
760 2.041985126598277 2.690454264958701 0
761 3.088994171272046 0.4627192424565206 0
762 3.54762351284305 1.611170753925144 0
763 1.943008423836719 2.029127790095473 0
764 2.420200258778605 2.32950136402475 0
765 2.522371408429217 2.17161022263856 0
766 2.04394274887751 1.058885651379554 0
767 2.444351345780983 1.038457961143365 0
768 2.756638069377926 3.141126626205315 0
769 1.600802315859633 1.966110159821178 0
770 3.697193539572305 2.524958654229454 0
771 1.256865393338679 1.090301224633739 0
772 0.8075188967339461 3.310592528105161 0
773 1.663356046559012 1.154530055705898 0
774 2.176054905567098 2.341029345406871 0
775 3.885752480003205 0.2561174538405526 0
776 0.2561174538405836 3.88575248000304 0
777 0.6742673545177833 1.257173761576701 0
778 2.086014930902106 1.637898902396836 0
779 0.1145541016770048 2.657622255172016 0
780 1.009224208247637 3.431056002368985 0
781 3.419966385670245 1.003993584267401 0
782 0.9487881426645498 3.267024340088187 0
783 2.198418776461287 0.4189186254131071 0
784 0.4887646748255104 1.398220183590468 0
785 3.171417289739427 2.557403219732699 0
786 1.07408120555331 3.061509765478563 0
787 0.9877772178015273 0.8262192371410697 0
788 2.907066288417342 1.135018866943918 0
789 1.529966407819818 0.3092032660832263 0
790 3.73234597646977 3.666413877517861 0
791 1.62812721638642 3.088644023947093 0
792 3.293308477875384 3.09278885364296 0
793 3.339177899456913 3.223639202442695 0
794 3.112682706410948 2.712557276399259 0
795 1.374277169643194 1.276282365683437 0
796 2.231098291100592 1.342349588206574 0
797 1.824645477022099 1.977310343865122 0
798 3.87037892263362 3.112678814134916 0
799 3.117415256854828 3.880031462096306 0
800 1.307144697403034 3.391931558755911 0
801 0.8924680139977453 3.879141316949585 0
802 3.87914131694963 0.8924680139973591 0
803 1.826055499796637 0.5296080813543854 0
804 3.074315773551567 0.2491857857655048 0
805 3.690185667551209 3.159536962634009 0
806 1.781186842625693 3.478832896258362 0
807 0.8609042380615861 1.148502356825095 0
808 1.375260798775272 2.728350555549284 0
809 1.285924243901474 2.785815115822551 0
810 0.6200441827608374 1.764081585571405 0
811 1.297836109409008 2.015624839637594 0
812 0.7611330293824731 0.8499912596662874 0
813 3.574455031030824 3.719290122804986 0
814 2.802839356061987 1.265427135159489 0
815 2.014697518209281 0.5470321491495781 0
816 3.755476746083172 3.890982422819569 0
817 3.91853193555098 3.745762727999841 0
818 1.562967690964321 2.854727975717946 0
819 1.75768867487415 1.669024599152199 0
820 2.682127043669165 3.37732299784653 0
821 3.213998797199203 0.6145381871663933 0
822 0.6003267929445212 3.384010920796706 0
823 2.612750812990052 1.132644353905177 0
824 3.442237911126326 1.556408365999378 0
825 1.453425771849952 3.261746752941107 0
826 3.106119151243139 2.919959684378059 0
827 2.7333268040532 0.9698002881120947 0
828 1.321465877599133 1.021729032185382 0
829 2.044396633954246 1.411391413993765 0
830 2.491812521477763 3.88259168451542 0
831 3.882583128295084 2.493632103513048 0
832 1.824692538355125 3.193742724709156 0
833 1.976677213901003 1.823103794393664 0
834 2.82005001393442 1.972199219530798 0
835 0.7207690228651692 2.240829630042855 0
836 3.465767774866197 1.791564107428806 0
837 1.667335761396207 1.906893229943067 0
838 3.389799133416257 0.6001527076014682 0
839 0.8855122915108293 1.337348273553791 0
840 2.935881133879944 0.0888619750926985 0
841 1.485275116229121 1.933461254016063 0
842 3.705415396113339 1.697719464690811 0
843 0.1172291173456354 2.010864625502584 0
844 0.6511480869442976 3.749823274703797 0
845 3.749823274703248 0.651148086944056 0
846 1.637901108332749 1.76326197159284 0
847 3.393493027924526 3.695401920640087 0
848 3.334000250729413 1.723731101129973 0
849 1.732867201759396 2.115287388753228 0
850 2.129509543579025 1.436217579188611 0
851 0.5481791813450114 1.836736151190848 0
852 2.157352780447042 2.090348123214422 0
853 0.9286026688324061 1.735164159428418 0
854 1.701042041842904 3.726282264677594 0
855 3.446011886086007 3.024484249447701 0
856 1.557128990432452 2.187851426812185 0
857 1.575328063831735 2.592972245945564 0
858 0.1079595229250833 2.444760128123287 0
859 3.54530939124373 0.7461427051805463 0
860 3.180070142191204 3.720937461437008 0
861 1.109171877154531 1.885959678658777 0
862 1.104563981757696 2.92068598691588 0
863 2.412330746166333 1.220729496176213 0
864 0.444969950251729 3.094440526990657 0
865 0.4919804532130662 3.868354094652153 0
866 3.868175226064776 0.4919323944076653 0
867 2.496653237247236 1.476484378178679 0
868 0.2651610503494787 2.595169023237112 0
869 2.577541049852077 2.755285712626268 0
870 2.471425968448659 0.2603370876366289 0
871 0.3988363834330613 1.735910733081624 0
872 1.196775247942562 0.4371611589013638 0
873 1.549316683126209 3.897205118786266 0
874 3.897780136631205 1.549131585909523 0
875 1.685765490846459 0.4243109626133108 0
876 0.7213482614637786 3.560709568083245 0
877 3.868893732228179 3.512887244105264 0
878 3.517064475262305 3.885520661309898 0
879 0.6858389776788805 1.436053233302528 0
880 1.888025231308167 1.262702298366713 0
881 2.880879332194729 3.466714811715238 0
882 1.073015702254326 0.2569506305613936 0
883 1.251999391723154 2.422107970837778 0
884 2.442854300191025 0.4638642167126922 0
885 2.333287849571655 2.309985559527719 0
886 1.520311499237852 1.632167623876231 0
887 2.28686377043442 1.55693837047647 0
888 2.861386909287301 0.2583761829319965 0
889 2.492649994032669 0.6725355567868199 0
890 0.4836669912663606 2.605428814032742 0
891 1.731409065566251 3.375994296109083 0
892 1.430179904451 2.03566011246042 0
893 0.3625376812634424 1.943669386195892 0
894 1.815884221390636 0.1110139853392071 0
895 2.210069377014788 1.156322960657313 0
896 3.632564245898937 2.017638166258614 0
897 2.023645037512807 3.620298799614746 0
898 0.9643755667184299 3.609756895489434 0
899 3.623456816364824 0.9442749060073328 0
900 2.781052386563794 3.697164938742127 0
901 1.725482549635678 1.531909881908086 0
902 1.929308564541641 1.610731582145474 0
903 0.09625690095230713 1.45281417318208 0
904 0.2961507540286087 1.382587503642281 0
905 3.758613490834497 3.348526144648571 0
906 1.361649245852058 0.8585030616785694 0
907 1.025956634153133 1.172852820151616 0
908 0.5324257500915718 2.954502327030737 0
909 1.658469222644195 3.190625874506797 0
910 2.90394215473874 3.109732544002673 0
911 1.38518177916715 0.2938143941555495 0
912 0.9530731010603338 2.189744931476155 0
913 0.8534576296649545 2.116897086732415 0
914 1.549395298086126 3.431772493570723 0
915 3.684027350482094 3.518966092139768 0
916 1.598518394729727 3.564980193002569 0
917 3.274308702020414 2.536584253964411 0
918 1.394040200022432 0.6448458704554095 0
919 3.320064255145682 2.359118635593549 0
920 3.688488850231116 0.4763666363504088 0
921 3.075282980073826 1.034077142417748 0
922 1.749814993719578 2.541816180184539 0
923 0.8942152350682343 2.973877511796128 0
924 1.421026909826471 1.586566629377054 0
925 2.164225586457491 1.537286253144049 0
926 0.2700792579970001 3.236961419420147 0
927 2.845585526044278 2.472106272720011 0
928 2.940839059486677 2.53834280090648 0
929 0.4744111675078747 3.687641810076897 0
930 2.993871439673206 0.5244900198604231 0
931 0.9946655106304808 1.349442794369693 0
932 1.486663338766761 1.195574730975554 0
933 0.7618181179903611 1.819927526293137 0
934 1.814680108258482 1.896259026086704 0
935 1.450000000000701 0.09994826437245279 0
936 2.083921573066413 2.520385337635493 0
937 2.944557507330732 0.894762872486524 0
938 1.189008091843481 3.707652338840785 0
939 3.707641015086298 1.189038013356865 0
940 0.2538829440750759 1.071065409513193 0
941 2.388621920120174 3.299429057248854 0
942 1.752315448835281 0.2725321441371857 0
943 0.30975531593242 3.550752347441313 0
944 1.313493010899037 1.6965003167187 0
945 0.8129814286503976 1.42504480321467 0
946 2.674837485327688 1.547075614967173 0
947 1.019270275176082 1.688913155957389 0
948 3.65422947835344 3.068942256563681 0
949 1.645453519750736 1.047225614165719 0
950 2.545321320209603 3.490521648338976 0
951 0.9505050684710545 2.723299386671689 0
952 2.283268494086329 2.507009505685398 0
953 1.357834605415454 3.90522353326361 0
954 3.905223533264484 1.35783460541975 0
955 3.928772577666317 2.850881746559526 0
956 2.841624754537061 3.898971536812052 0
957 2.28059891046863 1.960705870023707 0
958 0.9657812101128773 1.554666763548936 0
959 0.252383029343749 2.47881516027599 0
960 1.533314039097612 1.023594615948182 0
961 3.606099214685888 0.2900791051701593 0
962 2.368546455006744 2.715025155773595 0
963 1.452894335659898 1.413837702727838 0
964 2.934569399730218 1.850775731781142 0
965 3.203151795366601 0.7331476188668345 0
966 3.533329765040597 3.535542224937104 0
967 2.722469043608067 1.141472563728236 0
968 2.881586241960677 2.351092102703892 0
969 2.563393871213384 1.045050377983005 0
970 1.469499824571979 1.818988520511509 0
971 2.314983842736284 0.1079901669990615 0
972 0.08510903004957139 3.361455399625136 0
973 0.5697711480944099 2.394259398266858 0
974 1.129736291688676 1.746176255089517 0
975 3.029754761993323 1.925421449936837 0
976 2.124786636376385 2.900794376501304 0
977 1.154860677091226 0.8778871795231226 0
978 0.2497870181383652 2.815132329698426 0
979 2.727471385250262 2.601782805787657 0
980 3.761306466970639 2.764563797546234 0
981 3.139050010232054 1.795658640981932 0
982 2.38699219201927 2.092800089097032 0
983 1.858252418727281 1.809497800263544 0
984 1.89319211733114 0.8771894938150239 0
985 3.31697011623651 3.768847406481017 0
986 1.278351709415022 3.038377505330319 0
987 3.566198582692455 3.330421395538968 0
988 2.501232805514891 1.948406553422133 0
989 1.85033975885031 2.231018901555825 0
990 0.1034128259023925 3.17119111305229 0
991 2.466192233437958 3.096087325553856 0
992 2.773365526307189 0.8103450911869852 0
993 2.875877400224612 0.7954793187903439 0
994 1.990338911617731 2.143018996079962 0
995 1.902831266342659 0.3712211446971615 0
996 1.175851943214275 0.6143354393433885 0
997 2.606545217029559 1.345101104195265 0
998 0.2610627719249783 3.655766689794607 0
999 3.29633599571572 3.565233097380286 0
1000 2.140862693531194 0.1011652932644995 0
1001 3.497621979733631 0.2708124568341287 0
1002 2.877044763419377 1.487816967410871 0
1003 1.403445180607868 2.330994468161879 0
1004 1.194309471251377 2.218563682018832 0
1005 3.298406314595806 1.925119829589195 0
1006 0.2275183669840267 2.282543108944939 0
1007 1.555572960062 1.710648223513001 0
1008 1.124682109862836 2.740430089022239 0
1009 1.54117685893819 3.777195146074747 0
1010 3.780488673529011 1.544336615749449 0
1011 3.195150662807035 2.775436468829788 0
1012 1.227739360865125 3.121846246083751 0
1013 2.08677743410697 2.172015529377247 0
1014 2.718372960254881 2.291304665756615 0
1015 2.691266163240552 2.76677887530607 0
1016 0.8656026582244499 1.543556765013917 0
1017 3.494892094239777 2.515916125824324 0
1018 3.897018542987599 2.008674722630729 0
1019 2.008674722625316 3.897018542989251 0
1020 1.746279094043756 1.362331592052449 0
1021 1.471565302800962 2.905963177818595 0
1022 1.624353452454447 2.063165409051655 0
1023 0.8027115438698081 1.630063784326991 0
1024 2.038046771600237 1.974596243313558 0
1025 2.329421115646014 1.384660456643221 0
1026 3.447649916606791 3.359492989808023 0
1027 0.4364080747228543 3.240546946916339 0
1028 2.077558233370335 0.8250657311417663 0
1029 2.231031325095525 2.622232689913834 0
1030 0.2773068760884788 2.109323048242899 0
1031 3.66419235459948 1.809258624704864 0
1032 3.105830611857628 3.254006472013066 0
1033 0.1045343788933244 1.704944721168399 0
1034 0.8702215284228217 0.6449452071289303 0
1035 0.4110233555023335 2.421616694330118 0
1036 0.8816567455387687 1.949091310212737 0
1037 0.09934980897351564 1.239808362085698 0
1038 3.536839397550419 0.09158045448403219 0
1039 3.60591401086433 2.145217894198668 0
1040 2.146599227774581 3.606822668059356 0
1041 2.085510425381887 0.2743073748293123 0
1042 3.024473272799912 1.566765059850058 0
1043 2.272005739513884 0.2450378034014907 0
1044 3.078653139437407 1.441331809210173 0
1045 2.347652717874299 3.769651408476359 0
1046 3.771820455133793 2.348308910334456 0
1047 3.240711749879908 0.3028866156872594 0
1048 3.088450964522108 0.8406053348275719 0
1049 0.6010647765400493 1.172507637670387 0
1050 1.177755990788947 0.2773403882147153 0
1051 3.187046838161961 1.623740420901475 0
1052 1.432473447394547 2.526888446217809 0
1053 0.2810248421595833 1.177633773915842 0
1054 0.7846320470472846 2.905384822483747 0
1055 0.8039749015606474 2.799828744220085 0
1056 1.242095712220071 0.09936669877119428 0
1057 1.34058843902899 3.626440749922009 0
1058 3.626360327380437 1.340676040312352 0
1059 3.594507060120967 0.6516200853030747 0
1060 2.651937270753142 0.5320369344615893 0
1061 2.260504423988299 3.10614541971578 0
1062 2.169523487108732 3.277618002311698 0
1063 0.3990728035868074 1.335642774990738 0
1064 3.921314502219831 1.158121399109313 0
1065 1.158121399104397 3.921314502220988 0
1066 0.6013394276359404 2.869946542137099 0
1067 0.07468044580069873 3.537016984971752 0
1068 1.257449476570216 2.572688126495934 0
1069 0.0925625821308424 2.343605684219368 0
1070 1.99116461207686 2.837476779440271 0
1071 3.277212867791562 2.165557236658804 0
1072 0.7857344158975909 3.116062370966023 0
1073 3.485235541673517 3.675947080497126 0
1074 2.228219551209595 1.74043196685933 0
1075 2.954100684251611 2.825439751163448 0
1076 0.6466068401197732 3.598946225518107 0
1077 1.755845724859957 2.973673615951766 0
1078 1.41533991751569 3.457143885323363 0
1079 3.473122727160369 1.413304071917961 0
1080 1.119942539979709 2.289090323419615 0
1081 2.473337176638517 3.333073341620888 0
1082 1.393478049933722 0.4834550621479815 0
1083 1.357694673992752 1.519456663538893 0
1084 0.2885025321293806 1.754885178368088 0
1085 2.071441542327643 3.432264134278972 0
1086 3.43123534170815 2.068464792847241 0
1087 0.2404902325887658 1.861124249877755 0
1088 2.168891075092866 0.5277018589755835 0
1089 1.673320053555721 0.868190948290432 0
1090 0.09208579712759402 1.086533272607133 0
1091 1.06081994493778 2.104344757322418 0
1092 0.6164931588983247 0.914330843889867 0
1093 2.447069072873209 2.619130632640894 0
1094 1.077908387397119 0.08455145145779719 0
1095 3.084922677930111 2.100956945217933 0
1096 0.818829636212362 0.9167153812078268 0
1097 2.843569706832968 0.6230559162984454 0
1098 3.119656394891879 1.222360203471832 0
1099 1.353475970904763 3.792639577062045 0
1100 3.792639577062922 1.353475970905268 0
1101 3.602513239270605 2.726543147152898 0
1102 1.576721548996671 2.682933468913105 0
1103 0.7418212907542183 1.05941193741462 0
1104 3.674242970437188 3.751877521057464 0
1105 1.865264391007665 1.045389920290052 0
1106 0.6949314310644084 1.972260056601346 0
1107 0.9699332647794543 0.9702576589916676 0
1108 2.950329004542236 3.27893546677133 0
1109 0.08080641425801555 1.551927768719558 0
1110 1.751556461380648 2.20838832397606 0
1111 1.713668685736537 0.9697388225921083 0
1112 0.6901557268325239 3.052648143016045 0
1113 1.244041607250149 1.445796693073529 0
1114 1.059828432563326 0.7399662823613778 0
1115 2.570596025485836 0.8699624939277535 0
1116 2.464453731587551 0.8833008675596983 0
1117 3.172383162105439 0.09573533268332263 0
1118 3.908954655025066 2.258191455262179 0
1119 2.258191455252923 3.908954655026577 0
1120 1.966689200816214 2.402069786754868 0
1121 0.5946021116490581 1.93652809733105 0
1122 1.918211868194387 0.5689569524674245 0
1123 1.987643491632662 0.8987939921963036 0
1124 3.00084992737334 0.7032624265772194 0
1125 3.448771878913326 2.922840442187118 0
1126 1.926478246548656 2.675193443768483 0
1127 0.08242708684634488 2.762363142040876 0
1128 1.203603777581425 2.029676797137017 0
1129 3.57851709832374 3.229577072263361 0
1130 2.394531593312853 0.7439254256507023 0
1131 3.297633442937608 1.139502608262589 0
1132 3.458140301547003 1.252602809662204 0
1133 2.557530340141275 0.08925731331606081 0
1134 2.935081142021181 0.3247103661606204 0
1135 3.401789779660401 2.292086884128508 0
1136 2.289528809839392 3.400575771018321 0
1137 1.877028046738374 2.554609135276593 0
1138 0.754536291038492 2.430110130073517 0
1139 2.101987272095641 2.272767162907904 0
1140 0.4221138960926875 2.130078913233912 0
1141 2.782509290529533 0.43829522874282 0
1142 2.668095046319152 3.145878772223562 0
1143 0.3310762962861318 2.753861880631531 0
1144 0.08129906244081074 3.054980447196873 0
1145 3.285421210414154 2.745849438369062 0
1146 3.911954146224155 2.652363772641349 0
1147 2.658201317148779 3.908608573721576 0
1148 0.8319457517095624 1.75852418930541 0
1149 2.980508063503861 3.464884765429219 0
1150 3.356221469743186 1.619302867755422 0
1151 2.912487214787764 2.0604503676992 0
1152 3.265772104040442 1.80691926988758 0
1153 0.7612233162971922 3.225007403057486 0
1154 1.662466001717419 2.990875589109379 0
1155 0.4507252106958405 1.819702613452004 0
1156 1.247120832901041 3.460557863480834 0
1157 0.7828725234974913 1.916935804912784 0
1158 0.09115728694088836 2.164777592710826 0
1159 1.237577500558641 0.5272241904871061 0
1160 3.483619298168946 3.172429089991688 0
1161 1.153151262280964 2.397237123342282 0
1162 2.628199427058487 0.9557048983258198 0
1163 3.06925517230353 0.3489105577836617 0
1164 3.916320760687348 1.8500149720897 0
1165 1.850014972086892 3.916320760683442 0
1166 1.914789124861006 3.128219864692634 0
1167 2.197415705729726 1.900183434929278 0
1168 2.184950693355679 1.274126136519223 0
1169 2.681473507551453 3.784938102310941 0
1170 3.008840549586146 2.02939286734042 0
1171 3.436582039500598 3.477424248532378 0
1172 1.58174322524097 0.7971277059569275 0
1173 3.168945485068594 3.42523555594649 0
1174 3.276666040081038 3.407890941817394 0
1175 1.969887554122038 0.2297661090609846 0
1176 2.740070656183196 1.450678024105727 0
1177 3.08225022657696 3.011790757587991 0
1178 2.379432612649845 1.633120991762465 0
1179 2.733527406616587 2.017128316582169 0
1180 0.6556029635844207 1.339013034052397 0
1181 3.782378788435553 0.08633378997066479 0
1182 1.646474298291315 0.09748701796244216 0
1183 1.64510550825189 0.2134757538219485 0
1184 2.92209016387187 1.381323783425803 0
1185 0.4782663252806323 1.484323703560381 0
1186 0.6466509383058181 3.229503504730803 0
1187 2.570707108035035 2.018720223133697 0
1188 1.837407701096341 3.635822404776135 0
1189 1.105228282764001 3.249047784955501 0
1190 1.518809888143107 2.345138092988467 0
1191 0.2278658381163489 3.491241302948644 0
1192 1.92647972679042 3.32636395452477 0
1193 2.479908193924937 1.570383544309506 0
1194 0.5053537096432252 2.75884244943965 0
1195 1.626120339047855 0.6958817802643865 0
1196 3.729625828673493 2.262788798125887 0
1197 2.262494044785682 3.729027998791074 0
1198 1.126683299977364 3.136693505818045 0
1199 2.334749139809292 0.5826792827320457 0
1200 2.035727971729293 0.07865641150191914 0
1201 2.889945146781856 3.626534996120655 0
1202 0.6244620066415507 2.212271922853943 0
1203 2.858717233922135 2.679326222977423 0
1204 2.866590319227921 2.775781600589863 0
1205 0.7660234449963224 2.633238908984713 0
1206 0.7308744350948413 3.910321880832448 0
1207 3.910321880832041 0.7308744350964493 0
1208 3.025931420167944 2.491562106000043 0
1209 2.783836593137453 2.830962180448997 0
1210 3.33911126669199 2.459591461110494 0
1211 2.964124933895896 2.216118971578599 0
1212 3.441835153929273 1.882996766182525 0
1213 2.603625316955282 2.126587278927227 0
1214 1.675821110984599 2.263256510195811 0
1215 3.300120480264932 0.5644414376312586 0
1216 0.8569080808270375 3.45238747364461 0
1217 3.643359387617963 2.443486709882816 0
1218 1.909366778059646 0.7191783457934222 0
1219 1.384614080401136 3.173268264267227 0
1220 0.08454412275974696 3.783616967848025 0
1221 2.740477464686988 3.518236585058067 0
1222 3.137913970980108 1.126137236977026 0
1223 2.660345515254121 0.2220916747658663 0
1224 3.469275884004443 0.9192117069892577 0
1225 2.596581998914311 3.735959065309755 0
1226 0.9698367340475949 3.525253762401756 0
1227 3.018727447160177 3.634075276301401 0
1228 3.275497103598998 1.247037265211849 0
1229 1.640220693450802 1.352339285572863 0
1230 3.197090835834127 1.976212001153905 0
1231 2.885293621618437 2.151592713123629 0
1232 1.536456812644633 3.066058817362204 0
1233 1.833428693892511 3.293877528821626 0
1234 2.133379504228494 2.692734766875708 0
1235 1.247330763399449 0.2182179142142165 0
1236 2.001986152147496 0.4179480084393306 0
1237 2.897125706247477 0.4456397162903215 0
1238 0.431659223814854 1.160186052061649 0
1239 1.452771857063831 0.7888860533770339 0
1240 0.2140725817719659 1.247686677202292 0
1241 0.2611984624263327 3.147643546120191 0
1242 3.765729393686691 3.564011997817779 0
1243 1.017327979068555 0.356466142682185 0
1244 0.9561434510466229 1.848284751265182 0
1245 3.207987526479966 3.605180540019387 0
1246 0.6058065961370057 3.130409211899351 0
1247 2.73656046500855 0.3520983305768869 0
1248 3.305526515534871 0.213439151309317 0
1249 3.914323246811438 3.270482384063765 0
1250 3.261636332666994 3.925533799292932 0
1251 3.466931333745001 2.620362139047978 0
1252 0.2043976041515167 2.189035704485017 0
1253 2.612933359900929 3.62409757580517 0
1254 1.161643329229339 1.320183995311647 0
1255 0.2156560742591181 3.010111862368921 0
1256 0.6842945926096636 3.40540540251723 0
1257 0.8717441127526067 2.518678130365066 0
1258 3.166147747210029 1.385820843656495 0
1259 3.413767477463009 0.692566201719326 0
1260 1.31007301408043 0.9409410024087155 0
1261 1.306240076799924 2.340337978037568 0
1262 2.374555481474864 1.306620432101412 0
1263 2.706458399269103 2.1126288815589 0
1264 2.883038529313471 0.9699424416636944 0
1265 3.263921674674652 2.943221292893352 0
1266 0.3461862704046446 3.914172845616784 0
1267 3.914172845616985 0.3461862704058466 0
1268 0.3560521229395531 1.019663260808509 0
1269 0.08594631355573851 1.801705234004476 0
1270 1.833053530378198 2.375983350004326 0
1271 1.966274339733091 1.06537335219924 0
1272 0.5519338062352535 1.554170755754769 0
1273 1.684634730157585 2.362603947594776 0
1274 2.919204027082925 2.942467153407841 0
1275 2.986579939597811 2.350618017704059 0
1276 3.674404790984364 0.2256004304739446 0
1277 0.3746278420889281 2.603019326865542 0
1278 0.7689747603857149 3.75614964210616 0
1279 3.756228097930029 0.7687417566081018 0
1280 1.972776457237245 2.488729107266807 0
1281 3.437886422016437 2.745281325879549 0
1282 1.284048859245684 1.864804326103405 0
1283 1.232201787918872 1.190212673785638 0
1284 3.022201396706091 2.668885707047994 0
1285 0.2307213238014169 1.570356721775672 0
1286 1.902284672924405 2.959641283713836 0
1287 1.962861238022061 3.031251979622744 0
1288 2.711025460314807 3.604088895957291 0
1289 2.023632228793357 2.331344917155797 0
1290 2.418554103299741 0.3204761297302348 0
1291 0.4297879115008413 2.891468893506734 0
1292 3.654224465369008 3.918974330110306 0
1293 3.921168428892883 3.653265294913739 0
1294 0.6676514444539098 2.580938340355224 0
1295 2.471658970337032 3.439697404083247 0
1296 1.48652627849133 0.4721900354441777 0
1297 1.21265332506194 2.729761442650065 0
1298 2.907429782839316 0.7089068743477884 0
1299 2.591147709841081 2.512309504157192 0
1300 3.032325844967398 1.253320177871915 0
1301 1.337536207088546 0.3715874103152346 0
1302 2.580718719424351 0.383739618820578 0
1303 1.753216416717566 2.683186142797756 0
1304 3.793367264079075 2.666919191758346 0
1305 1.961605076068356 3.543078178520171 0
1306 3.573406580782776 1.955238000361051 0
1307 0.9535085156583787 2.885539458672141 0
1308 2.776749722503586 0.08770568947082474 0
1309 2.581968949391908 0.7014397321077399 0
1310 1.030675753160931 3.777222648646885 0
1311 3.777222648646153 1.030675753160303 0
1312 0.224509451164491 1.676415241326316 0
1313 3.308906767871159 1.404366210421792 0
1314 3.063209490380366 2.18796973967264 0
1315 0.07688806704362161 2.549848261072341 0
1316 0.7160468446726665 1.620173391161437 0
1317 1.244604263089294 3.299670267579508 0
1318 1.282218080508496 3.20205554996535 0
1319 2.162646677477031 0.9785370897769188 0
1320 2.103691407068428 3.102438604228709 0
1321 1.109567783788373 3.405079690921869 0
1322 3.397203731895424 1.122586626973827 0
1323 2.490136287462755 1.750209135176757 0
1324 1.007547393887269 2.452174555781474 0
1325 3.92409541523975 1.650136205911612 0
1326 1.648635854230627 3.924950144441977 0
1327 0.8540366003907645 3.061133611661512 0
1328 1.952528030848272 3.756376206815338 0
1329 3.75717086641937 1.9514245878184 0
1330 1.908664137751151 2.859915143913129 0
1331 2.159484851293796 0.2115647779546885 0
1332 2.430090939733314 2.78449635464748 0
1333 1.560826976498233 0.2256300273744693 0
1334 1.756752448093598 0.8105477452380316 0
1335 2.353104222912683 1.875531766753743 0
1336 1.799722987927939 0.9830255514891411 0
1337 1.004604196856948 2.287427924717941 0
1338 0.07388362555705599 1.349999999998271 0
1339 1.193187353446031 2.913417108443222 0
1340 2.403386298869316 1.129998628781795 0
1341 2.872298353953179 3.322330453278112 0
1342 2.558173074708319 2.906903345030988 0
1343 0.213813923151651 2.020146921767641 0
1344 0.519375045230718 3.3107801126131 0
1345 1.350000000000545 0.07335987139041956 0
1346 3.220456399816774 2.24189921094362 0
1347 0.09137463608672891 2.902089233933194 0
1348 2.25262939593144 1.049709108723617 0
1349 3.919857902786406 3.428048221276673 0
1350 3.428436345919514 3.921527645317839 0
1351 3.547010370783487 3.048152245503007 0
1352 1.600925374724594 2.418656897639106 0
1353 1.371681505738017 0.5674430628372547 0
1354 1.109586526664594 3.642395356775562 0
1355 3.642749732055484 1.110179848627187 0
1356 3.926161115665893 1.454210611666511 0
1357 1.454237054122119 3.926078970258555 0
1358 1.557905405087 2.265988717425664 0
1359 3.760151322335828 3.242120103204345 0
1360 0.5761247733432595 3.918101084382457 0
1361 3.91807979050323 0.576119052058101 0
1362 2.552230975284258 2.663247723369262 0
1363 2.77078267430545 2.526283056330962 0
1364 1.501622443919131 3.617902443378877 0
1365 3.627926687473216 1.510081008297285 0
1366 0.8027235718766679 3.597701302768454 0
1367 1.980422797284833 3.192181857651246 0
1368 3.535734660802081 0.9862857386546288 0
1369 3.920095467894916 3.029967211807963 0
1370 3.033295202026547 3.921604600887147 0
1371 3.402107738545476 3.274644085127238 0
1372 3.603776913966021 3.491441099789381 0
1373 1.075412361074497 0.8340642582716008 0
1374 2.106502948843397 0.3639044600725054 0
1375 0.3460333569809211 2.93184374025069 0
1376 0.6289347898978475 2.114944727475828 0
1377 1.931813903982209 2.214302727625225 0
1378 1.624984236440902 0.529163661094309 0
1379 2.404629945367361 2.874705809803714 0
1380 0.6584009383306146 1.536307434628561 0
1381 0.7148425870436977 2.061532681396182 0
1382 3.786228627702059 3.156733027050562 0
1383 2.550084908735623 1.672361688216388 0
1384 3.386533797548727 0.4027395809616048 0
1385 0.3868425962836078 1.58975745774686 0
1386 1.526747214173147 3.312314463662523 0
1387 1.772431256104482 0.4592009418841464 0
1388 3.779770855601251 0.4489975515966834 0
1389 2.649496767421509 1.964804682828844 0
1390 1.369441627862461 2.913772653338854 0
1391 3.779177343132642 2.96005374624349 0
1392 2.96099792474477 3.778437891945146 0
1393 2.730854274685718 1.227690258334825 0
1394 0.4470537260334009 3.776354983819607 0
1395 0.07273179897764091 3.252475560974007 0
1396 3.608821438752493 0.805115929491394 0
1397 3.305474942602659 0.4569901519917022 0
1398 3.233482122099705 0.4066810918918684 0
1399 2.569062608666159 3.925043759103473 0
1400 3.926185129972065 2.566876140307568 0
1401 2.905341079675171 0.5442043544867046 0
1402 2.504863176337455 1.385215289640758 0
1403 2.518930886438244 1.841544404363716 0
1404 2.481664404969563 2.512145192967345 0
1405 1.081221925378859 2.823238676488214 0
1406 3.112450095559005 2.49589298523394 0
1407 0.8631462674005352 3.790932797630012 0
1408 3.790966154698314 0.8630472011681241 0
1409 3.117684836669404 1.900364000970852 0
1410 1.737343236738075 0.0746419427008001 0
1411 3.186783307730926 1.285765336928779 0
1412 2.73793529784501 0.5163605075696384 0
1413 2.893736515129174 1.222745906284177 0
1414 1.109534668774564 0.4486495148563678 0
1415 2.808499218891896 2.300123973210968 0
1416 3.422582527851509 2.46452337660978 0
1417 3.141057452711026 3.528278152339401 0
1418 0.8755241045973496 2.77774959478657 0
1419 3.010590150192278 1.356789210049824 0
1420 1.346915447238004 2.089225447242709 0
1421 2.291775952394095 2.907342860134434 0
1422 2.768419277085044 1.629573497284564 0
1423 2.933520280148406 2.632773370663765 0
1424 1.702010612961118 3.553285600933104 0
1425 0.2458726959227379 3.325384319242053 0
1426 2.625441161232382 3.444777899381434 0
1427 0.9515310686865587 3.180009553608588 0
1428 0.5359775128185545 1.63529118591443 0
1429 3.248297836020324 0.0768910029399619 0
1430 3.275000931355966 1.65448282064538 0
1431 1.250872868742469 1.364496608065638 0
1432 2.181218134184681 3.073776139918899 0
1433 2.795338598561189 3.074558077864832 0
1434 3.024660344371399 2.760648255632374 0
1435 3.522470851210821 2.163943959799009 0
1436 2.164084912203593 3.522563571329973 0
1437 0.8975454562686469 0.7972156308861686 0
1438 3.792262900455316 1.714539810265887 0
1439 1.089789848819307 2.470532770057698 0
1440 1.410378465045481 3.563838041678227 0
1441 3.575116380599882 1.416821516511324 0
1442 0.5956958474449926 1.686428693754326 0
1443 1.018298131080795 2.014778217515027 0
1444 1.765505634731516 2.857209015262239 0
1445 3.297147960348496 2.611264170160647 0
1446 3.791582306795019 2.513309498580107 0
1447 3.626762252458767 2.907069897642707 0
1448 3.70690476593878 2.866240968890544 0
1449 2.707836475922011 2.43058490393176 0
1450 1.723481092710421 3.805614905735883 0
1451 3.35297721632837 3.045560779507764 0
1452 2.595735191287261 3.195903619935909 0
1453 1.291336487001836 2.498708489059314 0
1454 1.241396169115422 3.787872101058637 0
1455 3.787870213765241 1.241401156035003 0
1456 1.843516012587896 2.718538203050118 0
1457 3.357027874836703 3.613916371600203 0
1458 0.8243848429639036 3.925983113040428 0
1459 3.925983113040283 0.8243848429661773 0
1460 1.156734036188881 0.712464876857012 0
1461 1.50925233004349 0.6403937613877793 0
1462 1.893497934959851 3.465858111323357 0
1463 3.185728196587829 0.9582301074493139 0
1464 2.271254036153399 2.789252450480671 0
1465 3.124543734799922 1.698805924984099 0
1466 0.5037735027742616 3.154314091716758 0
1467 3.543044554731786 0.3424663970960335 0
1468 2.346390148564679 0.997024418221286 0
1469 2.448951272112661 3.629902530732702 0
1470 2.771866726193921 3.7871087192322 0
1471 1.187506548776575 1.844659743425163 0
1472 2.901729369511871 1.053685823382423 0
1473 0.6470251200078561 1.012687675908316 0
1474 2.008398449770677 1.593325027946569 0
1475 2.877851170140376 3.712619982028833 0
1476 2.617464156954275 1.818829097574532 0
1477 3.493867688913353 2.411244933923627 0
1478 2.404264444525385 3.488798131953357 0
1479 2.237242969600634 3.216132068839943 0
1480 3.216674429028267 3.09392946595012 0
1481 0.8817721532941925 2.037051395773251 0
1482 2.172963705462534 2.793638430715379 0
1483 3.695475607985863 2.075116459341303 0
1484 2.076347826812788 3.693582809804408 0
1485 3.349211483876483 1.538520084104824 0
1486 0.3605637886608622 1.196828740768292 0
1487 0.1934032441306264 3.185911915763111 0
1488 2.634344573496625 0.07690776750431214 0
1489 1.69746268120616 1.292773281997244 0
1490 3.512821678191148 1.720014821533889 0
1491 3.564999856002894 1.798776192632164 0
1492 3.705491296661077 0.5798238038899115 0
1493 2.237767387339757 0.07499702082273756 0
1494 3.383414669001509 1.937964532971431 0
1495 2.011112693260864 0.9904058804192974 0
1496 3.817829389478703 0.3048987306324406 0
1497 0.3064867204931145 3.817148834148147 0
1498 1.809932519881355 0.2013791920168878 0
1499 3.338572618076361 2.880339044924916 0
1500 2.338622357845699 1.468032896710853 0
1501 2.519742920885073 3.784750370010252 0
1502 1.095930203652389 2.567441266725316 0
1503 0.5798865438154527 3.705745710777608 0
1504 3.820831962761451 3.70443453251426 0
1505 0.211657084819924 1.377030499802256 0
1506 0.3102949324089604 2.423466779488452 0
1507 0.3979939937249383 3.384572636542435 0
1508 2.767690661766431 0.180846496167357 0
1509 3.154016757808556 0.5212680610521717 0
1510 1.373129880446546 0.2131727295745916 0
1511 2.305528306186888 1.154454795135944 0
1512 1.53462919729573 0.07915094627664035 0
1513 1.089061481203419 1.38364987183263 0
1514 3.009473184710042 3.37101897469519 0
1515 1.65308252702281 3.638104329819924 0
1516 1.058931699017278 0.1707697891940034 0
1517 3.027468514667211 3.120498780733223 0
1518 0.08114717836456288 2.082335513952625 0
1519 0.1780132322835161 2.909358561547906 0
1520 1.840104793693312 1.349275249902897 0
1521 2.626055893739618 3.304795051398253 0
1522 2.734574899173276 0.6696110497025697 0
1523 0.4869906166781569 0.9546663337437576 0
1524 3.631689159600597 1.654265090462065 0
1525 2.405336381496067 1.727941380111727 0
1526 1.574342975519504 2.508074089706039 0
1527 1.016293018065306 0.6472361642550417 0
1528 3.14432128767408 3.801885616943228 0
1529 0.9838064829621977 2.606750937295563 0
1530 0.9122781650021874 0.5522441816350339 0
1531 2.382665608558369 0.4133508676834647 0
1532 0.1930760425188846 2.627513372538476 0
1533 2.513766632588333 0.554429320476998 0
1534 3.917640559109127 0.975069666382948 0
1535 0.975069666380191 3.917640559109627 0
1536 1.51465944869893 0.387140320517488 0
1537 3.463491684610928 0.5479820028308983 0
1538 1.127206115014697 0.9783021589768777 0
1539 0.4256616284103879 2.532642023828573 0
1540 0.4877508091893218 3.019446338607671 0
1541 2.286708134745548 2.689365272265592 0
1542 0.4387068433749763 1.984823937442526 0
1543 3.033361643261467 0.07659002877041404 0
1544 3.535253598768508 3.80715511320116 0
1545 1.199337818996968 0.3558141375800665 0
1546 0.3985442984391803 2.303713851687339 0
1547 2.550718605632539 1.199996967889554 0
1548 2.61968384162807 2.293669301680853 0
1549 0.3933078451514718 1.511068422277235 0
1550 2.86333569537713 1.318897812196858 0
1551 3.921056801413622 2.160580067508899 0
1552 2.160580067500212 3.921056801415517 0
1553 0.5799473080058455 1.376195161478029 0
1554 2.53242520571084 3.581829116779529 0
1555 2.939580338368828 3.188616496797094 0
1556 1.500544496319288 3.700449919571734 0
1557 3.70791467408149 1.507004489365714 0
1558 3.098161908830629 3.699161944708717 0
1559 2.399579294777938 0.08647544330900057 0
1560 0.3025031970778838 1.994875431004501 0
1561 1.936567880907724 3.931488387348617 0
1562 3.931488387348989 1.936567880915014 0
1563 1.512912541870833 0.9334500448897669 0
1564 2.872980333305913 1.762335375134944 0
1565 3.2034326011366 1.534601864448208 0
1566 2.62836593541201 2.585678396105715 0
1567 2.726264646752731 2.685591441915982 0
1568 3.03522021594315 3.289309441072216 0
1569 2.674988387001798 2.93382844230436 0
1570 1.249419580179273 3.92508696418534 0
1571 3.92508696418519 1.249419580185043 0
1572 2.360636175056073 2.4086883383331 0
1573 2.243210738670611 2.292758922650514 0
1574 2.85293327119491 1.600088154462411 0
1575 2.103227546846695 3.777791673872853 0
1576 3.77787379235478 2.103174124336824 0
1577 0.5158560780114216 1.213408805422945 0
1578 1.784104194381761 3.695509209259262 0
1579 1.842787218204757 0.4426071718090514 0
1580 2.410770553622533 0.6504527151812812 0
1581 3.2602348583183 1.029130899914418 0
1582 3.835149015389113 1.84309710628299 0
1583 1.836711046322432 3.833528856526566 0
1584 1.069499675129467 0.5826224001914875 0
1585 2.546941730970722 3.04203877845758 0
1586 2.621946288694431 3.064153491169334 0
1587 1.803310133885346 0.6988206754710271 0
1588 3.547022065221374 0.5683731147531744 0
1589 0.1662389710741322 1.057134889182891 0
1590 2.2331647986416 3.545833316089593 0
1591 3.545436090817217 2.232784950440861 0
1592 0.7859293416031172 2.180602954625746 0
1593 2.40283159900753 0.8342615223970899 0
1594 2.001348815250117 2.760545736486642 0
1595 2.849264154959757 3.39202589740979 0
1596 0.5492149132084119 3.462681632043354 0
1597 1.047710451515371 1.009299923050727 0
1598 0.07285196059977567 1.630716391397405 0
1599 3.921795325957766 0.07820467404261429 0
1600 0.07820467404236921 3.921795325957534 0
1601 0.6490285560993361 2.761491171201237 0
1602 2.249038364683301 0.5076370463145191 0
1603 2.740125474512703 1.713134091727404 0
1604 1.69630222430263 1.606948008552048 0
1605 3.331452454499371 0.9859918078992596 0
1606 0.6992818248147659 1.156256477142512 0
1607 0.08503369573057429 3.629840600296656 0
1608 1.371551444487735 3.066516609692536 0
1609 1.75517401715549 1.171872148351953 0
1610 3.033961878640952 0.6230542006381314 0
1611 2.851176453299891 0.06435676271017807 0
1612 1.601682740085412 3.256014413617784 0
1613 2.825004396123989 2.926050813040661 0
1614 1.441323320838073 2.415572304983854 0
1615 3.305708110793783 2.082832606077341 0
1616 3.401584416632043 0.834261656009047 0
1617 3.372666474202253 0.7590538322758109 0
1618 3.145105087740993 0.6549656459849222 0
1619 2.250858640384251 0.8670703422317603 0
1620 0.5640705119937182 3.54880079873207 0
1621 2.289260063119284 0.4133939233592683 0
1622 1.765258608097766 0.5955238291359123 0
1623 1.843562585357576 0.3059279997218909 0
1624 1.382708753566534 3.345319644893516 0
1625 3.628737102491837 0.0751885767606759 0
1626 0.7194210872688263 3.823696346468543 0
1627 3.823712037633013 0.7193744865134595 0
1628 2.450196547041083 2.421764043038347 0
1629 0.1706629362184031 3.389359989818877 0
1630 1.668315534643555 0.6149533510656847 0
1631 3.266235561952376 3.250471575793743 0
1632 0.7977579398798851 0.7094224221732186 0
1633 0.5335984927238667 2.676620923195333 0
1634 1.72045383880377 0.3462743399472646 0
1635 3.046848585427254 3.542155661284124 0
1636 1.268034135521514 3.587166796051303 0
1637 3.586966731831404 1.268375166814833 0
1638 2.054863394720445 2.612913813682829 0
1639 0.07190547229929611 1.946365104510955 0
1640 2.077147847761444 3.300090033023181 0
1641 3.137901446637067 0.198716238175238 0
1642 1.72993663211541 3.146512318211003 0
1643 2.629161254854967 2.437642456027922 0
1644 1.685416835137881 2.820019777272922 0
1645 1.030670182821473 2.879030129440717 0
1646 1.565047154037695 1.214827329748953 0
1647 1.485079026397039 2.81782139064771 0
1648 0.448662833262732 1.655754415101437 0
1649 1.315162434699539 0.6824437918301682 0
1650 2.340067777811115 1.78879190403168 0
1651 0.7563022868700154 3.369264147866726 0
1652 0.821127120566764 3.388058292202803 0
1653 1.039602630954641 1.873179397764949 0
1654 2.410529189251455 3.008991049347703 0
1655 2.180908606651674 1.825465911275828 0
1656 2.317749292062836 3.011773255453999 0
1657 1.400042286679188 1.191492107310143 0
1658 3.691698906503997 3.834414666912356 0
1659 1.997551581536458 3.271948144436307 0
1660 1.574429181083249 1.30206050403716 0
1661 3.093119770712749 2.335238651437906 0
1662 2.520701305026 3.176105097245248 0
1663 1.787402135170563 3.561614113356335 0
1664 3.757100130196142 1.631314737089756 0
1665 3.216209302823797 1.113181618941043 0
1666 1.023487204623406 3.259878346905865 0
1667 0.9878493314498911 3.333269912059358 0
1668 3.388799567168821 0.1697277564410672 0
1669 1.487567716844431 3.006749654491312 0
1670 2.094106759069041 0.5262239526548697 0
1671 2.76762507902555 2.984015453776603 0
1672 1.390157955468772 1.350502303355869 0
1673 1.923797264973822 1.755120682918565 0
1674 0.4843800434853062 3.583978381869352 0
1675 0.331028193858473 3.629345691906146 0
1676 2.444513393753088 2.156997559559867 0
1677 1.594600612300423 0.3729280598690756 0
1678 0.5705352024347654 1.072724207901937 0
1679 1.10990164789612 1.655915976922772 0
1680 2.359641728703672 2.020635310082927 0
1681 3.590714961357378 0.4814904314866549 0
1682 2.170351138149433 0.6556054647449613 0
1683 2.542303227879652 0.2959345595417892 0
1684 1.045151395127584 2.750063809401564 0
1685 3.478563091701318 0.8407185367120245 0
1686 3.915950316137869 3.919373066243998 0
1687 1.312787768283595 1.233945975010091 0
1688 0.8397436784653579 2.439622556112611 0
1689 3.675740403001883 2.76191375010443 0
1690 0.7907737731648754 3.512598391937689 0
1691 1.044742767854818 1.095338617202359 0
1692 2.616415845151206 0.7865216907109682 0
1693 1.816359213115695 2.483605792750195 0
1694 3.390690502831009 0.07832696781338135 0
1695 1.80842504853068 3.076048018715101 0
1696 2.026379764271384 1.20068349224694 0
1697 0.5208680593354493 2.23388816728771 0
1698 2.019942485496749 3.813908004690644 0
1699 3.814054134370665 2.019749674575577 0
1700 3.155330853111689 2.389369791167539 0
1701 1.669893076908029 3.303717278381569 0
1702 2.284801421822533 1.648672814738806 0
1703 1.649951951945478 3.390580023356752 0
1704 1.540576572429604 0.5440473515652235 0
1705 0.8670749794636721 2.304326230664048 0
1706 2.398247504602684 3.150782443540419 0
1707 2.187626714365218 2.938616031657315 0
1708 2.750856928724336 3.22588232688984 0
1709 3.930808278479989 2.753029723036676 0
1710 2.749999999996711 3.939441555029031 0
1711 3.39427146356916 3.787183501044861 0
1712 1.83793760438455 2.991589974403855 0
1713 2.018474533304848 0.7373416334093416 0
1714 0.1636988582825096 2.754103626166418 0
1715 3.277043154597676 2.006878194828341 0
1716 2.7055130639135 2.856661805998629 0
1717 1.152977178821985 3.314556854679617 0
1718 3.33102992892511 0.2907833296862493 0
1719 0.5698481003270679 2.547201612015426 0
1720 3.536611960618634 2.773023756901179 0
1721 2.978507292523893 1.668194880535637 0
1722 3.04698314606619 1.732932939902703 0
1723 2.1447961701169 0.8966034390154003 0
1724 0.9534422452793885 2.522158784734832 0
1725 3.927084965432026 0.1752138422146596 0
1726 0.1752138422148087 3.927084965432018 0
1727 0.15531765772371 1.530113404745506 0
1728 2.187902320307708 2.553390038664684 0
1729 1.993670838667006 1.908447391026302 0
1730 2.751737794838935 1.062311057357088 0
1731 2.692464307589433 3.460317283698191 0
1732 1.388841997013786 2.635989083588724 0
1733 3.842698337096554 3.039547893593202 0
1734 3.045898450296706 3.843707880947346 0
1735 2.641842214819702 1.721140056992857 0
1736 0.318521480116917 1.456697277663459 0
1737 2.043413638899863 1.769691099544738 0
1738 2.421658521502244 1.457410795175903 0
1739 1.403887170247588 2.220204154617262 0
1740 3.279613467141828 3.021947080213043 0
1741 2.772129964009466 1.869209280336265 0
1742 0.6507368290597413 2.314191981637996 0
1743 3.154581045315235 2.079432734448843 0
1744 0.4371762643485649 3.321960101037993 0
1745 2.943639799716814 3.927723840830931 0
1746 3.93109192510033 2.944345633267523 0
1747 1.260518906022437 0.3876245882218242 0
1748 0.8944367477884232 2.37568864486709 0
1749 3.010734789048939 0.2972674487791944 0
1750 0.05918172210318954 2.249999999995701 0
1751 3.41192285162805 3.20083559186132 0
1752 3.926954069827535 1.07434636398664 0
1753 1.074346363982041 3.926954069829558 0
1754 1.338189130842829 2.18427455814803 0
1755 1.449394535008416 0.7101594305166858 0
1756 1.132778607161709 1.481314271869598 0
1757 0.6022024634385283 3.296419999844445 0
1758 0.5386994888341013 0.9142916395511537 0
1759 3.4858039582712 3.096277310757406 0
1760 2.423401575275495 3.926360211650424 0
1761 3.926360211651667 2.42340157528157 0
1762 1.624789905653667 2.910891915361458 0
1763 3.829169271176686 3.285119676864506 0
1764 0.445706865679362 3.455710319422503 0
1765 0.9565496174353711 0.4851734628558195 0
1766 1.513407720624633 0.1535027745084896 0
1767 3.45683030343619 0.4535028256467518 0
1768 2.372239928080051 3.585944470343345 0
1769 3.58568761215556 2.375650129433714 0
1770 0.8400903804032871 2.599784847060658 0
1771 2.711274918523224 0.7622352220547022 0
1772 1.38284770214469 1.663790962972037 0
1773 2.652621142011181 0.6371102682715464 0
1774 3.011812114139846 0.94503114772689 0
1775 3.377615354949829 2.215338590726915 0
1776 2.215360078500892 3.377532805560918 0
1777 1.924001974570742 0.2935792660670965 0
1778 1.83983405177116 2.813109584907248 0
1779 2.91707607135434 0.1749901145971723 0
1780 1.282981643047213 1.511611748427584 0
1781 0.8400364363633486 0.8473016540225382 0
1782 2.868129853035919 3.551788962550393 0
1783 2.580480571456754 2.367502964600047 0
1784 1.57801474209264 0.8820459807217358 0
1785 3.851786957736469 0.06024671532690562 0
1786 1.840172450598385 1.509334778533977 0
1787 0.4231302849452846 2.796068591659802 0
1788 1.075287362354987 3.487957716777127 0
1789 3.487957716777825 1.075287362354746 0
1790 0.4265373765622615 3.927989036419776 0
1791 3.927989036420225 0.4265373765635883 0
1792 3.108520404020107 1.618726680723053 0
1793 2.864456772639764 1.89846370979422 0
1794 1.433473467828511 1.881024137359981 0
1795 1.215313428403883 0.7878267999464319 0
1796 1.315503310988161 2.8578383731312 0
1797 3.64365175184407 3.680680221740969 0
1798 1.251587018617978 2.859187397677869 0
1799 0.7110345632234438 3.48023696096563 0
1800 0.3818892075009742 3.051259386978072 0
1801 0.8719982909337856 3.262937739230212 0
1802 3.528575150669091 1.216532425834081 0
1803 2.981293107618266 1.096753740016595 0
1804 3.92115789817037 3.839944231674591 0
1805 3.824952122655881 3.92861119877013 0
1806 2.38784144101852 2.553079170655921 0
1807 2.111542436608227 1.10506220891593 0
1808 3.156730470873551 2.85573815281828 0
1809 0.9507662097101337 1.146001652850278 0
1810 3.189868095938071 2.919753111665733 0
1811 3.5732025254452 2.655513264789012 0
1812 1.484475420742904 2.135447255287907 0
1813 0.5608332833751802 2.07765600880628 0
1814 2.484305785755531 2.257284799954194 0
1815 1.101659093384359 2.996521966495303 0
1816 0.05942723887245367 3.852325862238582 0
1817 2.970135245437476 1.191379562982688 0
1818 3.41858070916894 2.841037401451229 0
1819 2.242492669251302 0.7903856556996407 0
1820 1.372739892406041 3.713451120270962 0
1821 3.713442913889956 1.372748831312925 0
1822 3.399709845783072 1.757666498812902 0
1823 0.06761470107827222 1.161052791683583 0
1824 3.942836372091612 3.34999999999896 0
1825 3.34999999999828 3.942836372091731 0
1826 3.93940462621578 0.6506456964791505 0
1827 0.6506465138030419 3.939407668198732 0
1828 0.6227779381202061 2.67756567309226 0
1829 3.492386132811168 0.1872403389373486 0
1830 1.00665856075202 2.146883054188463 0
1831 2.06571445978013 0.6635038159747838 0
1832 1.462587361042387 3.180658876676409 0
1833 1.935185537676068 3.40184927687686 0
1834 1.963513376442017 1.431591815680277 0
1835 0.3145655793221229 2.667674168932582 0
1836 1.447838597049103 0.8874372781506024 0
1837 3.010501662462103 0.1613350385074078 0
1838 1.452698405452025 0.3172390205964036 0
1839 0.4902584739435909 2.4126072183959 0
1840 2.240385355742757 2.120951450339613 0
1841 1.182010252067503 1.046014854190112 0
1842 2.38832383430959 0.5151475617953724 0
1843 2.900785743625371 1.681315153910873 0
1844 0.06549073128021538 2.835998428158677 0
1845 3.285163258684287 1.492616624186429 0
1846 3.123793533760205 2.613066710791086 0
1847 1.369747501394001 1.089005819833358 0
1848 1.212395165092393 3.859845919670318 0
1849 3.859845542211085 1.212396162478916 0
1850 0.6704076469148359 0.846553051790109 0
1851 1.127579303169778 2.193136226562103 0
1852 0.908419411449555 1.072587265660212 0
1853 0.3517861791152756 2.139883385194454 0
1854 3.928852794371104 3.174923713152989 0
1855 3.180618258319582 3.926879980319243 0
1856 1.216619544987623 3.532131305315618 0
1857 1.245768247773941 3.65822034123329 0
1858 3.658199371673176 1.245807386930855 0
1859 0.4190840690671366 1.889919402714701 0
1860 1.716111568706814 1.738382763804493 0
1861 1.297160001275288 1.941702736266353 0
1862 1.159430665125227 0.06600751598504201 0
1863 0.9827649935742109 3.69401696179216 0
1864 3.696378737761873 0.9791818796779271 0
1865 3.092795284645546 3.175475857140414 0
1866 0.9441371989665406 2.004623996457374 0
1867 2.436142560055393 1.898491487893735 0
1868 0.5053495198470491 1.303501791347699 0
1869 2.941436260430511 1.537650997854886 0
1870 2.506559411736796 2.784832682730146 0
1871 2.939621987433074 2.287478802142258 0
1872 2.554294391970862 2.828509223616166 0
1873 3.814078228875514 2.180007292825552 0
1874 2.179994728740068 3.814042829654241 0
1875 1.134104148294062 3.551559494143402 0
1876 3.550059895793676 1.13643973917625 0
1877 2.132454391551841 2.419552324161948 0
1878 3.373118773842153 3.406115787104623 0
1879 3.687690738049174 3.60855428139592 0
1880 0.5288169712106989 2.002163626946377 0
1881 0.1678186117538876 3.797293887650369 0
1882 2.081564123731123 1.252455710641819 0
1883 0.7346617242553706 2.340703726408592 0
1884 3.444477381640916 2.146594586533211 0
1885 2.147668485033537 3.446313222048927 0
1886 3.25416635439065 0.8733738577024937 0
1887 0.1826301203439464 2.462367439142238 0
1888 0.9027840073804878 2.647227927428444 0
1889 3.554949294056362 2.88617000218287 0
1890 3.668683657404825 0.6342005082197061 0
1891 2.572295201383177 2.226096172203332 0
1892 3.798691064853937 0.170586834839442 0
1893 2.787134011984349 2.657974430930077 0
1894 1.862648856384138 3.744556060396175 0
1895 3.745827099912307 1.871049818323236 0
1896 2.27181796277183 0.6595543122468573 0
1897 2.563069674753707 1.510423746207816 0
1898 1.127044571077516 1.236147018973182 0
1899 3.2323799130177 2.335362261472149 0
1900 3.600544199965148 1.872834391823507 0
1901 0.9996677878302107 3.033906875358323 0
1902 1.015195402373392 3.114237340984363 0
1903 2.836377919140226 3.15708464643086 0
1904 2.345136711219636 3.940347227523002 0
1905 3.940347227522926 2.345136711228383 0
1906 2.808338993342554 0.9493634029811686 0
1907 0.5784129334266908 3.838014130830914 0
1908 3.836606792024645 0.5791997204751393 0
1909 3.289163282325789 2.820150796669734 0
1910 1.156325473811427 1.946834351382367 0
1911 0.8855465419184729 0.9781297161787053 0
1912 3.128752813990125 2.2500139500834 0
1913 0.4146747936485421 3.524062396737327 0
1914 0.05510344782529207 3.449999999998651 0
1915 3.534519855691029 3.618734986904931 0
1916 1.025891562656161 1.254577494033337 0
1917 2.819969728040132 1.100710729579019 0
1918 3.2497257074022 3.74638371500178 0
1919 3.019489327916094 3.714847892313027 0
1920 0.977976037691014 0.9006500266460766 0
1921 0.848284394764246 1.688895315789076 0
1922 1.153739207363775 1.583015799310295 0
1923 3.325797962419926 1.305438677652833 0
1924 0.9336822004413423 3.461886807841042 0
1925 3.643866273606963 2.590819388316471 0
1926 3.935611370492622 2.073711186498093 0
1927 2.073711186489032 3.935611370493937 0
1928 3.461290233172473 1.479733244869134 0
1929 2.80937614115145 1.470869376412286 0
1930 2.426757546077464 0.9561464725633558 0
1931 1.987127084336288 1.345572694082096 0
1932 1.388361332156785 0.1482668742842604 0
1933 1.557034347421935 1.484310157704566 0
1934 2.447823533631378 1.314068693385045 0
1935 2.925741119792182 3.035259828732804 0
1936 2.813698287871407 3.511689563943307 0
1937 0.8262117532039572 1.099876322262709 0
1938 2.705329995716212 1.305921687812951 0
1939 3.576250825771451 3.929923949681176 0
1940 3.929923949681328 3.576250825771139 0
1941 3.151049016903565 0.2788846147546514 0
1942 3.53164138690515 0.4204564857492393 0
1943 1.621639873651149 1.45257096652582 0
1944 0.2937957390771364 3.457991912373982 0
1945 0.4312190294372077 3.166938793398132 0
1946 1.810767944418323 2.157458385261322 0
1947 2.805071208598668 0.3059931133917603 0
1948 1.57250106896494 2.118132356349511 0
1949 2.103001435552336 2.005186984326322 0
1950 1.74430826117045 1.930677340738981 0
1951 2.288126281508648 1.311023428057485 0
1952 3.827622545563297 3.425842800738986 0
1953 1.273676130332964 2.248382695349726 0
1954 2.701505221673446 3.293650684706928 0
1955 0.9801968341649396 2.375772185012954 0
1956 1.887714360692023 1.434800561891344 0
1957 1.31000282240804 0.5309483394888851 0
1958 0.872548508687373 0.724930370757958 0
1959 0.8163464662828709 1.329174951843359 0
1960 1.908533103942389 1.115672701881163 0
1961 0.7948833734283233 0.9866762004575208 0
1962 2.157882322871611 1.693347173009079 0
1963 1.888299799183196 0.1641674544834197 0
1964 0.2982353842559823 2.869825945845114 0
1965 3.172403792917091 0.4521536086241666 0
1966 1.293620590529676 0.7781520717109134 0
1967 0.2978921786130694 1.911125959062584 0
1968 0.9493556257231938 0.6243308402317904 0
1969 1.92593696449041 3.61762803708896 0
1970 3.851690609432803 2.808599595646966 0
1971 0.3175485271732766 3.384514602224571 0
1972 0.6409295821599778 3.672031165000739 0
1973 3.599511610955513 2.517126176408439 0
1974 1.941733893509046 1.200638603164536 0
1975 1.887163617717177 0.0757377203959276 0
1976 0.1653829178448519 2.314189486228291 0
1977 1.645870732173286 2.565587171846648 0
1978 1.109939640764034 3.732786428474681 0
1979 3.732821433731327 1.110003237036982 0
1980 0.7195577154342672 2.950872022886279 0
1981 3.631461404011416 2.984955201937179 0
1982 2.167523727150046 0.7590071123461813 0
1983 1.06158548648911 1.946286942989503 0
1984 1.785106532283115 1.751570640389992 0
1985 1.458556523597148 2.694051111957598 0
1986 3.741202460200453 2.593547754640437 0
1987 0.6997440152007066 2.492078562664468 0
1988 1.617214179353217 3.741722803796511 0
1989 1.513764565519746 2.541217300611993 0
1990 0.7310932099225346 0.7776203876063673 0
1991 2.905643939187359 3.850249391943163 0
1992 3.855201361017611 2.898965099094596 0
1993 0.9782709905597797 1.629254867819728 0
1994 3.026555493006623 2.843974053826593 0
1995 1.680520262530775 2.712580793731048 0
1996 1.563109492163478 2.779357228519261 0
1997 1.104107798238184 1.821551578354554 0
1998 2.467137977385655 2.921064462544037 0
1999 3.837672931247764 3.804513281644702 0
2000 0.1638245325777317 1.95203200599583 0
2001 3.375621810181219 3.544453793899675 0
2002 0.1447988612412425 1.390023540218601 0
2003 0.9539987314467158 3.840707368588306 0
2004 3.840707368587813 0.9539987314460742 0
2005 1.738622597948698 0.7382191153643035 0
2006 0.6157737673939392 3.028129608662391 0
2007 2.674969078373672 1.879905181913044 0
2008 1.230045914278177 1.587431078600433 0
2009 2.768467771061651 0.8869297487723697 0
2010 1.529428156155162 1.993817538400322 0
2011 3.830139802887685 2.428195094518686 0
2012 2.428239322308597 3.826079853755658 0
2013 1.58753801674461 1.585218025971029 0
2014 1.866126395564913 1.643935229793767 0
2015 1.332111654987949 2.982293540063684 0
2016 2.762684132905733 2.461021391282823 0
2017 1.062437585549966 0.5117272001166526 0
2018 2.791562007632058 1.776488357329131 0
2019 2.164521676266544 1.369310354098897 0
2020 0.2468974215693463 1.322016014495494 0
2021 2.292546725967111 0.1764057907941336 0
2022 1.751687905508979 2.622461767658264 0
2023 1.702283837632029 1.221291686444982 0
2024 0.673722851000353 1.694264136849802 0
2025 1.986609935376957 3.686262634486104 0
2026 3.699619681006363 1.989647676176436 0
2027 1.688847286980146 2.433115208041857 0
2028 1.823781872130299 2.075788273600143 0
2029 0.7611853566370909 1.214025569328324 0
2030 0.9213334098505088 2.261261620965805 0
2031 0.5659629536496441 2.797546571686068 0
2032 0.8795234272233842 3.126270893149644 0
2033 2.097500959552822 2.352227339868737 0
2034 2.622266053540128 1.638580976095375 0
2035 3.158154726554038 1.470930761184833 0
2036 2.098109659834294 1.008416992820498 0
2037 1.241352650354306 2.972181873733011 0
2038 3.1047736038089 0.07162203660538465 0
2039 0.7422528553310462 2.734104530069907 0
2040 2.04435390969199 2.896554768855168 0
2041 3.408810312635303 0.3240309869978105 0
2042 2.498243331649828 2.359042885256798 0
2043 0.186982934571148 3.650995857437691 0
2044 1.316776939788571 0.2635881056004892 0
2045 3.017607454900133 2.981235557964646 0
2046 3.275997347523221 3.169721214767359 0
2047 3.45757069176295 0.05960435111913348 0
2048 3.443692494486444 3.843449504023513 0
2049 1.442168157177367 3.747517584277937 0
2050 3.749309263542159 1.44377293863842 0
2051 1.614628947834425 2.228909029313887 0
2052 3.732764201446112 3.422522833932041 0
2053 2.324085060998782 3.331303116623039 0
2054 3.478635725880304 0.7170693145259101 0
2055 2.368320910330023 0.270453961635059 0
2056 0.3534616684832106 3.236778485283225 0
2057 2.778461332126438 0.5775936736256007 0
2058 2.254245257398949 0.3450524043349512 0
2059 2.654905266726688 1.191671475805817 0
2060 2.043234669331405 1.130094965969267 0
2061 2.226625839649554 2.046986102356209 0
2062 0.7721981823550148 2.105884282355201 0
2063 2.441618316450645 0.1855964965801898 0
2064 2.299352937348265 0.7434461140211043 0
2065 1.437452739231275 2.766347589899458 0
2066 1.913202237694319 1.685757308373445 0
2067 2.211211379293518 2.418676129793203 0
2068 1.419197374924317 1.481517463358777 0
2069 0.7013779931636519 1.773777422720721 0
2070 1.321457328581801 1.324702412598578 0
2071 3.229294154351279 2.594104457027973 0
2072 0.7961486677966976 2.278856484528319 0
2073 2.428233118051292 1.994788896364315 0
2074 2.533915018520765 2.101931675881031 0
2075 3.708297193008199 3.01072620183793 0
2076 2.052123193665945 2.998067067636232 0
2077 0.4946308516474572 2.149127313277892 0
2078 1.759897658485525 1.454169102319309 0
2079 1.544134813299544 1.78797406794842 0
2080 0.9308451286716636 2.815250699025041 0
2081 1.033124487420764 3.637549642777658 0
2082 3.626418009355705 1.021909408207677 0
2083 3.014033803997902 0.8597333548237855 0
2084 1.636666484012636 1.8362693072521 0
2085 1.261569320389015 1.653838971674516 0
2086 3.052080312597294 0.78477561303702 0
2087 3.128884766877511 0.7893747303978593 0
2088 1.8597240109073 0.9455210001222609 0
2089 1.957126331984594 0.05738520924726151 0
2090 0.06267632996556947 2.967099710904274 0
2091 2.771673341806578 1.354905900958475 0
2092 0.8791955552089566 1.220333672846057 0
$EndNodes
$Elements
-4128
-1 15 2 12 5 4
-2 15 2 13 5 4
-3 1 2 9 2 5 21
-4 1 2 9 2 21 22
-5 1 2 9 2 22 23
-6 1 2 9 2 23 24
-7 1 2 9 2 24 25
-8 1 2 9 2 25 26
-9 1 2 9 2 26 27
-10 1 2 9 2 27 28
-11 1 2 9 2 28 29
-12 1 2 9 2 29 30
-13 1 2 9 2 30 31
-14 1 2 9 2 31 32
-15 1 2 9 2 32 33
-16 1 2 9 2 33 34
-17 1 2 9 2 34 35
-18 1 2 9 2 35 36
-19 1 2 9 2 36 37
-20 1 2 9 2 37 38
-21 1 2 9 2 38 39
-22 1 2 9 2 39 40
-23 1 2 9 2 40 41
-24 1 2 9 2 41 42
-25 1 2 9 2 42 43
-26 1 2 9 2 43 44
-27 1 2 9 2 44 45
-28 1 2 9 2 45 46
-29 1 2 9 2 46 47
-30 1 2 9 2 47 48
-31 1 2 9 2 48 49
-32 1 2 9 2 49 3
-33 1 2 11 3 3 50
-34 1 2 11 3 50 51
-35 1 2 11 3 51 52
-36 1 2 11 3 52 53
-37 1 2 11 3 53 54
-38 1 2 11 3 54 55
-39 1 2 11 3 55 56
-40 1 2 11 3 56 57
-41 1 2 11 3 57 58
-42 1 2 11 3 58 59
-43 1 2 11 3 59 60
-44 1 2 11 3 60 61
-45 1 2 11 3 61 62
-46 1 2 11 3 62 63
-47 1 2 11 3 63 64
-48 1 2 11 3 64 65
-49 1 2 11 3 65 66
-50 1 2 11 3 66 67
-51 1 2 11 3 67 68
-52 1 2 11 3 68 69
-53 1 2 11 3 69 70
-54 1 2 11 3 70 71
-55 1 2 11 3 71 72
-56 1 2 11 3 72 73
-57 1 2 11 3 73 74
-58 1 2 11 3 74 75
-59 1 2 11 3 75 76
-60 1 2 11 3 76 77
-61 1 2 11 3 77 78
-62 1 2 11 3 78 79
-63 1 2 11 3 79 80
-64 1 2 11 3 80 81
-65 1 2 11 3 81 82
-66 1 2 11 3 82 83
-67 1 2 11 3 83 84
-68 1 2 11 3 84 85
-69 1 2 11 3 85 86
-70 1 2 11 3 86 87
-71 1 2 11 3 87 88
-72 1 2 11 3 88 2
-73 1 2 10 5 1 128
-74 1 2 10 5 128 129
-75 1 2 10 5 129 130
-76 1 2 10 5 130 131
-77 1 2 10 5 131 132
-78 1 2 10 5 132 133
-79 1 2 10 5 133 134
-80 1 2 10 5 134 135
-81 1 2 10 5 135 136
-82 1 2 10 5 136 137
-83 1 2 10 5 137 138
-84 1 2 10 5 138 139
-85 1 2 10 5 139 140
-86 1 2 10 5 140 141
-87 1 2 10 5 141 142
-88 1 2 10 5 142 143
-89 1 2 10 5 143 144
-90 1 2 10 5 144 145
-91 1 2 10 5 145 146
-92 1 2 10 5 146 147
-93 1 2 10 5 147 148
-94 1 2 10 5 148 149
-95 1 2 10 5 149 150
-96 1 2 10 5 150 151
-97 1 2 10 5 151 152
-98 1 2 10 5 152 153
-99 1 2 10 5 153 154
-100 1 2 10 5 154 155
-101 1 2 10 5 155 156
-102 1 2 10 5 156 4
-103 2 2 8 7 159 1413 814
-104 2 2 8 7 1413 1550 814
-105 2 2 8 7 252 1331 1043
-106 2 2 8 7 668 1619 285
-107 2 2 8 7 232 905 662
-108 2 2 8 7 628 1250 463
-109 2 2 8 7 808 809 407
-110 2 2 8 7 327 809 808
-111 2 2 8 7 764 885 203
-112 2 2 8 7 163 1409 1230
-113 2 2 8 7 763 797 337
-114 2 2 8 7 484 1135 745
-115 2 2 8 7 744 1136 485
-116 2 2 8 7 417 851 810
-117 2 2 8 7 420 1488 652
-118 2 2 8 7 20 1090 5
-119 2 2 8 7 360 964 721
-120 2 2 8 7 715 1276 296
-121 2 2 8 7 673 1728 936
-122 2 2 8 7 863 1547 641
-123 2 2 8 7 1246 2006 1112
-124 2 2 8 7 231 1547 863
-125 2 2 8 7 807 2029 206
-126 2 2 8 7 437 1087 728
-127 2 2 8 7 1644 1762 818
-128 2 2 8 7 371 987 662
-129 2 2 8 7 285 1619 679
-130 2 2 8 7 662 987 232
-131 2 2 8 7 807 2092 2029
-132 2 2 8 7 278 1173 619
-133 2 2 8 7 416 1122 642
-134 2 2 8 7 1741 1793 834
-135 2 2 8 7 463 985 628
-136 2 2 8 7 4 1094 6
-137 2 2 8 7 396 1980 631
-138 2 2 8 7 302 930 761
-139 2 2 8 7 762 824 487
-140 2 2 8 7 1213 1263 329
-141 2 2 8 7 891 1233 507
-142 2 2 8 7 329 1263 750
-143 2 2 8 7 424 1737 644
-144 2 2 8 7 357 945 879
-145 2 2 8 7 320 820 740
-146 2 2 8 7 594 1304 1146
-147 2 2 8 7 645 1006 245
-148 2 2 8 7 445 1275 653
-149 2 2 8 7 551 1374 1236
-150 2 2 8 7 357 2029 742
-151 2 2 8 7 370 1006 645
-152 2 2 8 7 879 945 428
-153 2 2 8 7 5 1090 21
-154 2 2 8 7 936 1728 364
-155 2 2 8 7 595 1470 956
-156 2 2 8 7 630 1463 921
-157 2 2 8 7 516 1246 1112
-158 2 2 8 7 245 1546 645
-159 2 2 8 7 921 1463 208
-160 2 2 8 7 644 1737 778
-161 2 2 8 7 800 1317 537
-162 2 2 8 7 777 2029 357
-163 2 2 8 7 778 1737 210
-164 2 2 8 7 282 1317 800
-165 2 2 8 7 229 1278 844
-166 2 2 8 7 845 1279 230
-167 2 2 8 7 1348 1511 895
-168 2 2 8 7 1033 1269 27
-169 2 2 8 7 326 1644 818
-170 2 2 8 7 1146 1304 482
-171 2 2 8 7 683 1841 171
-172 2 2 8 7 390 1040 897
-173 2 2 8 7 896 1039 389
-174 2 2 8 7 240 1285 756
-175 2 2 8 7 356 931 839
-176 2 2 8 7 675 1119 411
-177 2 2 8 7 410 1118 676
-178 2 2 8 7 443 898 725
-179 2 2 8 7 726 899 444
-180 2 2 8 7 156 1094 4
-181 2 2 8 7 699 884 215
-182 2 2 8 7 771 1847 361
-183 2 2 8 7 637 1377 451
-184 2 2 8 7 257 989 637
-185 2 2 8 7 751 1081 340
-186 2 2 8 7 27 1269 28
-187 2 2 8 7 914 1386 549
-188 2 2 8 7 619 1514 278
-189 2 2 8 7 267 1247 692
-190 2 2 8 7 617 1741 834
-191 2 2 8 7 355 837 769
-192 2 2 8 7 914 1078 173
-193 2 2 8 7 486 1078 914
-194 2 2 8 7 311 824 762
-195 2 2 8 7 987 1026 508
-196 2 2 8 7 371 1026 987
-197 2 2 8 7 828 1847 771
-198 2 2 8 7 887 925 170
-199 2 2 8 7 447 1787 1143
-200 2 2 8 7 753 1573 388
-201 2 2 8 7 762 1365 237
-202 2 2 8 7 733 1238 475
-203 2 2 8 7 753 1676 203
-204 2 2 8 7 666 1177 216
-205 2 2 8 7 640 1501 292
-206 2 2 8 7 280 1238 733
-207 2 2 8 7 354 977 651
-208 2 2 8 7 1251 1281 701
-209 2 2 8 7 618 1063 238
-210 2 2 8 7 638 999 412
-211 2 2 8 7 217 931 729
-212 2 2 8 7 896 1306 610
-213 2 2 8 7 815 1236 474
-214 2 2 8 7 565 973 719
-215 2 2 8 7 354 828 771
-216 2 2 8 7 2029 2092 742
-217 2 2 8 7 709 1032 409
-218 2 2 8 7 268 1375 690
-219 2 2 8 7 278 1032 709
-220 2 2 8 7 871 1084 240
-221 2 2 8 7 630 1048 379
-222 2 2 8 7 469 1084 871
-223 2 2 8 7 849 1022 212
-224 2 2 8 7 29 1269 728
-225 2 2 8 7 450 1022 849
-226 2 2 8 7 379 1463 630
-227 2 2 8 7 62 1570 953
-228 2 2 8 7 954 1571 115
-229 2 2 8 7 240 1312 1285
-230 2 2 8 7 806 891 507
-231 2 2 8 7 1087 2000 728
-232 2 2 8 7 789 1333 244
-233 2 2 8 7 387 997 641
-234 2 2 8 7 259 1231 750
-235 2 2 8 7 956 1470 352
-236 2 2 8 7 750 1231 473
-237 2 2 8 7 717 1772 413
-238 2 2 8 7 702 963 209
-239 2 2 8 7 423 1198 786
-240 2 2 8 7 238 1486 618
-241 2 2 8 7 1610 1618 625
-242 2 2 8 7 66 759 67
-243 2 2 8 7 110 758 111
-244 2 2 8 7 1278 1626 844
-245 2 2 8 7 845 1627 1279
-246 2 2 8 7 964 975 457
-247 2 2 8 7 360 975 964
-248 2 2 8 7 805 1129 456
-249 2 2 8 7 718 1559 142
-250 2 2 8 7 232 1129 805
-251 2 2 8 7 769 837 212
-252 2 2 8 7 884 1531 215
-253 2 2 8 7 713 1176 222
-254 2 2 8 7 164 1320 688
-255 2 2 8 7 365 925 778
-256 2 2 8 7 688 1320 471
-257 2 2 8 7 349 1386 825
-258 2 2 8 7 631 1066 396
-259 2 2 8 7 778 925 384
-260 2 2 8 7 216 1480 666
-261 2 2 8 7 215 1531 1290
-262 2 2 8 7 1306 1900 610
-263 2 2 8 7 745 1477 484
-264 2 2 8 7 485 1478 744
-265 2 2 8 7 412 1174 638
-266 2 2 8 7 334 916 914
-267 2 2 8 7 914 916 486
-268 2 2 8 7 674 1834 365
-269 2 2 8 7 447 1633 1194
-270 2 2 8 7 890 1633 447
-271 2 2 8 7 769 841 355
-272 2 2 8 7 982 1676 753
-273 2 2 8 7 748 1232 349
-274 2 2 8 7 380 850 829
-275 2 2 8 7 237 1524 762
-276 2 2 8 7 637 1270 257
-277 2 2 8 7 760 1126 530
-278 2 2 8 7 1040 1484 897
-279 2 2 8 7 896 1483 1039
-280 2 2 8 7 1158 1252 578
-281 2 2 8 7 174 1313 727
-282 2 2 8 7 1182 1512 151
-283 2 2 8 7 742 1959 357
-284 2 2 8 7 923 1054 472
-285 2 2 8 7 243 1054 923
-286 2 2 8 7 451 1289 637
-287 2 2 8 7 1134 1237 582
-288 2 2 8 7 171 1841 771
-289 2 2 8 7 885 1573 753
-290 2 2 8 7 670 984 503
-291 2 2 8 7 292 1469 640
-292 2 2 8 7 880 1931 224
-293 2 2 8 7 1103 1606 678
-294 2 2 8 7 256 1233 891
-295 2 2 8 7 704 1128 310
-296 2 2 8 7 724 1931 880
-297 2 2 8 7 720 2053 254
-298 2 2 8 7 522 1419 1044
-299 2 2 8 7 373 2028 763
-300 2 2 8 7 206 1606 1103
-301 2 2 8 7 222 997 713
-302 2 2 8 7 420 2063 718
-303 2 2 8 7 637 1120 415
-304 2 2 8 7 415 1270 637
-305 2 2 8 7 927 928 350
-306 2 2 8 7 692 1223 267
-307 2 2 8 7 445 928 927
-308 2 2 8 7 392 1625 686
-309 2 2 8 7 760 1594 1126
-310 2 2 8 7 1421 1656 284
-311 2 2 8 7 1075 1274 160
-312 2 2 8 7 636 1274 1075
-313 2 2 8 7 746 880 398
-314 2 2 8 7 763 2028 797
-315 2 2 8 7 641 1547 387
-316 2 2 8 7 349 1232 791
-317 2 2 8 7 1124 1610 625
-318 2 2 8 7 427 1130 889
-319 2 2 8 7 698 1831 1682
-320 2 2 8 7 176 1251 701
-321 2 2 8 7 130 1181 686
-322 2 2 8 7 234 984 670
-323 2 2 8 7 200 929 716
-324 2 2 8 7 349 1612 1386
-325 2 2 8 7 365 1474 674
-326 2 2 8 7 36 779 37
-327 2 2 8 7 676 1046 410
-328 2 2 8 7 411 1045 675
-329 2 2 8 7 715 920 199
-330 2 2 8 7 645 1506 370
-331 2 2 8 7 414 1067 647
-332 2 2 8 7 140 1308 652
-333 2 2 8 7 185 968 927
-334 2 2 8 7 927 968 445
-335 2 2 8 7 731 1197 205
-336 2 2 8 7 204 1196 730
-337 2 2 8 7 569 1678 733
-338 2 2 8 7 1043 1331 531
-339 2 2 8 7 287 2000 1087
-340 2 2 8 7 652 1488 140
-341 2 2 8 7 745 1135 517
-342 2 2 8 7 518 1136 744
-343 2 2 8 7 170 925 850
-344 2 2 8 7 203 885 753
-345 2 2 8 7 429 1237 1134
-346 2 2 8 7 961 1276 715
-347 2 2 8 7 455 1252 1158
-348 2 2 8 7 1143 1787 584
-349 2 2 8 7 203 1814 764
-350 2 2 8 7 197 1348 895
-351 2 2 8 7 810 851 338
-352 2 2 8 7 841 970 355
-353 2 2 8 7 644 1655 424
-354 2 2 8 7 51 776 52
-355 2 2 8 7 125 775 126
-356 2 2 8 7 642 1218 416
-357 2 2 8 7 975 1409 163
-358 2 2 8 7 944 1772 717
-359 2 2 8 7 504 1245 860
-360 2 2 8 7 454 993 937
-361 2 2 8 7 1522 2057 1097
-362 2 2 8 7 936 1280 228
-363 2 2 8 7 937 993 241
-364 2 2 8 7 18 1268 940
-365 2 2 8 7 187 1236 815
-366 2 2 8 7 647 1191 414
-367 2 2 8 7 1375 1800 690
-368 2 2 8 7 1682 1982 698
-369 2 2 8 7 941 2053 720
-370 2 2 8 7 936 1877 673
-371 2 2 8 7 681 1656 1421
-372 2 2 8 7 441 1244 1036
-373 2 2 8 7 1036 1244 586
-374 2 2 8 7 380 2019 850
-375 2 2 8 7 829 850 365
-376 2 2 8 7 495 1233 832
-377 2 2 8 7 832 1233 256
-378 2 2 8 7 244 1333 1183
-379 2 2 8 7 828 1260 225
-380 2 2 8 7 400 1753 696
-381 2 2 8 7 697 1752 401
-382 2 2 8 7 431 1240 1037
-383 2 2 8 7 923 1901 629
-384 2 2 8 7 695 1220 47
-385 2 2 8 7 705 1546 245
-386 2 2 8 7 337 1729 763
-387 2 2 8 7 882 1243 8
-388 2 2 8 7 355 2084 837
-389 2 2 8 7 870 2063 420
-390 2 2 8 7 524 1669 748
-391 2 2 8 7 340 941 720
-392 2 2 8 7 1814 2042 764
-393 2 2 8 7 1056 1235 434
-394 2 2 8 7 382 944 717
-395 2 2 8 7 900 1169 248
-396 2 2 8 7 588 1512 1182
-397 2 2 8 7 733 1678 280
-398 2 2 8 7 220 892 811
-399 2 2 8 7 841 892 220
-400 2 2 8 7 340 1081 941
-401 2 2 8 7 142 1559 143
-402 2 2 8 7 750 1014 329
-403 2 2 8 7 1464 1541 962
-404 2 2 8 7 386 1950 837
-405 2 2 8 7 402 1642 791
-406 2 2 8 7 652 1223 420
-407 2 2 8 7 819 1604 359
-408 2 2 8 7 653 1208 445
-409 2 2 8 7 651 1260 354
-410 2 2 8 7 952 1572 575
-411 2 2 8 7 749 1847 225
-412 2 2 8 7 487 1365 762
-413 2 2 8 7 1700 1899 353
-414 2 2 8 7 934 1950 386
-415 2 2 8 7 1739 1812 172
-416 2 2 8 7 409 1865 666
-417 2 2 8 7 228 1280 1120
-418 2 2 8 7 245 1853 705
-419 2 2 8 7 1601 2039 396
-420 2 2 8 7 395 1522 1097
-421 2 2 8 7 933 1157 417
-422 2 2 8 7 204 1039 671
-423 2 2 8 7 672 1040 205
-424 2 2 8 7 710 2085 382
-425 2 2 8 7 509 1554 950
-426 2 2 8 7 1253 1554 509
-427 2 2 8 7 510 1201 900
-428 2 2 8 7 483 1169 1147
-429 2 2 8 7 372 960 949
-430 2 2 8 7 1147 1169 595
-431 2 2 8 7 805 948 308
-432 2 2 8 7 912 913 465
-433 2 2 8 7 442 1993 853
-434 2 2 8 7 932 1646 209
-435 2 2 8 7 341 913 912
-436 2 2 8 7 316 2046 792
-437 2 2 8 7 379 965 743
-438 2 2 8 7 793 2046 316
-439 2 2 8 7 1091 1851 196
-440 2 2 8 7 743 965 167
-441 2 2 8 7 797 2028 212
-442 2 2 8 7 199 961 715
-443 2 2 8 7 281 1793 1741
-444 2 2 8 7 1201 1475 900
-445 2 2 8 7 1646 1660 209
-446 2 2 8 7 662 1372 371
-447 2 2 8 7 62 953 63
-448 2 2 8 7 114 954 115
-449 2 2 8 7 853 1993 947
-450 2 2 8 7 384 925 887
-451 2 2 8 7 857 1102 219
-452 2 2 8 7 1012 1198 423
-453 2 2 8 7 372 932 749
-454 2 2 8 7 720 1061 560
-455 2 2 8 7 1130 1580 889
-456 2 2 8 7 337 983 833
-457 2 2 8 7 51 1726 776
-458 2 2 8 7 775 1725 126
-459 2 2 8 7 949 960 432
-460 2 2 8 7 761 930 429
-461 2 2 8 7 334 891 806
-462 2 2 8 7 363 958 729
-463 2 2 8 7 356 1916 931
-464 2 2 8 7 679 1593 285
-465 2 2 8 7 426 1144 663
-466 2 2 8 7 834 1151 259
-467 2 2 8 7 353 1899 919
-468 2 2 8 7 167 965 821
-469 2 2 8 7 457 1151 834
-470 2 2 8 7 253 1135 919
-471 2 2 8 7 172 1812 856
-472 2 2 8 7 919 1135 484
-473 2 2 8 7 791 909 349
-474 2 2 8 7 225 1260 906
-475 2 2 8 7 7 882 8
-476 2 2 8 7 196 1337 912
-477 2 2 8 7 767 969 231
-478 2 2 8 7 359 1604 901
-479 2 2 8 7 947 974 162
-480 2 2 8 7 663 1255 426
-481 2 2 8 7 743 1886 379
-482 2 2 8 7 741 1886 307
-483 2 2 8 7 307 1886 743
-484 2 2 8 7 692 1247 440
-485 2 2 8 7 729 1756 363
-486 2 2 8 7 488 969 767
-487 2 2 8 7 868 959 221
-488 2 2 8 7 684 1014 185
-489 2 2 8 7 1033 1312 437
-490 2 2 8 7 549 1703 914
-491 2 2 8 7 459 959 868
-492 2 2 8 7 179 1380 1272
-493 2 2 8 7 729 958 217
-494 2 2 8 7 742 2092 839
-495 2 2 8 7 839 2092 356
-496 2 2 8 7 212 2028 849
-497 2 2 8 7 748 1669 1232
-498 2 2 8 7 705 1697 369
-499 2 2 8 7 353 917 785
-500 2 2 8 7 961 1001 392
-501 2 2 8 7 413 970 717
-502 2 2 8 7 493 1291 908
-503 2 2 8 7 382 974 710
-504 2 2 8 7 777 1180 453
-505 2 2 8 7 18 940 19
-506 2 2 8 7 228 1877 936
-507 2 2 8 7 357 1180 777
-508 2 2 8 7 714 973 369
-509 2 2 8 7 310 1128 811
-510 2 2 8 7 413 924 886
-511 2 2 8 7 225 1847 828
-512 2 2 8 7 773 1646 372
-513 2 2 8 7 444 1685 859
-514 2 2 8 7 571 1646 773
-515 2 2 8 7 369 1697 714
-516 2 2 8 7 699 1060 272
-517 2 2 8 7 440 1060 699
-518 2 2 8 7 838 1215 331
-519 2 2 8 7 719 973 168
-520 2 2 8 7 791 1642 909
-521 2 2 8 7 666 1480 409
-522 2 2 8 7 734 996 452
-523 2 2 8 7 841 1794 970
-524 2 2 8 7 981 1722 1465
-525 2 2 8 7 403 1161 1080
-526 2 2 8 7 773 949 161
-527 2 2 8 7 648 1239 1172
-528 2 2 8 7 1172 1239 489
-529 2 2 8 7 365 1834 829
-530 2 2 8 7 1517 1555 910
-531 2 2 8 7 749 960 372
-532 2 2 8 7 421 1175 689
-533 2 2 8 7 764 1572 885
-534 2 2 8 7 202 1372 915
-535 2 2 8 7 66 1326 759
-536 2 2 8 7 758 1325 111
-537 2 2 8 7 763 1729 1024
-538 2 2 8 7 1337 2030 912
-539 2 2 8 7 225 960 749
-540 2 2 8 7 833 1737 424
-541 2 2 8 7 240 1648 871
-542 2 2 8 7 815 1831 642
-543 2 2 8 7 1106 1121 417
-544 2 2 8 7 372 949 773
-545 2 2 8 7 293 1831 815
-546 2 2 8 7 704 1851 1091
-547 2 2 8 7 561 1121 1106
-548 2 2 8 7 723 2005 1195
-549 2 2 8 7 702 1933 963
-550 2 2 8 7 590 1440 1364
-551 2 2 8 7 1365 1441 591
-552 2 2 8 7 719 1719 565
-553 2 2 8 7 380 1931 724
-554 2 2 8 7 194 1227 1201
-555 2 2 8 7 226 1423 928
-556 2 2 8 7 795 1657 209
-557 2 2 8 7 1201 1227 656
-558 2 2 8 7 797 934 337
-559 2 2 8 7 551 1175 1041
-560 2 2 8 7 285 1468 668
-561 2 2 8 7 272 1773 1309
-562 2 2 8 7 1644 1995 583
-563 2 2 8 7 721 1722 360
-564 2 2 8 7 344 1517 910
-565 2 2 8 7 1041 1175 421
-566 2 2 8 7 396 2039 1055
-567 2 2 8 7 310 1004 704
-568 2 2 8 7 1933 2013 375
-569 2 2 8 7 997 1938 713
-570 2 2 8 7 883 1453 242
-571 2 2 8 7 727 1079 174
-572 2 2 8 7 406 1079 727
-573 2 2 8 7 725 1863 300
-574 2 2 8 7 301 1864 726
-575 2 2 8 7 298 1229 1020
-576 2 2 8 7 366 1052 739
-577 2 2 8 7 417 1157 1106
-578 2 2 8 7 195 1021 818
-579 2 2 8 7 522 1044 1042
-580 2 2 8 7 503 1334 670
-581 2 2 8 7 690 1800 218
-582 2 2 8 7 714 1742 973
-583 2 2 8 7 973 1742 168
-584 2 2 8 7 1042 1044 374
-585 2 2 8 7 560 1706 720
-586 2 2 8 7 500 1468 767
-587 2 2 8 7 720 1706 340
-588 2 2 8 7 1236 1374 474
-589 2 2 8 7 1229 1489 1020
-590 2 2 8 7 28 1269 29
-591 2 2 8 7 738 1068 407
-592 2 2 8 7 242 1068 738
-593 2 2 8 7 439 1281 1251
-594 2 2 8 7 1385 1648 240
-595 2 2 8 7 966 1372 202
-596 2 2 8 7 1682 1831 293
-597 2 2 8 7 800 1624 1078
-598 2 2 8 7 424 1167 682
-599 2 2 8 7 471 1062 688
-600 2 2 8 7 222 1176 946
-601 2 2 8 7 953 1570 573
-602 2 2 8 7 572 1571 954
-603 2 2 8 7 375 2013 886
-604 2 2 8 7 359 1786 902
-605 2 2 8 7 902 1786 674
-606 2 2 8 7 154 1345 1056
-607 2 2 8 7 348 1464 962
-608 2 2 8 7 763 994 373
-609 2 2 8 7 297 998 716
-610 2 2 8 7 538 1235 1056
-611 2 2 8 7 842 1031 505
-612 2 2 8 7 946 1422 330
-613 2 2 8 7 305 1031 842
-614 2 2 8 7 615 1425 926
-615 2 2 8 7 328 1511 863
-616 2 2 8 7 693 1071 480
-617 2 2 8 7 900 1470 1169
-618 2 2 8 7 361 1283 771
-619 2 2 8 7 1054 1980 396
-620 2 2 8 7 716 1394 491
-621 2 2 8 7 185 1449 684
-622 2 2 8 7 863 1511 1340
-623 2 2 8 7 456 948 805
-624 2 2 8 7 778 1962 644
-625 2 2 8 7 671 1196 204
-626 2 2 8 7 205 1197 672
-627 2 2 8 7 851 1155 338
-628 2 2 8 7 565 1539 1035
-629 2 2 8 7 1037 1240 526
-630 2 2 8 7 859 1396 444
-631 2 2 8 7 349 1832 748
-632 2 2 8 7 367 1502 738
-633 2 2 8 7 716 1675 200
-634 2 2 8 7 217 945 839
-635 2 2 8 7 767 1340 500
-636 2 2 8 7 1313 1923 727
-637 2 2 8 7 493 1800 1375
-638 2 2 8 7 137 840 138
-639 2 2 8 7 670 1218 234
-640 2 2 8 7 378 1295 950
-641 2 2 8 7 492 1388 715
-642 2 2 8 7 963 1933 375
-643 2 2 8 7 474 1670 815
-644 2 2 8 7 336 982 753
-645 2 2 8 7 624 2057 1522
-646 2 2 8 7 811 1128 579
-647 2 2 8 7 875 1378 543
-648 2 2 8 7 1284 1423 226
-649 2 2 8 7 299 1378 875
-650 2 2 8 7 321 2027 922
-651 2 2 8 7 753 1840 336
-652 2 2 8 7 170 2019 796
-653 2 2 8 7 384 1962 778
-654 2 2 8 7 860 1558 504
-655 2 2 8 7 730 1769 204
-656 2 2 8 7 205 1768 731
-657 2 2 8 7 382 2085 944
-658 2 2 8 7 216 1177 826
-659 2 2 8 7 338 1155 871
-660 2 2 8 7 284 1707 1421
-661 2 2 8 7 695 2043 297
-662 2 2 8 7 1756 1922 363
-663 2 2 8 7 157 1949 852
-664 2 2 8 7 409 1631 709
-665 2 2 8 7 642 1122 815
-666 2 2 8 7 852 1949 682
-667 2 2 8 7 36 1315 779
-668 2 2 8 7 417 1121 851
-669 2 2 8 7 839 931 217
-670 2 2 8 7 901 1943 298
-671 2 2 8 7 706 1943 901
-672 2 2 8 7 850 925 365
-673 2 2 8 7 1133 1488 420
-674 2 2 8 7 732 1982 1682
-675 2 2 8 7 387 1938 997
-676 2 2 8 7 86 816 87
-677 2 2 8 7 90 817 91
-678 2 2 8 7 901 1786 359
-679 2 2 8 7 173 1386 914
-680 2 2 8 7 210 1474 778
-681 2 2 8 7 682 1949 424
-682 2 2 8 7 901 2078 1786
-683 2 2 8 7 168 1987 719
-684 2 2 8 7 760 1234 246
-685 2 2 8 7 877 1242 332
-686 2 2 8 7 496 1242 877
-687 2 2 8 7 272 1533 699
-688 2 2 8 7 1078 1624 173
-689 2 2 8 7 626 2042 1814
-690 2 2 8 7 1082 1301 436
-691 2 2 8 7 473 1415 750
-692 2 2 8 7 685 1707 284
-693 2 2 8 7 246 1482 976
-694 2 2 8 7 976 1482 613
-695 2 2 8 7 204 1769 745
-696 2 2 8 7 744 1768 205
-697 2 2 8 7 546 1321 780
-698 2 2 8 7 781 1322 547
-699 2 2 8 7 581 1762 1644
-700 2 2 8 7 386 983 934
-701 2 2 8 7 823 969 381
-702 2 2 8 7 981 1152 513
-703 2 2 8 7 251 1152 981
-704 2 2 8 7 860 1245 233
-705 2 2 8 7 969 1162 381
-706 2 2 8 7 686 1276 392
-707 2 2 8 7 178 1029 952
-708 2 2 8 7 34 858 35
-709 2 2 8 7 738 1008 367
-710 2 2 8 7 362 2010 1022
-711 2 2 8 7 1173 1417 619
-712 2 2 8 7 705 1853 1140
-713 2 2 8 7 145 1000 146
-714 2 2 8 7 947 1679 974
-715 2 2 8 7 112 874 113
-716 2 2 8 7 64 873 65
-717 2 2 8 7 615 1971 1425
-718 2 2 8 7 242 1453 1068
-719 2 2 8 7 429 1163 761
-720 2 2 8 7 776 1881 297
-721 2 2 8 7 606 1881 776
-722 2 2 8 7 761 1163 214
-723 2 2 8 7 800 1078 405
-724 2 2 8 7 1215 1397 331
-725 2 2 8 7 367 1529 1502
-726 2 2 8 7 186 1155 851
-727 2 2 8 7 211 1162 1115
-728 2 2 8 7 171 1691 683
-729 2 2 8 7 850 2019 170
-730 2 2 8 7 922 2027 708
-731 2 2 8 7 209 1657 932
-732 2 2 8 7 886 924 375
-733 2 2 8 7 1126 1594 477
-734 2 2 8 7 686 1892 296
-735 2 2 8 7 196 1830 1091
-736 2 2 8 7 783 1088 474
-737 2 2 8 7 265 1437 787
-738 2 2 8 7 378 1478 1295
-739 2 2 8 7 1037 1338 23
-740 2 2 8 7 179 1553 879
-741 2 2 8 7 157 994 763
-742 2 2 8 7 1089 1172 260
-743 2 2 8 7 272 1309 889
-744 2 2 8 7 347 1572 952
-745 2 2 8 7 922 1137 183
-746 2 2 8 7 284 1432 685
-747 2 2 8 7 576 1301 1082
-748 2 2 8 7 296 1892 775
-749 2 2 8 7 629 1327 923
-750 2 2 8 7 853 947 162
-751 2 2 8 7 775 1892 605
-752 2 2 8 7 603 1650 1074
-753 2 2 8 7 218 1241 690
-754 2 2 8 7 690 1241 426
-755 2 2 8 7 821 1215 167
-756 2 2 8 7 1898 1916 907
-757 2 2 8 7 1294 1719 719
-758 2 2 8 7 1044 1419 250
-759 2 2 8 7 829 1931 380
-760 2 2 8 7 500 1511 1348
-761 2 2 8 7 704 1091 346
-762 2 2 8 7 360 1722 981
-763 2 2 8 7 333 1073 813
-764 2 2 8 7 689 1200 421
-765 2 2 8 7 1022 2010 769
-766 2 2 8 7 369 1546 705
-767 2 2 8 7 145 1493 1000
-768 2 2 8 7 241 1298 1124
-769 2 2 8 7 171 1898 907
-770 2 2 8 7 731 1469 292
-771 2 2 8 7 292 1045 731
-772 2 2 8 7 730 1046 291
-773 2 2 8 7 855 1125 193
-774 2 2 8 7 1286 1330 479
-775 2 2 8 7 1038 1625 392
-776 2 2 8 7 951 1529 367
-777 2 2 8 7 794 1011 313
-778 2 2 8 7 291 1217 730
-779 2 2 8 7 142 1133 718
-780 2 2 8 7 1065 1753 400
-781 2 2 8 7 401 1752 1064
-782 2 2 8 7 858 1069 370
-783 2 2 8 7 296 1276 686
-784 2 2 8 7 1275 1661 653
-785 2 2 8 7 686 1625 130
-786 2 2 8 7 690 1255 268
-787 2 2 8 7 688 1367 164
-788 2 2 8 7 41 990 42
-789 2 2 8 7 381 967 823
-790 2 2 8 7 488 1162 969
-791 2 2 8 7 733 1523 569
-792 2 2 8 7 601 1102 857
-793 2 2 8 7 167 1215 838
-794 2 2 8 7 425 1429 737
-795 2 2 8 7 1668 1829 273
-796 2 2 8 7 255 1015 869
-797 2 2 8 7 231 969 823
-798 2 2 8 7 565 1839 973
-799 2 2 8 7 453 1049 777
-800 2 2 8 7 717 1282 382
-801 2 2 8 7 464 1243 882
-802 2 2 8 7 527 1889 1720
-803 2 2 8 7 277 1719 1294
-804 2 2 8 7 816 1999 661
-805 2 2 8 7 1391 1733 308
-806 2 2 8 7 309 1734 1392
-807 2 2 8 7 325 1901 923
-808 2 2 8 7 1182 1183 588
-809 2 2 8 7 481 1183 1182
-810 2 2 8 7 426 1255 690
-811 2 2 8 7 964 1564 721
-812 2 2 8 7 699 1533 884
-813 2 2 8 7 1448 1689 980
-814 2 2 8 7 1102 1985 219
-815 2 2 8 7 908 1291 184
-816 2 2 8 7 763 1024 157
-817 2 2 8 7 346 1128 704
-818 2 2 8 7 550 1422 946
-819 2 2 8 7 701 1145 393
-820 2 2 8 7 692 1683 420
-821 2 2 8 7 1199 1602 358
-822 2 2 8 7 701 1445 176
-823 2 2 8 7 824 1928 487
-824 2 2 8 7 217 1016 945
-825 2 2 8 7 759 1326 466
-826 2 2 8 7 467 1325 758
-827 2 2 8 7 583 1995 1303
-828 2 2 8 7 480 1743 693
-829 2 2 8 7 314 1837 804
-830 2 2 8 7 1045 1197 731
-831 2 2 8 7 730 1196 1046
-832 2 2 8 7 315 1999 816
-833 2 2 8 7 804 1837 596
-834 2 2 8 7 696 1310 400
-835 2 2 8 7 401 1311 697
-836 2 2 8 7 502 1314 1211
-837 2 2 8 7 178 1093 962
-838 2 2 8 7 771 1841 354
-839 2 2 8 7 276 1145 701
-840 2 2 8 7 317 2006 1246
-841 2 2 8 7 212 1022 769
-842 2 2 8 7 962 1093 458
-843 2 2 8 7 1089 1784 1172
-844 2 2 8 7 134 1694 737
-845 2 2 8 7 879 1380 179
-846 2 2 8 7 547 1605 781
-847 2 2 8 7 781 1605 307
-848 2 2 8 7 166 1153 772
-849 2 2 8 7 296 1496 715
-850 2 2 8 7 716 1497 297
-851 2 2 8 7 418 1009 873
-852 2 2 8 7 874 1010 419
-853 2 2 8 7 491 1497 716
-854 2 2 8 7 715 1496 492
-855 2 2 8 7 873 1009 466
-856 2 2 8 7 467 1010 874
-857 2 2 8 7 1041 1374 551
-858 2 2 8 7 570 1721 1042
-859 2 2 8 7 420 1223 692
-860 2 2 8 7 847 1073 333
-861 2 2 8 7 479 1330 1070
-862 2 2 8 7 1195 2005 260
-863 2 2 8 7 282 1156 711
-864 2 2 8 7 407 1297 738
-865 2 2 8 7 747 1569 295
-866 2 2 8 7 832 1166 495
-867 2 2 8 7 359 2014 819
-868 2 2 8 7 819 2014 664
-869 2 2 8 7 447 1277 890
-870 2 2 8 7 951 1888 1529
-871 2 2 8 7 283 1132 727
-872 2 2 8 7 219 1732 1052
-873 2 2 8 7 1052 1732 739
-874 2 2 8 7 727 1132 406
-875 2 2 8 7 353 1210 917
-876 2 2 8 7 17 1523 733
-877 2 2 8 7 393 1445 701
-878 2 2 8 7 837 2084 386
-879 2 2 8 7 179 1185 784
-880 2 2 8 7 787 1920 265
-881 2 2 8 7 930 1237 429
-882 2 2 8 7 919 1210 353
-883 2 2 8 7 728 1639 29
-884 2 2 8 7 784 1185 438
-885 2 2 8 7 407 1068 739
-886 2 2 8 7 712 1132 283
-887 2 2 8 7 300 1407 725
-888 2 2 8 7 726 1408 301
-889 2 2 8 7 898 1863 725
-890 2 2 8 7 726 1864 899
-891 2 2 8 7 393 1011 794
-892 2 2 8 7 328 1951 1168
-893 2 2 8 7 674 1474 902
-894 2 2 8 7 847 985 233
-895 2 2 8 7 884 1533 563
-896 2 2 8 7 1074 1702 603
-897 2 2 8 7 388 1840 753
-898 2 2 8 7 512 1312 1033
-899 2 2 8 7 709 1631 169
-900 2 2 8 7 362 1812 892
-901 2 2 8 7 302 1618 1610
-902 2 2 8 7 1168 1951 796
-903 2 2 8 7 386 2084 846
-904 2 2 8 7 244 1183 942
-905 2 2 8 7 297 1881 695
-906 2 2 8 7 892 1812 659
-907 2 2 8 7 694 1258 470
-908 2 2 8 7 440 1302 692
-909 2 2 8 7 1080 1161 490
-910 2 2 8 7 640 1253 1225
-911 2 2 8 7 1225 1253 248
-912 2 2 8 7 942 1183 481
-913 2 2 8 7 827 1730 381
-914 2 2 8 7 470 1313 694
-915 2 2 8 7 585 1730 827
-916 2 2 8 7 198 1342 747
-917 2 2 8 7 885 1572 347
-918 2 2 8 7 900 1288 510
-919 2 2 8 7 248 1288 900
-920 2 2 8 7 770 1217 291
-921 2 2 8 7 290 1086 735
-922 2 2 8 7 736 1085 289
-923 2 2 8 7 172 1190 1003
-924 2 2 8 7 718 1133 420
-925 2 2 8 7 902 1474 210
-926 2 2 8 7 827 1162 211
-927 2 2 8 7 940 1268 475
-928 2 2 8 7 41 1144 990
-929 2 2 8 7 614 1362 1093
-930 2 2 8 7 1093 1362 458
-931 2 2 8 7 47 1607 695
-932 2 2 8 7 879 1553 1180
-933 2 2 8 7 385 1850 812
-934 2 2 8 7 238 1063 904
-935 2 2 8 7 945 1016 428
-936 2 2 8 7 1309 1773 680
-937 2 2 8 7 709 1173 278
-938 2 2 8 7 169 1174 709
-939 2 2 8 7 796 1025 170
-940 2 2 8 7 539 1898 1283
-941 2 2 8 7 724 1882 380
-942 2 2 8 7 904 1063 438
-943 2 2 8 7 273 1829 1001
-944 2 2 8 7 513 1152 1005
-945 2 2 8 7 1118 1873 1551
-946 2 2 8 7 1552 1874 1119
-947 2 2 8 7 699 1302 440
-948 2 2 8 7 215 1302 699
-949 2 2 8 7 1005 1152 435
-950 2 2 8 7 575 1806 952
-951 2 2 8 7 335 1239 906
-952 2 2 8 7 779 1315 459
-953 2 2 8 7 414 2043 1607
-954 2 2 8 7 231 1340 767
-955 2 2 8 7 270 1525 1178
-956 2 2 8 7 177 1081 751
-957 2 2 8 7 268 1519 978
-958 2 2 8 7 614 1566 1362
-959 2 2 8 7 961 1467 1001
-960 2 2 8 7 289 1085 754
-961 2 2 8 7 755 1086 290
-962 2 2 8 7 681 1998 1654
-963 2 2 8 7 754 1085 390
-964 2 2 8 7 389 1086 755
-965 2 2 8 7 186 1859 1155
-966 2 2 8 7 1062 1776 736
-967 2 2 8 7 1657 1847 749
-968 2 2 8 7 818 1996 326
-969 2 2 8 7 312 1184 1002
-970 2 2 8 7 819 1860 175
-971 2 2 8 7 209 1660 702
-972 2 2 8 7 701 1281 276
-973 2 2 8 7 452 1649 734
-974 2 2 8 7 1002 1184 522
-975 2 2 8 7 254 1776 1062
-976 2 2 8 7 1195 1630 723
-977 2 2 8 7 1042 1792 570
-978 2 2 8 7 740 1708 223
-979 2 2 8 7 802 1459 119
-980 2 2 8 7 58 1458 801
-981 2 2 8 7 388 1013 852
-982 2 2 8 7 1576 1699 599
-983 2 2 8 7 600 1698 1575
-984 2 2 8 7 931 1916 622
-985 2 2 8 7 289 1640 736
-986 2 2 8 7 740 1595 320
-987 2 2 8 7 717 1794 220
-988 2 2 8 7 161 1105 746
-989 2 2 8 7 627 1763 1249
-990 2 2 8 7 478 1344 1027
-991 2 2 8 7 1754 1953 310
-992 2 2 8 7 498 1629 972
-993 2 2 8 7 1392 1919 309
-994 2 2 8 7 1131 1665 1581
-995 2 2 8 7 948 2075 308
-996 2 2 8 7 762 1490 311
-997 2 2 8 7 505 1490 762
-998 2 2 8 7 943 998 414
-999 2 2 8 7 1141 1237 182
-1000 2 2 8 7 668 1723 1619
-1001 2 2 8 7 582 1237 1141
-1002 2 2 8 7 790 1242 496
-1003 2 2 8 7 256 1701 909
-1004 2 2 8 7 1131 1581 547
-1005 2 2 8 7 1138 1688 449
-1006 2 2 8 7 1364 1440 486
-1007 2 2 8 7 487 1441 1365
-1008 2 2 8 7 1960 1974 746
-1009 2 2 8 7 164 2076 1320
-1010 2 2 8 7 735 1615 290
-1011 2 2 8 7 841 2010 892
-1012 2 2 8 7 257 1270 708
-1013 2 2 8 7 882 1050 464
-1014 2 2 8 7 1028 1982 343
-1015 2 2 8 7 708 1273 257
-1016 2 2 8 7 412 1417 1173
-1017 2 2 8 7 739 1732 407
-1018 2 2 8 7 1569 1671 295
-1019 2 2 8 7 772 1801 306
-1020 2 2 8 7 808 2065 327
-1021 2 2 8 7 780 1667 546
-1022 2 2 8 7 414 1607 1067
-1023 2 2 8 7 306 1667 780
-1024 2 2 8 7 438 1063 784
-1025 2 2 8 7 813 1915 202
-1026 2 2 8 7 351 1448 980
-1027 2 2 8 7 166 1186 1153
-1028 2 2 8 7 921 1774 630
-1029 2 2 8 7 175 1007 886
-1030 2 2 8 7 212 1950 797
-1031 2 2 8 7 206 1937 807
-1032 2 2 8 7 886 1007 413
-1033 2 2 8 7 175 1860 846
-1034 2 2 8 7 112 1325 874
-1035 2 2 8 7 873 1326 65
-1036 2 2 8 7 390 1305 754
-1037 2 2 8 7 755 1306 389
-1038 2 2 8 7 993 1298 241
-1039 2 2 8 7 1188 1894 1578
-1040 2 2 8 7 846 1007 175
-1041 2 2 8 7 720 1479 1061
-1042 2 2 8 7 474 1374 783
-1043 2 2 8 7 154 1056 155
-1044 2 2 8 7 711 1321 282
-1045 2 2 8 7 283 1322 712
-1046 2 2 8 7 746 1609 161
-1047 2 2 8 7 157 1013 994
-1048 2 2 8 7 783 1374 252
-1049 2 2 8 7 751 1521 177
-1050 2 2 8 7 994 1013 451
-1051 2 2 8 7 883 1161 403
-1052 2 2 8 7 958 1016 217
-1053 2 2 8 7 746 1974 880
-1054 2 2 8 7 306 1801 782
-1055 2 2 8 7 755 1212 189
-1056 2 2 8 7 442 1016 958
-1057 2 2 8 7 449 1688 1257
-1058 2 2 8 7 379 1886 1463
-1059 2 2 8 7 774 1573 347
-1060 2 2 8 7 302 1610 930
-1061 2 2 8 7 1498 1623 942
-1062 2 2 8 7 660 2039 1601
-1063 2 2 8 7 733 1268 17
-1064 2 2 8 7 22 1037 23
-1065 2 2 8 7 768 1142 295
-1066 2 2 8 7 342 1774 921
-1067 2 2 8 7 794 1846 393
-1068 2 2 8 7 992 1771 395
-1069 2 2 8 7 1468 1930 767
-1070 2 2 8 7 852 1013 157
-1071 2 2 8 7 267 1508 888
-1072 2 2 8 7 220 1282 717
-1073 2 2 8 7 371 1171 1026
-1074 2 2 8 7 803 1122 416
-1075 2 2 8 7 294 1623 1498
-1076 2 2 8 7 1425 1629 498
-1077 2 2 8 7 187 1122 803
-1078 2 2 8 7 386 1984 983
-1079 2 2 8 7 1035 1546 369
-1080 2 2 8 7 743 1616 307
-1081 2 2 8 7 167 1617 743
-1082 2 2 8 7 917 1210 176
-1083 2 2 8 7 1056 1345 538
-1084 2 2 8 7 645 1546 1035
-1085 2 2 8 7 254 1479 720
-1086 2 2 8 7 658 1602 1199
-1087 2 2 8 7 752 1140 499
-1088 2 2 8 7 24 903 25
-1089 2 2 8 7 859 1685 555
-1090 2 2 8 7 34 1069 858
-1091 2 2 8 7 232 1359 905
-1092 2 2 8 7 888 1508 552
-1093 2 2 8 7 563 1533 889
-1094 2 2 8 7 934 983 337
-1095 2 2 8 7 909 1701 1612
-1096 2 2 8 7 889 1533 272
-1097 2 2 8 7 398 1609 746
-1098 2 2 8 7 376 1114 787
-1099 2 2 8 7 785 1406 353
-1100 2 2 8 7 779 1127 37
-1101 2 2 8 7 395 1771 1522
-1102 2 2 8 7 308 2075 1391
-1103 2 2 8 7 218 1800 864
-1104 2 2 8 7 410 1873 1118
-1105 2 2 8 7 1119 1874 411
-1106 2 2 8 7 848 1150 311
-1107 2 2 8 7 633 1584 996
-1108 2 2 8 7 786 1815 423
-1109 2 2 8 7 996 1584 269
-1110 2 2 8 7 971 1559 368
-1111 2 2 8 7 869 1015 383
-1112 2 2 8 7 1559 2063 368
-1113 2 2 8 7 748 1608 524
-1114 2 2 8 7 858 1315 35
-1115 2 2 8 7 744 1590 518
-1116 2 2 8 7 517 1591 745
-1117 2 2 8 7 832 1695 1166
-1118 2 2 8 7 205 1590 744
-1119 2 2 8 7 745 1591 204
-1120 2 2 8 7 1054 1055 472
-1121 2 2 8 7 1077 1712 1695
-1122 2 2 8 7 396 1055 1054
-1123 2 2 8 7 1320 2076 685
-1124 2 2 8 7 1077 1695 402
-1125 2 2 8 7 725 1278 229
-1126 2 2 8 7 230 1279 726
-1127 2 2 8 7 728 1269 437
-1128 2 2 8 7 727 1923 283
-1129 2 2 8 7 1344 1744 1027
-1130 2 2 8 7 747 1585 198
-1131 2 2 8 7 444 1396 726
-1132 2 2 8 7 1047 1398 214
-1133 2 2 8 7 589 1398 1047
-1134 2 2 8 7 1197 1874 672
-1135 2 2 8 7 671 1873 1196
-1136 2 2 8 7 295 1586 747
-1137 2 2 8 7 759 1165 67
-1138 2 2 8 7 110 1164 758
-1139 2 2 8 7 161 1609 773
-1140 2 2 8 7 813 1104 497
-1141 2 2 8 7 315 1104 790
-1142 2 2 8 7 636 1994 826
-1143 2 2 8 7 826 1994 313
-1144 2 2 8 7 1035 1839 565
-1145 2 2 8 7 361 1847 1657
-1146 2 2 8 7 1071 1775 253
-1147 2 2 8 7 735 1775 1071
-1148 2 2 8 7 726 1396 230
-1149 2 2 8 7 229 1366 725
-1150 2 2 8 7 302 1509 821
-1151 2 2 8 7 1178 1525 603
-1152 2 2 8 7 725 1366 443
-1153 2 2 8 7 821 1509 529
-1154 2 2 8 7 180 1461 918
-1155 2 2 8 7 530 1638 760
-1156 2 2 8 7 328 1168 895
-1157 2 2 8 7 307 1605 741
-1158 2 2 8 7 840 1611 138
-1159 2 2 8 7 507 1462 806
-1160 2 2 8 7 806 1462 188
-1161 2 2 8 7 910 1433 577
-1162 2 2 8 7 1190 1614 1003
-1163 2 2 8 7 929 1394 716
-1164 2 2 8 7 895 1168 604
-1165 2 2 8 7 892 2010 362
-1166 2 2 8 7 852 1840 388
-1167 2 2 8 7 888 1134 582
-1168 2 2 8 7 347 2067 774
-1169 2 2 8 7 989 1377 637
-1170 2 2 8 7 848 1152 251
-1171 2 2 8 7 851 1121 186
-1172 2 2 8 7 435 1152 848
-1173 2 2 8 7 738 1502 242
-1174 2 2 8 7 1074 1650 249
-1175 2 2 8 7 1115 1162 488
-1176 2 2 8 7 443 1226 898
-1177 2 2 8 7 1230 1409 513
-1178 2 2 8 7 715 1388 920
-1179 2 2 8 7 908 1540 493
-1180 2 2 8 7 310 1953 1004
-1181 2 2 8 7 1317 1717 536
-1182 2 2 8 7 768 1708 1142
-1183 2 2 8 7 1142 1708 394
-1184 2 2 8 7 774 1139 388
-1185 2 2 8 7 750 1263 259
-1186 2 2 8 7 737 1248 425
-1187 2 2 8 7 144 1559 971
-1188 2 2 8 7 988 1403 181
-1189 2 2 8 7 1427 1801 391
-1190 2 2 8 7 605 1725 775
-1191 2 2 8 7 776 1726 606
-1192 2 2 8 7 876 1076 397
-1193 2 2 8 7 537 1219 825
-1194 2 2 8 7 976 2076 2040
-1195 2 2 8 7 1049 1678 678
-1196 2 2 8 7 675 1904 1119
-1197 2 2 8 7 1118 1905 676
-1198 2 2 8 7 1281 1720 608
-1199 2 2 8 7 280 1678 1049
-1200 2 2 8 7 820 1954 740
-1201 2 2 8 7 1029 1234 364
-1202 2 2 8 7 533 1234 1029
-1203 2 2 8 7 9 1243 757
-1204 2 2 8 7 791 1154 402
-1205 2 2 8 7 475 1268 733
-1206 2 2 8 7 1138 1987 168
-1207 2 2 8 7 181 1187 988
-1208 2 2 8 7 313 1434 794
-1209 2 2 8 7 299 1387 803
-1210 2 2 8 7 812 1096 385
-1211 2 2 8 7 403 1080 1004
-1212 2 2 8 7 800 1156 282
-1213 2 2 8 7 757 1765 9
-1214 2 2 8 7 782 1801 1427
-1215 2 2 8 7 214 1965 761
-1216 2 2 8 7 1225 1501 640
-1217 2 2 8 7 737 1429 134
-1218 2 2 8 7 698 1982 1028
-1219 2 2 8 7 1254 1431 303
-1220 2 2 8 7 1852 1911 1107
-1221 2 2 8 7 1616 1685 1224
-1222 2 2 8 7 307 1616 1224
-1223 2 2 8 7 526 1338 1037
-1224 2 2 8 7 404 1059 859
-1225 2 2 8 7 967 1917 159
-1226 2 2 8 7 661 1805 816
-1227 2 2 8 7 499 1542 752
-1228 2 2 8 7 422 1852 1107
-1229 2 2 8 7 632 1251 1017
-1230 2 2 8 7 47 1220 48
-1231 2 2 8 7 515 1209 1015
-1232 2 2 8 7 609 1894 1188
-1233 2 2 8 7 859 1059 230
-1234 2 2 8 7 835 1202 535
-1235 2 2 8 7 810 2069 417
-1236 2 2 8 7 129 1181 130
-1237 2 2 8 7 599 1699 1018
-1238 2 2 8 7 1019 1698 600
-1239 2 2 8 7 576 1159 872
-1240 2 2 8 7 999 1245 412
-1241 2 2 8 7 814 1393 159
-1242 2 2 8 7 318 1714 779
-1243 2 2 8 7 739 1453 366
-1244 2 2 8 7 169 1631 793
-1245 2 2 8 7 1002 1869 1574
-1246 2 2 8 7 1035 1539 221
-1247 2 2 8 7 152 935 153
-1248 2 2 8 7 978 1964 268
-1249 2 2 8 7 602 1680 957
-1250 2 2 8 7 875 1677 244
-1251 2 2 8 7 932 1657 749
-1252 2 2 8 7 204 1591 1039
-1253 2 2 8 7 1040 1590 205
-1254 2 2 8 7 750 1415 1014
-1255 2 2 8 7 125 1267 775
-1256 2 2 8 7 776 1266 52
-1257 2 2 8 7 170 1500 887
-1258 2 2 8 7 407 1732 808
-1259 2 2 8 7 941 1081 485
-1260 2 2 8 7 1272 1380 544
-1261 2 2 8 7 887 1500 541
-1262 2 2 8 7 1587 1622 416
-1263 2 2 8 7 632 1811 1251
-1264 2 2 8 7 1379 1998 681
-1265 2 2 8 7 195 1154 791
-1266 2 2 8 7 978 1519 564
-1267 2 2 8 7 855 1451 523
-1268 2 2 8 7 957 1680 336
-1269 2 2 8 7 316 1451 855
-1270 2 2 8 7 881 1149 194
-1271 2 2 8 7 448 1073 847
-1272 2 2 8 7 411 1874 1197
-1273 2 2 8 7 1196 1873 410
-1274 2 2 8 7 811 1861 220
-1275 2 2 8 7 773 2023 571
-1276 2 2 8 7 988 1867 1403
-1277 2 2 8 7 822 1256 397
-1278 2 2 8 7 685 2076 976
-1279 2 2 8 7 579 1861 811
-1280 2 2 8 7 843 1518 30
-1281 2 2 8 7 757 1243 464
-1282 2 2 8 7 285 1930 1468
-1283 2 2 8 7 223 1341 740
-1284 2 2 8 7 434 1050 882
-1285 2 2 8 7 772 1651 166
-1286 2 2 8 7 678 1473 1103
-1287 2 2 8 7 405 1156 800
-1288 2 2 8 7 822 1596 324
-1289 2 2 8 7 1092 1850 385
-1290 2 2 8 7 177 1521 820
-1291 2 2 8 7 330 2034 946
-1292 2 2 8 7 815 1122 187
-1293 2 2 8 7 305 1438 758
-1294 2 2 8 7 762 1524 505
-1295 2 2 8 7 758 1438 467
-1296 2 2 8 7 992 993 454
-1297 2 2 8 7 395 993 992
-1298 2 2 8 7 339 1736 756
-1299 2 2 8 7 707 1922 1756
-1300 2 2 8 7 475 1053 940
-1301 2 2 8 7 1463 1886 741
-1302 2 2 8 7 1368 1789 781
-1303 2 2 8 7 761 1509 302
-1304 2 2 8 7 920 1492 548
-1305 2 2 8 7 323 1492 920
-1306 2 2 8 7 391 1153 1072
-1307 2 2 8 7 158 1297 809
-1308 2 2 8 7 1072 1153 516
-1309 2 2 8 7 930 1401 1237
-1310 2 2 8 7 843 1343 455
-1311 2 2 8 7 553 1503 929
-1312 2 2 8 7 929 1503 322
-1313 2 2 8 7 265 1781 1437
-1314 2 2 8 7 340 1662 751
-1315 2 2 8 7 446 1222 1098
-1316 2 2 8 7 1098 1222 545
-1317 2 2 8 7 957 1335 602
-1318 2 2 8 7 756 1285 339
-1319 2 2 8 7 682 2061 852
-1320 2 2 8 7 922 1693 1137
-1321 2 2 8 7 1179 1389 617
-1322 2 2 8 7 908 1066 631
-1323 2 2 8 7 604 1807 895
-1324 2 2 8 7 1254 1898 539
-1325 2 2 8 7 184 1066 908
-1326 2 2 8 7 1730 1917 967
-1327 2 2 8 7 940 1053 431
-1328 2 2 8 7 895 1807 197
-1329 2 2 8 7 189 1306 755
-1330 2 2 8 7 1952 2052 905
-1331 2 2 8 7 769 2010 841
-1332 2 2 8 7 297 2043 998
-1333 2 2 8 7 334 1424 916
-1334 2 2 8 7 874 1325 467
-1335 2 2 8 7 466 1326 873
-1336 2 2 8 7 1547 2059 387
-1337 2 2 8 7 323 1908 845
-1338 2 2 8 7 844 1907 322
-1339 2 2 8 7 555 2054 859
-1340 2 2 8 7 845 1908 598
-1341 2 2 8 7 597 1907 844
-1342 2 2 8 7 86 1292 816
-1343 2 2 8 7 817 1293 91
-1344 2 2 8 7 476 1263 1213
-1345 2 2 8 7 1277 1539 890
-1346 2 2 8 7 466 1450 759
-1347 2 2 8 7 249 1335 957
-1348 2 2 8 7 290 1494 755
-1349 2 2 8 7 758 1582 305
-1350 2 2 8 7 459 1315 858
-1351 2 2 8 7 1305 1462 754
-1352 2 2 8 7 754 1833 289
-1353 2 2 8 7 43 972 44
-1354 2 2 8 7 608 1818 1281
-1355 2 2 8 7 188 1462 1305
-1356 2 2 8 7 627 1952 905
-1357 2 2 8 7 1126 1137 530
-1358 2 2 8 7 664 1984 819
-1359 2 2 8 7 183 1137 1126
-1360 2 2 8 7 956 1710 595
-1361 2 2 8 7 192 1789 1368
-1362 2 2 8 7 826 2045 636
-1363 2 2 8 7 790 1504 315
-1364 2 2 8 7 496 1504 790
-1365 2 2 8 7 143 1559 144
-1366 2 2 8 7 1708 1903 223
-1367 2 2 8 7 256 1642 832
-1368 2 2 8 7 1039 1591 1435
-1369 2 2 8 7 1436 1590 1040
-1370 2 2 8 7 901 1604 706
-1371 2 2 8 7 99 955 100
-1372 2 2 8 7 77 956 78
-1373 2 2 8 7 306 1652 772
-1374 2 2 8 7 797 1950 934
-1375 2 2 8 7 1171 1878 1026
-1376 2 2 8 7 250 1411 1258
-1377 2 2 8 7 307 1224 781
-1378 2 2 8 7 229 1076 876
-1379 2 2 8 7 1450 1583 759
-1380 2 2 8 7 798 1854 462
-1381 2 2 8 7 463 1855 799
-1382 2 2 8 7 838 1259 167
-1383 2 2 8 7 756 1385 240
-1384 2 2 8 7 304 1583 1450
-1385 2 2 8 7 416 1622 803
-1386 2 2 8 7 246 1594 760
-1387 2 2 8 7 628 1825 1250
-1388 2 2 8 7 1249 1824 627
-1389 2 2 8 7 541 1178 887
-1390 2 2 8 7 639 1383 1193
-1391 2 2 8 7 464 1414 757
-1392 2 2 8 7 476 1389 1179
-1393 2 2 8 7 189 1212 836
-1394 2 2 8 7 1362 1566 255
-1395 2 2 8 7 865 1360 54
-1396 2 2 8 7 123 1361 866
-1397 2 2 8 7 1274 2045 1935
-1398 2 2 8 7 798 1382 308
-1399 2 2 8 7 1239 1836 906
-1400 2 2 8 7 462 1382 798
-1401 2 2 8 7 782 1667 306
-1402 2 2 8 7 651 1966 906
-1403 2 2 8 7 327 1796 809
-1404 2 2 8 7 1014 1548 329
-1405 2 2 8 7 723 1622 1587
-1406 2 2 8 7 906 1966 335
-1407 2 2 8 7 533 1541 1464
-1408 2 2 8 7 809 1798 158
-1409 2 2 8 7 931 1513 729
-1410 2 2 8 7 263 1012 986
-1411 2 2 8 7 1003 1739 172
-1412 2 2 8 7 244 1634 875
-1413 2 2 8 7 665 1739 1003
-1414 2 2 8 7 1193 1383 270
-1415 2 2 8 7 1520 1956 700
-1416 2 2 8 7 331 1537 838
-1417 2 2 8 7 771 1283 171
-1418 2 2 8 7 591 1441 1058
-1419 2 2 8 7 1057 1440 590
-1420 2 2 8 7 413 2079 970
-1421 2 2 8 7 633 1460 1114
-1422 2 2 8 7 1502 1529 616
-1423 2 2 8 7 580 1781 812
-1424 2 2 8 7 347 1573 885
-1425 2 2 8 7 1114 1460 201
-1426 2 2 8 7 552 1611 840
-1427 2 2 8 7 263 1318 1012
-1428 2 2 8 7 323 1388 866
-1429 2 2 8 7 388 1573 774
-1430 2 2 8 7 1095 1314 502
-1431 2 2 8 7 866 1388 492
-1432 2 2 8 7 311 1150 824
-1433 2 2 8 7 849 1110 450
-1434 2 2 8 7 839 1959 742
-1435 2 2 8 7 1017 1477 377
-1436 2 2 8 7 1125 1889 193
-1437 2 2 8 7 361 1687 1283
-1438 2 2 8 7 1219 1608 748
-1439 2 2 8 7 263 1608 1219
-1440 2 2 8 7 1069 1976 370
-1441 2 2 8 7 834 1179 617
-1442 2 2 8 7 202 1797 813
-1443 2 2 8 7 827 1906 585
-1444 2 2 8 7 883 1261 366
-1445 2 2 8 7 1029 1728 952
-1446 2 2 8 7 1153 1186 516
-1447 2 2 8 7 983 1673 833
-1448 2 2 8 7 780 1924 306
-1449 2 2 8 7 535 1592 835
-1450 2 2 8 7 384 1702 1074
-1451 2 2 8 7 1574 1869 190
-1452 2 2 8 7 791 1232 195
-1453 2 2 8 7 1098 1411 250
-1454 2 2 8 7 308 1733 798
-1455 2 2 8 7 837 1950 212
-1456 2 2 8 7 209 1672 795
-1457 2 2 8 7 997 1402 641
-1458 2 2 8 7 867 1402 222
-1459 2 2 8 7 1189 1198 536
-1460 2 2 8 7 983 1984 664
-1461 2 2 8 7 816 1805 87
-1462 2 2 8 7 90 1804 817
-1463 2 2 8 7 767 1930 488
-1464 2 2 8 7 295 1433 768
-1465 2 2 8 7 381 1162 827
-1466 2 2 8 7 482 1446 831
-1467 2 2 8 7 1032 1865 409
-1468 2 2 8 7 201 1795 977
-1469 2 2 8 7 1061 1479 471
-1470 2 2 8 7 573 1099 953
-1471 2 2 8 7 954 1100 572
-1472 2 2 8 7 291 1446 770
-1473 2 2 8 7 798 1369 97
-1474 2 2 8 7 80 1370 799
-1475 2 2 8 7 1007 2079 413
-1476 2 2 8 7 1041 1331 252
-1477 2 2 8 7 986 1012 423
-1478 2 2 8 7 865 1394 322
-1479 2 2 8 7 677 1671 1569
-1480 2 2 8 7 491 1394 865
-1481 2 2 8 7 1846 2071 393
-1482 2 2 8 7 977 1795 651
-1483 2 2 8 7 922 1977 321
-1484 2 2 8 7 523 1125 855
-1485 2 2 8 7 1073 1915 813
-1486 2 2 8 7 521 1550 1413
-1487 2 2 8 7 654 1913 943
-1488 2 2 8 7 943 1913 200
-1489 2 2 8 7 1596 1764 324
-1490 2 2 8 7 1424 1515 916
-1491 2 2 8 7 1012 1318 536
-1492 2 2 8 7 659 1812 1739
-1493 2 2 8 7 432 1111 949
-1494 2 2 8 7 1005 1230 513
-1495 2 2 8 7 789 1838 345
-1496 2 2 8 7 982 2073 408
-1497 2 2 8 7 1321 1788 780
-1498 2 2 8 7 781 1789 1322
-1499 2 2 8 7 779 1532 318
-1500 2 2 8 7 880 1520 398
-1501 2 2 8 7 413 1772 924
-1502 2 2 8 7 825 1624 537
-1503 2 2 8 7 173 1624 825
-1504 2 2 8 7 875 1387 299
-1505 2 2 8 7 914 1703 334
-1506 2 2 8 7 1813 2077 752
-1507 2 2 8 7 938 1454 400
-1508 2 2 8 7 401 1455 939
-1509 2 2 8 7 775 1496 296
-1510 2 2 8 7 297 1497 776
-1511 2 2 8 7 1680 2073 982
-1512 2 2 8 7 331 1767 1537
-1513 2 2 8 7 1085 1885 390
-1514 2 2 8 7 389 1884 1086
-1515 2 2 8 7 1016 1023 428
-1516 2 2 8 7 965 1618 821
-1517 2 2 8 7 1000 1200 146
-1518 2 2 8 7 975 1170 457
-1519 2 2 8 7 784 1553 179
-1520 2 2 8 7 899 1368 444
-1521 2 2 8 7 163 1170 975
-1522 2 2 8 7 442 1023 1016
-1523 2 2 8 7 316 1751 793
-1524 2 2 8 7 639 1897 946
-1525 2 2 8 7 946 1897 222
-1526 2 2 8 7 706 2013 1933
-1527 2 2 8 7 938 1354 558
-1528 2 2 8 7 559 1355 939
-1529 2 2 8 7 1134 1749 429
-1530 2 2 8 7 370 1506 959
-1531 2 2 8 7 476 1213 1187
-1532 2 2 8 7 778 1474 365
-1533 2 2 8 7 390 1885 1436
-1534 2 2 8 7 1435 1884 389
-1535 2 2 8 7 537 1624 800
-1536 2 2 8 7 259 1179 834
-1537 2 2 8 7 429 1749 1163
-1538 2 2 8 7 1093 1806 1404
-1539 2 2 8 7 1592 2072 835
-1540 2 2 8 7 489 1461 1195
-1541 2 2 8 7 844 1972 229
-1542 2 2 8 7 441 1148 853
-1543 2 2 8 7 804 1749 314
-1544 2 2 8 7 823 2059 1547
-1545 2 2 8 7 459 1532 779
-1546 2 2 8 7 1195 1461 669
-1547 2 2 8 7 252 2058 783
-1548 2 2 8 7 818 1762 195
-1549 2 2 8 7 460 1407 801
-1550 2 2 8 7 802 1408 461
-1551 2 2 8 7 399 1738 1025
-1552 2 2 8 7 1020 1520 700
-1553 2 2 8 7 1935 2045 344
-1554 2 2 8 7 1093 1404 614
-1555 2 2 8 7 803 1579 187
-1556 2 2 8 7 227 1083 924
-1557 2 2 8 7 40 1144 41
-1558 2 2 8 7 529 1215 821
-1559 2 2 8 7 219 1989 857
-1560 2 2 8 7 854 1515 511
-1561 2 2 8 7 391 1801 1153
-1562 2 2 8 7 159 1917 788
-1563 2 2 8 7 1153 1801 772
-1564 2 2 8 7 803 1622 299
-1565 2 2 8 7 567 1989 1052
-1566 2 2 8 7 97 1854 798
-1567 2 2 8 7 799 1855 80
-1568 2 2 8 7 1116 1593 427
-1569 2 2 8 7 1654 1998 198
-1570 2 2 8 7 596 1641 804
-1571 2 2 8 7 1416 1477 1017
-1572 2 2 8 7 1072 1112 243
-1573 2 2 8 7 516 1112 1072
-1574 2 2 8 7 1234 1638 364
-1575 2 2 8 7 441 1157 933
-1576 2 2 8 7 427 1593 1130
-1577 2 2 8 7 1406 1846 226
-1578 2 2 8 7 1285 1312 512
-1579 2 2 8 7 924 2068 375
-1580 2 2 8 7 345 1333 789
-1581 2 2 8 7 760 1638 1234
-1582 2 2 8 7 389 1306 896
-1583 2 2 8 7 897 1305 390
-1584 2 2 8 7 417 2069 933
-1585 2 2 8 7 863 1262 328
-1586 2 2 8 7 313 1808 826
-1587 2 2 8 7 1108 1514 514
-1588 2 2 8 7 427 1692 1115
-1589 2 2 8 7 826 1810 216
-1590 2 2 8 7 787 1437 376
-1591 2 2 8 7 319 1974 1960
-1592 2 2 8 7 857 1977 601
-1593 2 2 8 7 573 1454 1099
-1594 2 2 8 7 1100 1455 572
-1595 2 2 8 7 1149 1635 194
-1596 2 2 8 7 903 1109 25
-1597 2 2 8 7 830 1399 74
-1598 2 2 8 7 103 1400 831
-1599 2 2 8 7 341 2072 1592
-1600 2 2 8 7 424 1729 833
-1601 2 2 8 7 1234 1482 246
-1602 2 2 8 7 787 1373 494
-1603 2 2 8 7 788 1413 159
-1604 2 2 8 7 1526 1989 567
-1605 2 2 8 7 494 1920 787
-1606 2 2 8 7 1166 1695 566
-1607 2 2 8 7 801 1458 460
-1608 2 2 8 7 461 1459 802
-1609 2 2 8 7 1149 1514 619
-1610 2 2 8 7 793 1371 169
-1611 2 2 8 7 898 1226 191
-1612 2 2 8 7 836 1212 435
-1613 2 2 8 7 871 1155 469
-1614 2 2 8 7 308 1382 805
-1615 2 2 8 7 258 1148 933
-1616 2 2 8 7 1245 1417 412
-1617 2 2 8 7 1030 1560 499
-1618 2 2 8 7 933 1148 441
-1619 2 2 8 7 792 1451 316
-1620 2 2 8 7 244 1677 789
-1621 2 2 8 7 872 1159 269
-1622 2 2 8 7 1786 2078 700
-1623 2 2 8 7 543 1677 875
-1624 2 2 8 7 1720 1889 608
-1625 2 2 8 7 909 1642 256
-1626 2 2 8 7 536 1717 1189
-1627 2 2 8 7 314 1134 888
-1628 2 2 8 7 1359 1763 905
-1629 2 2 8 7 420 1683 870
-1630 2 2 8 7 1600 1726 50
-1631 2 2 8 7 127 1725 1599
-1632 2 2 8 7 873 1357 418
-1633 2 2 8 7 419 1356 874
-1634 2 2 8 7 523 1499 1125
-1635 2 2 8 7 682 1167 957
-1636 2 2 8 7 514 1149 881
-1637 2 2 8 7 799 1528 463
-1638 2 2 8 7 281 1564 964
-1639 2 2 8 7 250 1258 1044
-1640 2 2 8 7 809 1297 407
-1641 2 2 8 7 1461 1755 918
-1642 2 2 8 7 288 2077 1813
-1643 2 2 8 7 801 1535 58
-1644 2 2 8 7 119 1534 802
-1645 2 2 8 7 1282 1471 382
-1646 2 2 8 7 1309 1692 427
-1647 2 2 8 7 877 1349 93
-1648 2 2 8 7 84 1350 878
-1649 2 2 8 7 1128 1910 579
-1650 2 2 8 7 508 1160 1129
-1651 2 2 8 7 676 2011 1046
-1652 2 2 8 7 1045 2012 675
-1653 2 2 8 7 833 1673 210
-1654 2 2 8 7 207 1198 1189
-1655 2 2 8 7 1108 1568 1514
-1656 2 2 8 7 1319 1723 668
-1657 2 2 8 7 916 1364 486
-1658 2 2 8 7 236 1364 916
-1659 2 2 8 7 923 1307 325
-1660 2 2 8 7 472 1307 923
-1661 2 2 8 7 1619 1723 343
-1662 2 2 8 7 74 1760 830
-1663 2 2 8 7 831 1761 103
-1664 2 2 8 7 435 1822 836
-1665 2 2 8 7 1604 2013 706
-1666 2 2 8 7 166 1256 822
-1667 2 2 8 7 805 1359 232
-1668 2 2 8 7 924 1772 227
-1669 2 2 8 7 418 2049 1009
-1670 2 2 8 7 1010 2050 419
-1671 2 2 8 7 242 1161 883
-1672 2 2 8 7 995 1236 187
-1673 2 2 8 7 1113 1756 303
-1674 2 2 8 7 1273 1352 501
-1675 2 2 8 7 551 1236 995
-1676 2 2 8 7 949 1111 161
-1677 2 2 8 7 1402 1934 641
-1678 2 2 8 7 707 1756 1113
-1679 2 2 8 7 1025 1738 1500
-1680 2 2 8 7 264 1661 1275
-1681 2 2 8 7 830 1501 483
-1682 2 2 8 7 862 1815 325
-1683 2 2 8 7 176 1445 917
-1684 2 2 8 7 1406 1700 353
-1685 2 2 8 7 1009 2049 1556
-1686 2 2 8 7 1557 2050 1010
-1687 2 2 8 7 354 1260 828
-1688 2 2 8 7 382 1471 974
-1689 2 2 8 7 957 2061 682
-1690 2 2 8 7 336 2061 957
-1691 2 2 8 7 1000 1493 531
-1692 2 2 8 7 133 1694 134
-1693 2 2 8 7 834 1793 457
-1694 2 2 8 7 879 1180 357
-1695 2 2 8 7 1176 2091 312
-1696 2 2 8 7 867 1193 541
-1697 2 2 8 7 317 1466 864
-1698 2 2 8 7 785 1846 1406
-1699 2 2 8 7 817 1504 1293
-1700 2 2 8 7 1066 1601 396
-1701 2 2 8 7 366 1614 1052
-1702 2 2 8 7 768 1903 1708
-1703 2 2 8 7 862 1339 423
-1704 2 2 8 7 953 1099 418
-1705 2 2 8 7 419 1100 954
-1706 2 2 8 7 890 1719 277
-1707 2 2 8 7 565 1719 890
-1708 2 2 8 7 356 1809 907
-1709 2 2 8 7 1194 1787 447
-1710 2 2 8 7 227 1772 944
-1711 2 2 8 7 662 2052 915
-1712 2 2 8 7 915 2052 332
-1713 2 2 8 7 836 1822 311
-1714 2 2 8 7 952 1806 178
-1715 2 2 8 7 119 1459 120
-1716 2 2 8 7 57 1458 58
-1717 2 2 8 7 806 1424 334
-1718 2 2 8 7 188 1663 806
-1719 2 2 8 7 1129 1160 456
-1720 2 2 8 7 233 1918 860
-1721 2 2 8 7 1117 1429 425
-1722 2 2 8 7 527 1689 1448
-1723 2 2 8 7 146 1200 147
-1724 2 2 8 7 812 1990 580
-1725 2 2 8 7 946 2034 639
-1726 2 2 8 7 230 1890 845
-1727 2 2 8 7 813 1544 333
-1728 2 2 8 7 1076 1972 553
-1729 2 2 8 7 497 1544 813
-1730 2 2 8 7 1022 1948 362
-1731 2 2 8 7 910 1903 1433
-1732 2 2 8 7 738 1297 1008
-1733 2 2 8 7 853 1244 441
-1734 2 2 8 7 581 1444 1077
-1735 2 2 8 7 1077 1444 266
-1736 2 2 8 7 162 1244 853
-1737 2 2 8 7 210 1737 833
-1738 2 2 8 7 404 1259 838
-1739 2 2 8 7 537 1318 1219
-1740 2 2 8 7 907 1691 171
-1741 2 2 8 7 1177 1517 344
-1742 2 2 8 7 825 1832 349
-1743 2 2 8 7 666 1517 1177
-1744 2 2 8 7 1175 1963 689
-1745 2 2 8 7 320 1731 820
-1746 2 2 8 7 864 1945 218
-1747 2 2 8 7 1911 1961 1096
-1748 2 2 8 7 980 1304 594
-1749 2 2 8 7 338 1442 810
-1750 2 2 8 7 149 1975 894
-1751 2 2 8 7 811 1420 310
-1752 2 2 8 7 846 2084 2079
-1753 2 2 8 7 657 2030 1337
-1754 2 2 8 7 2055 2063 870
-1755 2 2 8 7 488 1116 1115
-1756 2 2 8 7 1273 2027 1352
-1757 2 2 8 7 833 1729 337
-1758 2 2 8 7 175 1604 819
-1759 2 2 8 7 1115 1116 427
-1760 2 2 8 7 824 1485 174
-1761 2 2 8 7 1319 1348 197
-1762 2 2 8 7 668 1348 1319
-1763 2 2 8 7 846 1860 386
-1764 2 2 8 7 24 1338 903
-1765 2 2 8 7 821 1618 302
-1766 2 2 8 7 541 1193 1178
-1767 2 2 8 7 1178 1193 270
-1768 2 2 8 7 1499 1818 1125
-1769 2 2 8 7 1465 1722 570
-1770 2 2 8 7 1343 1560 1030
-1771 2 2 8 7 303 1431 1113
-1772 2 2 8 7 1002 1574 550
-1773 2 2 8 7 31 1158 32
-1774 2 2 8 7 631 2006 908
-1775 2 2 8 7 211 2009 827
-1776 2 2 8 7 908 2006 317
-1777 2 2 8 7 618 1868 1063
-1778 2 2 8 7 1063 1868 784
-1779 2 2 8 7 566 1287 1166
-1780 2 2 8 7 1166 1287 164
-1781 2 2 8 7 120 1207 121
-1782 2 2 8 7 56 1206 57
-1783 2 2 8 7 33 1069 34
-1784 2 2 8 7 840 1779 552
-1785 2 2 8 7 816 1658 315
-1786 2 2 8 7 815 1670 293
-1787 2 2 8 7 505 1524 842
-1788 2 2 8 7 647 1629 1191
-1789 2 2 8 7 842 1524 237
-1790 2 2 8 7 553 1972 1503
-1791 2 2 8 7 578 1252 1006
-1792 2 2 8 7 159 1393 967
-1793 2 2 8 7 332 2052 1952
-1794 2 2 8 7 265 1911 1096
-1795 2 2 8 7 1421 1707 613
-1796 2 2 8 7 311 1822 848
-1797 2 2 8 7 324 1344 822
-1798 2 2 8 7 14 1990 1850
-1799 2 2 8 7 1267 1496 775
-1800 2 2 8 7 776 1497 1266
-1801 2 2 8 7 952 2067 347
-1802 2 2 8 7 673 2067 952
-1803 2 2 8 7 370 1887 858
-1804 2 2 8 7 1099 1454 261
-1805 2 2 8 7 262 1455 1100
-1806 2 2 8 7 483 1399 830
-1807 2 2 8 7 831 1400 482
-1808 2 2 8 7 820 1426 177
-1809 2 2 8 7 945 1959 839
-1810 2 2 8 7 357 1959 945
-1811 2 2 8 7 118 1752 1534
-1812 2 2 8 7 1535 1753 59
-1813 2 2 8 7 195 1669 1021
-1814 2 2 8 7 1209 1716 1015
-1815 2 2 8 7 333 1711 847
-1816 2 2 8 7 906 1260 651
-1817 2 2 8 7 646 1985 1102
-1818 2 2 8 7 191 2081 898
-1819 2 2 8 7 601 1995 1102
-1820 2 2 8 7 976 1707 685
-1821 2 2 8 7 854 1988 1515
-1822 2 2 8 7 220 1794 841
-1823 2 2 8 7 822 1757 166
-1824 2 2 8 7 257 1110 989
-1825 2 2 8 7 1077 1154 581
-1826 2 2 8 7 1444 1778 266
-1827 2 2 8 7 165 1580 1130
-1828 2 2 8 7 1047 1941 425
-1829 2 2 8 7 511 1578 854
-1830 2 2 8 7 440 1412 1060
-1831 2 2 8 7 135 2038 136
-1832 2 2 8 7 1184 1419 522
-1833 2 2 8 7 1815 1901 325
-1834 2 2 8 7 1392 1734 635
-1835 2 2 8 7 634 1733 1391
-1836 2 2 8 7 1141 1247 582
-1837 2 2 8 7 458 1362 869
-1838 2 2 8 7 1213 2074 1187
-1839 2 2 8 7 869 1362 255
-1840 2 2 8 7 1117 2038 135
-1841 2 2 8 7 298 2078 901
-1842 2 2 8 7 1163 1941 214
-1843 2 2 8 7 181 1389 1187
-1844 2 2 8 7 804 1941 1163
-1845 2 2 8 7 1211 1314 264
-1846 2 2 8 7 397 1596 822
-1847 2 2 8 7 424 1949 1024
-1848 2 2 8 7 1011 1909 574
-1849 2 2 8 7 601 1977 922
-1850 2 2 8 7 366 1261 1003
-1851 2 2 8 7 848 1822 435
-1852 2 2 8 7 11 1034 12
-1853 2 2 8 7 445 1208 928
-1854 2 2 8 7 928 1208 226
-1855 2 2 8 7 825 1386 173
-1856 2 2 8 7 326 1995 1644
-1857 2 2 8 7 621 1899 1700
-1858 2 2 8 7 823 1547 231
-1859 2 2 8 7 131 1038 132
-1860 2 2 8 7 886 2013 175
-1861 2 2 8 7 200 1674 929
-1862 2 2 8 7 139 1308 140
-1863 2 2 8 7 990 1144 426
-1864 2 2 8 7 853 1921 442
-1865 2 2 8 7 1083 2068 924
-1866 2 2 8 7 224 1520 880
-1867 2 2 8 7 16 1523 17
-1868 2 2 8 7 1537 1767 722
-1869 2 2 8 7 984 1123 430
-1870 2 2 8 7 174 1928 824
-1871 2 2 8 7 388 1139 1013
-1872 2 2 8 7 921 1222 446
-1873 2 2 8 7 208 1222 921
-1874 2 2 8 7 1083 1780 433
-1875 2 2 8 7 1042 1721 190
-1876 2 2 8 7 780 1788 1226
-1877 2 2 8 7 222 1897 867
-1878 2 2 8 7 1226 1788 191
-1879 2 2 8 7 619 1635 1149
-1880 2 2 8 7 1088 1682 293
-1881 2 2 8 7 456 1351 948
-1882 2 2 8 7 1053 1240 431
-1883 2 2 8 7 1515 1988 236
-1884 2 2 8 7 658 1682 1088
-1885 2 2 8 7 189 1900 1306
-1886 2 2 8 7 1066 2031 1601
-1887 2 2 8 7 408 1676 982
-1888 2 2 8 7 368 2063 2055
-1889 2 2 8 7 1089 1111 432
-1890 2 2 8 7 436 1296 1082
-1891 2 2 8 7 938 1978 1354
-1892 2 2 8 7 1355 1979 939
-1893 2 2 8 7 1249 1763 462
-1894 2 2 8 7 508 1129 987
-1895 2 2 8 7 233 1457 847
-1896 2 2 8 7 880 1974 724
-1897 2 2 8 7 221 1277 868
-1898 2 2 8 7 437 1312 1084
-1899 2 2 8 7 392 1276 961
-1900 2 2 8 7 222 1402 997
-1901 2 2 8 7 935 1345 153
-1902 2 2 8 7 150 1182 151
-1903 2 2 8 7 234 1123 984
-1904 2 2 8 7 434 1235 1050
-1905 2 2 8 7 589 2041 1384
-1906 2 2 8 7 1718 2041 589
-1907 2 2 8 7 455 1518 843
-1908 2 2 8 7 45 1067 46
-1909 2 2 8 7 43 1395 972
-1910 2 2 8 7 856 1948 450
-1911 2 2 8 7 433 1780 1113
-1912 2 2 8 7 1036 1157 441
-1913 2 2 8 7 398 1520 1020
-1914 2 2 8 7 966 1171 371
-1915 2 2 8 7 954 1356 419
-1916 2 2 8 7 418 1357 953
-1917 2 2 8 7 448 1171 966
-1918 2 2 8 7 423 1815 862
-1919 2 2 8 7 230 1396 859
-1920 2 2 8 7 54 1790 865
-1921 2 2 8 7 866 1791 123
-1922 2 2 8 7 1210 1416 176
-1923 2 2 8 7 1023 1316 428
-1924 2 2 8 7 1202 1697 288
-1925 2 2 8 7 1583 1894 556
-1926 2 2 8 7 557 1895 1582
-1927 2 2 8 7 714 1697 1202
-1928 2 2 8 7 882 1516 434
-1929 2 2 8 7 1213 1891 765
-1930 2 2 8 7 946 1176 550
-1931 2 2 8 7 856 1358 172
-1932 2 2 8 7 871 1648 338
-1933 2 2 8 7 403 1261 883
-1934 2 2 8 7 30 1518 31
-1935 2 2 8 7 484 1210 919
-1936 2 2 8 7 311 1490 836
-1937 2 2 8 7 929 1674 553
-1938 2 2 8 7 836 1491 189
-1939 2 2 8 7 215 1290 870
-1940 2 2 8 7 888 1947 267
-1941 2 2 8 7 957 1167 249
-1942 2 2 8 7 548 1890 1059
-1943 2 2 8 7 1046 2011 291
-1944 2 2 8 7 292 2012 1045
-1945 2 2 8 7 903 2002 339
-1946 2 2 8 7 928 1423 350
-1947 2 2 8 7 1081 1295 485
-1948 2 2 8 7 1141 1412 440
-1949 2 2 8 7 905 2052 662
-1950 2 2 8 7 869 1870 458
-1951 2 2 8 7 1383 2034 1735
-1952 2 2 8 7 1383 1735 592
-1953 2 2 8 7 210 2066 902
-1954 2 2 8 7 425 1941 1641
-1955 2 2 8 7 865 1790 491
-1956 2 2 8 7 492 1791 866
-1957 2 2 8 7 383 1872 869
-1958 2 2 8 7 329 1891 1213
-1959 2 2 8 7 838 1537 404
-1960 2 2 8 7 610 2026 896
-1961 2 2 8 7 356 2092 1809
-1962 2 2 8 7 50 1726 51
-1963 2 2 8 7 126 1725 127
-1964 2 2 8 7 1316 1380 428
-1965 2 2 8 7 415 1693 1270
-1966 2 2 8 7 978 1143 584
-1967 2 2 8 7 492 1496 1267
-1968 2 2 8 7 1266 1497 491
-1969 2 2 8 7 318 1143 978
-1970 2 2 8 7 193 1351 855
-1971 2 2 8 7 137 1543 840
-1972 2 2 8 7 414 1191 943
-1973 2 2 8 7 987 1129 232
-1974 2 2 8 7 854 1578 304
-1975 2 2 8 7 959 1506 221
-1976 2 2 8 7 970 1794 717
-1977 2 2 8 7 158 1339 862
-1978 2 2 8 7 1191 1629 279
-1979 2 2 8 7 40 2090 1144
-1980 2 2 8 7 237 1664 842
-1981 2 2 8 7 556 1894 1328
-1982 2 2 8 7 1329 1895 557
-1983 2 2 8 7 436 1301 911
-1984 2 2 8 7 846 2079 1007
-1985 2 2 8 7 863 1340 231
-1986 2 2 8 7 859 2054 404
-1987 2 2 8 7 1031 1491 505
-1988 2 2 8 7 177 1426 950
-1989 2 2 8 7 1480 2046 409
-1990 2 2 8 7 269 1159 996
-1991 2 2 8 7 950 1426 509
-1992 2 2 8 7 93 1940 877
-1993 2 2 8 7 878 1939 84
-1994 2 2 8 7 1198 1902 786
-1995 2 2 8 7 158 1405 1008
-1996 2 2 8 7 877 1940 496
-1997 2 2 8 7 497 1939 878
-1998 2 2 8 7 207 1902 1198
-1999 2 2 8 7 892 1420 811
-2000 2 2 8 7 450 2051 856
-2001 2 2 8 7 876 1366 229
-2002 2 2 8 7 469 1087 1084
-2003 2 2 8 7 342 1264 937
-2004 2 2 8 7 937 1264 454
-2005 2 2 8 7 703 1764 1596
-2006 2 2 8 7 1145 1909 1011
-2007 2 2 8 7 1084 1087 437
-2008 2 2 8 7 996 1159 452
-2009 2 2 8 7 408 2074 1676
-2010 2 2 8 7 1513 1756 729
-2011 2 2 8 7 842 1438 305
-2012 2 2 8 7 141 1133 142
-2013 2 2 8 7 920 1681 199
-2014 2 2 8 7 719 1987 1294
-2015 2 2 8 7 844 1626 597
-2016 2 2 8 7 598 1627 845
-2017 2 2 8 7 367 1684 951
-2018 2 2 8 7 1211 1231 502
-2019 2 2 8 7 951 1684 562
-2020 2 2 8 7 332 1242 915
-2021 2 2 8 7 902 2014 359
-2022 2 2 8 7 858 1887 459
-2023 2 2 8 7 1124 1298 519
-2024 2 2 8 7 860 1918 463
-2025 2 2 8 7 251 1430 848
-2026 2 2 8 7 116 1064 117
-2027 2 2 8 7 60 1065 61
-2028 2 2 8 7 548 1681 920
-2029 2 2 8 7 529 1397 1215
-2030 2 2 8 7 345 1838 911
-2031 2 2 8 7 446 1817 1803
-2032 2 2 8 7 904 1736 339
-2033 2 2 8 7 466 1988 854
-2034 2 2 8 7 536 1198 1012
-2035 2 2 8 7 1177 2045 826
-2036 2 2 8 7 847 1457 448
-2037 2 2 8 7 1013 1139 451
-2038 2 2 8 7 1174 1878 638
-2039 2 2 8 7 1293 1504 496
-2040 2 2 8 7 845 1492 323
-2041 2 2 8 7 343 1723 1028
-2042 2 2 8 7 622 1916 1898
-2043 2 2 8 7 322 1503 844
-2044 2 2 8 7 1850 1990 812
-2045 2 2 8 7 481 1410 894
-2046 2 2 8 7 30 1639 843
-2047 2 2 8 7 660 1828 1294
-2048 2 2 8 7 541 1738 867
-2049 2 2 8 7 582 1947 888
-2050 2 2 8 7 630 2083 1048
-2051 2 2 8 7 1270 1693 708
-2052 2 2 8 7 637 1289 1120
-2053 2 2 8 7 862 1405 158
-2054 2 2 8 7 463 1528 860
-2055 2 2 8 7 1027 1466 478
-2056 2 2 8 7 64 1357 873
-2057 2 2 8 7 874 1356 113
-2058 2 2 8 7 963 2068 433
-2059 2 2 8 7 304 1450 854
-2060 2 2 8 7 854 1450 466
-2061 2 2 8 7 397 1799 876
-2062 2 2 8 7 1028 1123 234
-2063 2 2 8 7 431 1589 940
-2064 2 2 8 7 1101 1811 247
-2065 2 2 8 7 641 1934 863
-2066 2 2 8 7 383 1569 1342
-2067 2 2 8 7 250 1300 1098
-2068 2 2 8 7 1342 1569 747
-2069 2 2 8 7 1003 1261 665
-2070 2 2 8 7 926 1241 218
-2071 2 2 8 7 1008 1297 158
-2072 2 2 8 7 1168 1882 604
-2073 2 2 8 7 425 1248 1047
-2074 2 2 8 7 625 1618 965
-2075 2 2 8 7 257 1273 1214
-2076 2 2 8 7 542 1123 1028
-2077 2 2 8 7 322 1907 865
-2078 2 2 8 7 866 1908 323
-2079 2 2 8 7 393 1145 1011
-2080 2 2 8 7 872 1414 464
-2081 2 2 8 7 855 1759 316
-2082 2 2 8 7 457 1170 1151
-2083 2 2 8 7 1151 1170 502
-2084 2 2 8 7 889 1309 427
-2085 2 2 8 7 269 1414 872
-2086 2 2 8 7 972 1395 498
-2087 2 2 8 7 376 1527 1114
-2088 2 2 8 7 1080 1851 1004
-2089 2 2 8 7 54 1360 55
-2090 2 2 8 7 122 1361 123
-2091 2 2 8 7 11 1530 1034
-2092 2 2 8 7 160 1613 1209
-2093 2 2 8 7 1209 1613 677
-2094 2 2 8 7 1686 1804 89
-2095 2 2 8 7 88 1805 1686
-2096 2 2 8 7 464 1545 872
-2097 2 2 8 7 1223 1508 267
-2098 2 2 8 7 257 1214 1110
-2099 2 2 8 7 652 1508 1223
-2100 2 2 8 7 325 1645 862
-2101 2 2 8 7 1258 2035 1044
-2102 2 2 8 7 363 1993 958
-2103 2 2 8 7 864 1540 317
-2104 2 2 8 7 503 1111 1089
-2105 2 2 8 7 955 1709 100
-2106 2 2 8 7 77 1710 956
-2107 2 2 8 7 947 1993 363
-2108 2 2 8 7 2079 2084 355
-2109 2 2 8 7 99 1746 955
-2110 2 2 8 7 956 1745 78
-2111 2 2 8 7 1034 1632 12
-2112 2 2 8 7 520 1387 875
-2113 2 2 8 7 670 1587 1218
-2114 2 2 8 7 868 1532 459
-2115 2 2 8 7 1925 1973 770
-2116 2 2 8 7 1218 1587 416
-2117 2 2 8 7 561 1381 1376
-2118 2 2 8 7 428 1380 879
-2119 2 2 8 7 358 1842 1199
-2120 2 2 8 7 1131 1322 283
-2121 2 2 8 7 547 1322 1131
-2122 2 2 8 7 563 1842 884
-2123 2 2 8 7 1105 2088 430
-2124 2 2 8 7 923 1327 243
-2125 2 2 8 7 684 1548 1014
-2126 2 2 8 7 534 1555 1517
-2127 2 2 8 7 1020 2078 298
-2128 2 2 8 7 700 2078 1020
-2129 2 2 8 7 1492 1890 548
-2130 2 2 8 7 960 1563 432
-2131 2 2 8 7 888 1779 314
-2132 2 2 8 7 552 1779 888
-2133 2 2 8 7 2040 2076 479
-2134 2 2 8 7 470 1923 1313
-2135 2 2 8 7 377 1769 1217
-2136 2 2 8 7 963 1672 209
-2137 2 2 8 7 446 1803 921
-2138 2 2 8 7 1217 1769 730
-2139 2 2 8 7 255 1567 1015
-2140 2 2 8 7 870 1683 215
-2141 2 2 8 7 1052 1614 567
-2142 2 2 8 7 294 1963 1175
-2143 2 2 8 7 312 1929 1176
-2144 2 2 8 7 868 1835 318
-2145 2 2 8 7 977 1373 201
-2146 2 2 8 7 494 1373 977
-2147 2 2 8 7 318 1532 868
-2148 2 2 8 7 332 1952 877
-2149 2 2 8 7 785 2071 1846
-2150 2 2 8 7 881 1595 514
-2151 2 2 8 7 320 1595 881
-2152 2 2 8 7 435 1494 1005
-2153 2 2 8 7 234 1713 1028
-2154 2 2 8 7 953 1357 63
-2155 2 2 8 7 114 1356 954
-2156 2 2 8 7 930 1610 519
-2157 2 2 8 7 1028 1713 698
-2158 2 2 8 7 502 1170 1095
-2159 2 2 8 7 1534 1752 697
-2160 2 2 8 7 696 1753 1535
-2161 2 2 8 7 1095 1170 163
-2162 2 2 8 7 261 1857 1057
-2163 2 2 8 7 1058 1858 262
-2164 2 2 8 7 1402 1738 399
-2165 2 2 8 7 665 1953 1754
-2166 2 2 8 7 867 1738 1402
-2167 2 2 8 7 1019 1927 69
-2168 2 2 8 7 108 1926 1018
-2169 2 2 8 7 994 1377 373
-2170 2 2 8 7 878 1544 497
-2171 2 2 8 7 186 1880 1542
-2172 2 2 8 7 988 1187 408
-2173 2 2 8 7 1114 1527 633
-2174 2 2 8 7 360 1409 975
-2175 2 2 8 7 872 1747 576
-2176 2 2 8 7 1528 1558 860
-2177 2 2 8 7 309 1558 1528
-2178 2 2 8 7 881 1936 320
-2179 2 2 8 7 37 1127 38
-2180 2 2 8 7 1446 2011 831
-2181 2 2 8 7 434 1862 1056
-2182 2 2 8 7 1168 2019 380
-2183 2 2 8 7 1811 1925 247
-2184 2 2 8 7 796 2019 1168
-2185 2 2 8 7 25 1109 26
-2186 2 2 8 7 527 1720 1101
-2187 2 2 8 7 530 1280 936
-2188 2 2 8 7 981 1409 360
-2189 2 2 8 7 875 1634 520
-2190 2 2 8 7 218 2056 926
-2191 2 2 8 7 926 2056 615
-2192 2 2 8 7 786 1901 1815
-2193 2 2 8 7 1037 1823 431
-2194 2 2 8 7 1336 2088 1105
-2195 2 2 8 7 718 2063 1559
-2196 2 2 8 7 918 1755 335
-2197 2 2 8 7 1092 1473 569
-2198 2 2 8 7 922 2022 601
-2199 2 2 8 7 1000 1331 421
-2200 2 2 8 7 183 2022 922
-2201 2 2 8 7 385 1473 1092
-2202 2 2 8 7 374 1792 1042
-2203 2 2 8 7 531 1331 1000
-2204 2 2 8 7 660 1294 1205
-2205 2 2 8 7 402 1154 1077
-2206 2 2 8 7 235 1157 1036
-2207 2 2 8 7 194 1782 881
-2208 2 2 8 7 709 1174 1173
-2209 2 2 8 7 1103 1473 385
-2210 2 2 8 7 1173 1174 412
-2211 2 2 8 7 713 2091 1176
-2212 2 2 8 7 893 1967 469
-2213 2 2 8 7 918 1353 180
-2214 2 2 8 7 1271 2060 319
-2215 2 2 8 7 1292 1658 816
-2216 2 2 8 7 933 2069 258
-2217 2 2 8 7 366 1453 883
-2218 2 2 8 7 457 1793 964
-2219 2 2 8 7 1774 2083 630
-2220 2 2 8 7 955 1970 1709
-2221 2 2 8 7 1038 1829 612
-2222 2 2 8 7 340 1706 991
-2223 2 2 8 7 439 1720 1281
-2224 2 2 8 7 1454 1848 400
-2225 2 2 8 7 401 1849 1455
-2226 2 2 8 7 7 1516 882
-2227 2 2 8 7 579 1471 1282
-2228 2 2 8 7 848 1430 1150
-2229 2 2 8 7 878 2048 1544
-2230 2 2 8 7 907 1916 356
-2231 2 2 8 7 1251 1811 439
-2232 2 2 8 7 264 1912 1661
-2233 2 2 8 7 335 1649 918
-2234 2 2 8 7 1005 1715 1230
-2235 2 2 8 7 894 1410 149
-2236 2 2 8 7 221 1506 1035
-2237 2 2 8 7 345 1932 935
-2238 2 2 8 7 893 1542 499
-2239 2 2 8 7 1765 2017 568
-2240 2 2 8 7 1544 2048 333
-2241 2 2 8 7 1575 1698 274
-2242 2 2 8 7 275 1699 1576
-2243 2 2 8 7 436 1536 1296
-2244 2 2 8 7 1341 1595 740
-2245 2 2 8 7 1094 1862 434
-2246 2 2 8 7 577 1935 910
-2247 2 2 8 7 659 1420 892
-2248 2 2 8 7 910 1935 344
-2249 2 2 8 7 241 2083 937
-2250 2 2 8 7 986 1608 263
-2251 2 2 8 7 1219 1318 263
-2252 2 2 8 7 350 1363 927
-2253 2 2 8 7 843 2000 1343
-2254 2 2 8 7 887 1702 384
-2255 2 2 8 7 1181 1892 686
-2256 2 2 8 7 452 1353 918
-2257 2 2 8 7 1803 1817 788
-2258 2 2 8 7 224 1956 1520
-2259 2 2 8 7 105 1118 106
-2260 2 2 8 7 71 1119 72
-2261 2 2 8 7 1607 2043 695
-2262 2 2 8 7 1279 1408 726
-2263 2 2 8 7 725 1407 1278
-2264 2 2 8 7 498 1487 926
-2265 2 2 8 7 421 1200 1000
-2266 2 2 8 7 469 1859 893
-2267 2 2 8 7 944 2085 227
-2268 2 2 8 7 1023 1921 258
-2269 2 2 8 7 927 2016 185
-2270 2 2 8 7 612 1829 1668
-2271 2 2 8 7 915 1372 662
-2272 2 2 8 7 415 1280 1137
-2273 2 2 8 7 966 1915 448
-2274 2 2 8 7 1137 1280 530
-2275 2 2 8 7 942 1623 520
-2276 2 2 8 7 437 1269 1033
-2277 2 2 8 7 148 1975 149
-2278 2 2 8 7 1379 1421 348
-2279 2 2 8 7 681 1421 1379
-2280 2 2 8 7 501 1352 1190
-2281 2 2 8 7 950 1295 177
-2282 2 2 8 7 812 1781 1096
-2283 2 2 8 7 1190 1352 567
-2284 2 2 8 7 1255 1519 268
-2285 2 2 8 7 1021 1390 327
-2286 2 2 8 7 663 1519 1255
-2287 2 2 8 7 524 1390 1021
-2288 2 2 8 7 1 1599 128
-2289 2 2 8 7 127 1599 1
-2290 2 2 8 7 3 1600 50
-2291 2 2 8 7 49 1600 3
-2292 2 2 8 7 458 1332 962
-2293 2 2 8 7 1060 1773 272
-2294 2 2 8 7 962 1332 348
-2295 2 2 8 7 952 1728 673
-2296 2 2 8 7 624 1773 1060
-2297 2 2 8 7 431 1823 1090
-2298 2 2 8 7 906 1836 225
-2299 2 2 8 7 779 1714 1127
-2300 2 2 8 7 734 1460 996
-2301 2 2 8 7 891 1701 256
-2302 2 2 8 7 371 1372 966
-2303 2 2 8 7 1106 1157 235
-2304 2 2 8 7 481 1498 942
-2305 2 2 8 7 334 1703 891
-2306 2 2 8 7 917 2071 785
-2307 2 2 8 7 894 1498 481
-2308 2 2 8 7 392 1829 1038
-2309 2 2 8 7 889 1580 563
-2310 2 2 8 7 45 1914 1067
-2311 2 2 8 7 890 1539 565
-2312 2 2 8 7 766 2060 1271
-2313 2 2 8 7 893 1859 1542
-2314 2 2 8 7 1299 1566 614
-2315 2 2 8 7 239 2044 1301
-2316 2 2 8 7 303 1756 1513
-2317 2 2 8 7 277 1633 890
-2318 2 2 8 7 352 1470 900
-2319 2 2 8 7 608 1889 1125
-2320 2 2 8 7 1024 1729 424
-2321 2 2 8 7 160 1204 1075
-2322 2 2 8 7 1075 1204 468
-2323 2 2 8 7 900 1475 352
-2324 2 2 8 7 912 2030 341
-2325 2 2 8 7 1542 1859 186
-2326 2 2 8 7 1471 1997 974
-2327 2 2 8 7 1301 2044 911
-2328 2 2 8 7 411 1197 1045
-2329 2 2 8 7 1046 1196 410
-2330 2 2 8 7 647 1914 972
-2331 2 2 8 7 339 1727 903
-2332 2 2 8 7 972 1914 44
-2333 2 2 8 7 920 1388 323
-2334 2 2 8 7 1097 1298 395
-2335 2 2 8 7 75 1147 76
-2336 2 2 8 7 101 1146 102
-2337 2 2 8 7 895 1511 328
-2338 2 2 8 7 519 1298 1097
-2339 2 2 8 7 1247 1947 582
-2340 2 2 8 7 968 1275 445
-2341 2 2 8 7 69 1927 70
-2342 2 2 8 7 107 1926 108
-2343 2 2 8 7 499 1560 893
-2344 2 2 8 7 847 1711 985
-2345 2 2 8 7 574 1499 1265
-2346 2 2 8 7 465 1830 912
-2347 2 2 8 7 539 1431 1254
-2348 2 2 8 7 904 2020 238
-2349 2 2 8 7 915 1879 202
-2350 2 2 8 7 177 1295 1081
-2351 2 2 8 7 905 1763 627
-2352 2 2 8 7 235 1481 913
-2353 2 2 8 7 1088 1670 474
-2354 2 2 8 7 1216 1924 443
-2355 2 2 8 7 1031 1900 1491
-2356 2 2 8 7 502 1231 1151
-2357 2 2 8 7 438 1736 904
-2358 2 2 8 7 226 1846 1284
-2359 2 2 8 7 443 1924 1226
-2360 2 2 8 7 1284 1846 794
-2361 2 2 8 7 433 2068 1083
-2362 2 2 8 7 1154 1762 581
-2363 2 2 8 7 339 1505 904
-2364 2 2 8 7 978 1714 318
-2365 2 2 8 7 564 1714 978
-2366 2 2 8 7 911 1838 436
-2367 2 2 8 7 912 1830 196
-2368 2 2 8 7 1290 2055 870
-2369 2 2 8 7 473 1231 1211
-2370 2 2 8 7 169 1371 1026
-2371 2 2 8 7 991 1654 198
-2372 2 2 8 7 1026 1371 508
-2373 2 2 8 7 943 1675 998
-2374 2 2 8 7 560 1654 991
-2375 2 2 8 7 1139 1289 451
-2376 2 2 8 7 322 1394 929
-2377 2 2 8 7 1741 2007 687
-2378 2 2 8 7 653 1700 1406
-2379 2 2 8 7 405 1856 1156
-2380 2 2 8 7 249 1655 1074
-2381 2 2 8 7 364 1638 936
-2382 2 2 8 7 519 1401 930
-2383 2 2 8 7 936 1638 530
-2384 2 2 8 7 120 1459 1207
-2385 2 2 8 7 1206 1458 57
-2386 2 2 8 7 656 1919 1392
-2387 2 2 8 7 317 1540 908
-2388 2 2 8 7 93 1349 94
-2389 2 2 8 7 83 1350 84
-2390 2 2 8 7 913 1481 465
-2391 2 2 8 7 1106 1381 561
-2392 2 2 8 7 89 1804 90
-2393 2 2 8 7 87 1805 88
-2394 2 2 8 7 971 1493 144
-2395 2 2 8 7 1340 1511 500
-2396 2 2 8 7 394 1521 1452
-2397 2 2 8 7 1452 1521 751
-2398 2 2 8 7 460 1626 1278
-2399 2 2 8 7 1279 1627 461
-2400 2 2 8 7 1542 1880 752
-2401 2 2 8 7 951 1418 213
-2402 2 2 8 7 909 1612 349
-2403 2 2 8 7 926 1425 498
-2404 2 2 8 7 792 2046 1480
-2405 2 2 8 7 913 2062 235
-2406 2 2 8 7 916 1515 236
-2407 2 2 8 7 911 1510 345
-2408 2 2 8 7 67 1165 68
-2409 2 2 8 7 109 1164 110
-2410 2 2 8 7 1050 1545 464
-2411 2 2 8 7 233 1245 999
-2412 2 2 8 7 250 1419 1300
-2413 2 2 8 7 198 1998 1342
-2414 2 2 8 7 991 1662 340
-2415 2 2 8 7 1067 1914 647
-2416 2 2 8 7 1011 1808 313
-2417 2 2 8 7 943 1944 654
-2418 2 2 8 7 1230 1743 163
-2419 2 2 8 7 921 1803 342
-2420 2 2 8 7 794 1434 1284
-2421 2 2 8 7 693 1743 1230
-2422 2 2 8 7 335 1966 1649
-2423 2 2 8 7 400 1978 938
-2424 2 2 8 7 939 1979 401
-2425 2 2 8 7 425 1641 1117
-2426 2 2 8 7 1117 1641 596
-2427 2 2 8 7 9 1765 10
-2428 2 2 8 7 1006 1252 245
-2429 2 2 8 7 1334 2005 670
-2430 2 2 8 7 341 1592 913
-2431 2 2 8 7 17 1268 18
-2432 2 2 8 7 991 1706 560
-2433 2 2 8 7 373 1377 989
-2434 2 2 8 7 1132 1802 406
-2435 2 2 8 7 247 1304 980
-2436 2 2 8 7 1299 1404 286
-2437 2 2 8 7 266 1778 1330
-2438 2 2 8 7 614 1404 1299
-2439 2 2 8 7 27 1598 1033
-2440 2 2 8 7 1224 1368 781
-2441 2 2 8 7 918 1649 452
-2442 2 2 8 7 485 2053 941
-2443 2 2 8 7 919 1899 253
-2444 2 2 8 7 354 1538 977
-2445 2 2 8 7 1057 1857 1636
-2446 2 2 8 7 1637 1858 1058
-2447 2 2 8 7 897 2025 1969
-2448 2 2 8 7 708 1693 922
-2449 2 2 8 7 179 1272 1185
-2450 2 2 8 7 1204 1209 515
-2451 2 2 8 7 1017 1251 176
-2452 2 2 8 7 160 1209 1204
-2453 2 2 8 7 13 1990 14
-2454 2 2 8 7 1185 1272 532
-2455 2 2 8 7 979 1363 350
-2456 2 2 8 7 261 1454 938
-2457 2 2 8 7 939 1455 262
-2458 2 2 8 7 974 1679 710
-2459 2 2 8 7 258 1921 1148
-2460 2 2 8 7 670 2005 1587
-2461 2 2 8 7 618 1486 1238
-2462 2 2 8 7 245 1252 1030
-2463 2 2 8 7 1746 1992 955
-2464 2 2 8 7 956 1991 1745
-2465 2 2 8 7 1030 1252 455
-2466 2 2 8 7 1131 1228 545
-2467 2 2 8 7 1031 1895 610
-2468 2 2 8 7 622 1513 931
-2469 2 2 8 7 283 1228 1131
-2470 2 2 8 7 305 1895 1031
-2471 2 2 8 7 251 1465 1051
-2472 2 2 8 7 1186 1246 516
-2473 2 2 8 7 1405 1684 1008
-2474 2 2 8 7 509 1288 1253
-2475 2 2 8 7 379 2087 965
-2476 2 2 8 7 1076 1620 397
-2477 2 2 8 7 965 2087 625
-2478 2 2 8 7 459 1887 959
-2479 2 2 8 7 980 1970 351
-2480 2 2 8 7 462 1854 1249
-2481 2 2 8 7 1250 1855 463
-2482 2 2 8 7 752 2077 1140
-2483 2 2 8 7 594 1970 980
-2484 2 2 8 7 1050 1235 239
-2485 2 2 8 7 1208 1406 226
-2486 2 2 8 7 1636 1856 405
-2487 2 2 8 7 992 2009 211
-2488 2 2 8 7 1254 1513 622
-2489 2 2 8 7 152 1512 935
-2490 2 2 8 7 303 1513 1254
-2491 2 2 8 7 1025 1262 399
-2492 2 2 8 7 574 1909 1499
-2493 2 2 8 7 558 1857 938
-2494 2 2 8 7 939 1858 559
-2495 2 2 8 7 377 1973 1017
-2496 2 2 8 7 207 1666 1427
-2497 2 2 8 7 938 1857 261
-2498 2 2 8 7 262 1858 939
-2499 2 2 8 7 1017 1973 632
-2500 2 2 8 7 1427 1666 782
-2501 2 2 8 7 31 1518 1158
-2502 2 2 8 7 395 1298 993
-2503 2 2 8 7 200 1675 943
-2504 2 2 8 7 1351 1981 948
-2505 2 2 8 7 1283 1898 171
-2506 2 2 8 7 453 1577 1049
-2507 2 2 8 7 238 1240 1053
-2508 2 2 8 7 790 1879 1242
-2509 2 2 8 7 1281 1818 276
-2510 2 2 8 7 1302 1683 692
-2511 2 2 8 7 266 1330 1286
-2512 2 2 8 7 1167 1655 249
-2513 2 2 8 7 511 1515 1424
-2514 2 2 8 7 935 1766 345
-2515 2 2 8 7 489 1195 1172
-2516 2 2 8 7 942 1634 244
-2517 2 2 8 7 520 1634 942
-2518 2 2 8 7 1090 1589 431
-2519 2 2 8 7 8 1243 9
-2520 2 2 8 7 1172 1195 260
-2521 2 2 8 7 1034 1958 1632
-2522 2 2 8 7 643 2041 1001
-2523 2 2 8 7 372 1646 932
-2524 2 2 8 7 1001 2041 273
-2525 2 2 8 7 255 1566 979
-2526 2 2 8 7 979 1566 528
-2527 2 2 8 7 940 1589 19
-2528 2 2 8 7 1551 1873 599
-2529 2 2 8 7 600 1874 1552
-2530 2 2 8 7 1649 1966 734
-2531 2 2 8 7 169 1878 1174
-2532 2 2 8 7 562 2080 951
-2533 2 2 8 7 648 1836 1239
-2534 2 2 8 7 528 1363 979
-2535 2 2 8 7 151 1512 152
-2536 2 2 8 7 937 1774 342
-2537 2 2 8 7 198 1585 991
-2538 2 2 8 7 638 1878 1171
-2539 2 2 8 7 215 1683 1302
-2540 2 2 8 7 1214 1273 501
-2541 2 2 8 7 116 1571 1064
-2542 2 2 8 7 1065 1570 61
-2543 2 2 8 7 991 1585 540
-2544 2 2 8 7 1212 1494 435
-2545 2 2 8 7 1051 1430 251
-2546 2 2 8 7 525 1430 1051
-2547 2 2 8 7 375 2068 963
-2548 2 2 8 7 2 1686 89
-2549 2 2 8 7 88 1686 2
-2550 2 2 8 7 1809 2092 807
-2551 2 2 8 7 1178 1702 887
-2552 2 2 8 7 74 1399 75
-2553 2 2 8 7 102 1400 103
-2554 2 2 8 7 999 1457 233
-2555 2 2 8 7 391 2032 1427
-2556 2 2 8 7 352 1991 956
-2557 2 2 8 7 543 1704 1296
-2558 2 2 8 7 1386 1612 549
-2559 2 2 8 7 185 1415 968
-2560 2 2 8 7 968 1415 473
-2561 2 2 8 7 1354 1978 649
-2562 2 2 8 7 650 1979 1355
-2563 2 2 8 7 1110 1214 450
-2564 2 2 8 7 695 1881 1220
-2565 2 2 8 7 984 2088 503
-2566 2 2 8 7 430 1271 1105
-2567 2 2 8 7 448 1915 1073
-2568 2 2 8 7 450 1948 1022
-2569 2 2 8 7 1082 1957 576
-2570 2 2 8 7 1578 1894 304
-2571 2 2 8 7 544 1442 1428
-2572 2 2 8 7 260 1334 1089
-2573 2 2 8 7 571 1660 1646
-2574 2 2 8 7 1314 1912 264
-2575 2 2 8 7 1089 1334 503
-2576 2 2 8 7 950 1554 378
-2577 2 2 8 7 103 1761 104
-2578 2 2 8 7 73 1760 74
-2579 2 2 8 7 363 1679 947
-2580 2 2 8 7 199 1467 961
-2581 2 2 8 7 757 2017 1765
-2582 2 2 8 7 1403 1867 506
-2583 2 2 8 7 213 1888 951
-2584 2 2 8 7 958 1993 442
-2585 2 2 8 7 770 1973 1217
-2586 2 2 8 7 501 2051 1214
-2587 2 2 8 7 1049 1606 777
-2588 2 2 8 7 1748 1955 271
-2589 2 2 8 7 503 1336 1111
-2590 2 2 8 7 463 1918 985
-2591 2 2 8 7 1094 1516 6
-2592 2 2 8 7 369 1839 1035
-2593 2 2 8 7 497 1658 1292
-2594 2 2 8 7 990 1395 42
-2595 2 2 8 7 1969 2025 609
-2596 2 2 8 7 1192 1233 495
-2597 2 2 8 7 504 1635 1417
-2598 2 2 8 7 507 1233 1192
-2599 2 2 8 7 26 1598 27
-2600 2 2 8 7 1378 1704 543
-2601 2 2 8 7 976 2040 246
-2602 2 2 8 7 574 1808 1011
-2603 2 2 8 7 962 1541 178
-2604 2 2 8 7 513 1409 981
-2605 2 2 8 7 434 1516 1094
-2606 2 2 8 7 136 1543 137
-2607 2 2 8 7 97 1369 98
-2608 2 2 8 7 79 1370 80
-2609 2 2 8 7 864 1800 1540
-2610 2 2 8 7 970 2079 355
-2611 2 2 8 7 1463 1581 208
-2612 2 2 8 7 592 1476 1403
-2613 2 2 8 7 258 1316 1023
-2614 2 2 8 7 741 1581 1463
-2615 2 2 8 7 406 1802 1637
-2616 2 2 8 7 1563 1784 432
-2617 2 2 8 7 130 1625 131
-2618 2 2 8 7 1221 1288 509
-2619 2 2 8 7 63 1357 64
-2620 2 2 8 7 113 1356 114
-2621 2 2 8 7 538 2044 1235
-2622 2 2 8 7 175 2013 1604
-2623 2 2 8 7 1294 1828 277
-2624 2 2 8 7 243 1327 1072
-2625 2 2 8 7 1407 2003 801
-2626 2 2 8 7 802 2004 1408
-2627 2 2 8 7 540 1662 991
-2628 2 2 8 7 1480 1740 792
-2629 2 2 8 7 15 1850 1092
-2630 2 2 8 7 225 1563 960
-2631 2 2 8 7 6 1516 7
-2632 2 2 8 7 1169 1225 248
-2633 2 2 8 7 1027 1945 1466
-2634 2 2 8 7 291 2011 1446
-2635 2 2 8 7 544 1428 1272
-2636 2 2 8 7 483 1225 1169
-2637 2 2 8 7 959 1887 370
-2638 2 2 8 7 350 1423 1203
-2639 2 2 8 7 259 1263 1179
-2640 2 2 8 7 1540 1800 493
-2641 2 2 8 7 1203 1204 515
-2642 2 2 8 7 544 1380 1316
-2643 2 2 8 7 1925 1986 247
-2644 2 2 8 7 426 1487 990
-2645 2 2 8 7 468 1204 1203
-2646 2 2 8 7 1261 1953 665
-2647 2 2 8 7 990 1487 498
-2648 2 2 8 7 106 1551 107
-2649 2 2 8 7 70 1552 71
-2650 2 2 8 7 1709 1970 594
-2651 2 2 8 7 1043 2055 611
-2652 2 2 8 7 1530 1968 1034
-2653 2 2 8 7 967 2059 823
-2654 2 2 8 7 1376 1381 535
-2655 2 2 8 7 498 1395 990
-2656 2 2 8 7 1108 1341 223
-2657 2 2 8 7 514 1341 1108
-2658 2 2 8 7 611 2058 1043
-2659 2 2 8 7 644 1962 1074
-2660 2 2 8 7 117 1752 118
-2661 2 2 8 7 59 1753 60
-2662 2 2 8 7 531 1493 971
-2663 2 2 8 7 1074 1962 384
-2664 2 2 8 7 1111 1336 161
-2665 2 2 8 7 669 1630 1195
-2666 2 2 8 7 451 1377 994
-2667 2 2 8 7 1358 2051 501
-2668 2 2 8 7 1392 1475 656
-2669 2 2 8 7 632 1973 1925
-2670 2 2 8 7 95 1249 96
-2671 2 2 8 7 81 1250 82
-2672 2 2 8 7 216 1740 1480
-2673 2 2 8 7 981 1465 251
-2674 2 2 8 7 432 1784 1089
-2675 2 2 8 7 567 1614 1190
-2676 2 2 8 7 1151 1231 259
-2677 2 2 8 7 1510 2044 538
-2678 2 2 8 7 368 2021 971
-2679 2 2 8 7 1246 1466 317
-2680 2 2 8 7 421 1331 1041
-2681 2 2 8 7 14 1850 15
-2682 2 2 8 7 455 1343 1030
-2683 2 2 8 7 1120 1280 415
-2684 2 2 8 7 282 1717 1317
-2685 2 2 8 7 672 1484 1040
-2686 2 2 8 7 1039 1483 671
-2687 2 2 8 7 1080 1337 196
-2688 2 2 8 7 404 1588 1059
-2689 2 2 8 7 490 1337 1080
-2690 2 2 8 7 280 1577 1238
-2691 2 2 8 7 830 2012 1501
-2692 2 2 8 7 783 1621 1602
-2693 2 2 8 7 996 1460 633
-2694 2 2 8 7 433 1672 963
-2695 2 2 8 7 270 1383 1323
-2696 2 2 8 7 1323 1383 592
-2697 2 2 8 7 1571 1849 1064
-2698 2 2 8 7 1065 1848 1570
-2699 2 2 8 7 1238 1577 618
-2700 2 2 8 7 508 1751 1160
-2701 2 2 8 7 1553 1868 453
-2702 2 2 8 7 1059 1588 548
-2703 2 2 8 7 430 2088 984
-2704 2 2 8 7 964 1793 281
-2705 2 2 8 7 424 1655 1167
-2706 2 2 8 7 202 1915 966
-2707 2 2 8 7 1676 2074 765
-2708 2 2 8 7 1287 2076 164
-2709 2 2 8 7 1020 1489 398
-2710 2 2 8 7 590 1820 1057
-2711 2 2 8 7 1058 1821 591
-2712 2 2 8 7 1057 1820 261
-2713 2 2 8 7 262 1821 1058
-2714 2 2 8 7 553 1620 1076
-2715 2 2 8 7 105 1905 1118
-2716 2 2 8 7 1119 1904 72
-2717 2 2 8 7 687 2007 1476
-2718 2 2 8 7 1259 1617 167
-2719 2 2 8 7 52 1266 53
-2720 2 2 8 7 124 1267 125
-2721 2 2 8 7 352 1475 1392
-2722 2 2 8 7 440 1247 1141
-2723 2 2 8 7 642 1713 1218
-2724 2 2 8 7 1010 1664 237
-2725 2 2 8 7 380 1882 1168
-2726 2 2 8 7 1009 1988 466
-2727 2 2 8 7 1082 1296 180
-2728 2 2 8 7 1404 1806 575
-2729 2 2 8 7 465 1443 1091
-2730 2 2 8 7 53 1790 54
-2731 2 2 8 7 123 1791 124
-2732 2 2 8 7 985 1918 233
-2733 2 2 8 7 350 1893 979
-2734 2 2 8 7 1001 1467 643
-2735 2 2 8 7 977 1538 494
-2736 2 2 8 7 96 1854 97
-2737 2 2 8 7 80 1855 81
-2738 2 2 8 7 1368 2082 192
-2739 2 2 8 7 1602 1621 358
-2740 2 2 8 7 899 2082 1368
-2741 2 2 8 7 46 1607 47
-2742 2 2 8 7 655 1448 1391
-2743 2 2 8 7 1391 1448 351
-2744 2 2 8 7 1218 1713 234
-2745 2 2 8 7 1097 1401 519
-2746 2 2 8 7 182 1401 1097
-2747 2 2 8 7 284 1656 1061
-2748 2 2 8 7 1148 1921 853
-2749 2 2 8 7 1061 1656 560
-2750 2 2 8 7 612 2047 1038
-2751 2 2 8 7 533 1482 1234
-2752 2 2 8 7 1032 1568 534
-2753 2 2 8 7 1144 2090 663
-2754 2 2 8 7 974 1997 162
-2755 2 2 8 7 278 1568 1032
-2756 2 2 8 7 381 1730 967
-2757 2 2 8 7 606 1726 1600
-2758 2 2 8 7 1599 1725 605
-2759 2 2 8 7 979 1567 255
-2760 2 2 8 7 92 1940 93
-2761 2 2 8 7 84 1939 85
-2762 2 2 8 7 283 1923 1228
-2763 2 2 8 7 1069 1750 578
-2764 2 2 8 7 972 1629 647
-2765 2 2 8 7 33 1750 1069
-2766 2 2 8 7 1332 1379 348
-2767 2 2 8 7 587 1379 1332
-2768 2 2 8 7 473 1871 968
-2769 2 2 8 7 1084 1312 240
-2770 2 2 8 7 576 1957 1159
-2771 2 2 8 7 971 2021 531
-2772 2 2 8 7 1070 1330 477
-2773 2 2 8 7 252 1374 1041
-2774 2 2 8 7 980 1689 247
-2775 2 2 8 7 1014 1415 185
-2776 2 2 8 7 1183 1333 588
-2777 2 2 8 7 1015 1567 515
-2778 2 2 8 7 180 1353 1082
-2779 2 2 8 7 1098 1300 446
-2780 2 2 8 7 1770 1888 213
-2781 2 2 8 7 1205 1770 213
-2782 2 2 8 7 144 1493 145
-2783 2 2 8 7 339 2002 1505
-2784 2 2 8 7 471 1432 1061
-2785 2 2 8 7 20 1589 1090
-2786 2 2 8 7 584 1964 978
-2787 2 2 8 7 1123 1495 430
-2788 2 2 8 7 213 1418 1055
-2789 2 2 8 7 1102 1995 326
-2790 2 2 8 7 176 1416 1017
-2791 2 2 8 7 1146 1709 594
-2792 2 2 8 7 595 1710 1147
-2793 2 2 8 7 480 1314 1095
-2794 2 2 8 7 1150 1430 525
-2795 2 2 8 7 101 1709 1146
-2796 2 2 8 7 1147 1710 76
-2797 2 2 8 7 1021 1647 818
-2798 2 2 8 7 300 2003 1407
-2799 2 2 8 7 1408 2004 301
-2800 2 2 8 7 1120 1289 228
-2801 2 2 8 7 1206 1626 460
-2802 2 2 8 7 461 1627 1207
-2803 2 2 8 7 85 1292 86
-2804 2 2 8 7 91 1293 92
-2805 2 2 8 7 597 1626 1206
-2806 2 2 8 7 1207 1627 598
-2807 2 2 8 7 1071 1346 480
-2808 2 2 8 7 1143 1835 447
-2809 2 2 8 7 1253 1288 248
-2810 2 2 8 7 1062 1479 254
-2811 2 2 8 7 1425 1971 279
-2812 2 2 8 7 478 1246 1186
-2813 2 2 8 7 1194 1633 691
-2814 2 2 8 7 973 1839 369
-2815 2 2 8 7 187 1579 995
-2816 2 2 8 7 995 1579 520
-2817 2 2 8 7 613 1707 976
-2818 2 2 8 7 336 1680 982
-2819 2 2 8 7 253 1346 1071
-2820 2 2 8 7 664 1673 983
-2821 2 2 8 7 835 1742 1202
-2822 2 2 8 7 736 1640 1062
-2823 2 2 8 7 1229 1943 702
-2824 2 2 8 7 298 1943 1229
-2825 2 2 8 7 408 2073 988
-2826 2 2 8 7 195 1762 1154
-2827 2 2 8 7 1028 1723 542
-2828 2 2 8 7 271 1724 1257
-2829 2 2 8 7 1257 1724 667
-2830 2 2 8 7 1531 1842 358
-2831 2 2 8 7 884 1842 1531
-2832 2 2 8 7 1179 1263 476
-2833 2 2 8 7 1018 1562 108
-2834 2 2 8 7 69 1561 1019
-2835 2 2 8 7 475 1486 1053
-2836 2 2 8 7 423 2037 986
-2837 2 2 8 7 468 1434 1075
-2838 2 2 8 7 542 1495 1123
-2839 2 2 8 7 985 1711 628
-2840 2 2 8 7 35 1315 36
-2841 2 2 8 7 1005 1494 290
-2842 2 2 8 7 271 1955 1324
-2843 2 2 8 7 1036 1481 235
-2844 2 2 8 7 19 1589 20
-2845 2 2 8 7 1161 1439 490
-2846 2 2 8 7 1114 1373 787
-2847 2 2 8 7 38 1844 39
-2848 2 2 8 7 201 1373 1114
-2849 2 2 8 7 140 1488 141
-2850 2 2 8 7 1193 1897 639
-2851 2 2 8 7 756 1736 1549
-2852 2 2 8 7 161 1336 1105
-2853 2 2 8 7 477 1456 1126
-2854 2 2 8 7 583 1778 1444
-2855 2 2 8 7 1027 2056 218
-2856 2 2 8 7 615 2056 1027
-2857 2 2 8 7 1039 1435 389
-2858 2 2 8 7 390 1436 1040
-2859 2 2 8 7 111 1325 112
-2860 2 2 8 7 65 1326 66
-2861 2 2 8 7 693 1615 1071
-2862 2 2 8 7 986 2015 1608
-2863 2 2 8 7 1248 1718 1047
-2864 2 2 8 7 799 1734 1528
-2865 2 2 8 7 1038 2047 132
-2866 2 2 8 7 469 1967 1087
-2867 2 2 8 7 1182 1410 481
-2868 2 2 8 7 264 1871 1211
-2869 2 2 8 7 1335 1650 506
-2870 2 2 8 7 1555 1903 910
-2871 2 2 8 7 405 1440 1057
-2872 2 2 8 7 1058 1441 406
-2873 2 2 8 7 223 1903 1555
-2874 2 2 8 7 678 1606 1049
-2875 2 2 8 7 679 2064 1130
-2876 2 2 8 7 368 2055 1043
-2877 2 2 8 7 1130 2064 165
-2878 2 2 8 7 1150 1485 824
-2879 2 2 8 7 1070 1594 246
-2880 2 2 8 7 784 1868 1553
-2881 2 2 8 7 1353 1957 1082
-2882 2 2 8 7 23 1338 24
-2883 2 2 8 7 1109 1727 512
-2884 2 2 8 7 1043 2058 252
-2885 2 2 8 7 579 1910 1471
-2886 2 2 8 7 326 1996 1102
-2887 2 2 8 7 1102 1996 646
-2888 2 2 8 7 1612 1701 549
-2889 2 2 8 7 636 2045 1274
-2890 2 2 8 7 1471 1910 861
-2891 2 2 8 7 1068 1453 739
-2892 2 2 8 7 1015 1716 383
-2893 2 2 8 7 867 1897 1193
-2894 2 2 8 7 1528 1734 309
-2895 2 2 8 7 1055 1418 472
-2896 2 2 8 7 196 1851 1080
-2897 2 2 8 7 1291 1375 584
-2898 2 2 8 7 1025 1500 170
-2899 2 2 8 7 989 1946 373
-2900 2 2 8 7 153 1345 154
-2901 2 2 8 7 1944 1971 654
-2902 2 2 8 7 520 1623 995
-2903 2 2 8 7 1465 1792 1051
-2904 2 2 8 7 246 2040 1070
-2905 2 2 8 7 399 1934 1402
-2906 2 2 8 7 401 1979 1311
-2907 2 2 8 7 1310 1978 400
-2908 2 2 8 7 346 1910 1128
-2909 2 2 8 7 1009 1556 236
-2910 2 2 8 7 237 1557 1010
-2911 2 2 8 7 134 1429 135
-2912 2 2 8 7 1060 1412 624
-2913 2 2 8 7 454 2009 992
-2914 2 2 8 7 759 1583 1165
-2915 2 2 8 7 1164 1582 758
-2916 2 2 8 7 1403 1476 181
-2917 2 2 8 7 178 1541 1029
-2918 2 2 8 7 1529 1888 667
-2919 2 2 8 7 1186 1757 478
-2920 2 2 8 7 1417 1635 619
-2921 2 2 8 7 1035 1506 645
-2922 2 2 8 7 1113 1780 707
-2923 2 2 8 7 1258 1411 470
-2924 2 2 8 7 221 1539 1277
-2925 2 2 8 7 135 1429 1117
-2926 2 2 8 7 1033 1598 512
-2927 2 2 8 7 1256 1799 397
-2928 2 2 8 7 504 1417 1245
-2929 2 2 8 7 1138 1883 623
-2930 2 2 8 7 1237 1401 182
-2931 2 2 8 7 168 1883 1138
-2932 2 2 8 7 1679 1922 710
-2933 2 2 8 7 1003 1614 366
-2934 2 2 8 7 1202 1376 535
-2935 2 2 8 7 288 1376 1202
-2936 2 2 8 7 522 1869 1002
-2937 2 2 8 7 370 1976 1006
-2938 2 2 8 7 1158 1518 455
-2939 2 2 8 7 1006 1976 578
-2940 2 2 8 7 1371 1751 508
-2941 2 2 8 7 482 1400 1146
-2942 2 2 8 7 1147 1399 483
-2943 2 2 8 7 1078 1440 405
-2944 2 2 8 7 406 1441 1079
-2945 2 2 8 7 42 1395 43
-2946 2 2 8 7 1640 1659 688
-2947 2 2 8 7 1095 1743 480
-2948 2 2 8 7 638 2001 999
-2949 2 2 8 7 504 1558 1227
-2950 2 2 8 7 661 1804 1686
-2951 2 2 8 7 1686 1805 661
-2952 2 2 8 7 211 1771 992
-2953 2 2 8 7 1061 1432 284
-2954 2 2 8 7 1062 1640 688
-2955 2 2 8 7 998 1675 716
-2956 2 2 8 7 998 2043 414
-2957 2 2 8 7 1275 1871 264
-2958 2 2 8 7 193 1981 1351
-2959 2 2 8 7 183 1456 1303
-2960 2 2 8 7 1303 1456 583
-2961 2 2 8 7 499 1853 1030
-2962 2 2 8 7 557 1562 1018
-2963 2 2 8 7 1019 1561 556
-2964 2 2 8 7 510 1288 1221
-2965 2 2 8 7 1549 1736 438
-2966 2 2 8 7 1205 1294 449
-2967 2 2 8 7 479 1287 1286
-2968 2 2 8 7 1029 1541 533
-2969 2 2 8 7 1034 1968 376
-2970 2 2 8 7 164 1367 1166
-2971 2 2 8 7 1286 1287 566
-2972 2 2 8 7 668 1468 1348
-2973 2 2 8 7 995 1777 551
-2974 2 2 8 7 1072 2032 391
-2975 2 2 8 7 374 1565 1051
-2976 2 2 8 7 1051 1565 525
-2977 2 2 8 7 235 1381 1106
-2978 2 2 8 7 1323 1525 270
-2979 2 2 8 7 694 2035 1258
-2980 2 2 8 7 1142 1452 540
-2981 2 2 8 7 1047 1718 589
-2982 2 2 8 7 394 1452 1142
-2983 2 2 8 7 467 1664 1010
-2984 2 2 8 7 447 1835 1277
-2985 2 2 8 7 1053 1486 238
-2986 2 2 8 7 58 1535 59
-2987 2 2 8 7 118 1534 119
-2988 2 2 8 7 1091 1830 465
-2989 2 2 8 7 444 1368 1224
-2990 2 2 8 7 1290 1531 611
-2991 2 2 8 7 1343 2000 287
-2992 2 2 8 7 1169 1470 595
-2993 2 2 8 7 1008 1684 367
-2994 2 2 8 7 290 1715 1005
-2995 2 2 8 7 402 1695 1642
-2996 2 2 8 7 1642 1695 832
-2997 2 2 8 7 95 1824 1249
-2998 2 2 8 7 1250 1825 82
-2999 2 2 8 7 1018 1699 557
-3000 2 2 8 7 556 1698 1019
-3001 2 2 8 7 354 1841 1538
-3002 2 2 8 7 764 1628 1572
-3003 2 2 8 7 654 1971 1507
-3004 2 2 8 7 1572 1628 575
-3005 2 2 8 7 149 1410 150
-3006 2 2 8 7 603 1702 1178
-3007 2 2 8 7 172 1358 1190
-3008 2 2 8 7 1004 1953 403
-3009 2 2 8 7 342 1803 1472
-3010 2 2 8 7 403 1953 1261
-3011 2 2 8 7 1001 1829 392
-3012 2 2 8 7 1002 1929 312
-3013 2 2 8 7 550 1929 1002
-3014 2 2 8 7 1164 1562 557
-3015 2 2 8 7 556 1561 1165
-3016 2 2 8 7 468 1423 1284
-3017 2 2 8 7 607 1937 1103
-3018 2 2 8 7 109 1562 1164
-3019 2 2 8 7 1165 1561 68
-3020 2 2 8 7 486 1440 1078
-3021 2 2 8 7 1079 1441 487
-3022 2 2 8 7 545 1411 1098
-3023 2 2 8 7 1103 1937 206
-3024 2 2 8 7 896 2026 1483
-3025 2 2 8 7 1484 2025 897
-3026 2 2 8 7 1472 1803 788
-3027 2 2 8 7 691 2031 1194
-3028 2 2 8 7 1004 1851 704
-3029 2 2 8 7 1483 2026 275
-3030 2 2 8 7 274 2025 1484
-3031 2 2 8 7 1194 2031 184
-3032 2 2 8 7 1142 1586 295
-3033 2 2 8 7 1021 1669 524
-3034 2 2 8 7 471 1479 1062
-3035 2 2 8 7 335 1755 1239
-3036 2 2 8 7 1378 1630 669
-3037 2 2 8 7 462 1763 1359
-3038 2 2 8 7 496 1940 1293
-3039 2 2 8 7 1292 1939 497
-3040 2 2 8 7 2015 2037 593
-3041 2 2 8 7 1391 2075 655
-3042 2 2 8 7 299 1630 1378
-3043 2 2 8 7 1112 1980 243
-3044 2 2 8 7 1647 1996 818
-3045 2 2 8 7 1687 2070 539
-3046 2 2 8 7 631 1980 1112
-3047 2 2 8 7 182 1412 1141
-3048 2 2 8 7 236 1988 1009
-3049 2 2 8 7 327 1647 1021
-3050 2 2 8 7 1228 1411 545
-3051 2 2 8 7 470 1411 1228
-3052 2 2 8 7 1079 1928 174
-3053 2 2 8 7 293 1670 1088
-3054 2 2 8 7 1121 1880 186
-3055 2 2 8 7 528 2016 1363
-3056 2 2 8 7 1071 1615 735
-3057 2 2 8 7 331 1397 1384
-3058 2 2 8 7 1384 1397 589
-3059 2 2 8 7 1199 1896 658
-3060 2 2 8 7 165 1896 1199
-3061 2 2 8 7 702 1660 1229
-3062 2 2 8 7 491 1790 1266
-3063 2 2 8 7 1267 1791 492
-3064 2 2 8 7 592 1403 1323
-3065 2 2 8 7 1091 1443 346
-3066 2 2 8 7 242 1502 1439
-3067 2 2 8 7 239 1545 1050
-3068 2 2 8 7 1447 1889 527
-3069 2 2 8 7 131 1625 1038
-3070 2 2 8 7 711 1788 1321
-3071 2 2 8 7 1322 1789 712
-3072 2 2 8 7 506 1650 1525
-3073 2 2 8 7 1166 1367 495
-3074 2 2 8 7 460 1458 1206
-3075 2 2 8 7 1207 1459 461
-3076 2 2 8 7 174 1845 1313
-3077 2 2 8 7 453 1868 1577
-3078 2 2 8 7 1049 1577 280
-3079 2 2 8 7 986 2037 2015
-3080 2 2 8 7 75 1399 1147
-3081 2 2 8 7 1146 1400 102
-3082 2 2 8 7 1387 1579 803
-3083 2 2 8 7 1691 1809 422
-3084 2 2 8 7 1042 1869 522
-3085 2 2 8 7 1107 1597 422
-3086 2 2 8 7 907 1809 1691
-3087 2 2 8 7 1501 2012 292
-3088 2 2 8 7 1180 1553 453
-3089 2 2 8 7 1096 1961 385
-3090 2 2 8 7 1136 2053 485
-3091 2 2 8 7 623 1688 1138
-3092 2 2 8 7 1187 1389 476
-3093 2 2 8 7 315 1658 1104
-3094 2 2 8 7 1137 1693 415
-3095 2 2 8 7 385 1961 1103
-3096 2 2 8 7 521 1817 1300
-3097 2 2 8 7 108 1562 109
-3098 2 2 8 7 68 1561 69
-3099 2 2 8 7 1190 1358 501
-3100 2 2 8 7 488 1930 1116
-3101 2 2 8 7 586 1866 1036
-3102 2 2 8 7 1449 2016 528
-3103 2 2 8 7 364 1728 1029
-3104 2 2 8 7 1113 1431 433
-3105 2 2 8 7 1027 1744 615
-3106 2 2 8 7 1160 1759 456
-3107 2 2 8 7 1090 1823 21
-3108 2 2 8 7 242 1439 1161
-3109 2 2 8 7 569 1758 1092
-3110 2 2 8 7 490 1439 1324
-3111 2 2 8 7 1018 1926 599
-3112 2 2 8 7 600 1927 1019
-3113 2 2 8 7 531 2021 1043
-3114 2 2 8 7 247 1986 1304
-3115 2 2 8 7 926 1487 1241
-3116 2 2 8 7 1139 2033 1289
-3117 2 2 8 7 495 1659 1192
-3118 2 2 8 7 1099 2049 418
-3119 2 2 8 7 419 2050 1100
-3120 2 2 8 7 1107 1920 494
-3121 2 2 8 7 1437 1781 580
-3122 2 2 8 7 376 1958 1034
-3123 2 2 8 7 289 1833 1192
-3124 2 2 8 7 442 1921 1023
-3125 2 2 8 7 1024 1949 157
-3126 2 2 8 7 1026 1878 169
-3127 2 2 8 7 484 1416 1210
-3128 2 2 8 7 796 1951 1025
-3129 2 2 8 7 1030 1853 245
-3130 2 2 8 7 218 1945 1027
-3131 2 2 8 7 783 1602 1088
-3132 2 2 8 7 478 1757 1344
-3133 2 2 8 7 610 1900 1031
-3134 2 2 8 7 1439 1502 616
-3135 2 2 8 7 534 1865 1032
-3136 2 2 8 7 1057 1636 405
-3137 2 2 8 7 406 1637 1058
-3138 2 2 8 7 223 1555 1108
-3139 2 2 8 7 1108 1555 534
-3140 2 2 8 7 21 1823 22
-3141 2 2 8 7 338 1648 1428
-3142 2 2 8 7 1191 1944 943
-3143 2 2 8 7 1296 1536 543
-3144 2 2 8 7 1126 1456 183
-3145 2 2 8 7 1510 1932 345
-3146 2 2 8 7 903 1727 1109
-3147 2 2 8 7 477 1594 1070
-3148 2 2 8 7 22 1823 1037
-3149 2 2 8 7 1155 1859 469
-3150 2 2 8 7 1597 1691 422
-3151 2 2 8 7 897 1969 1305
-3152 2 2 8 7 1067 1607 46
-3153 2 2 8 7 1581 1665 208
-3154 2 2 8 7 745 1769 1477
-3155 2 2 8 7 1478 1768 744
-3156 2 2 8 7 1477 1769 377
-3157 2 2 8 7 378 1768 1478
-3158 2 2 8 7 1227 1635 504
-3159 2 2 8 7 1044 2035 374
-3160 2 2 8 7 190 1869 1042
-3161 2 2 8 7 1690 1799 554
-3162 2 2 8 7 876 1799 1690
-3163 2 2 8 7 512 1598 1109
-3164 2 2 8 7 1043 2021 368
-3165 2 2 8 7 1199 1580 165
-3166 2 2 8 7 324 1744 1344
-3167 2 2 8 7 563 1580 1199
-3168 2 2 8 7 512 1727 1285
-3169 2 2 8 7 289 1659 1640
-3170 2 2 8 7 1413 1817 521
-3171 2 2 8 7 634 1992 1746
-3172 2 2 8 7 1745 1991 635
-3173 2 2 8 7 770 1986 1925
-3174 2 2 8 7 1485 1845 174
-3175 2 2 8 7 1187 2074 408
-3176 2 2 8 7 156 1862 1094
-3177 2 2 8 7 1048 2087 379
-3178 2 2 8 7 1338 2002 903
-3179 2 2 8 7 29 1639 30
-3180 2 2 8 7 805 1382 1359
-3181 2 2 8 7 1300 1419 521
-3182 2 2 8 7 1657 1687 361
-3183 2 2 8 7 150 1410 1182
-3184 2 2 8 7 795 1687 1657
-3185 2 2 8 7 783 2058 1621
-3186 2 2 8 7 39 1844 1347
-3187 2 2 8 7 1460 1795 201
-3188 2 2 8 7 536 1318 1317
-3189 2 2 8 7 1317 1318 537
-3190 2 2 8 7 1051 1792 374
-3191 2 2 8 7 734 1795 1460
-3192 2 2 8 7 788 1917 1472
-3193 2 2 8 7 540 1586 1142
-3194 2 2 8 7 1130 1593 679
-3195 2 2 8 7 755 1494 1212
-3196 2 2 8 7 141 1488 1133
-3197 2 2 8 7 521 1419 1184
-3198 2 2 8 7 214 1941 1047
-3199 2 2 8 7 1088 1602 658
-3200 2 2 8 7 1483 1576 671
-3201 2 2 8 7 672 1575 1484
-3202 2 2 8 7 275 1576 1483
-3203 2 2 8 7 1484 1575 274
-3204 2 2 8 7 640 1554 1253
-3205 2 2 8 7 1074 1655 644
-3206 2 2 8 7 1780 2008 707
-3207 2 2 8 7 813 1797 1104
-3208 2 2 8 7 484 1477 1416
-3209 2 2 8 7 155 1862 156
-3210 2 2 8 7 1109 1598 26
-3211 2 2 8 7 578 1750 1158
-3212 2 2 8 7 1469 1768 378
-3213 2 2 8 7 1188 1663 188
-3214 2 2 8 7 731 1768 1469
-3215 2 2 8 7 10 1530 11
-3216 2 2 8 7 1158 1750 32
-3217 2 2 8 7 935 1932 1345
-3218 2 2 8 7 1695 1712 566
-3219 2 2 8 7 653 1406 1208
-3220 2 2 8 7 1308 1508 652
-3221 2 2 8 7 552 1508 1308
-3222 2 2 8 7 39 2090 40
-3223 2 2 8 7 646 1996 1647
-3224 2 2 8 7 1104 1797 790
-3225 2 2 8 7 607 1961 1911
-3226 2 2 8 7 1052 1989 219
-3227 2 2 8 7 321 1977 1526
-3228 2 2 8 7 1526 1977 857
-3229 2 2 8 7 525 1485 1150
-3230 2 2 8 7 509 1731 1221
-3231 2 2 8 7 449 1770 1205
-3232 2 2 8 7 1110 1946 989
-3233 2 2 8 7 1551 1926 107
-3234 2 2 8 7 70 1927 1552
-3235 2 2 8 7 1238 1486 475
-3236 2 2 8 7 751 1662 1452
-3237 2 2 8 7 138 1611 139
-3238 2 2 8 7 534 1568 1108
-3239 2 2 8 7 247 1689 1101
-3240 2 2 8 7 1316 2024 544
-3241 2 2 8 7 1807 2036 197
-3242 2 2 8 7 1320 1432 471
-3243 2 2 8 7 1201 1782 194
-3244 2 2 8 7 61 1570 62
-3245 2 2 8 7 115 1571 116
-3246 2 2 8 7 1055 2039 213
-3247 2 2 8 7 1064 1752 117
-3248 2 2 8 7 60 1753 1065
-3249 2 2 8 7 863 1934 1262
-3250 2 2 8 7 607 1911 1852
-3251 2 2 8 7 243 1980 1054
-3252 2 2 8 7 1203 1423 468
-3253 2 2 8 7 494 1597 1107
-3254 2 2 8 7 1118 1551 106
-3255 2 2 8 7 71 1552 1119
-3256 2 2 8 7 1059 1890 230
-3257 2 2 8 7 1240 2020 526
-3258 2 2 8 7 656 1475 1201
-3259 2 2 8 7 1056 1862 155
-3260 2 2 8 7 318 1835 1143
-3261 2 2 8 7 266 1712 1077
-3262 2 2 8 7 514 1514 1149
-3263 2 2 8 7 687 2018 1741
-3264 2 2 8 7 1135 1775 517
-3265 2 2 8 7 518 1776 1136
-3266 2 2 8 7 312 1550 1184
-3267 2 2 8 7 1171 2001 638
-3268 2 2 8 7 1661 1912 621
-3269 2 2 8 7 448 2001 1171
-3270 2 2 8 7 555 1617 1259
-3271 2 2 8 7 685 1432 1320
-3272 2 2 8 7 795 2070 1687
-3273 2 2 8 7 1428 1442 338
-3274 2 2 8 7 316 1759 1160
-3275 2 2 8 7 285 1593 1116
-3276 2 2 8 7 572 1849 1571
-3277 2 2 8 7 1570 1848 573
-3278 2 2 8 7 1064 1849 401
-3279 2 2 8 7 400 1848 1065
-3280 2 2 8 7 1262 1951 328
-3281 2 2 8 7 136 2038 1543
-3282 2 2 8 7 1140 1853 499
-3283 2 2 8 7 1104 1658 497
-3284 2 2 8 7 436 1838 1536
-3285 2 2 8 7 1536 1838 789
-3286 2 2 8 7 648 1784 1563
-3287 2 2 8 7 723 1630 1622
-3288 2 2 8 7 12 1632 13
-3289 2 2 8 7 493 1375 1291
-3290 2 2 8 7 1622 1630 299
-3291 2 2 8 7 1366 1690 443
-3292 2 2 8 7 876 1690 1366
-3293 2 2 8 7 1464 1482 533
-3294 2 2 8 7 1514 1568 278
-3295 2 2 8 7 613 1482 1464
-3296 2 2 8 7 1101 1689 527
-3297 2 2 8 7 1092 1758 15
-3298 2 2 8 7 1421 1464 348
-3299 2 2 8 7 227 1780 1083
-3300 2 2 8 7 613 1464 1421
-3301 2 2 8 7 519 1610 1124
-3302 2 2 8 7 184 2031 1066
-3303 2 2 8 7 578 1976 1069
-3304 2 2 8 7 1257 1770 449
-3305 2 2 8 7 1070 2040 479
-3306 2 2 8 7 523 1740 1265
-3307 2 2 8 7 163 1743 1095
-3308 2 2 8 7 1491 1900 189
-3309 2 2 8 7 1422 1574 620
-3310 2 2 8 7 1278 1407 460
-3311 2 2 8 7 461 1408 1279
-3312 2 2 8 7 1797 1879 790
-3313 2 2 8 7 1294 1987 449
-3314 2 2 8 7 1101 1720 439
-3315 2 2 8 7 562 1684 1405
-3316 2 2 8 7 683 1691 1597
-3317 2 2 8 7 1367 1659 495
-3318 2 2 8 7 545 1665 1131
-3319 2 2 8 7 1274 1613 160
-3320 2 2 8 7 722 1681 1588
-3321 2 2 8 7 577 1613 1274
-3322 2 2 8 7 1588 1681 548
-3323 2 2 8 7 1295 1478 485
-3324 2 2 8 7 544 2024 1442
-3325 2 2 8 7 178 1806 1093
-3326 2 2 8 7 1075 1994 636
-3327 2 2 8 7 1124 2086 241
-3328 2 2 8 7 625 2086 1124
-3329 2 2 8 7 487 1928 1079
-3330 2 2 8 7 532 1549 1185
-3331 2 2 8 7 128 1785 129
-3332 2 2 8 7 229 1972 1076
-3333 2 2 8 7 1538 1841 683
-3334 2 2 8 7 1310 2003 300
-3335 2 2 8 7 301 2004 1311
-3336 2 2 8 7 696 2003 1310
-3337 2 2 8 7 1311 2004 697
-3338 2 2 8 7 1311 1979 650
-3339 2 2 8 7 649 1978 1310
-3340 2 2 8 7 1473 1678 569
-3341 2 2 8 7 1086 1884 735
-3342 2 2 8 7 736 1885 1085
-3343 2 2 8 7 1274 1935 577
-3344 2 2 8 7 100 1709 101
-3345 2 2 8 7 76 1710 77
-3346 2 2 8 7 678 1678 1473
-3347 2 2 8 7 1115 1692 211
-3348 2 2 8 7 1096 1781 265
-3349 2 2 8 7 1272 1428 532
-3350 2 2 8 7 378 1554 1469
-3351 2 2 8 7 555 1685 1616
-3352 2 2 8 7 287 1560 1343
-3353 2 2 8 7 865 1907 1360
-3354 2 2 8 7 1361 1908 866
-3355 2 2 8 7 1469 1554 640
-3356 2 2 8 7 132 2047 133
-3357 2 2 8 7 557 1582 1164
-3358 2 2 8 7 1165 1583 556
-3359 2 2 8 7 456 1759 1351
-3360 2 2 8 7 1087 1967 287
-3361 2 2 8 7 1504 1999 315
-3362 2 2 8 7 817 1999 1504
-3363 2 2 8 7 483 1501 1225
-3364 2 2 8 7 261 1820 1099
-3365 2 2 8 7 1100 1821 262
-3366 2 2 8 7 571 1489 1229
-3367 2 2 8 7 363 1922 1679
-3368 2 2 8 7 78 1745 79
-3369 2 2 8 7 98 1746 99
-3370 2 2 8 7 617 2007 1741
-3371 2 2 8 7 439 1811 1101
-3372 2 2 8 7 15 1758 16
-3373 2 2 8 7 1189 1717 546
-3374 2 2 8 7 1184 1550 521
-3375 2 2 8 7 1185 1549 438
-3376 2 2 8 7 1202 1742 714
-3377 2 2 8 7 1359 1382 462
-3378 2 2 8 7 32 1750 33
-3379 2 2 8 7 1323 1403 506
-3380 2 2 8 7 478 1466 1246
-3381 2 2 8 7 529 1398 1397
-3382 2 2 8 7 1397 1398 589
-3383 2 2 8 7 213 2039 1205
-3384 2 2 8 7 1205 2039 660
-3385 2 2 8 7 1284 1434 468
-3386 2 2 8 7 48 1816 49
-3387 2 2 8 7 1203 1893 350
-3388 2 2 8 7 1444 1644 583
-3389 2 2 8 7 1127 1714 564
-3390 2 2 8 7 616 1724 1324
-3391 2 2 8 7 1241 1487 426
-3392 2 2 8 7 1324 1724 271
-3393 2 2 8 7 1327 2032 1072
-3394 2 2 8 7 188 1969 1188
-3395 2 2 8 7 1188 1969 609
-3396 2 2 8 7 561 1880 1121
-3397 2 2 8 7 1339 2037 423
-3398 2 2 8 7 1199 1842 563
-3399 2 2 8 7 722 1942 1681
-3400 2 2 8 7 342 1472 1264
-3401 2 2 8 7 1206 1827 597
-3402 2 2 8 7 598 1826 1207
-3403 2 2 8 7 56 1827 1206
-3404 2 2 8 7 1207 1826 121
-3405 2 2 8 7 1565 1845 525
-3406 2 2 8 7 430 1495 1271
-3407 2 2 8 7 1271 1495 766
-3408 2 2 8 7 1248 1668 273
-3409 2 2 8 7 1188 1578 511
-3410 2 2 8 7 737 1668 1248
-3411 2 2 8 7 94 1824 95
-3412 2 2 8 7 82 1825 83
-3413 2 2 8 7 121 1826 122
-3414 2 2 8 7 55 1827 56
-3415 2 2 8 7 1107 1911 265
-3416 2 2 8 7 1264 1472 585
-3417 2 2 8 7 1103 1961 607
-3418 2 2 8 7 1097 2057 182
-3419 2 2 8 7 532 1648 1385
-3420 2 2 8 7 1163 1749 804
-3421 2 2 8 7 564 1519 1347
-3422 2 2 8 7 1347 1519 663
-3423 2 2 8 7 265 1920 1107
-3424 2 2 8 7 877 1952 1349
-3425 2 2 8 7 312 2091 1550
-3426 2 2 8 7 1105 1960 746
-3427 2 2 8 7 592 1735 1476
-3428 2 2 8 7 570 1792 1465
-3429 2 2 8 7 1775 1884 517
-3430 2 2 8 7 518 1885 1776
-3431 2 2 8 7 1476 1735 687
-3432 2 2 8 7 1574 1843 620
-3433 2 2 8 7 314 1749 1134
-3434 2 2 8 7 147 2089 148
-3435 2 2 8 7 1310 1863 649
-3436 2 2 8 7 650 1864 1311
-3437 2 2 8 7 300 1863 1310
-3438 2 2 8 7 1311 1864 301
-3439 2 2 8 7 1283 1687 539
-3440 2 2 8 7 737 1694 1668
-3441 2 2 8 7 1668 1694 612
-3442 2 2 8 7 1422 1603 330
-3443 2 2 8 7 72 1904 73
-3444 2 2 8 7 104 1905 105
-3445 2 2 8 7 1299 1643 528
-3446 2 2 8 7 620 1603 1422
-3447 2 2 8 7 1265 1499 523
-3448 2 2 8 7 267 1947 1247
-3449 2 2 8 7 44 1914 45
-3450 2 2 8 7 1324 1439 616
-3451 2 2 8 7 180 1704 1461
-3452 2 2 8 7 1221 1936 510
-3453 2 2 8 7 1192 1833 507
-3454 2 2 8 7 842 1664 1438
-3455 2 2 8 7 1461 1704 669
-3456 2 2 8 7 1438 1664 467
-3457 2 2 8 7 253 1775 1135
-3458 2 2 8 7 1136 1776 254
-3459 2 2 8 7 564 1844 1127
-3460 2 2 8 7 1125 1818 608
-3461 2 2 8 7 1127 1844 38
-3462 2 2 8 7 849 1946 1110
-3463 2 2 8 7 1159 1957 452
-3464 2 2 8 7 489 1755 1461
-3465 2 2 8 7 712 1802 1132
-3466 2 2 8 7 1189 1666 207
-3467 2 2 8 7 546 1666 1189
-3468 2 2 8 7 1601 2031 691
-3469 2 2 8 7 279 1629 1425
-3470 2 2 8 7 1216 1652 306
-3471 2 2 8 7 1242 1879 915
-3472 2 2 8 7 1910 1983 861
-3473 2 2 8 7 306 1924 1216
-3474 2 2 8 7 688 1659 1367
-3475 2 2 8 7 1116 1930 285
-3476 2 2 8 7 1426 1731 509
-3477 2 2 8 7 1558 1919 1227
-3478 2 2 8 7 1112 2006 631
-3479 2 2 8 7 526 2020 1505
-3480 2 2 8 7 1375 1964 584
-3481 2 2 8 7 511 1663 1188
-3482 2 2 8 7 1620 1674 703
-3483 2 2 8 7 553 1674 1620
-3484 2 2 8 7 202 1879 1797
-3485 2 2 8 7 1244 1653 586
-3486 2 2 8 7 162 1653 1244
-3487 2 2 8 7 1192 1659 289
-3488 2 2 8 7 1160 1751 316
-3489 2 2 8 7 276 1818 1499
-3490 2 2 8 7 585 1917 1730
-3491 2 2 8 7 1370 1745 635
-3492 2 2 8 7 634 1746 1369
-3493 2 2 8 7 79 1745 1370
-3494 2 2 8 7 1369 1746 98
-3495 2 2 8 7 596 2038 1117
-3496 2 2 8 7 756 1549 1385
-3497 2 2 8 7 689 2089 1200
-3498 2 2 8 7 1867 2073 602
-3499 2 2 8 7 988 2073 1867
-3500 2 2 8 7 1451 1740 523
-3501 2 2 8 7 1653 1997 861
-3502 2 2 8 7 162 1997 1653
-3503 2 2 8 7 1222 1665 545
-3504 2 2 8 7 951 2080 1418
-3505 2 2 8 7 728 2000 1639
-3506 2 2 8 7 1639 2000 843
-3507 2 2 8 7 1348 1468 500
-3508 2 2 8 7 551 1777 1175
-3509 2 2 8 7 527 1448 1447
-3510 2 2 8 7 1447 1448 655
-3511 2 2 8 7 1434 1994 1075
-3512 2 2 8 7 672 1874 1575
-3513 2 2 8 7 1576 1873 671
-3514 2 2 8 7 554 1652 1216
-3515 2 2 8 7 194 1635 1227
-3516 2 2 8 7 1674 1913 703
-3517 2 2 8 7 1550 2091 814
-3518 2 2 8 7 657 1955 1748
-3519 2 2 8 7 1538 1597 494
-3520 2 2 8 7 694 1845 1565
-3521 2 2 8 7 683 1597 1538
-3522 2 2 8 7 1384 1767 331
-3523 2 2 8 7 643 1767 1384
-3524 2 2 8 7 1156 1856 711
-3525 2 2 8 7 276 1909 1145
-3526 2 2 8 7 1352 2027 321
-3527 2 2 8 7 208 1665 1222
-3528 2 2 8 7 1433 1903 768
-3529 2 2 8 7 1175 1777 294
-3530 2 2 8 7 321 1526 1352
-3531 2 2 8 7 1352 1526 567
-3532 2 2 8 7 1230 1715 693
-3533 2 2 8 7 1172 1784 648
-3534 2 2 8 7 477 1778 1456
-3535 2 2 8 7 1216 1690 554
-3536 2 2 8 7 443 1690 1216
-3537 2 2 8 7 518 1590 1436
-3538 2 2 8 7 1435 1591 517
-3539 2 2 8 7 449 1987 1138
-3540 2 2 8 7 1229 1660 571
-3541 2 2 8 7 254 2053 1136
-3542 2 2 8 7 766 2036 1807
-3543 2 2 8 7 286 1643 1299
-3544 2 2 8 7 1779 1837 314
-3545 2 2 8 7 840 1837 1779
-3546 2 2 8 7 1181 1785 605
-3547 2 2 8 7 129 1785 1181
-3548 2 2 8 7 166 1757 1186
-3549 2 2 8 7 1232 1669 195
-3550 2 2 8 7 659 1754 1420
-3551 2 2 8 7 677 1716 1209
-3552 2 2 8 7 1420 1754 310
-3553 2 2 8 7 506 1525 1323
-3554 2 2 8 7 1224 1685 444
-3555 2 2 8 7 503 2088 1336
-3556 2 2 8 7 774 2033 1139
-3557 2 2 8 7 835 1883 1742
-3558 2 2 8 7 1742 1883 168
-3559 2 2 8 7 667 1888 1770
-3560 2 2 8 7 1522 1771 680
-3561 2 2 8 7 1176 1929 550
-3562 2 2 8 7 465 1866 1443
-3563 2 2 8 7 1140 2077 705
-3564 2 2 8 7 546 1717 1321
-3565 2 2 8 7 1219 1832 825
-3566 2 2 8 7 789 1677 1536
-3567 2 2 8 7 346 1983 1910
-3568 2 2 8 7 139 1611 1308
-3569 2 2 8 7 528 1566 1299
-3570 2 2 8 7 166 1651 1256
-3571 2 2 8 7 197 2036 1319
-3572 2 2 8 7 1347 2090 39
-3573 2 2 8 7 528 1643 1449
-3574 2 2 8 7 184 1787 1194
-3575 2 2 8 7 1256 1651 554
-3576 2 2 8 7 1200 2089 147
-3577 2 2 8 7 1676 1814 203
-3578 2 2 8 7 1221 1731 320
-3579 2 2 8 7 765 1814 1676
-3580 2 2 8 7 1681 1942 199
-3581 2 2 8 7 510 1782 1201
-3582 2 2 8 7 693 1715 1615
-3583 2 2 8 7 1615 1715 290
-3584 2 2 8 7 1495 2036 766
-3585 2 2 8 7 568 1584 1527
-3586 2 2 8 7 542 2036 1495
-3587 2 2 8 7 515 1893 1203
-3588 2 2 8 7 605 1892 1181
-3589 2 2 8 7 1527 1584 633
-3590 2 2 8 7 286 1783 1643
-3591 2 2 8 7 627 1824 1349
-3592 2 2 8 7 1350 1825 628
-3593 2 2 8 7 1349 1824 94
-3594 2 2 8 7 83 1825 1350
-3595 2 2 8 7 320 1936 1221
-3596 2 2 8 7 1271 1960 1105
-3597 2 2 8 7 606 1816 1220
-3598 2 2 8 7 236 1556 1364
-3599 2 2 8 7 1365 1557 237
-3600 2 2 8 7 1364 1556 590
-3601 2 2 8 7 591 1557 1365
-3602 2 2 8 7 1802 1876 559
-3603 2 2 8 7 620 1843 1564
-3604 2 2 8 7 1564 1843 721
-3605 2 2 8 7 1582 1895 305
-3606 2 2 8 7 304 1894 1583
-3607 2 2 8 7 253 1899 1346
-3608 2 2 8 7 273 2041 1718
-3609 2 2 8 7 1385 1549 532
-3610 2 2 8 7 1257 1688 271
-3611 2 2 8 7 680 1773 1522
-3612 2 2 8 7 238 2020 1240
-3613 2 2 8 7 1522 1773 624
-3614 2 2 8 7 735 1884 1775
-3615 2 2 8 7 1776 1885 736
-3616 2 2 8 7 1308 1611 552
-3617 2 2 8 7 632 1925 1811
-3618 2 2 8 7 490 1955 1337
-3619 2 2 8 7 1337 1955 657
-3620 2 2 8 7 1530 1765 568
-3621 2 2 8 7 273 1718 1248
-3622 2 2 8 7 383 1716 1569
-3623 2 2 8 7 1569 1716 677
-3624 2 2 8 7 1654 1656 681
-3625 2 2 8 7 560 1656 1654
-3626 2 2 8 7 1735 2034 330
-3627 2 2 8 7 1427 2032 629
-3628 2 2 8 7 1632 1958 580
-3629 2 2 8 7 249 1650 1335
-3630 2 2 8 7 1211 1871 473
-3631 2 2 8 7 514 1595 1341
-3632 2 2 8 7 1490 1491 836
-3633 2 2 8 7 1220 1816 48
-3634 2 2 8 7 1291 1787 184
-3635 2 2 8 7 404 2054 1259
-3636 2 2 8 7 562 1645 1307
-3637 2 2 8 7 505 1491 1490
-3638 2 2 8 7 584 1787 1291
-3639 2 2 8 7 1307 1645 325
-3640 2 2 8 7 1328 1698 556
-3641 2 2 8 7 557 1699 1329
-3642 2 2 8 7 279 1944 1191
-3643 2 2 8 7 1239 1755 489
-3644 2 2 8 7 748 1832 1219
-3645 2 2 8 7 680 1692 1309
-3646 2 2 8 7 344 2045 1177
-3647 2 2 8 7 517 1884 1435
-3648 2 2 8 7 1436 1885 518
-3649 2 2 8 7 1344 1757 822
-3650 2 2 8 7 968 1871 1275
-3651 2 2 8 7 1603 2018 687
-3652 2 2 8 7 1608 2015 524
-3653 2 2 8 7 687 1735 1603
-3654 2 2 8 7 1603 1735 330
-3655 2 2 8 7 1548 1783 626
-3656 2 2 8 7 684 1783 1548
-3657 2 2 8 7 1220 1881 606
-3658 2 2 8 7 1523 1758 569
-3659 2 2 8 7 1529 1724 616
-3660 2 2 8 7 1970 1992 351
-3661 2 2 8 7 955 1992 1970
-3662 2 2 8 7 667 1724 1529
-3663 2 2 8 7 568 2017 1584
-3664 2 2 8 7 200 1913 1674
-3665 2 2 8 7 1896 2064 732
-3666 2 2 8 7 241 2086 2083
-3667 2 2 8 7 2083 2086 1048
-3668 2 2 8 7 1286 1712 266
-3669 2 2 8 7 747 1586 1585
-3670 2 2 8 7 397 1620 1596
-3671 2 2 8 7 1265 1740 216
-3672 2 2 8 7 1398 1965 214
-3673 2 2 8 7 1596 1620 703
-3674 2 2 8 7 1585 1586 540
-3675 2 2 8 7 313 1994 1434
-3676 2 2 8 7 566 1712 1286
-3677 2 2 8 7 558 1875 1856
-3678 2 2 8 7 1301 1747 239
-3679 2 2 8 7 576 1747 1301
-3680 2 2 8 7 667 1770 1257
-3681 2 2 8 7 345 1766 1333
-3682 2 2 8 7 520 1579 1387
-3683 2 2 8 7 1285 1727 339
-3684 2 2 8 7 1333 1766 588
-3685 2 2 8 7 227 2008 1780
-3686 2 2 8 7 1296 1704 180
-3687 2 2 8 7 1643 1783 684
-3688 2 2 8 7 1354 1875 558
-3689 2 2 8 7 559 1876 1355
-3690 2 2 8 7 1741 2018 281
-3691 2 2 8 7 554 1799 1256
-3692 2 2 8 7 793 1751 1371
-3693 2 2 8 7 288 1813 1376
-3694 2 2 8 7 1226 1924 780
-3695 2 2 8 7 1577 1868 618
-3696 2 2 8 7 1227 1919 656
-3697 2 2 8 7 362 1948 1812
-3698 2 2 8 7 1812 1948 856
-3699 2 2 8 7 1289 2033 228
-3700 2 2 8 7 376 1968 1527
-3701 2 2 8 7 1346 1912 480
-3702 2 2 8 7 1265 1810 574
-3703 2 2 8 7 216 1810 1265
-3704 2 2 8 7 1025 1951 1262
-3705 2 2 8 7 1217 1973 377
-3706 2 2 8 7 1266 1790 53
-3707 2 2 8 7 124 1791 1267
-3708 2 2 8 7 1228 1923 470
-3709 2 2 8 7 550 1574 1422
-3710 2 2 8 7 158 1798 1339
-3711 2 2 8 7 573 1848 1454
-3712 2 2 8 7 1455 1849 572
-3713 2 2 8 7 1339 1798 593
-3714 2 2 8 7 1820 2049 1099
-3715 2 2 8 7 1100 2050 1821
-3716 2 2 8 7 585 1906 1264
-3717 2 2 8 7 1264 1906 454
-3718 2 2 8 7 1335 1867 602
-3719 2 2 8 7 506 1867 1335
-3720 2 2 8 7 1249 1854 96
-3721 2 2 8 7 81 1855 1250
-3722 2 2 8 7 1537 1588 404
-3723 2 2 8 7 722 1588 1537
-3724 2 2 8 7 621 1912 1346
-3725 2 2 8 7 862 1645 1405
-3726 2 2 8 7 286 2042 1783
-3727 2 2 8 7 1350 2048 878
-3728 2 2 8 7 274 1698 1328
-3729 2 2 8 7 1329 1699 275
-3730 2 2 8 7 529 1965 1398
-3731 2 2 8 7 1321 1717 282
-3732 2 2 8 7 1361 1826 598
-3733 2 2 8 7 597 1827 1360
-3734 2 2 8 7 122 1826 1361
-3735 2 2 8 7 1360 1827 55
-3736 2 2 8 7 472 2080 1307
-3737 2 2 8 7 542 1723 1319
-3738 2 2 8 7 765 2074 1213
-3739 2 2 8 7 1214 2051 450
-3740 2 2 8 7 575 1628 1404
-3741 2 2 8 7 1404 1628 286
-3742 2 2 8 7 622 1898 1254
-3743 2 2 8 7 539 2070 1431
-3744 2 2 8 7 324 1764 1507
-3745 2 2 8 7 1507 1764 654
-3746 2 2 8 7 358 1621 1531
-3747 2 2 8 7 1277 1835 868
-3748 2 2 8 7 1531 1621 611
-3749 2 2 8 7 1342 1998 587
-3750 2 2 8 7 220 1861 1282
-3751 2 2 8 7 856 2051 1358
-3752 2 2 8 7 1282 1861 579
-3753 2 2 8 7 1405 1645 562
-3754 2 2 8 7 1381 2062 535
-3755 2 2 8 7 820 1731 1426
-3756 2 2 8 7 1390 2015 593
-3757 2 2 8 7 2024 2069 810
-3758 2 2 8 7 206 2029 1606
-3759 2 2 8 7 798 1733 1369
-3760 2 2 8 7 1370 1734 799
-3761 2 2 8 7 1628 2042 286
-3762 2 2 8 7 1433 1671 577
-3763 2 2 8 7 1606 2029 777
-3764 2 2 8 7 580 1990 1632
-3765 2 2 8 7 1666 1667 782
-3766 2 2 8 7 546 1667 1666
-3767 2 2 8 7 507 1833 1462
-3768 2 2 8 7 596 1837 1543
-3769 2 2 8 7 1543 1837 840
-3770 2 2 8 7 1601 1828 660
-3771 2 2 8 7 806 1663 1424
-3772 2 2 8 7 691 1828 1601
-3773 2 2 8 7 1424 1663 511
-3774 2 2 8 7 409 2046 1631
-3775 2 2 8 7 1631 2046 793
-3776 2 2 8 7 1262 1934 399
-3777 2 2 8 7 1428 1648 532
-3778 2 2 8 7 712 1876 1802
-3779 2 2 8 7 1641 1941 804
-3780 2 2 8 7 1300 1817 446
-3781 2 2 8 7 319 1960 1271
-3782 2 2 8 7 1330 1778 477
-3783 2 2 8 7 1235 2044 239
-3784 2 2 8 7 669 1704 1378
-3785 2 2 8 7 219 1985 1732
-3786 2 2 8 7 1732 1985 808
-3787 2 2 8 7 680 1771 1692
-3788 2 2 8 7 581 1644 1444
-3789 2 2 8 7 1449 1643 684
-3790 2 2 8 7 1304 1986 482
-3791 2 2 8 7 999 2001 1457
-3792 2 2 8 7 1721 1722 721
-3793 2 2 8 7 570 1722 1721
-3794 2 2 8 7 571 2023 1489
-3795 2 2 8 7 1351 1759 855
-3796 2 2 8 7 741 1605 1581
-3797 2 2 8 7 224 1931 1834
-3798 2 2 8 7 295 1671 1433
-3799 2 2 8 7 1834 1931 829
-3800 2 2 8 7 1369 1733 634
-3801 2 2 8 7 635 1734 1370
-3802 2 2 8 7 697 2004 1534
-3803 2 2 8 7 1535 2003 696
-3804 2 2 8 7 1534 2004 802
-3805 2 2 8 7 801 2003 1535
-3806 2 2 8 7 628 2048 1350
-3807 2 2 8 7 1452 1662 540
-3808 2 2 8 7 1509 1965 529
-3809 2 2 8 7 1313 1845 694
-3810 2 2 8 7 792 1740 1451
-3811 2 2 8 7 894 1975 1963
-3812 2 2 8 7 1963 1975 689
-3813 2 2 8 7 1761 2011 676
-3814 2 2 8 7 675 2012 1760
-3815 2 2 8 7 831 2011 1761
-3816 2 2 8 7 1760 2012 830
-3817 2 2 8 7 277 1828 1633
-3818 2 2 8 7 1633 1828 691
-3819 2 2 8 7 1500 1738 541
-3820 2 2 8 7 190 1843 1574
-3821 2 2 8 7 1560 1967 893
-3822 2 2 8 7 287 1967 1560
-3823 2 2 8 7 260 2005 1334
-3824 2 2 8 7 861 1997 1471
-3825 2 2 8 7 458 1870 1332
-3826 2 2 8 7 1332 1870 587
-3827 2 2 8 7 1259 2054 555
-3828 2 2 8 7 1442 2024 810
-3829 2 2 8 7 235 2062 1381
-3830 2 2 8 7 857 1989 1526
-3831 2 2 8 7 1456 1778 583
-3832 2 2 8 7 85 1939 1292
-3833 2 2 8 7 1293 1940 92
-3834 2 2 8 7 1692 1771 211
-3835 2 2 8 7 845 1890 1492
-3836 2 2 8 7 1623 1777 995
-3837 2 2 8 7 708 2027 1273
-3838 2 2 8 7 294 1777 1623
-3839 2 2 8 7 1696 1882 724
-3840 2 2 8 7 1503 1972 844
-3841 2 2 8 7 1581 1605 547
-3842 2 2 8 7 814 1938 1393
-3843 2 2 8 7 1390 1796 327
-3844 2 2 8 7 593 1796 1390
-3845 2 2 8 7 1507 1744 324
-3846 2 2 8 7 480 1912 1314
-3847 2 2 8 7 615 1744 1507
-3848 2 2 8 7 898 2081 1863
-3849 2 2 8 7 1864 2082 899
-3850 2 2 8 7 1863 2081 649
-3851 2 2 8 7 650 2082 1864
-3852 2 2 8 7 1525 1650 603
-3853 2 2 8 7 1328 1894 609
-3854 2 2 8 7 610 1895 1329
-3855 2 2 8 7 558 1856 1636
-3856 2 2 8 7 1036 1866 1481
-3857 2 2 8 7 1637 1802 559
-3858 2 2 8 7 587 1872 1342
-3859 2 2 8 7 1342 1872 383
-3860 2 2 8 7 1418 2080 472
-3861 2 2 8 7 1347 1844 564
-3862 2 2 8 7 721 1843 1721
-3863 2 2 8 7 1721 1843 190
-3864 2 2 8 7 1856 1875 711
-3865 2 2 8 7 1981 2075 948
-3866 2 2 8 7 655 2075 1981
-3867 2 2 8 7 343 1819 1619
-3868 2 2 8 7 1305 1969 188
-3869 2 2 8 7 525 1845 1485
-3870 2 2 8 7 1619 1819 679
-3871 2 2 8 7 510 1936 1782
-3872 2 2 8 7 743 1617 1616
-3873 2 2 8 7 1616 1617 555
-3874 2 2 8 7 1808 1810 826
-3875 2 2 8 7 574 1810 1808
-3876 2 2 8 7 1437 1958 376
-3877 2 2 8 7 577 1671 1613
-3878 2 2 8 7 191 1875 1354
-3879 2 2 8 7 1355 1876 192
-3880 2 2 8 7 788 1817 1413
-3881 2 2 8 7 1376 1813 561
-3882 2 2 8 7 1427 1902 207
-3883 2 2 8 7 629 1902 1427
-3884 2 2 8 7 772 1652 1651
-3885 2 2 8 7 1651 1652 554
-3886 2 2 8 7 601 2022 1303
-3887 2 2 8 7 1303 2022 183
-3888 2 2 8 7 1303 1995 601
-3889 2 2 8 7 1346 1899 621
-3890 2 2 8 7 1324 1955 490
-3891 2 2 8 7 1545 1747 872
-3892 2 2 8 7 1705 1748 623
-3893 2 2 8 7 1536 1677 543
-3894 2 2 8 7 1661 1700 653
-3895 2 2 8 7 621 1700 1661
-3896 2 2 8 7 611 2055 1290
-3897 2 2 8 7 1701 1703 549
-3898 2 2 8 7 1354 2081 191
-3899 2 2 8 7 192 2082 1355
-3900 2 2 8 7 891 1703 1701
-3901 2 2 8 7 649 2081 1354
-3902 2 2 8 7 1355 2082 650
-3903 2 2 8 7 1345 1932 538
-3904 2 2 8 7 1708 1954 394
-3905 2 2 8 7 526 2002 1338
-3906 2 2 8 7 740 1954 1708
-3907 2 2 8 7 479 2076 1287
-3908 2 2 8 7 535 2062 1592
-3909 2 2 8 7 1613 1671 677
-3910 2 2 8 7 1852 1937 607
-3911 2 2 8 7 609 2025 1328
-3912 2 2 8 7 1329 2026 610
-3913 2 2 8 7 1328 2025 274
-3914 2 2 8 7 275 2026 1329
-3915 2 2 8 7 1360 1907 597
-3916 2 2 8 7 598 1908 1361
-3917 2 2 8 7 807 1937 1852
-3918 2 2 8 7 1431 2070 433
-3919 2 2 8 7 279 1971 1944
-3920 2 2 8 7 1682 1896 732
-3921 2 2 8 7 814 2091 1938
-3922 2 2 8 7 658 1896 1682
-3923 2 2 8 7 1414 2017 757
-3924 2 2 8 7 642 1831 1713
-3925 2 2 8 7 1713 1831 698
-3926 2 2 8 7 599 1926 1551
-3927 2 2 8 7 1552 1927 600
-3928 2 2 8 7 586 1983 1443
-3929 2 2 8 7 269 2017 1414
-3930 2 2 8 7 1349 1952 627
-3931 2 2 8 7 258 2024 1316
-3932 2 2 8 7 1443 1866 586
-3933 2 2 8 7 452 1957 1353
-3934 2 2 8 7 1392 1991 352
-3935 2 2 8 7 351 1992 1391
-3936 2 2 8 7 635 1991 1392
-3937 2 2 8 7 1391 1992 634
-3938 2 2 8 7 1636 1857 558
-3939 2 2 8 7 559 1858 1637
-3940 2 2 8 7 182 2057 1412
-3941 2 2 8 7 1499 1909 276
-3942 2 2 8 7 1307 2080 562
-3943 2 2 8 7 1319 2036 542
-3944 2 2 8 7 568 1968 1530
-3945 2 2 8 7 1447 1981 193
-3946 2 2 8 7 655 1981 1447
-3947 2 2 8 7 629 2032 1327
-3948 2 2 8 7 1467 1942 643
-3949 2 2 8 7 199 1942 1467
-3950 2 2 8 7 268 1964 1375
-3951 2 2 8 7 588 1766 1512
-3952 2 2 8 7 1599 1785 128
-3953 2 2 8 7 1512 1766 935
-3954 2 2 8 7 165 2064 1896
-3955 2 2 8 7 16 1758 1523
-3956 2 2 8 7 482 1986 1446
-3957 2 2 8 7 593 2037 1339
-3958 2 2 8 7 657 1748 1705
-3959 2 2 8 7 1804 1999 817
-3960 2 2 8 7 661 1999 1804
-3961 2 2 8 7 724 1974 1696
-3962 2 2 8 7 1696 1974 319
-3963 2 2 8 7 623 1748 1688
-3964 2 2 8 7 937 2083 1774
-3965 2 2 8 7 239 1747 1545
-3966 2 2 8 7 1393 1938 387
-3967 2 2 8 7 1498 1963 294
-3968 2 2 8 7 1462 1833 754
-3969 2 2 8 7 10 1765 1530
-3970 2 2 8 7 894 1963 1498
-3971 2 2 8 7 1363 2016 927
-3972 2 2 8 7 225 1836 1563
-3973 2 2 8 7 1563 1836 648
-3974 2 2 8 7 258 2069 2024
-3975 2 2 8 7 181 2007 1389
-3976 2 2 8 7 1389 2007 617
-3977 2 2 8 7 1767 1942 722
-3978 2 2 8 7 193 1889 1447
-3979 2 2 8 7 374 2035 1565
-3980 2 2 8 7 1565 2035 694
-3981 2 2 8 7 587 1998 1379
-3982 2 2 8 7 1609 2023 773
-3983 2 2 8 7 398 2023 1609
-3984 2 2 8 7 663 2090 1347
-3985 2 2 8 7 911 2044 1510
-3986 2 2 8 7 861 1983 1653
-3987 2 2 8 7 827 2009 1906
-3988 2 2 8 7 1906 2009 454
-3989 2 2 8 7 666 1865 1517
-3990 2 2 8 7 1517 1865 534
-3991 2 2 8 7 1786 1956 674
-3992 2 2 8 7 1481 1866 465
-3993 2 2 8 7 133 2047 1694
-3994 2 2 8 7 1946 2028 373
-3995 2 2 8 7 711 1875 1788
-3996 2 2 8 7 1789 1876 712
-3997 2 2 8 7 1600 1816 606
-3998 2 2 8 7 849 2028 1946
-3999 2 2 8 7 1788 1875 191
-4000 2 2 8 7 192 1876 1789
-4001 2 2 8 7 1445 2071 917
-4002 2 2 8 7 703 1913 1764
-4003 2 2 8 7 732 2064 1819
-4004 2 2 8 7 49 1816 1600
-4005 2 2 8 7 1567 1893 515
-4006 2 2 8 7 734 1966 1795
-4007 2 2 8 7 602 2073 1680
-4008 2 2 8 7 524 2015 1390
-4009 2 2 8 7 639 2034 1383
-4010 2 2 8 7 605 1785 1599
-4011 2 2 8 7 1393 2059 967
-4012 2 2 8 7 580 1958 1437
-4013 2 2 8 7 1384 2041 643
-4014 2 2 8 7 1466 1945 864
-4015 2 2 8 7 1938 2091 713
-4016 2 2 8 7 1472 1917 585
-4017 2 2 8 7 1653 1983 586
-4018 2 2 8 7 1412 2057 624
-4019 2 2 8 7 1688 1748 271
-4020 2 2 8 7 433 2070 1672
-4021 2 2 8 7 387 2059 1393
-4022 2 2 8 7 1443 1983 346
-4023 2 2 8 7 665 1754 1739
-4024 2 2 8 7 538 1932 1510
-4025 2 2 8 7 1446 1986 770
-4026 2 2 8 7 626 1891 1548
-4027 2 2 8 7 319 2060 1696
-4028 2 2 8 7 1711 2048 628
-4029 2 2 8 7 700 1956 1786
-4030 2 2 8 7 1548 1891 329
-4031 2 2 8 7 1556 2049 590
-4032 2 2 8 7 591 2050 1557
-4033 2 2 8 7 869 1872 1870
-4034 2 2 8 7 1870 1872 587
-4035 2 2 8 7 1457 2001 448
-4036 2 2 8 7 599 1873 1576
-4037 2 2 8 7 1575 1874 600
-4038 2 2 8 7 1739 1754 659
-4039 2 2 8 7 1564 2018 620
-4040 2 2 8 7 774 2067 1877
-4041 2 2 8 7 309 1919 1558
-4042 2 2 8 7 979 1893 1567
-4043 2 2 8 7 185 2016 1449
-4044 2 2 8 7 1521 1954 820
-4045 2 2 8 7 761 1965 1509
-4046 2 2 8 7 1507 1971 615
-4047 2 2 8 7 1813 1880 561
-4048 2 2 8 7 394 1954 1521
-4049 2 2 8 7 620 2018 1603
-4050 2 2 8 7 1476 2007 181
-4051 2 2 8 7 1527 1968 568
-4052 2 2 8 7 1505 2002 526
-4053 2 2 8 7 393 2071 1445
-4054 2 2 8 7 1809 1852 422
-4055 2 2 8 7 807 1852 1809
-4056 2 2 8 7 1489 2023 398
-4057 2 2 8 7 1505 2020 904
-4058 2 2 8 7 1796 1798 809
-4059 2 2 8 7 593 1798 1796
-4060 2 2 8 7 343 1982 1819
-4061 2 2 8 7 1819 1982 732
-4062 2 2 8 7 852 2061 1840
-4063 2 2 8 7 1840 2061 336
-4064 2 2 8 7 1543 2038 596
-4065 2 2 8 7 765 1891 1814
-4066 2 2 8 7 1877 2033 774
-4067 2 2 8 7 228 2033 1877
-4068 2 2 8 7 604 1882 1696
-4069 2 2 8 7 341 2030 1705
-4070 2 2 8 7 623 2072 1705
-4071 2 2 8 7 327 2065 1647
-4072 2 2 8 7 786 1902 1901
-4073 2 2 8 7 1901 1902 629
-4074 2 2 8 7 281 2018 1564
-4075 2 2 8 7 1587 2005 723
-4076 2 2 8 7 1760 1904 675
-4077 2 2 8 7 676 1905 1761
-4078 2 2 8 7 73 1904 1760
-4079 2 2 8 7 1761 1905 104
-4080 2 2 8 7 1697 2077 288
-4081 2 2 8 7 705 2077 1697
-4082 2 2 8 7 1584 2017 269
-4083 2 2 8 7 1632 1990 13
-4084 2 2 8 7 1783 2042 626
-4085 2 2 8 7 1814 1891 626
-4086 2 2 8 7 674 1956 1834
-4087 2 2 8 7 752 1880 1813
-4088 2 2 8 7 1764 1913 654
-4089 2 2 8 7 1696 2060 604
-4090 2 2 8 7 819 1984 1860
-4091 2 2 8 7 1705 2072 341
-4092 2 2 8 7 1592 2062 913
-4093 2 2 8 7 643 1942 1767
-4094 2 2 8 7 764 2042 1628
-4095 2 2 8 7 664 2066 1673
-4096 2 2 8 7 1782 1936 881
-4097 2 2 8 7 1621 2058 611
-4098 2 2 8 7 1883 2072 623
-4099 2 2 8 7 1922 2008 710
-4100 2 2 8 7 1647 2065 646
-4101 2 2 8 7 1673 2066 210
-4102 2 2 8 7 1795 1966 651
-4103 2 2 8 7 148 2089 1975
-4104 2 2 8 7 604 2060 1807
-4105 2 2 8 7 1985 2065 808
-4106 2 2 8 7 646 2065 1985
-4107 2 2 8 7 1705 2030 657
-4108 2 2 8 7 1672 2070 795
-4109 2 2 8 7 1834 1956 224
-4110 2 2 8 7 1694 2047 612
-4111 2 2 8 7 333 2048 1711
-4112 2 2 8 7 702 1943 1933
-4113 2 2 8 7 1933 1943 706
-4114 2 2 8 7 2086 2087 1048
-4115 2 2 8 7 625 2087 2086
-4116 2 2 8 7 1860 1984 386
-4117 2 2 8 7 2008 2085 710
-4118 2 2 8 7 1807 2060 766
-4119 2 2 8 7 590 2049 1820
-4120 2 2 8 7 1821 2050 591
-4121 2 2 8 7 707 2008 1922
-4122 2 2 8 7 1819 2064 679
-4123 2 2 8 7 1877 2067 673
-4124 2 2 8 7 835 2072 1883
-4125 2 2 8 7 2014 2066 664
-4126 2 2 8 7 902 2066 2014
-4127 2 2 8 7 1975 2089 689
-4128 2 2 8 7 227 2085 2008
+5 4127
+5 0 15 1
+1 4
+2 1 1 30
+2 5 21
+3 21 22
+4 22 23
+5 23 24
+6 24 25
+7 25 26
+8 26 27
+9 27 28
+10 28 29
+11 29 30
+12 30 31
+13 31 32
+14 32 33
+15 33 34
+16 34 35
+17 35 36
+18 36 37
+19 37 38
+20 38 39
+21 39 40
+22 40 41
+23 41 42
+24 42 43
+25 43 44
+26 44 45
+27 45 46
+28 46 47
+29 47 48
+30 48 49
+31 49 3
+3 1 1 40
+32 3 50
+33 50 51
+34 51 52
+35 52 53
+36 53 54
+37 54 55
+38 55 56
+39 56 57
+40 57 58
+41 58 59
+42 59 60
+43 60 61
+44 61 62
+45 62 63
+46 63 64
+47 64 65
+48 65 66
+49 66 67
+50 67 68
+51 68 69
+52 69 70
+53 70 71
+54 71 72
+55 72 73
+56 73 74
+57 74 75
+58 75 76
+59 76 77
+60 77 78
+61 78 79
+62 79 80
+63 80 81
+64 81 82
+65 82 83
+66 83 84
+67 84 85
+68 85 86
+69 86 87
+70 87 88
+71 88 2
+5 1 1 30
+72 1 128
+73 128 129
+74 129 130
+75 130 131
+76 131 132
+77 132 133
+78 133 134
+79 134 135
+80 135 136
+81 136 137
+82 137 138
+83 138 139
+84 139 140
+85 140 141
+86 141 142
+87 142 143
+88 143 144
+89 144 145
+90 145 146
+91 146 147
+92 147 148
+93 148 149
+94 149 150
+95 150 151
+96 151 152
+97 152 153
+98 153 154
+99 154 155
+100 155 156
+101 156 4
+7 2 2 4026
+102 159 1413 814
+103 1413 1550 814
+104 252 1331 1043
+105 668 1619 285
+106 232 905 662
+107 628 1250 463
+108 808 809 407
+109 327 809 808
+110 764 885 203
+111 163 1409 1230
+112 763 797 337
+113 484 1135 745
+114 744 1136 485
+115 417 851 810
+116 420 1488 652
+117 20 1090 5
+118 360 964 721
+119 715 1276 296
+120 673 1728 936
+121 863 1547 641
+122 1246 2006 1112
+123 231 1547 863
+124 807 2029 206
+125 437 1087 728
+126 1644 1762 818
+127 371 987 662
+128 285 1619 679
+129 662 987 232
+130 807 2092 2029
+131 278 1173 619
+132 416 1122 642
+133 1741 1793 834
+134 463 985 628
+135 4 1094 6
+136 396 1980 631
+137 302 930 761
+138 762 824 487
+139 1213 1263 329
+140 891 1233 507
+141 329 1263 750
+142 424 1737 644
+143 357 945 879
+144 320 820 740
+145 594 1304 1146
+146 645 1006 245
+147 445 1275 653
+148 551 1374 1236
+149 357 2029 742
+150 370 1006 645
+151 879 945 428
+152 5 1090 21
+153 936 1728 364
+154 595 1470 956
+155 630 1463 921
+156 516 1246 1112
+157 245 1546 645
+158 921 1463 208
+159 644 1737 778
+160 800 1317 537
+161 777 2029 357
+162 778 1737 210
+163 282 1317 800
+164 229 1278 844
+165 845 1279 230
+166 1348 1511 895
+167 1033 1269 27
+168 326 1644 818
+169 1146 1304 482
+170 683 1841 171
+171 390 1040 897
+172 896 1039 389
+173 240 1285 756
+174 356 931 839
+175 675 1119 411
+176 410 1118 676
+177 443 898 725
+178 726 899 444
+179 156 1094 4
+180 699 884 215
+181 771 1847 361
+182 637 1377 451
+183 257 989 637
+184 751 1081 340
+185 27 1269 28
+186 914 1386 549
+187 619 1514 278
+188 267 1247 692
+189 617 1741 834
+190 355 837 769
+191 914 1078 173
+192 486 1078 914
+193 311 824 762
+194 987 1026 508
+195 371 1026 987
+196 828 1847 771
+197 887 925 170
+198 447 1787 1143
+199 753 1573 388
+200 762 1365 237
+201 733 1238 475
+202 753 1676 203
+203 666 1177 216
+204 640 1501 292
+205 280 1238 733
+206 354 977 651
+207 1251 1281 701
+208 618 1063 238
+209 638 999 412
+210 217 931 729
+211 896 1306 610
+212 815 1236 474
+213 565 973 719
+214 354 828 771
+215 2029 2092 742
+216 709 1032 409
+217 268 1375 690
+218 278 1032 709
+219 871 1084 240
+220 630 1048 379
+221 469 1084 871
+222 849 1022 212
+223 29 1269 728
+224 450 1022 849
+225 379 1463 630
+226 62 1570 953
+227 954 1571 115
+228 240 1312 1285
+229 806 891 507
+230 1087 2000 728
+231 789 1333 244
+232 387 997 641
+233 259 1231 750
+234 956 1470 352
+235 750 1231 473
+236 717 1772 413
+237 702 963 209
+238 423 1198 786
+239 238 1486 618
+240 1610 1618 625
+241 66 759 67
+242 110 758 111
+243 1278 1626 844
+244 845 1627 1279
+245 964 975 457
+246 360 975 964
+247 805 1129 456
+248 718 1559 142
+249 232 1129 805
+250 769 837 212
+251 884 1531 215
+252 713 1176 222
+253 164 1320 688
+254 365 925 778
+255 688 1320 471
+256 349 1386 825
+257 631 1066 396
+258 778 925 384
+259 216 1480 666
+260 215 1531 1290
+261 1306 1900 610
+262 745 1477 484
+263 485 1478 744
+264 412 1174 638
+265 334 916 914
+266 914 916 486
+267 674 1834 365
+268 447 1633 1194
+269 890 1633 447
+270 769 841 355
+271 982 1676 753
+272 748 1232 349
+273 380 850 829
+274 237 1524 762
+275 637 1270 257
+276 760 1126 530
+277 1040 1484 897
+278 896 1483 1039
+279 1158 1252 578
+280 174 1313 727
+281 1182 1512 151
+282 742 1959 357
+283 923 1054 472
+284 243 1054 923
+285 451 1289 637
+286 1134 1237 582
+287 171 1841 771
+288 885 1573 753
+289 670 984 503
+290 292 1469 640
+291 880 1931 224
+292 1103 1606 678
+293 256 1233 891
+294 704 1128 310
+295 724 1931 880
+296 720 2053 254
+297 522 1419 1044
+298 373 2028 763
+299 206 1606 1103
+300 222 997 713
+301 420 2063 718
+302 637 1120 415
+303 415 1270 637
+304 927 928 350
+305 692 1223 267
+306 445 928 927
+307 392 1625 686
+308 760 1594 1126
+309 1421 1656 284
+310 1075 1274 160
+311 636 1274 1075
+312 746 880 398
+313 763 2028 797
+314 641 1547 387
+315 349 1232 791
+316 1124 1610 625
+317 427 1130 889
+318 698 1831 1682
+319 176 1251 701
+320 130 1181 686
+321 234 984 670
+322 200 929 716
+323 349 1612 1386
+324 365 1474 674
+325 36 779 37
+326 676 1046 410
+327 411 1045 675
+328 715 920 199
+329 645 1506 370
+330 414 1067 647
+331 140 1308 652
+332 185 968 927
+333 927 968 445
+334 731 1197 205
+335 204 1196 730
+336 569 1678 733
+337 1043 1331 531
+338 287 2000 1087
+339 652 1488 140
+340 745 1135 517
+341 518 1136 744
+342 170 925 850
+343 203 885 753
+344 429 1237 1134
+345 961 1276 715
+346 455 1252 1158
+347 1143 1787 584
+348 203 1814 764
+349 197 1348 895
+350 810 851 338
+351 841 970 355
+352 644 1655 424
+353 51 776 52
+354 125 775 126
+355 642 1218 416
+356 975 1409 163
+357 944 1772 717
+358 504 1245 860
+359 454 993 937
+360 1522 2057 1097
+361 936 1280 228
+362 937 993 241
+363 18 1268 940
+364 187 1236 815
+365 647 1191 414
+366 1375 1800 690
+367 1682 1982 698
+368 941 2053 720
+369 936 1877 673
+370 681 1656 1421
+371 441 1244 1036
+372 1036 1244 586
+373 380 2019 850
+374 829 850 365
+375 495 1233 832
+376 832 1233 256
+377 244 1333 1183
+378 828 1260 225
+379 400 1753 696
+380 697 1752 401
+381 431 1240 1037
+382 923 1901 629
+383 695 1220 47
+384 705 1546 245
+385 337 1729 763
+386 882 1243 8
+387 355 2084 837
+388 870 2063 420
+389 524 1669 748
+390 340 941 720
+391 1814 2042 764
+392 1056 1235 434
+393 382 944 717
+394 900 1169 248
+395 588 1512 1182
+396 733 1678 280
+397 220 892 811
+398 841 892 220
+399 340 1081 941
+400 142 1559 143
+401 750 1014 329
+402 1464 1541 962
+403 386 1950 837
+404 402 1642 791
+405 652 1223 420
+406 819 1604 359
+407 653 1208 445
+408 651 1260 354
+409 952 1572 575
+410 749 1847 225
+411 487 1365 762
+412 1700 1899 353
+413 934 1950 386
+414 1739 1812 172
+415 409 1865 666
+416 228 1280 1120
+417 245 1853 705
+418 1601 2039 396
+419 395 1522 1097
+420 933 1157 417
+421 204 1039 671
+422 672 1040 205
+423 710 2085 382
+424 509 1554 950
+425 1253 1554 509
+426 510 1201 900
+427 483 1169 1147
+428 372 960 949
+429 1147 1169 595
+430 805 948 308
+431 912 913 465
+432 442 1993 853
+433 932 1646 209
+434 341 913 912
+435 316 2046 792
+436 379 965 743
+437 793 2046 316
+438 1091 1851 196
+439 743 965 167
+440 797 2028 212
+441 199 961 715
+442 281 1793 1741
+443 1201 1475 900
+444 1646 1660 209
+445 662 1372 371
+446 62 953 63
+447 114 954 115
+448 853 1993 947
+449 384 925 887
+450 857 1102 219
+451 1012 1198 423
+452 372 932 749
+453 720 1061 560
+454 1130 1580 889
+455 337 983 833
+456 51 1726 776
+457 775 1725 126
+458 949 960 432
+459 761 930 429
+460 334 891 806
+461 363 958 729
+462 356 1916 931
+463 679 1593 285
+464 426 1144 663
+465 834 1151 259
+466 353 1899 919
+467 167 965 821
+468 457 1151 834
+469 253 1135 919
+470 172 1812 856
+471 919 1135 484
+472 791 909 349
+473 225 1260 906
+474 7 882 8
+475 196 1337 912
+476 767 969 231
+477 359 1604 901
+478 947 974 162
+479 663 1255 426
+480 743 1886 379
+481 741 1886 307
+482 307 1886 743
+483 692 1247 440
+484 729 1756 363
+485 488 969 767
+486 868 959 221
+487 684 1014 185
+488 1033 1312 437
+489 549 1703 914
+490 459 959 868
+491 179 1380 1272
+492 729 958 217
+493 742 2092 839
+494 839 2092 356
+495 212 2028 849
+496 748 1669 1232
+497 705 1697 369
+498 353 917 785
+499 961 1001 392
+500 413 970 717
+501 493 1291 908
+502 382 974 710
+503 777 1180 453
+504 18 940 19
+505 228 1877 936
+506 357 1180 777
+507 714 973 369
+508 310 1128 811
+509 413 924 886
+510 225 1847 828
+511 773 1646 372
+512 444 1685 859
+513 571 1646 773
+514 369 1697 714
+515 699 1060 272
+516 440 1060 699
+517 838 1215 331
+518 719 973 168
+519 791 1642 909
+520 666 1480 409
+521 734 996 452
+522 841 1794 970
+523 981 1722 1465
+524 403 1161 1080
+525 773 949 161
+526 648 1239 1172
+527 1172 1239 489
+528 365 1834 829
+529 1517 1555 910
+530 749 960 372
+531 421 1175 689
+532 764 1572 885
+533 202 1372 915
+534 66 1326 759
+535 758 1325 111
+536 763 1729 1024
+537 1337 2030 912
+538 225 960 749
+539 833 1737 424
+540 240 1648 871
+541 815 1831 642
+542 1106 1121 417
+543 372 949 773
+544 293 1831 815
+545 704 1851 1091
+546 561 1121 1106
+547 723 2005 1195
+548 702 1933 963
+549 590 1440 1364
+550 1365 1441 591
+551 719 1719 565
+552 380 1931 724
+553 194 1227 1201
+554 226 1423 928
+555 795 1657 209
+556 1201 1227 656
+557 797 934 337
+558 551 1175 1041
+559 285 1468 668
+560 272 1773 1309
+561 1644 1995 583
+562 721 1722 360
+563 344 1517 910
+564 1041 1175 421
+565 396 2039 1055
+566 310 1004 704
+567 1933 2013 375
+568 997 1938 713
+569 883 1453 242
+570 727 1079 174
+571 406 1079 727
+572 725 1863 300
+573 301 1864 726
+574 298 1229 1020
+575 366 1052 739
+576 417 1157 1106
+577 195 1021 818
+578 522 1044 1042
+579 503 1334 670
+580 690 1800 218
+581 714 1742 973
+582 973 1742 168
+583 1042 1044 374
+584 560 1706 720
+585 500 1468 767
+586 720 1706 340
+587 1236 1374 474
+588 1229 1489 1020
+589 28 1269 29
+590 738 1068 407
+591 242 1068 738
+592 439 1281 1251
+593 1385 1648 240
+594 966 1372 202
+595 1682 1831 293
+596 800 1624 1078
+597 424 1167 682
+598 471 1062 688
+599 222 1176 946
+600 953 1570 573
+601 572 1571 954
+602 375 2013 886
+603 359 1786 902
+604 902 1786 674
+605 154 1345 1056
+606 348 1464 962
+607 763 994 373
+608 297 998 716
+609 538 1235 1056
+610 842 1031 505
+611 946 1422 330
+612 305 1031 842
+613 615 1425 926
+614 328 1511 863
+615 693 1071 480
+616 900 1470 1169
+617 361 1283 771
+618 1054 1980 396
+619 716 1394 491
+620 185 1449 684
+621 863 1511 1340
+622 456 948 805
+623 778 1962 644
+624 671 1196 204
+625 205 1197 672
+626 851 1155 338
+627 565 1539 1035
+628 1037 1240 526
+629 859 1396 444
+630 349 1832 748
+631 367 1502 738
+632 716 1675 200
+633 217 945 839
+634 767 1340 500
+635 1313 1923 727
+636 493 1800 1375
+637 137 840 138
+638 670 1218 234
+639 378 1295 950
+640 492 1388 715
+641 963 1933 375
+642 474 1670 815
+643 336 982 753
+644 624 2057 1522
+645 811 1128 579
+646 875 1378 543
+647 1284 1423 226
+648 299 1378 875
+649 321 2027 922
+650 753 1840 336
+651 170 2019 796
+652 384 1962 778
+653 860 1558 504
+654 730 1769 204
+655 205 1768 731
+656 382 2085 944
+657 216 1177 826
+658 338 1155 871
+659 284 1707 1421
+660 695 2043 297
+661 1756 1922 363
+662 157 1949 852
+663 409 1631 709
+664 642 1122 815
+665 852 1949 682
+666 36 1315 779
+667 417 1121 851
+668 839 931 217
+669 901 1943 298
+670 706 1943 901
+671 850 925 365
+672 1133 1488 420
+673 732 1982 1682
+674 387 1938 997
+675 86 816 87
+676 90 817 91
+677 901 1786 359
+678 173 1386 914
+679 210 1474 778
+680 682 1949 424
+681 901 2078 1786
+682 168 1987 719
+683 760 1234 246
+684 877 1242 332
+685 496 1242 877
+686 272 1533 699
+687 1078 1624 173
+688 626 2042 1814
+689 1082 1301 436
+690 473 1415 750
+691 685 1707 284
+692 246 1482 976
+693 976 1482 613
+694 204 1769 745
+695 744 1768 205
+696 546 1321 780
+697 781 1322 547
+698 581 1762 1644
+699 386 983 934
+700 823 969 381
+701 981 1152 513
+702 251 1152 981
+703 860 1245 233
+704 969 1162 381
+705 686 1276 392
+706 178 1029 952
+707 34 858 35
+708 738 1008 367
+709 362 2010 1022
+710 1173 1417 619
+711 705 1853 1140
+712 145 1000 146
+713 947 1679 974
+714 112 874 113
+715 64 873 65
+716 615 1971 1425
+717 242 1453 1068
+718 429 1163 761
+719 776 1881 297
+720 606 1881 776
+721 761 1163 214
+722 800 1078 405
+723 1215 1397 331
+724 367 1529 1502
+725 186 1155 851
+726 211 1162 1115
+727 171 1691 683
+728 850 2019 170
+729 922 2027 708
+730 209 1657 932
+731 886 924 375
+732 1126 1594 477
+733 686 1892 296
+734 196 1830 1091
+735 783 1088 474
+736 265 1437 787
+737 378 1478 1295
+738 1037 1338 23
+739 179 1553 879
+740 157 994 763
+741 1089 1172 260
+742 272 1309 889
+743 347 1572 952
+744 922 1137 183
+745 284 1432 685
+746 576 1301 1082
+747 296 1892 775
+748 629 1327 923
+749 853 947 162
+750 775 1892 605
+751 603 1650 1074
+752 218 1241 690
+753 690 1241 426
+754 821 1215 167
+755 1898 1916 907
+756 1294 1719 719
+757 1044 1419 250
+758 829 1931 380
+759 500 1511 1348
+760 704 1091 346
+761 360 1722 981
+762 333 1073 813
+763 689 1200 421
+764 1022 2010 769
+765 369 1546 705
+766 145 1493 1000
+767 241 1298 1124
+768 171 1898 907
+769 731 1469 292
+770 292 1045 731
+771 730 1046 291
+772 855 1125 193
+773 1286 1330 479
+774 1038 1625 392
+775 951 1529 367
+776 794 1011 313
+777 291 1217 730
+778 142 1133 718
+779 1065 1753 400
+780 401 1752 1064
+781 858 1069 370
+782 296 1276 686
+783 1275 1661 653
+784 686 1625 130
+785 690 1255 268
+786 688 1367 164
+787 41 990 42
+788 381 967 823
+789 488 1162 969
+790 733 1523 569
+791 601 1102 857
+792 167 1215 838
+793 425 1429 737
+794 1668 1829 273
+795 255 1015 869
+796 231 969 823
+797 565 1839 973
+798 453 1049 777
+799 717 1282 382
+800 464 1243 882
+801 527 1889 1720
+802 277 1719 1294
+803 816 1999 661
+804 1391 1733 308
+805 309 1734 1392
+806 325 1901 923
+807 1182 1183 588
+808 481 1183 1182
+809 426 1255 690
+810 964 1564 721
+811 699 1533 884
+812 1448 1689 980
+813 1102 1985 219
+814 908 1291 184
+815 763 1024 157
+816 346 1128 704
+817 550 1422 946
+818 701 1145 393
+819 692 1683 420
+820 1199 1602 358
+821 701 1445 176
+822 824 1928 487
+823 217 1016 945
+824 759 1326 466
+825 467 1325 758
+826 583 1995 1303
+827 480 1743 693
+828 314 1837 804
+829 1045 1197 731
+830 730 1196 1046
+831 315 1999 816
+832 804 1837 596
+833 696 1310 400
+834 401 1311 697
+835 502 1314 1211
+836 178 1093 962
+837 771 1841 354
+838 276 1145 701
+839 317 2006 1246
+840 212 1022 769
+841 962 1093 458
+842 1089 1784 1172
+843 134 1694 737
+844 879 1380 179
+845 547 1605 781
+846 781 1605 307
+847 166 1153 772
+848 296 1496 715
+849 716 1497 297
+850 418 1009 873
+851 874 1010 419
+852 491 1497 716
+853 715 1496 492
+854 873 1009 466
+855 467 1010 874
+856 1041 1374 551
+857 570 1721 1042
+858 420 1223 692
+859 847 1073 333
+860 479 1330 1070
+861 1195 2005 260
+862 282 1156 711
+863 407 1297 738
+864 747 1569 295
+865 832 1166 495
+866 359 2014 819
+867 819 2014 664
+868 447 1277 890
+869 951 1888 1529
+870 283 1132 727
+871 219 1732 1052
+872 1052 1732 739
+873 727 1132 406
+874 353 1210 917
+875 17 1523 733
+876 393 1445 701
+877 837 2084 386
+878 179 1185 784
+879 787 1920 265
+880 930 1237 429
+881 919 1210 353
+882 728 1639 29
+883 784 1185 438
+884 407 1068 739
+885 712 1132 283
+886 300 1407 725
+887 726 1408 301
+888 898 1863 725
+889 726 1864 899
+890 393 1011 794
+891 328 1951 1168
+892 674 1474 902
+893 847 985 233
+894 884 1533 563
+895 1074 1702 603
+896 388 1840 753
+897 512 1312 1033
+898 709 1631 169
+899 362 1812 892
+900 302 1618 1610
+901 1168 1951 796
+902 386 2084 846
+903 244 1183 942
+904 297 1881 695
+905 892 1812 659
+906 694 1258 470
+907 440 1302 692
+908 1080 1161 490
+909 640 1253 1225
+910 1225 1253 248
+911 942 1183 481
+912 827 1730 381
+913 470 1313 694
+914 585 1730 827
+915 198 1342 747
+916 885 1572 347
+917 900 1288 510
+918 248 1288 900
+919 770 1217 291
+920 290 1086 735
+921 736 1085 289
+922 172 1190 1003
+923 718 1133 420
+924 902 1474 210
+925 827 1162 211
+926 940 1268 475
+927 41 1144 990
+928 614 1362 1093
+929 1093 1362 458
+930 47 1607 695
+931 879 1553 1180
+932 385 1850 812
+933 238 1063 904
+934 945 1016 428
+935 1309 1773 680
+936 709 1173 278
+937 169 1174 709
+938 796 1025 170
+939 539 1898 1283
+940 724 1882 380
+941 904 1063 438
+942 273 1829 1001
+943 513 1152 1005
+944 1118 1873 1551
+945 1552 1874 1119
+946 699 1302 440
+947 215 1302 699
+948 1005 1152 435
+949 575 1806 952
+950 335 1239 906
+951 779 1315 459
+952 414 2043 1607
+953 231 1340 767
+954 270 1525 1178
+955 177 1081 751
+956 268 1519 978
+957 614 1566 1362
+958 961 1467 1001
+959 289 1085 754
+960 755 1086 290
+961 681 1998 1654
+962 754 1085 390
+963 389 1086 755
+964 186 1859 1155
+965 1062 1776 736
+966 1657 1847 749
+967 818 1996 326
+968 312 1184 1002
+969 819 1860 175
+970 209 1660 702
+971 701 1281 276
+972 452 1649 734
+973 1002 1184 522
+974 254 1776 1062
+975 1195 1630 723
+976 1042 1792 570
+977 740 1708 223
+978 802 1459 119
+979 58 1458 801
+980 388 1013 852
+981 1576 1699 599
+982 600 1698 1575
+983 931 1916 622
+984 289 1640 736
+985 740 1595 320
+986 717 1794 220
+987 161 1105 746
+988 627 1763 1249
+989 478 1344 1027
+990 1754 1953 310
+991 498 1629 972
+992 1392 1919 309
+993 1131 1665 1581
+994 948 2075 308
+995 762 1490 311
+996 505 1490 762
+997 943 998 414
+998 1141 1237 182
+999 668 1723 1619
+1000 582 1237 1141
+1001 790 1242 496
+1002 256 1701 909
+1003 1131 1581 547
+1004 1138 1688 449
+1005 1364 1440 486
+1006 487 1441 1365
+1007 1960 1974 746
+1008 164 2076 1320
+1009 735 1615 290
+1010 841 2010 892
+1011 257 1270 708
+1012 882 1050 464
+1013 1028 1982 343
+1014 708 1273 257
+1015 412 1417 1173
+1016 739 1732 407
+1017 1569 1671 295
+1018 772 1801 306
+1019 808 2065 327
+1020 780 1667 546
+1021 414 1607 1067
+1022 306 1667 780
+1023 438 1063 784
+1024 813 1915 202
+1025 351 1448 980
+1026 166 1186 1153
+1027 921 1774 630
+1028 175 1007 886
+1029 212 1950 797
+1030 206 1937 807
+1031 886 1007 413
+1032 175 1860 846
+1033 112 1325 874
+1034 873 1326 65
+1035 390 1305 754
+1036 755 1306 389
+1037 993 1298 241
+1038 1188 1894 1578
+1039 846 1007 175
+1040 720 1479 1061
+1041 474 1374 783
+1042 154 1056 155
+1043 711 1321 282
+1044 283 1322 712
+1045 746 1609 161
+1046 157 1013 994
+1047 783 1374 252
+1048 751 1521 177
+1049 994 1013 451
+1050 883 1161 403
+1051 958 1016 217
+1052 746 1974 880
+1053 306 1801 782
+1054 755 1212 189
+1055 442 1016 958
+1056 449 1688 1257
+1057 379 1886 1463
+1058 774 1573 347
+1059 302 1610 930
+1060 1498 1623 942
+1061 660 2039 1601
+1062 733 1268 17
+1063 22 1037 23
+1064 768 1142 295
+1065 342 1774 921
+1066 794 1846 393
+1067 992 1771 395
+1068 1468 1930 767
+1069 852 1013 157
+1070 267 1508 888
+1071 220 1282 717
+1072 371 1171 1026
+1073 803 1122 416
+1074 294 1623 1498
+1075 1425 1629 498
+1076 187 1122 803
+1077 386 1984 983
+1078 1035 1546 369
+1079 743 1616 307
+1080 167 1617 743
+1081 917 1210 176
+1082 1056 1345 538
+1083 645 1546 1035
+1084 254 1479 720
+1085 658 1602 1199
+1086 752 1140 499
+1087 24 903 25
+1088 859 1685 555
+1089 34 1069 858
+1090 232 1359 905
+1091 888 1508 552
+1092 563 1533 889
+1093 934 983 337
+1094 909 1701 1612
+1095 889 1533 272
+1096 398 1609 746
+1097 376 1114 787
+1098 785 1406 353
+1099 779 1127 37
+1100 395 1771 1522
+1101 308 2075 1391
+1102 218 1800 864
+1103 410 1873 1118
+1104 1119 1874 411
+1105 848 1150 311
+1106 633 1584 996
+1107 786 1815 423
+1108 996 1584 269
+1109 971 1559 368
+1110 869 1015 383
+1111 1559 2063 368
+1112 748 1608 524
+1113 858 1315 35
+1114 744 1590 518
+1115 517 1591 745
+1116 832 1695 1166
+1117 205 1590 744
+1118 745 1591 204
+1119 1054 1055 472
+1120 1077 1712 1695
+1121 396 1055 1054
+1122 1320 2076 685
+1123 1077 1695 402
+1124 725 1278 229
+1125 230 1279 726
+1126 728 1269 437
+1127 727 1923 283
+1128 1344 1744 1027
+1129 747 1585 198
+1130 444 1396 726
+1131 1047 1398 214
+1132 589 1398 1047
+1133 1197 1874 672
+1134 671 1873 1196
+1135 295 1586 747
+1136 759 1165 67
+1137 110 1164 758
+1138 161 1609 773
+1139 813 1104 497
+1140 315 1104 790
+1141 636 1994 826
+1142 826 1994 313
+1143 1035 1839 565
+1144 361 1847 1657
+1145 1071 1775 253
+1146 735 1775 1071
+1147 726 1396 230
+1148 229 1366 725
+1149 302 1509 821
+1150 1178 1525 603
+1151 725 1366 443
+1152 821 1509 529
+1153 180 1461 918
+1154 530 1638 760
+1155 328 1168 895
+1156 307 1605 741
+1157 840 1611 138
+1158 507 1462 806
+1159 806 1462 188
+1160 910 1433 577
+1161 1190 1614 1003
+1162 929 1394 716
+1163 895 1168 604
+1164 892 2010 362
+1165 852 1840 388
+1166 888 1134 582
+1167 347 2067 774
+1168 989 1377 637
+1169 848 1152 251
+1170 851 1121 186
+1171 435 1152 848
+1172 738 1502 242
+1173 1074 1650 249
+1174 1115 1162 488
+1175 443 1226 898
+1176 1230 1409 513
+1177 715 1388 920
+1178 908 1540 493
+1179 310 1953 1004
+1180 1317 1717 536
+1181 768 1708 1142
+1182 1142 1708 394
+1183 774 1139 388
+1184 750 1263 259
+1185 737 1248 425
+1186 144 1559 971
+1187 988 1403 181
+1188 1427 1801 391
+1189 605 1725 775
+1190 776 1726 606
+1191 876 1076 397
+1192 537 1219 825
+1193 976 2076 2040
+1194 1049 1678 678
+1195 675 1904 1119
+1196 1118 1905 676
+1197 1281 1720 608
+1198 280 1678 1049
+1199 820 1954 740
+1200 1029 1234 364
+1201 533 1234 1029
+1202 9 1243 757
+1203 791 1154 402
+1204 475 1268 733
+1205 1138 1987 168
+1206 181 1187 988
+1207 313 1434 794
+1208 299 1387 803
+1209 812 1096 385
+1210 403 1080 1004
+1211 800 1156 282
+1212 757 1765 9
+1213 782 1801 1427
+1214 214 1965 761
+1215 1225 1501 640
+1216 737 1429 134
+1217 698 1982 1028
+1218 1254 1431 303
+1219 1852 1911 1107
+1220 1616 1685 1224
+1221 307 1616 1224
+1222 526 1338 1037
+1223 404 1059 859
+1224 967 1917 159
+1225 661 1805 816
+1226 499 1542 752
+1227 422 1852 1107
+1228 632 1251 1017
+1229 47 1220 48
+1230 515 1209 1015
+1231 609 1894 1188
+1232 859 1059 230
+1233 835 1202 535
+1234 810 2069 417
+1235 129 1181 130
+1236 599 1699 1018
+1237 1019 1698 600
+1238 576 1159 872
+1239 999 1245 412
+1240 814 1393 159
+1241 318 1714 779
+1242 739 1453 366
+1243 169 1631 793
+1244 1002 1869 1574
+1245 1035 1539 221
+1246 152 935 153
+1247 978 1964 268
+1248 602 1680 957
+1249 875 1677 244
+1250 932 1657 749
+1251 204 1591 1039
+1252 1040 1590 205
+1253 750 1415 1014
+1254 125 1267 775
+1255 776 1266 52
+1256 170 1500 887
+1257 407 1732 808
+1258 941 1081 485
+1259 1272 1380 544
+1260 887 1500 541
+1261 1587 1622 416
+1262 632 1811 1251
+1263 1379 1998 681
+1264 195 1154 791
+1265 978 1519 564
+1266 855 1451 523
+1267 957 1680 336
+1268 316 1451 855
+1269 881 1149 194
+1270 448 1073 847
+1271 411 1874 1197
+1272 1196 1873 410
+1273 811 1861 220
+1274 773 2023 571
+1275 988 1867 1403
+1276 822 1256 397
+1277 685 2076 976
+1278 579 1861 811
+1279 843 1518 30
+1280 757 1243 464
+1281 285 1930 1468
+1282 223 1341 740
+1283 434 1050 882
+1284 772 1651 166
+1285 678 1473 1103
+1286 405 1156 800
+1287 822 1596 324
+1288 1092 1850 385
+1289 177 1521 820
+1290 330 2034 946
+1291 815 1122 187
+1292 305 1438 758
+1293 762 1524 505
+1294 758 1438 467
+1295 992 993 454
+1296 395 993 992
+1297 339 1736 756
+1298 707 1922 1756
+1299 475 1053 940
+1300 1463 1886 741
+1301 1368 1789 781
+1302 761 1509 302
+1303 920 1492 548
+1304 323 1492 920
+1305 391 1153 1072
+1306 158 1297 809
+1307 1072 1153 516
+1308 930 1401 1237
+1309 843 1343 455
+1310 553 1503 929
+1311 929 1503 322
+1312 265 1781 1437
+1313 340 1662 751
+1314 446 1222 1098
+1315 1098 1222 545
+1316 957 1335 602
+1317 756 1285 339
+1318 682 2061 852
+1319 922 1693 1137
+1320 1179 1389 617
+1321 908 1066 631
+1322 604 1807 895
+1323 1254 1898 539
+1324 184 1066 908
+1325 1730 1917 967
+1326 940 1053 431
+1327 895 1807 197
+1328 189 1306 755
+1329 1952 2052 905
+1330 769 2010 841
+1331 297 2043 998
+1332 334 1424 916
+1333 874 1325 467
+1334 466 1326 873
+1335 1547 2059 387
+1336 323 1908 845
+1337 844 1907 322
+1338 555 2054 859
+1339 845 1908 598
+1340 597 1907 844
+1341 86 1292 816
+1342 817 1293 91
+1343 476 1263 1213
+1344 1277 1539 890
+1345 466 1450 759
+1346 249 1335 957
+1347 290 1494 755
+1348 758 1582 305
+1349 459 1315 858
+1350 1305 1462 754
+1351 754 1833 289
+1352 43 972 44
+1353 608 1818 1281
+1354 188 1462 1305
+1355 627 1952 905
+1356 1126 1137 530
+1357 664 1984 819
+1358 183 1137 1126
+1359 956 1710 595
+1360 192 1789 1368
+1361 826 2045 636
+1362 790 1504 315
+1363 496 1504 790
+1364 143 1559 144
+1365 1708 1903 223
+1366 256 1642 832
+1367 1039 1591 1435
+1368 1436 1590 1040
+1369 901 1604 706
+1370 99 955 100
+1371 77 956 78
+1372 306 1652 772
+1373 797 1950 934
+1374 1171 1878 1026
+1375 250 1411 1258
+1376 307 1224 781
+1377 229 1076 876
+1378 1450 1583 759
+1379 798 1854 462
+1380 463 1855 799
+1381 838 1259 167
+1382 756 1385 240
+1383 304 1583 1450
+1384 416 1622 803
+1385 246 1594 760
+1386 628 1825 1250
+1387 1249 1824 627
+1388 541 1178 887
+1389 639 1383 1193
+1390 464 1414 757
+1391 476 1389 1179
+1392 189 1212 836
+1393 1362 1566 255
+1394 865 1360 54
+1395 123 1361 866
+1396 1274 2045 1935
+1397 798 1382 308
+1398 1239 1836 906
+1399 462 1382 798
+1400 782 1667 306
+1401 651 1966 906
+1402 327 1796 809
+1403 1014 1548 329
+1404 723 1622 1587
+1405 906 1966 335
+1406 533 1541 1464
+1407 809 1798 158
+1408 931 1513 729
+1409 263 1012 986
+1410 1003 1739 172
+1411 244 1634 875
+1412 665 1739 1003
+1413 1193 1383 270
+1414 1520 1956 700
+1415 331 1537 838
+1416 771 1283 171
+1417 591 1441 1058
+1418 1057 1440 590
+1419 413 2079 970
+1420 633 1460 1114
+1421 1502 1529 616
+1422 580 1781 812
+1423 347 1573 885
+1424 1114 1460 201
+1425 552 1611 840
+1426 263 1318 1012
+1427 323 1388 866
+1428 388 1573 774
+1429 1095 1314 502
+1430 866 1388 492
+1431 311 1150 824
+1432 849 1110 450
+1433 839 1959 742
+1434 1017 1477 377
+1435 1125 1889 193
+1436 361 1687 1283
+1437 1219 1608 748
+1438 263 1608 1219
+1439 1069 1976 370
+1440 834 1179 617
+1441 202 1797 813
+1442 827 1906 585
+1443 883 1261 366
+1444 1029 1728 952
+1445 1153 1186 516
+1446 983 1673 833
+1447 780 1924 306
+1448 535 1592 835
+1449 384 1702 1074
+1450 1574 1869 190
+1451 791 1232 195
+1452 1098 1411 250
+1453 308 1733 798
+1454 837 1950 212
+1455 209 1672 795
+1456 997 1402 641
+1457 867 1402 222
+1458 1189 1198 536
+1459 983 1984 664
+1460 816 1805 87
+1461 90 1804 817
+1462 767 1930 488
+1463 295 1433 768
+1464 381 1162 827
+1465 482 1446 831
+1466 1032 1865 409
+1467 201 1795 977
+1468 1061 1479 471
+1469 573 1099 953
+1470 954 1100 572
+1471 291 1446 770
+1472 798 1369 97
+1473 80 1370 799
+1474 1007 2079 413
+1475 1041 1331 252
+1476 986 1012 423
+1477 865 1394 322
+1478 677 1671 1569
+1479 491 1394 865
+1480 1846 2071 393
+1481 977 1795 651
+1482 922 1977 321
+1483 523 1125 855
+1484 1073 1915 813
+1485 521 1550 1413
+1486 654 1913 943
+1487 943 1913 200
+1488 1596 1764 324
+1489 1424 1515 916
+1490 1012 1318 536
+1491 659 1812 1739
+1492 432 1111 949
+1493 1005 1230 513
+1494 789 1838 345
+1495 982 2073 408
+1496 1321 1788 780
+1497 781 1789 1322
+1498 779 1532 318
+1499 880 1520 398
+1500 413 1772 924
+1501 825 1624 537
+1502 173 1624 825
+1503 875 1387 299
+1504 914 1703 334
+1505 1813 2077 752
+1506 938 1454 400
+1507 401 1455 939
+1508 775 1496 296
+1509 297 1497 776
+1510 1680 2073 982
+1511 331 1767 1537
+1512 1085 1885 390
+1513 389 1884 1086
+1514 1016 1023 428
+1515 965 1618 821
+1516 1000 1200 146
+1517 975 1170 457
+1518 784 1553 179
+1519 899 1368 444
+1520 163 1170 975
+1521 442 1023 1016
+1522 316 1751 793
+1523 639 1897 946
+1524 946 1897 222
+1525 706 2013 1933
+1526 938 1354 558
+1527 559 1355 939
+1528 1134 1749 429
+1529 370 1506 959
+1530 476 1213 1187
+1531 778 1474 365
+1532 390 1885 1436
+1533 1435 1884 389
+1534 537 1624 800
+1535 259 1179 834
+1536 429 1749 1163
+1537 1093 1806 1404
+1538 1592 2072 835
+1539 489 1461 1195
+1540 844 1972 229
+1541 441 1148 853
+1542 804 1749 314
+1543 823 2059 1547
+1544 459 1532 779
+1545 1195 1461 669
+1546 252 2058 783
+1547 818 1762 195
+1548 460 1407 801
+1549 802 1408 461
+1550 399 1738 1025
+1551 1020 1520 700
+1552 1935 2045 344
+1553 1093 1404 614
+1554 803 1579 187
+1555 227 1083 924
+1556 40 1144 41
+1557 529 1215 821
+1558 219 1989 857
+1559 854 1515 511
+1560 391 1801 1153
+1561 159 1917 788
+1562 1153 1801 772
+1563 803 1622 299
+1564 567 1989 1052
+1565 97 1854 798
+1566 799 1855 80
+1567 1116 1593 427
+1568 1654 1998 198
+1569 596 1641 804
+1570 1416 1477 1017
+1571 1072 1112 243
+1572 516 1112 1072
+1573 1234 1638 364
+1574 441 1157 933
+1575 427 1593 1130
+1576 1406 1846 226
+1577 1285 1312 512
+1578 924 2068 375
+1579 345 1333 789
+1580 760 1638 1234
+1581 389 1306 896
+1582 897 1305 390
+1583 417 2069 933
+1584 863 1262 328
+1585 313 1808 826
+1586 1108 1514 514
+1587 427 1692 1115
+1588 826 1810 216
+1589 787 1437 376
+1590 319 1974 1960
+1591 857 1977 601
+1592 573 1454 1099
+1593 1100 1455 572
+1594 1149 1635 194
+1595 903 1109 25
+1596 830 1399 74
+1597 103 1400 831
+1598 341 2072 1592
+1599 424 1729 833
+1600 1234 1482 246
+1601 787 1373 494
+1602 788 1413 159
+1603 1526 1989 567
+1604 494 1920 787
+1605 1166 1695 566
+1606 801 1458 460
+1607 461 1459 802
+1608 1149 1514 619
+1609 793 1371 169
+1610 898 1226 191
+1611 836 1212 435
+1612 871 1155 469
+1613 308 1382 805
+1614 258 1148 933
+1615 1245 1417 412
+1616 1030 1560 499
+1617 933 1148 441
+1618 792 1451 316
+1619 244 1677 789
+1620 872 1159 269
+1621 1786 2078 700
+1622 543 1677 875
+1623 1720 1889 608
+1624 909 1642 256
+1625 536 1717 1189
+1626 314 1134 888
+1627 1359 1763 905
+1628 420 1683 870
+1629 1600 1726 50
+1630 127 1725 1599
+1631 873 1357 418
+1632 419 1356 874
+1633 523 1499 1125
+1634 682 1167 957
+1635 514 1149 881
+1636 799 1528 463
+1637 281 1564 964
+1638 250 1258 1044
+1639 809 1297 407
+1640 1461 1755 918
+1641 288 2077 1813
+1642 801 1535 58
+1643 119 1534 802
+1644 1282 1471 382
+1645 1309 1692 427
+1646 877 1349 93
+1647 84 1350 878
+1648 1128 1910 579
+1649 508 1160 1129
+1650 676 2011 1046
+1651 1045 2012 675
+1652 833 1673 210
+1653 207 1198 1189
+1654 1108 1568 1514
+1655 1319 1723 668
+1656 916 1364 486
+1657 236 1364 916
+1658 923 1307 325
+1659 472 1307 923
+1660 1619 1723 343
+1661 74 1760 830
+1662 831 1761 103
+1663 435 1822 836
+1664 1604 2013 706
+1665 166 1256 822
+1666 805 1359 232
+1667 924 1772 227
+1668 418 2049 1009
+1669 1010 2050 419
+1670 242 1161 883
+1671 995 1236 187
+1672 1113 1756 303
+1673 1273 1352 501
+1674 551 1236 995
+1675 949 1111 161
+1676 1402 1934 641
+1677 707 1756 1113
+1678 1025 1738 1500
+1679 264 1661 1275
+1680 830 1501 483
+1681 862 1815 325
+1682 176 1445 917
+1683 1406 1700 353
+1684 1009 2049 1556
+1685 1557 2050 1010
+1686 354 1260 828
+1687 382 1471 974
+1688 957 2061 682
+1689 336 2061 957
+1690 1000 1493 531
+1691 133 1694 134
+1692 834 1793 457
+1693 879 1180 357
+1694 1176 2091 312
+1695 867 1193 541
+1696 317 1466 864
+1697 785 1846 1406
+1698 817 1504 1293
+1699 1066 1601 396
+1700 366 1614 1052
+1701 768 1903 1708
+1702 862 1339 423
+1703 953 1099 418
+1704 419 1100 954
+1705 890 1719 277
+1706 565 1719 890
+1707 356 1809 907
+1708 1194 1787 447
+1709 227 1772 944
+1710 662 2052 915
+1711 915 2052 332
+1712 836 1822 311
+1713 952 1806 178
+1714 119 1459 120
+1715 57 1458 58
+1716 806 1424 334
+1717 188 1663 806
+1718 1129 1160 456
+1719 233 1918 860
+1720 1117 1429 425
+1721 527 1689 1448
+1722 146 1200 147
+1723 812 1990 580
+1724 946 2034 639
+1725 230 1890 845
+1726 813 1544 333
+1727 1076 1972 553
+1728 497 1544 813
+1729 1022 1948 362
+1730 910 1903 1433
+1731 738 1297 1008
+1732 853 1244 441
+1733 581 1444 1077
+1734 1077 1444 266
+1735 162 1244 853
+1736 210 1737 833
+1737 404 1259 838
+1738 537 1318 1219
+1739 907 1691 171
+1740 1177 1517 344
+1741 825 1832 349
+1742 666 1517 1177
+1743 1175 1963 689
+1744 320 1731 820
+1745 864 1945 218
+1746 1911 1961 1096
+1747 980 1304 594
+1748 338 1442 810
+1749 149 1975 894
+1750 811 1420 310
+1751 846 2084 2079
+1752 657 2030 1337
+1753 2055 2063 870
+1754 488 1116 1115
+1755 1273 2027 1352
+1756 833 1729 337
+1757 175 1604 819
+1758 1115 1116 427
+1759 824 1485 174
+1760 1319 1348 197
+1761 668 1348 1319
+1762 846 1860 386
+1763 24 1338 903
+1764 821 1618 302
+1765 541 1193 1178
+1766 1178 1193 270
+1767 1499 1818 1125
+1768 1465 1722 570
+1769 1343 1560 1030
+1770 303 1431 1113
+1771 1002 1574 550
+1772 31 1158 32
+1773 631 2006 908
+1774 211 2009 827
+1775 908 2006 317
+1776 618 1868 1063
+1777 1063 1868 784
+1778 566 1287 1166
+1779 1166 1287 164
+1780 120 1207 121
+1781 56 1206 57
+1782 33 1069 34
+1783 840 1779 552
+1784 816 1658 315
+1785 815 1670 293
+1786 505 1524 842
+1787 647 1629 1191
+1788 842 1524 237
+1789 553 1972 1503
+1790 578 1252 1006
+1791 159 1393 967
+1792 332 2052 1952
+1793 265 1911 1096
+1794 1421 1707 613
+1795 311 1822 848
+1796 324 1344 822
+1797 14 1990 1850
+1798 1267 1496 775
+1799 776 1497 1266
+1800 952 2067 347
+1801 673 2067 952
+1802 370 1887 858
+1803 1099 1454 261
+1804 262 1455 1100
+1805 483 1399 830
+1806 831 1400 482
+1807 820 1426 177
+1808 945 1959 839
+1809 357 1959 945
+1810 118 1752 1534
+1811 1535 1753 59
+1812 195 1669 1021
+1813 1209 1716 1015
+1814 333 1711 847
+1815 906 1260 651
+1816 646 1985 1102
+1817 191 2081 898
+1818 601 1995 1102
+1819 976 1707 685
+1820 854 1988 1515
+1821 220 1794 841
+1822 822 1757 166
+1823 257 1110 989
+1824 1077 1154 581
+1825 1444 1778 266
+1826 165 1580 1130
+1827 1047 1941 425
+1828 511 1578 854
+1829 440 1412 1060
+1830 135 2038 136
+1831 1184 1419 522
+1832 1815 1901 325
+1833 1392 1734 635
+1834 634 1733 1391
+1835 1141 1247 582
+1836 458 1362 869
+1837 1213 2074 1187
+1838 869 1362 255
+1839 1117 2038 135
+1840 298 2078 901
+1841 1163 1941 214
+1842 181 1389 1187
+1843 804 1941 1163
+1844 1211 1314 264
+1845 397 1596 822
+1846 424 1949 1024
+1847 1011 1909 574
+1848 601 1977 922
+1849 366 1261 1003
+1850 848 1822 435
+1851 11 1034 12
+1852 445 1208 928
+1853 928 1208 226
+1854 825 1386 173
+1855 326 1995 1644
+1856 621 1899 1700
+1857 823 1547 231
+1858 131 1038 132
+1859 886 2013 175
+1860 200 1674 929
+1861 139 1308 140
+1862 990 1144 426
+1863 853 1921 442
+1864 1083 2068 924
+1865 224 1520 880
+1866 16 1523 17
+1867 1537 1767 722
+1868 984 1123 430
+1869 174 1928 824
+1870 388 1139 1013
+1871 921 1222 446
+1872 208 1222 921
+1873 1083 1780 433
+1874 1042 1721 190
+1875 780 1788 1226
+1876 222 1897 867
+1877 1226 1788 191
+1878 619 1635 1149
+1879 1088 1682 293
+1880 456 1351 948
+1881 1053 1240 431
+1882 1515 1988 236
+1883 658 1682 1088
+1884 189 1900 1306
+1885 1066 2031 1601
+1886 408 1676 982
+1887 368 2063 2055
+1888 1089 1111 432
+1889 436 1296 1082
+1890 938 1978 1354
+1891 1355 1979 939
+1892 1249 1763 462
+1893 508 1129 987
+1894 233 1457 847
+1895 880 1974 724
+1896 221 1277 868
+1897 437 1312 1084
+1898 392 1276 961
+1899 222 1402 997
+1900 935 1345 153
+1901 150 1182 151
+1902 234 1123 984
+1903 434 1235 1050
+1904 589 2041 1384
+1905 1718 2041 589
+1906 455 1518 843
+1907 45 1067 46
+1908 43 1395 972
+1909 856 1948 450
+1910 433 1780 1113
+1911 1036 1157 441
+1912 398 1520 1020
+1913 966 1171 371
+1914 954 1356 419
+1915 418 1357 953
+1916 448 1171 966
+1917 423 1815 862
+1918 230 1396 859
+1919 54 1790 865
+1920 866 1791 123
+1921 1210 1416 176
+1922 1023 1316 428
+1923 1202 1697 288
+1924 1583 1894 556
+1925 557 1895 1582
+1926 714 1697 1202
+1927 882 1516 434
+1928 1213 1891 765
+1929 946 1176 550
+1930 856 1358 172
+1931 871 1648 338
+1932 403 1261 883
+1933 30 1518 31
+1934 484 1210 919
+1935 311 1490 836
+1936 929 1674 553
+1937 836 1491 189
+1938 215 1290 870
+1939 888 1947 267
+1940 957 1167 249
+1941 548 1890 1059
+1942 1046 2011 291
+1943 292 2012 1045
+1944 903 2002 339
+1945 928 1423 350
+1946 1081 1295 485
+1947 1141 1412 440
+1948 905 2052 662
+1949 869 1870 458
+1950 1383 2034 1735
+1951 1383 1735 592
+1952 210 2066 902
+1953 425 1941 1641
+1954 865 1790 491
+1955 492 1791 866
+1956 383 1872 869
+1957 329 1891 1213
+1958 838 1537 404
+1959 610 2026 896
+1960 356 2092 1809
+1961 50 1726 51
+1962 126 1725 127
+1963 1316 1380 428
+1964 415 1693 1270
+1965 978 1143 584
+1966 492 1496 1267
+1967 1266 1497 491
+1968 318 1143 978
+1969 193 1351 855
+1970 137 1543 840
+1971 414 1191 943
+1972 987 1129 232
+1973 854 1578 304
+1974 959 1506 221
+1975 970 1794 717
+1976 158 1339 862
+1977 1191 1629 279
+1978 40 2090 1144
+1979 237 1664 842
+1980 556 1894 1328
+1981 1329 1895 557
+1982 436 1301 911
+1983 846 2079 1007
+1984 863 1340 231
+1985 859 2054 404
+1986 1031 1491 505
+1987 177 1426 950
+1988 1480 2046 409
+1989 269 1159 996
+1990 950 1426 509
+1991 93 1940 877
+1992 878 1939 84
+1993 1198 1902 786
+1994 158 1405 1008
+1995 877 1940 496
+1996 497 1939 878
+1997 207 1902 1198
+1998 892 1420 811
+1999 450 2051 856
+2000 876 1366 229
+2001 469 1087 1084
+2002 342 1264 937
+2003 937 1264 454
+2004 703 1764 1596
+2005 1145 1909 1011
+2006 1084 1087 437
+2007 996 1159 452
+2008 408 2074 1676
+2009 1513 1756 729
+2010 842 1438 305
+2011 141 1133 142
+2012 920 1681 199
+2013 719 1987 1294
+2014 844 1626 597
+2015 598 1627 845
+2016 367 1684 951
+2017 1211 1231 502
+2018 951 1684 562
+2019 332 1242 915
+2020 902 2014 359
+2021 858 1887 459
+2022 1124 1298 519
+2023 860 1918 463
+2024 251 1430 848
+2025 116 1064 117
+2026 60 1065 61
+2027 548 1681 920
+2028 529 1397 1215
+2029 345 1838 911
+2030 446 1817 1803
+2031 904 1736 339
+2032 466 1988 854
+2033 536 1198 1012
+2034 1177 2045 826
+2035 847 1457 448
+2036 1013 1139 451
+2037 1174 1878 638
+2038 1293 1504 496
+2039 845 1492 323
+2040 343 1723 1028
+2041 622 1916 1898
+2042 322 1503 844
+2043 1850 1990 812
+2044 481 1410 894
+2045 30 1639 843
+2046 660 1828 1294
+2047 541 1738 867
+2048 582 1947 888
+2049 630 2083 1048
+2050 1270 1693 708
+2051 637 1289 1120
+2052 862 1405 158
+2053 463 1528 860
+2054 1027 1466 478
+2055 64 1357 873
+2056 874 1356 113
+2057 963 2068 433
+2058 304 1450 854
+2059 854 1450 466
+2060 397 1799 876
+2061 1028 1123 234
+2062 431 1589 940
+2063 1101 1811 247
+2064 641 1934 863
+2065 383 1569 1342
+2066 250 1300 1098
+2067 1342 1569 747
+2068 1003 1261 665
+2069 926 1241 218
+2070 1008 1297 158
+2071 1168 1882 604
+2072 425 1248 1047
+2073 625 1618 965
+2074 257 1273 1214
+2075 542 1123 1028
+2076 322 1907 865
+2077 866 1908 323
+2078 393 1145 1011
+2079 872 1414 464
+2080 855 1759 316
+2081 457 1170 1151
+2082 1151 1170 502
+2083 889 1309 427
+2084 269 1414 872
+2085 972 1395 498
+2086 376 1527 1114
+2087 1080 1851 1004
+2088 54 1360 55
+2089 122 1361 123
+2090 11 1530 1034
+2091 160 1613 1209
+2092 1209 1613 677
+2093 1686 1804 89
+2094 88 1805 1686
+2095 464 1545 872
+2096 1223 1508 267
+2097 257 1214 1110
+2098 652 1508 1223
+2099 325 1645 862
+2100 1258 2035 1044
+2101 363 1993 958
+2102 864 1540 317
+2103 503 1111 1089
+2104 955 1709 100
+2105 77 1710 956
+2106 947 1993 363
+2107 2079 2084 355
+2108 99 1746 955
+2109 956 1745 78
+2110 1034 1632 12
+2111 520 1387 875
+2112 670 1587 1218
+2113 868 1532 459
+2114 1925 1973 770
+2115 1218 1587 416
+2116 561 1381 1376
+2117 428 1380 879
+2118 358 1842 1199
+2119 1131 1322 283
+2120 547 1322 1131
+2121 563 1842 884
+2122 1105 2088 430
+2123 923 1327 243
+2124 684 1548 1014
+2125 534 1555 1517
+2126 1020 2078 298
+2127 700 2078 1020
+2128 1492 1890 548
+2129 960 1563 432
+2130 888 1779 314
+2131 552 1779 888
+2132 2040 2076 479
+2133 470 1923 1313
+2134 377 1769 1217
+2135 963 1672 209
+2136 446 1803 921
+2137 1217 1769 730
+2138 255 1567 1015
+2139 870 1683 215
+2140 1052 1614 567
+2141 294 1963 1175
+2142 312 1929 1176
+2143 868 1835 318
+2144 977 1373 201
+2145 494 1373 977
+2146 318 1532 868
+2147 332 1952 877
+2148 785 2071 1846
+2149 881 1595 514
+2150 320 1595 881
+2151 435 1494 1005
+2152 234 1713 1028
+2153 953 1357 63
+2154 114 1356 954
+2155 930 1610 519
+2156 1028 1713 698
+2157 502 1170 1095
+2158 1534 1752 697
+2159 696 1753 1535
+2160 1095 1170 163
+2161 261 1857 1057
+2162 1058 1858 262
+2163 1402 1738 399
+2164 665 1953 1754
+2165 867 1738 1402
+2166 1019 1927 69
+2167 108 1926 1018
+2168 994 1377 373
+2169 878 1544 497
+2170 186 1880 1542
+2171 988 1187 408
+2172 1114 1527 633
+2173 360 1409 975
+2174 872 1747 576
+2175 1528 1558 860
+2176 309 1558 1528
+2177 881 1936 320
+2178 37 1127 38
+2179 1446 2011 831
+2180 434 1862 1056
+2181 1168 2019 380
+2182 1811 1925 247
+2183 796 2019 1168
+2184 25 1109 26
+2185 527 1720 1101
+2186 530 1280 936
+2187 981 1409 360
+2188 875 1634 520
+2189 218 2056 926
+2190 926 2056 615
+2191 786 1901 1815
+2192 1037 1823 431
+2193 1336 2088 1105
+2194 718 2063 1559
+2195 918 1755 335
+2196 1092 1473 569
+2197 922 2022 601
+2198 1000 1331 421
+2199 183 2022 922
+2200 385 1473 1092
+2201 374 1792 1042
+2202 531 1331 1000
+2203 660 1294 1205
+2204 402 1154 1077
+2205 235 1157 1036
+2206 194 1782 881
+2207 709 1174 1173
+2208 1103 1473 385
+2209 1173 1174 412
+2210 713 2091 1176
+2211 893 1967 469
+2212 918 1353 180
+2213 1271 2060 319
+2214 1292 1658 816
+2215 933 2069 258
+2216 366 1453 883
+2217 457 1793 964
+2218 1774 2083 630
+2219 955 1970 1709
+2220 1038 1829 612
+2221 340 1706 991
+2222 439 1720 1281
+2223 1454 1848 400
+2224 401 1849 1455
+2225 7 1516 882
+2226 579 1471 1282
+2227 848 1430 1150
+2228 878 2048 1544
+2229 907 1916 356
+2230 1251 1811 439
+2231 264 1912 1661
+2232 335 1649 918
+2233 1005 1715 1230
+2234 894 1410 149
+2235 221 1506 1035
+2236 345 1932 935
+2237 893 1542 499
+2238 1765 2017 568
+2239 1544 2048 333
+2240 1575 1698 274
+2241 275 1699 1576
+2242 436 1536 1296
+2243 1341 1595 740
+2244 1094 1862 434
+2245 577 1935 910
+2246 659 1420 892
+2247 910 1935 344
+2248 241 2083 937
+2249 986 1608 263
+2250 1219 1318 263
+2251 350 1363 927
+2252 843 2000 1343
+2253 887 1702 384
+2254 1181 1892 686
+2255 452 1353 918
+2256 1803 1817 788
+2257 224 1956 1520
+2258 105 1118 106
+2259 71 1119 72
+2260 1607 2043 695
+2261 1279 1408 726
+2262 725 1407 1278
+2263 498 1487 926
+2264 421 1200 1000
+2265 469 1859 893
+2266 944 2085 227
+2267 1023 1921 258
+2268 927 2016 185
+2269 612 1829 1668
+2270 915 1372 662
+2271 415 1280 1137
+2272 966 1915 448
+2273 1137 1280 530
+2274 942 1623 520
+2275 437 1269 1033
+2276 148 1975 149
+2277 1379 1421 348
+2278 681 1421 1379
+2279 501 1352 1190
+2280 950 1295 177
+2281 812 1781 1096
+2282 1190 1352 567
+2283 1255 1519 268
+2284 1021 1390 327
+2285 663 1519 1255
+2286 524 1390 1021
+2287 1 1599 128
+2288 127 1599 1
+2289 3 1600 50
+2290 49 1600 3
+2291 458 1332 962
+2292 1060 1773 272
+2293 962 1332 348
+2294 952 1728 673
+2295 624 1773 1060
+2296 431 1823 1090
+2297 906 1836 225
+2298 779 1714 1127
+2299 734 1460 996
+2300 891 1701 256
+2301 371 1372 966
+2302 1106 1157 235
+2303 481 1498 942
+2304 334 1703 891
+2305 917 2071 785
+2306 894 1498 481
+2307 392 1829 1038
+2308 889 1580 563
+2309 45 1914 1067
+2310 890 1539 565
+2311 766 2060 1271
+2312 893 1859 1542
+2313 1299 1566 614
+2314 239 2044 1301
+2315 303 1756 1513
+2316 277 1633 890
+2317 352 1470 900
+2318 608 1889 1125
+2319 1024 1729 424
+2320 160 1204 1075
+2321 1075 1204 468
+2322 900 1475 352
+2323 912 2030 341
+2324 1542 1859 186
+2325 1471 1997 974
+2326 1301 2044 911
+2327 411 1197 1045
+2328 1046 1196 410
+2329 647 1914 972
+2330 339 1727 903
+2331 972 1914 44
+2332 920 1388 323
+2333 1097 1298 395
+2334 75 1147 76
+2335 101 1146 102
+2336 895 1511 328
+2337 519 1298 1097
+2338 1247 1947 582
+2339 968 1275 445
+2340 69 1927 70
+2341 107 1926 108
+2342 499 1560 893
+2343 847 1711 985
+2344 574 1499 1265
+2345 465 1830 912
+2346 539 1431 1254
+2347 904 2020 238
+2348 915 1879 202
+2349 177 1295 1081
+2350 905 1763 627
+2351 235 1481 913
+2352 1088 1670 474
+2353 1216 1924 443
+2354 1031 1900 1491
+2355 502 1231 1151
+2356 438 1736 904
+2357 226 1846 1284
+2358 443 1924 1226
+2359 1284 1846 794
+2360 433 2068 1083
+2361 1154 1762 581
+2362 339 1505 904
+2363 978 1714 318
+2364 564 1714 978
+2365 911 1838 436
+2366 912 1830 196
+2367 1290 2055 870
+2368 473 1231 1211
+2369 169 1371 1026
+2370 991 1654 198
+2371 1026 1371 508
+2372 943 1675 998
+2373 560 1654 991
+2374 1139 1289 451
+2375 322 1394 929
+2376 1741 2007 687
+2377 653 1700 1406
+2378 405 1856 1156
+2379 249 1655 1074
+2380 364 1638 936
+2381 519 1401 930
+2382 936 1638 530
+2383 120 1459 1207
+2384 1206 1458 57
+2385 656 1919 1392
+2386 317 1540 908
+2387 93 1349 94
+2388 83 1350 84
+2389 913 1481 465
+2390 1106 1381 561
+2391 89 1804 90
+2392 87 1805 88
+2393 971 1493 144
+2394 1340 1511 500
+2395 394 1521 1452
+2396 1452 1521 751
+2397 460 1626 1278
+2398 1279 1627 461
+2399 1542 1880 752
+2400 951 1418 213
+2401 909 1612 349
+2402 926 1425 498
+2403 792 2046 1480
+2404 913 2062 235
+2405 916 1515 236
+2406 911 1510 345
+2407 67 1165 68
+2408 109 1164 110
+2409 1050 1545 464
+2410 233 1245 999
+2411 250 1419 1300
+2412 198 1998 1342
+2413 991 1662 340
+2414 1067 1914 647
+2415 1011 1808 313
+2416 943 1944 654
+2417 1230 1743 163
+2418 921 1803 342
+2419 794 1434 1284
+2420 693 1743 1230
+2421 335 1966 1649
+2422 400 1978 938
+2423 939 1979 401
+2424 425 1641 1117
+2425 1117 1641 596
+2426 9 1765 10
+2427 1006 1252 245
+2428 1334 2005 670
+2429 341 1592 913
+2430 17 1268 18
+2431 991 1706 560
+2432 373 1377 989
+2433 1132 1802 406
+2434 247 1304 980
+2435 1299 1404 286
+2436 266 1778 1330
+2437 614 1404 1299
+2438 27 1598 1033
+2439 1224 1368 781
+2440 918 1649 452
+2441 485 2053 941
+2442 919 1899 253
+2443 354 1538 977
+2444 1057 1857 1636
+2445 1637 1858 1058
+2446 897 2025 1969
+2447 708 1693 922
+2448 179 1272 1185
+2449 1204 1209 515
+2450 1017 1251 176
+2451 160 1209 1204
+2452 13 1990 14
+2453 1185 1272 532
+2454 979 1363 350
+2455 261 1454 938
+2456 939 1455 262
+2457 974 1679 710
+2458 258 1921 1148
+2459 670 2005 1587
+2460 618 1486 1238
+2461 245 1252 1030
+2462 1746 1992 955
+2463 956 1991 1745
+2464 1030 1252 455
+2465 1131 1228 545
+2466 1031 1895 610
+2467 622 1513 931
+2468 283 1228 1131
+2469 305 1895 1031
+2470 251 1465 1051
+2471 1186 1246 516
+2472 1405 1684 1008
+2473 509 1288 1253
+2474 379 2087 965
+2475 1076 1620 397
+2476 965 2087 625
+2477 459 1887 959
+2478 980 1970 351
+2479 462 1854 1249
+2480 1250 1855 463
+2481 752 2077 1140
+2482 594 1970 980
+2483 1050 1235 239
+2484 1208 1406 226
+2485 1636 1856 405
+2486 992 2009 211
+2487 1254 1513 622
+2488 152 1512 935
+2489 303 1513 1254
+2490 1025 1262 399
+2491 574 1909 1499
+2492 558 1857 938
+2493 939 1858 559
+2494 377 1973 1017
+2495 207 1666 1427
+2496 938 1857 261
+2497 262 1858 939
+2498 1017 1973 632
+2499 1427 1666 782
+2500 31 1518 1158
+2501 395 1298 993
+2502 200 1675 943
+2503 1351 1981 948
+2504 1283 1898 171
+2505 453 1577 1049
+2506 238 1240 1053
+2507 790 1879 1242
+2508 1281 1818 276
+2509 1302 1683 692
+2510 266 1330 1286
+2511 1167 1655 249
+2512 511 1515 1424
+2513 935 1766 345
+2514 489 1195 1172
+2515 942 1634 244
+2516 520 1634 942
+2517 1090 1589 431
+2518 8 1243 9
+2519 1172 1195 260
+2520 1034 1958 1632
+2521 643 2041 1001
+2522 372 1646 932
+2523 1001 2041 273
+2524 255 1566 979
+2525 979 1566 528
+2526 940 1589 19
+2527 1551 1873 599
+2528 600 1874 1552
+2529 1649 1966 734
+2530 169 1878 1174
+2531 562 2080 951
+2532 648 1836 1239
+2533 528 1363 979
+2534 151 1512 152
+2535 937 1774 342
+2536 198 1585 991
+2537 638 1878 1171
+2538 215 1683 1302
+2539 1214 1273 501
+2540 116 1571 1064
+2541 1065 1570 61
+2542 991 1585 540
+2543 1212 1494 435
+2544 1051 1430 251
+2545 525 1430 1051
+2546 375 2068 963
+2547 2 1686 89
+2548 88 1686 2
+2549 1809 2092 807
+2550 1178 1702 887
+2551 74 1399 75
+2552 102 1400 103
+2553 999 1457 233
+2554 391 2032 1427
+2555 352 1991 956
+2556 543 1704 1296
+2557 1386 1612 549
+2558 185 1415 968
+2559 968 1415 473
+2560 1354 1978 649
+2561 650 1979 1355
+2562 1110 1214 450
+2563 695 1881 1220
+2564 984 2088 503
+2565 430 1271 1105
+2566 448 1915 1073
+2567 450 1948 1022
+2568 1082 1957 576
+2569 1578 1894 304
+2570 544 1442 1428
+2571 260 1334 1089
+2572 571 1660 1646
+2573 1314 1912 264
+2574 1089 1334 503
+2575 950 1554 378
+2576 103 1761 104
+2577 73 1760 74
+2578 363 1679 947
+2579 199 1467 961
+2580 757 2017 1765
+2581 1403 1867 506
+2582 213 1888 951
+2583 958 1993 442
+2584 770 1973 1217
+2585 501 2051 1214
+2586 1049 1606 777
+2587 1748 1955 271
+2588 503 1336 1111
+2589 463 1918 985
+2590 1094 1516 6
+2591 369 1839 1035
+2592 497 1658 1292
+2593 990 1395 42
+2594 1969 2025 609
+2595 1192 1233 495
+2596 504 1635 1417
+2597 507 1233 1192
+2598 26 1598 27
+2599 1378 1704 543
+2600 976 2040 246
+2601 574 1808 1011
+2602 962 1541 178
+2603 513 1409 981
+2604 434 1516 1094
+2605 136 1543 137
+2606 97 1369 98
+2607 79 1370 80
+2608 864 1800 1540
+2609 970 2079 355
+2610 1463 1581 208
+2611 592 1476 1403
+2612 258 1316 1023
+2613 741 1581 1463
+2614 406 1802 1637
+2615 1563 1784 432
+2616 130 1625 131
+2617 1221 1288 509
+2618 63 1357 64
+2619 113 1356 114
+2620 538 2044 1235
+2621 175 2013 1604
+2622 1294 1828 277
+2623 243 1327 1072
+2624 1407 2003 801
+2625 802 2004 1408
+2626 540 1662 991
+2627 1480 1740 792
+2628 15 1850 1092
+2629 225 1563 960
+2630 6 1516 7
+2631 1169 1225 248
+2632 1027 1945 1466
+2633 291 2011 1446
+2634 544 1428 1272
+2635 483 1225 1169
+2636 959 1887 370
+2637 350 1423 1203
+2638 259 1263 1179
+2639 1540 1800 493
+2640 1203 1204 515
+2641 544 1380 1316
+2642 1925 1986 247
+2643 426 1487 990
+2644 468 1204 1203
+2645 1261 1953 665
+2646 990 1487 498
+2647 106 1551 107
+2648 70 1552 71
+2649 1709 1970 594
+2650 1043 2055 611
+2651 1530 1968 1034
+2652 967 2059 823
+2653 1376 1381 535
+2654 498 1395 990
+2655 1108 1341 223
+2656 514 1341 1108
+2657 611 2058 1043
+2658 644 1962 1074
+2659 117 1752 118
+2660 59 1753 60
+2661 531 1493 971
+2662 1074 1962 384
+2663 1111 1336 161
+2664 669 1630 1195
+2665 451 1377 994
+2666 1358 2051 501
+2667 1392 1475 656
+2668 632 1973 1925
+2669 95 1249 96
+2670 81 1250 82
+2671 216 1740 1480
+2672 981 1465 251
+2673 432 1784 1089
+2674 567 1614 1190
+2675 1151 1231 259
+2676 1510 2044 538
+2677 368 2021 971
+2678 1246 1466 317
+2679 421 1331 1041
+2680 14 1850 15
+2681 455 1343 1030
+2682 1120 1280 415
+2683 282 1717 1317
+2684 672 1484 1040
+2685 1039 1483 671
+2686 1080 1337 196
+2687 404 1588 1059
+2688 490 1337 1080
+2689 280 1577 1238
+2690 830 2012 1501
+2691 783 1621 1602
+2692 996 1460 633
+2693 433 1672 963
+2694 270 1383 1323
+2695 1323 1383 592
+2696 1571 1849 1064
+2697 1065 1848 1570
+2698 1238 1577 618
+2699 508 1751 1160
+2700 1553 1868 453
+2701 1059 1588 548
+2702 430 2088 984
+2703 964 1793 281
+2704 424 1655 1167
+2705 202 1915 966
+2706 1676 2074 765
+2707 1287 2076 164
+2708 1020 1489 398
+2709 590 1820 1057
+2710 1058 1821 591
+2711 1057 1820 261
+2712 262 1821 1058
+2713 553 1620 1076
+2714 105 1905 1118
+2715 1119 1904 72
+2716 687 2007 1476
+2717 1259 1617 167
+2718 52 1266 53
+2719 124 1267 125
+2720 352 1475 1392
+2721 440 1247 1141
+2722 642 1713 1218
+2723 1010 1664 237
+2724 380 1882 1168
+2725 1009 1988 466
+2726 1082 1296 180
+2727 1404 1806 575
+2728 465 1443 1091
+2729 53 1790 54
+2730 123 1791 124
+2731 985 1918 233
+2732 350 1893 979
+2733 1001 1467 643
+2734 977 1538 494
+2735 96 1854 97
+2736 80 1855 81
+2737 1368 2082 192
+2738 1602 1621 358
+2739 899 2082 1368
+2740 46 1607 47
+2741 655 1448 1391
+2742 1391 1448 351
+2743 1218 1713 234
+2744 1097 1401 519
+2745 182 1401 1097
+2746 284 1656 1061
+2747 1148 1921 853
+2748 1061 1656 560
+2749 612 2047 1038
+2750 533 1482 1234
+2751 1032 1568 534
+2752 1144 2090 663
+2753 974 1997 162
+2754 278 1568 1032
+2755 381 1730 967
+2756 606 1726 1600
+2757 1599 1725 605
+2758 979 1567 255
+2759 92 1940 93
+2760 84 1939 85
+2761 283 1923 1228
+2762 1069 1750 578
+2763 972 1629 647
+2764 33 1750 1069
+2765 1332 1379 348
+2766 587 1379 1332
+2767 473 1871 968
+2768 1084 1312 240
+2769 576 1957 1159
+2770 971 2021 531
+2771 1070 1330 477
+2772 252 1374 1041
+2773 980 1689 247
+2774 1014 1415 185
+2775 1183 1333 588
+2776 1015 1567 515
+2777 180 1353 1082
+2778 1098 1300 446
+2779 1770 1888 213
+2780 1205 1770 213
+2781 144 1493 145
+2782 339 2002 1505
+2783 471 1432 1061
+2784 20 1589 1090
+2785 584 1964 978
+2786 1123 1495 430
+2787 213 1418 1055
+2788 1102 1995 326
+2789 176 1416 1017
+2790 1146 1709 594
+2791 595 1710 1147
+2792 480 1314 1095
+2793 1150 1430 525
+2794 101 1709 1146
+2795 1147 1710 76
+2796 1021 1647 818
+2797 300 2003 1407
+2798 1408 2004 301
+2799 1120 1289 228
+2800 1206 1626 460
+2801 461 1627 1207
+2802 85 1292 86
+2803 91 1293 92
+2804 597 1626 1206
+2805 1207 1627 598
+2806 1071 1346 480
+2807 1143 1835 447
+2808 1253 1288 248
+2809 1062 1479 254
+2810 1425 1971 279
+2811 478 1246 1186
+2812 1194 1633 691
+2813 973 1839 369
+2814 187 1579 995
+2815 995 1579 520
+2816 613 1707 976
+2817 336 1680 982
+2818 253 1346 1071
+2819 664 1673 983
+2820 835 1742 1202
+2821 736 1640 1062
+2822 1229 1943 702
+2823 298 1943 1229
+2824 408 2073 988
+2825 195 1762 1154
+2826 1028 1723 542
+2827 271 1724 1257
+2828 1257 1724 667
+2829 1531 1842 358
+2830 884 1842 1531
+2831 1179 1263 476
+2832 1018 1562 108
+2833 69 1561 1019
+2834 475 1486 1053
+2835 423 2037 986
+2836 468 1434 1075
+2837 542 1495 1123
+2838 985 1711 628
+2839 35 1315 36
+2840 1005 1494 290
+2841 271 1955 1324
+2842 1036 1481 235
+2843 19 1589 20
+2844 1161 1439 490
+2845 1114 1373 787
+2846 38 1844 39
+2847 201 1373 1114
+2848 140 1488 141
+2849 1193 1897 639
+2850 756 1736 1549
+2851 161 1336 1105
+2852 477 1456 1126
+2853 583 1778 1444
+2854 1027 2056 218
+2855 615 2056 1027
+2856 1039 1435 389
+2857 390 1436 1040
+2858 111 1325 112
+2859 65 1326 66
+2860 693 1615 1071
+2861 986 2015 1608
+2862 1248 1718 1047
+2863 799 1734 1528
+2864 1038 2047 132
+2865 469 1967 1087
+2866 1182 1410 481
+2867 264 1871 1211
+2868 1335 1650 506
+2869 1555 1903 910
+2870 405 1440 1057
+2871 1058 1441 406
+2872 223 1903 1555
+2873 678 1606 1049
+2874 679 2064 1130
+2875 368 2055 1043
+2876 1130 2064 165
+2877 1150 1485 824
+2878 1070 1594 246
+2879 784 1868 1553
+2880 1353 1957 1082
+2881 23 1338 24
+2882 1109 1727 512
+2883 1043 2058 252
+2884 579 1910 1471
+2885 326 1996 1102
+2886 1102 1996 646
+2887 1612 1701 549
+2888 636 2045 1274
+2889 1471 1910 861
+2890 1068 1453 739
+2891 1015 1716 383
+2892 867 1897 1193
+2893 1528 1734 309
+2894 1055 1418 472
+2895 196 1851 1080
+2896 1291 1375 584
+2897 1025 1500 170
+2898 989 1946 373
+2899 153 1345 154
+2900 1944 1971 654
+2901 520 1623 995
+2902 1465 1792 1051
+2903 246 2040 1070
+2904 399 1934 1402
+2905 401 1979 1311
+2906 1310 1978 400
+2907 346 1910 1128
+2908 1009 1556 236
+2909 237 1557 1010
+2910 134 1429 135
+2911 1060 1412 624
+2912 454 2009 992
+2913 759 1583 1165
+2914 1164 1582 758
+2915 1403 1476 181
+2916 178 1541 1029
+2917 1529 1888 667
+2918 1186 1757 478
+2919 1417 1635 619
+2920 1035 1506 645
+2921 1113 1780 707
+2922 1258 1411 470
+2923 221 1539 1277
+2924 135 1429 1117
+2925 1033 1598 512
+2926 1256 1799 397
+2927 504 1417 1245
+2928 1138 1883 623
+2929 1237 1401 182
+2930 168 1883 1138
+2931 1679 1922 710
+2932 1003 1614 366
+2933 1202 1376 535
+2934 288 1376 1202
+2935 522 1869 1002
+2936 370 1976 1006
+2937 1158 1518 455
+2938 1006 1976 578
+2939 1371 1751 508
+2940 482 1400 1146
+2941 1147 1399 483
+2942 1078 1440 405
+2943 406 1441 1079
+2944 42 1395 43
+2945 1640 1659 688
+2946 1095 1743 480
+2947 638 2001 999
+2948 504 1558 1227
+2949 661 1804 1686
+2950 1686 1805 661
+2951 211 1771 992
+2952 1061 1432 284
+2953 1062 1640 688
+2954 998 1675 716
+2955 998 2043 414
+2956 1275 1871 264
+2957 193 1981 1351
+2958 183 1456 1303
+2959 1303 1456 583
+2960 499 1853 1030
+2961 557 1562 1018
+2962 1019 1561 556
+2963 510 1288 1221
+2964 1549 1736 438
+2965 1205 1294 449
+2966 479 1287 1286
+2967 1029 1541 533
+2968 1034 1968 376
+2969 164 1367 1166
+2970 1286 1287 566
+2971 668 1468 1348
+2972 995 1777 551
+2973 1072 2032 391
+2974 374 1565 1051
+2975 1051 1565 525
+2976 235 1381 1106
+2977 1323 1525 270
+2978 694 2035 1258
+2979 1142 1452 540
+2980 1047 1718 589
+2981 394 1452 1142
+2982 467 1664 1010
+2983 447 1835 1277
+2984 1053 1486 238
+2985 58 1535 59
+2986 118 1534 119
+2987 1091 1830 465
+2988 444 1368 1224
+2989 1290 1531 611
+2990 1343 2000 287
+2991 1169 1470 595
+2992 1008 1684 367
+2993 290 1715 1005
+2994 402 1695 1642
+2995 1642 1695 832
+2996 95 1824 1249
+2997 1250 1825 82
+2998 1018 1699 557
+2999 556 1698 1019
+3000 354 1841 1538
+3001 764 1628 1572
+3002 654 1971 1507
+3003 1572 1628 575
+3004 149 1410 150
+3005 603 1702 1178
+3006 172 1358 1190
+3007 1004 1953 403
+3008 342 1803 1472
+3009 403 1953 1261
+3010 1001 1829 392
+3011 1002 1929 312
+3012 550 1929 1002
+3013 1164 1562 557
+3014 556 1561 1165
+3015 468 1423 1284
+3016 607 1937 1103
+3017 109 1562 1164
+3018 1165 1561 68
+3019 486 1440 1078
+3020 1079 1441 487
+3021 545 1411 1098
+3022 1103 1937 206
+3023 896 2026 1483
+3024 1484 2025 897
+3025 1472 1803 788
+3026 691 2031 1194
+3027 1004 1851 704
+3028 1483 2026 275
+3029 274 2025 1484
+3030 1194 2031 184
+3031 1142 1586 295
+3032 1021 1669 524
+3033 471 1479 1062
+3034 335 1755 1239
+3035 1378 1630 669
+3036 462 1763 1359
+3037 496 1940 1293
+3038 1292 1939 497
+3039 2015 2037 593
+3040 1391 2075 655
+3041 299 1630 1378
+3042 1112 1980 243
+3043 1647 1996 818
+3044 1687 2070 539
+3045 631 1980 1112
+3046 182 1412 1141
+3047 236 1988 1009
+3048 327 1647 1021
+3049 1228 1411 545
+3050 470 1411 1228
+3051 1079 1928 174
+3052 293 1670 1088
+3053 1121 1880 186
+3054 528 2016 1363
+3055 1071 1615 735
+3056 331 1397 1384
+3057 1384 1397 589
+3058 1199 1896 658
+3059 165 1896 1199
+3060 702 1660 1229
+3061 491 1790 1266
+3062 1267 1791 492
+3063 592 1403 1323
+3064 1091 1443 346
+3065 242 1502 1439
+3066 239 1545 1050
+3067 1447 1889 527
+3068 131 1625 1038
+3069 711 1788 1321
+3070 1322 1789 712
+3071 506 1650 1525
+3072 1166 1367 495
+3073 460 1458 1206
+3074 1207 1459 461
+3075 174 1845 1313
+3076 453 1868 1577
+3077 1049 1577 280
+3078 986 2037 2015
+3079 75 1399 1147
+3080 1146 1400 102
+3081 1387 1579 803
+3082 1691 1809 422
+3083 1042 1869 522
+3084 1107 1597 422
+3085 907 1809 1691
+3086 1501 2012 292
+3087 1180 1553 453
+3088 1096 1961 385
+3089 1136 2053 485
+3090 623 1688 1138
+3091 1187 1389 476
+3092 315 1658 1104
+3093 1137 1693 415
+3094 385 1961 1103
+3095 521 1817 1300
+3096 108 1562 109
+3097 68 1561 69
+3098 1190 1358 501
+3099 488 1930 1116
+3100 586 1866 1036
+3101 1449 2016 528
+3102 364 1728 1029
+3103 1113 1431 433
+3104 1027 1744 615
+3105 1160 1759 456
+3106 1090 1823 21
+3107 242 1439 1161
+3108 569 1758 1092
+3109 490 1439 1324
+3110 1018 1926 599
+3111 600 1927 1019
+3112 531 2021 1043
+3113 247 1986 1304
+3114 926 1487 1241
+3115 1139 2033 1289
+3116 495 1659 1192
+3117 1099 2049 418
+3118 419 2050 1100
+3119 1107 1920 494
+3120 1437 1781 580
+3121 376 1958 1034
+3122 289 1833 1192
+3123 442 1921 1023
+3124 1024 1949 157
+3125 1026 1878 169
+3126 484 1416 1210
+3127 796 1951 1025
+3128 1030 1853 245
+3129 218 1945 1027
+3130 783 1602 1088
+3131 478 1757 1344
+3132 610 1900 1031
+3133 1439 1502 616
+3134 534 1865 1032
+3135 1057 1636 405
+3136 406 1637 1058
+3137 223 1555 1108
+3138 1108 1555 534
+3139 21 1823 22
+3140 338 1648 1428
+3141 1191 1944 943
+3142 1296 1536 543
+3143 1126 1456 183
+3144 1510 1932 345
+3145 903 1727 1109
+3146 477 1594 1070
+3147 22 1823 1037
+3148 1155 1859 469
+3149 1597 1691 422
+3150 897 1969 1305
+3151 1067 1607 46
+3152 1581 1665 208
+3153 745 1769 1477
+3154 1478 1768 744
+3155 1477 1769 377
+3156 378 1768 1478
+3157 1227 1635 504
+3158 1044 2035 374
+3159 190 1869 1042
+3160 1690 1799 554
+3161 876 1799 1690
+3162 512 1598 1109
+3163 1043 2021 368
+3164 1199 1580 165
+3165 324 1744 1344
+3166 563 1580 1199
+3167 512 1727 1285
+3168 289 1659 1640
+3169 1413 1817 521
+3170 634 1992 1746
+3171 1745 1991 635
+3172 770 1986 1925
+3173 1485 1845 174
+3174 1187 2074 408
+3175 156 1862 1094
+3176 1048 2087 379
+3177 1338 2002 903
+3178 29 1639 30
+3179 805 1382 1359
+3180 1300 1419 521
+3181 1657 1687 361
+3182 150 1410 1182
+3183 795 1687 1657
+3184 783 2058 1621
+3185 39 1844 1347
+3186 1460 1795 201
+3187 536 1318 1317
+3188 1317 1318 537
+3189 1051 1792 374
+3190 734 1795 1460
+3191 788 1917 1472
+3192 540 1586 1142
+3193 1130 1593 679
+3194 755 1494 1212
+3195 141 1488 1133
+3196 521 1419 1184
+3197 214 1941 1047
+3198 1088 1602 658
+3199 1483 1576 671
+3200 672 1575 1484
+3201 275 1576 1483
+3202 1484 1575 274
+3203 640 1554 1253
+3204 1074 1655 644
+3205 1780 2008 707
+3206 813 1797 1104
+3207 484 1477 1416
+3208 155 1862 156
+3209 1109 1598 26
+3210 578 1750 1158
+3211 1469 1768 378
+3212 1188 1663 188
+3213 731 1768 1469
+3214 10 1530 11
+3215 1158 1750 32
+3216 935 1932 1345
+3217 1695 1712 566
+3218 653 1406 1208
+3219 1308 1508 652
+3220 552 1508 1308
+3221 39 2090 40
+3222 646 1996 1647
+3223 1104 1797 790
+3224 607 1961 1911
+3225 1052 1989 219
+3226 321 1977 1526
+3227 1526 1977 857
+3228 525 1485 1150
+3229 509 1731 1221
+3230 449 1770 1205
+3231 1110 1946 989
+3232 1551 1926 107
+3233 70 1927 1552
+3234 1238 1486 475
+3235 751 1662 1452
+3236 138 1611 139
+3237 534 1568 1108
+3238 247 1689 1101
+3239 1316 2024 544
+3240 1807 2036 197
+3241 1320 1432 471
+3242 1201 1782 194
+3243 61 1570 62
+3244 115 1571 116
+3245 1055 2039 213
+3246 1064 1752 117
+3247 60 1753 1065
+3248 863 1934 1262
+3249 607 1911 1852
+3250 243 1980 1054
+3251 1203 1423 468
+3252 494 1597 1107
+3253 1118 1551 106
+3254 71 1552 1119
+3255 1059 1890 230
+3256 1240 2020 526
+3257 656 1475 1201
+3258 1056 1862 155
+3259 318 1835 1143
+3260 266 1712 1077
+3261 514 1514 1149
+3262 687 2018 1741
+3263 1135 1775 517
+3264 518 1776 1136
+3265 312 1550 1184
+3266 1171 2001 638
+3267 1661 1912 621
+3268 448 2001 1171
+3269 555 1617 1259
+3270 685 1432 1320
+3271 795 2070 1687
+3272 1428 1442 338
+3273 316 1759 1160
+3274 285 1593 1116
+3275 572 1849 1571
+3276 1570 1848 573
+3277 1064 1849 401
+3278 400 1848 1065
+3279 1262 1951 328
+3280 136 2038 1543
+3281 1140 1853 499
+3282 1104 1658 497
+3283 436 1838 1536
+3284 1536 1838 789
+3285 648 1784 1563
+3286 723 1630 1622
+3287 12 1632 13
+3288 493 1375 1291
+3289 1622 1630 299
+3290 1366 1690 443
+3291 876 1690 1366
+3292 1464 1482 533
+3293 1514 1568 278
+3294 613 1482 1464
+3295 1101 1689 527
+3296 1092 1758 15
+3297 1421 1464 348
+3298 227 1780 1083
+3299 613 1464 1421
+3300 519 1610 1124
+3301 184 2031 1066
+3302 578 1976 1069
+3303 1257 1770 449
+3304 1070 2040 479
+3305 523 1740 1265
+3306 163 1743 1095
+3307 1491 1900 189
+3308 1422 1574 620
+3309 1278 1407 460
+3310 461 1408 1279
+3311 1797 1879 790
+3312 1294 1987 449
+3313 1101 1720 439
+3314 562 1684 1405
+3315 683 1691 1597
+3316 1367 1659 495
+3317 545 1665 1131
+3318 1274 1613 160
+3319 722 1681 1588
+3320 577 1613 1274
+3321 1588 1681 548
+3322 1295 1478 485
+3323 544 2024 1442
+3324 178 1806 1093
+3325 1075 1994 636
+3326 1124 2086 241
+3327 625 2086 1124
+3328 487 1928 1079
+3329 532 1549 1185
+3330 128 1785 129
+3331 229 1972 1076
+3332 1538 1841 683
+3333 1310 2003 300
+3334 301 2004 1311
+3335 696 2003 1310
+3336 1311 2004 697
+3337 1311 1979 650
+3338 649 1978 1310
+3339 1473 1678 569
+3340 1086 1884 735
+3341 736 1885 1085
+3342 1274 1935 577
+3343 100 1709 101
+3344 76 1710 77
+3345 678 1678 1473
+3346 1115 1692 211
+3347 1096 1781 265
+3348 1272 1428 532
+3349 378 1554 1469
+3350 555 1685 1616
+3351 287 1560 1343
+3352 865 1907 1360
+3353 1361 1908 866
+3354 1469 1554 640
+3355 132 2047 133
+3356 557 1582 1164
+3357 1165 1583 556
+3358 456 1759 1351
+3359 1087 1967 287
+3360 1504 1999 315
+3361 817 1999 1504
+3362 483 1501 1225
+3363 261 1820 1099
+3364 1100 1821 262
+3365 571 1489 1229
+3366 363 1922 1679
+3367 78 1745 79
+3368 98 1746 99
+3369 617 2007 1741
+3370 439 1811 1101
+3371 15 1758 16
+3372 1189 1717 546
+3373 1184 1550 521
+3374 1185 1549 438
+3375 1202 1742 714
+3376 1359 1382 462
+3377 32 1750 33
+3378 1323 1403 506
+3379 478 1466 1246
+3380 529 1398 1397
+3381 1397 1398 589
+3382 213 2039 1205
+3383 1205 2039 660
+3384 1284 1434 468
+3385 48 1816 49
+3386 1203 1893 350
+3387 1444 1644 583
+3388 1127 1714 564
+3389 616 1724 1324
+3390 1241 1487 426
+3391 1324 1724 271
+3392 1327 2032 1072
+3393 188 1969 1188
+3394 1188 1969 609
+3395 561 1880 1121
+3396 1339 2037 423
+3397 1199 1842 563
+3398 722 1942 1681
+3399 342 1472 1264
+3400 1206 1827 597
+3401 598 1826 1207
+3402 56 1827 1206
+3403 1207 1826 121
+3404 1565 1845 525
+3405 430 1495 1271
+3406 1271 1495 766
+3407 1248 1668 273
+3408 1188 1578 511
+3409 737 1668 1248
+3410 94 1824 95
+3411 82 1825 83
+3412 121 1826 122
+3413 55 1827 56
+3414 1107 1911 265
+3415 1264 1472 585
+3416 1103 1961 607
+3417 1097 2057 182
+3418 532 1648 1385
+3419 1163 1749 804
+3420 564 1519 1347
+3421 1347 1519 663
+3422 265 1920 1107
+3423 877 1952 1349
+3424 312 2091 1550
+3425 1105 1960 746
+3426 592 1735 1476
+3427 570 1792 1465
+3428 1775 1884 517
+3429 518 1885 1776
+3430 1476 1735 687
+3431 1574 1843 620
+3432 314 1749 1134
+3433 147 2089 148
+3434 1310 1863 649
+3435 650 1864 1311
+3436 300 1863 1310
+3437 1311 1864 301
+3438 1283 1687 539
+3439 737 1694 1668
+3440 1668 1694 612
+3441 1422 1603 330
+3442 72 1904 73
+3443 104 1905 105
+3444 1299 1643 528
+3445 620 1603 1422
+3446 1265 1499 523
+3447 267 1947 1247
+3448 44 1914 45
+3449 1324 1439 616
+3450 180 1704 1461
+3451 1221 1936 510
+3452 1192 1833 507
+3453 842 1664 1438
+3454 1461 1704 669
+3455 1438 1664 467
+3456 253 1775 1135
+3457 1136 1776 254
+3458 564 1844 1127
+3459 1125 1818 608
+3460 1127 1844 38
+3461 849 1946 1110
+3462 1159 1957 452
+3463 489 1755 1461
+3464 712 1802 1132
+3465 1189 1666 207
+3466 546 1666 1189
+3467 1601 2031 691
+3468 279 1629 1425
+3469 1216 1652 306
+3470 1242 1879 915
+3471 1910 1983 861
+3472 306 1924 1216
+3473 688 1659 1367
+3474 1116 1930 285
+3475 1426 1731 509
+3476 1558 1919 1227
+3477 1112 2006 631
+3478 526 2020 1505
+3479 1375 1964 584
+3480 511 1663 1188
+3481 1620 1674 703
+3482 553 1674 1620
+3483 202 1879 1797
+3484 1244 1653 586
+3485 162 1653 1244
+3486 1192 1659 289
+3487 1160 1751 316
+3488 276 1818 1499
+3489 585 1917 1730
+3490 1370 1745 635
+3491 634 1746 1369
+3492 79 1745 1370
+3493 1369 1746 98
+3494 596 2038 1117
+3495 756 1549 1385
+3496 689 2089 1200
+3497 1867 2073 602
+3498 988 2073 1867
+3499 1451 1740 523
+3500 1653 1997 861
+3501 162 1997 1653
+3502 1222 1665 545
+3503 951 2080 1418
+3504 728 2000 1639
+3505 1639 2000 843
+3506 1348 1468 500
+3507 551 1777 1175
+3508 527 1448 1447
+3509 1447 1448 655
+3510 1434 1994 1075
+3511 672 1874 1575
+3512 1576 1873 671
+3513 554 1652 1216
+3514 194 1635 1227
+3515 1674 1913 703
+3516 1550 2091 814
+3517 657 1955 1748
+3518 1538 1597 494
+3519 694 1845 1565
+3520 683 1597 1538
+3521 1384 1767 331
+3522 643 1767 1384
+3523 1156 1856 711
+3524 276 1909 1145
+3525 1352 2027 321
+3526 208 1665 1222
+3527 1433 1903 768
+3528 1175 1777 294
+3529 321 1526 1352
+3530 1352 1526 567
+3531 1230 1715 693
+3532 1172 1784 648
+3533 477 1778 1456
+3534 1216 1690 554
+3535 443 1690 1216
+3536 518 1590 1436
+3537 1435 1591 517
+3538 449 1987 1138
+3539 1229 1660 571
+3540 254 2053 1136
+3541 766 2036 1807
+3542 286 1643 1299
+3543 1779 1837 314
+3544 840 1837 1779
+3545 1181 1785 605
+3546 129 1785 1181
+3547 166 1757 1186
+3548 1232 1669 195
+3549 659 1754 1420
+3550 677 1716 1209
+3551 1420 1754 310
+3552 506 1525 1323
+3553 1224 1685 444
+3554 503 2088 1336
+3555 774 2033 1139
+3556 835 1883 1742
+3557 1742 1883 168
+3558 667 1888 1770
+3559 1522 1771 680
+3560 1176 1929 550
+3561 465 1866 1443
+3562 1140 2077 705
+3563 546 1717 1321
+3564 1219 1832 825
+3565 789 1677 1536
+3566 346 1983 1910
+3567 139 1611 1308
+3568 528 1566 1299
+3569 166 1651 1256
+3570 197 2036 1319
+3571 1347 2090 39
+3572 528 1643 1449
+3573 184 1787 1194
+3574 1256 1651 554
+3575 1200 2089 147
+3576 1676 1814 203
+3577 1221 1731 320
+3578 765 1814 1676
+3579 1681 1942 199
+3580 510 1782 1201
+3581 693 1715 1615
+3582 1615 1715 290
+3583 1495 2036 766
+3584 568 1584 1527
+3585 542 2036 1495
+3586 515 1893 1203
+3587 605 1892 1181
+3588 1527 1584 633
+3589 286 1783 1643
+3590 627 1824 1349
+3591 1350 1825 628
+3592 1349 1824 94
+3593 83 1825 1350
+3594 320 1936 1221
+3595 1271 1960 1105
+3596 606 1816 1220
+3597 236 1556 1364
+3598 1365 1557 237
+3599 1364 1556 590
+3600 591 1557 1365
+3601 1802 1876 559
+3602 620 1843 1564
+3603 1564 1843 721
+3604 1582 1895 305
+3605 304 1894 1583
+3606 253 1899 1346
+3607 273 2041 1718
+3608 1385 1549 532
+3609 1257 1688 271
+3610 680 1773 1522
+3611 238 2020 1240
+3612 1522 1773 624
+3613 735 1884 1775
+3614 1776 1885 736
+3615 1308 1611 552
+3616 632 1925 1811
+3617 490 1955 1337
+3618 1337 1955 657
+3619 1530 1765 568
+3620 273 1718 1248
+3621 383 1716 1569
+3622 1569 1716 677
+3623 1654 1656 681
+3624 560 1656 1654
+3625 1735 2034 330
+3626 1427 2032 629
+3627 1632 1958 580
+3628 249 1650 1335
+3629 1211 1871 473
+3630 514 1595 1341
+3631 1490 1491 836
+3632 1220 1816 48
+3633 1291 1787 184
+3634 404 2054 1259
+3635 562 1645 1307
+3636 505 1491 1490
+3637 584 1787 1291
+3638 1307 1645 325
+3639 1328 1698 556
+3640 557 1699 1329
+3641 279 1944 1191
+3642 1239 1755 489
+3643 748 1832 1219
+3644 680 1692 1309
+3645 344 2045 1177
+3646 517 1884 1435
+3647 1436 1885 518
+3648 1344 1757 822
+3649 968 1871 1275
+3650 1603 2018 687
+3651 1608 2015 524
+3652 687 1735 1603
+3653 1603 1735 330
+3654 1548 1783 626
+3655 684 1783 1548
+3656 1220 1881 606
+3657 1523 1758 569
+3658 1529 1724 616
+3659 1970 1992 351
+3660 955 1992 1970
+3661 667 1724 1529
+3662 568 2017 1584
+3663 200 1913 1674
+3664 1896 2064 732
+3665 241 2086 2083
+3666 2083 2086 1048
+3667 1286 1712 266
+3668 747 1586 1585
+3669 397 1620 1596
+3670 1265 1740 216
+3671 1398 1965 214
+3672 1596 1620 703
+3673 1585 1586 540
+3674 313 1994 1434
+3675 566 1712 1286
+3676 558 1875 1856
+3677 1301 1747 239
+3678 576 1747 1301
+3679 667 1770 1257
+3680 345 1766 1333
+3681 520 1579 1387
+3682 1285 1727 339
+3683 1333 1766 588
+3684 227 2008 1780
+3685 1296 1704 180
+3686 1643 1783 684
+3687 1354 1875 558
+3688 559 1876 1355
+3689 1741 2018 281
+3690 554 1799 1256
+3691 793 1751 1371
+3692 288 1813 1376
+3693 1226 1924 780
+3694 1577 1868 618
+3695 1227 1919 656
+3696 362 1948 1812
+3697 1812 1948 856
+3698 1289 2033 228
+3699 376 1968 1527
+3700 1346 1912 480
+3701 1265 1810 574
+3702 216 1810 1265
+3703 1025 1951 1262
+3704 1217 1973 377
+3705 1266 1790 53
+3706 124 1791 1267
+3707 1228 1923 470
+3708 550 1574 1422
+3709 158 1798 1339
+3710 573 1848 1454
+3711 1455 1849 572
+3712 1339 1798 593
+3713 1820 2049 1099
+3714 1100 2050 1821
+3715 585 1906 1264
+3716 1264 1906 454
+3717 1335 1867 602
+3718 506 1867 1335
+3719 1249 1854 96
+3720 81 1855 1250
+3721 1537 1588 404
+3722 722 1588 1537
+3723 621 1912 1346
+3724 862 1645 1405
+3725 286 2042 1783
+3726 1350 2048 878
+3727 274 1698 1328
+3728 1329 1699 275
+3729 529 1965 1398
+3730 1321 1717 282
+3731 1361 1826 598
+3732 597 1827 1360
+3733 122 1826 1361
+3734 1360 1827 55
+3735 472 2080 1307
+3736 542 1723 1319
+3737 765 2074 1213
+3738 1214 2051 450
+3739 575 1628 1404
+3740 1404 1628 286
+3741 622 1898 1254
+3742 539 2070 1431
+3743 324 1764 1507
+3744 1507 1764 654
+3745 358 1621 1531
+3746 1277 1835 868
+3747 1531 1621 611
+3748 1342 1998 587
+3749 220 1861 1282
+3750 856 2051 1358
+3751 1282 1861 579
+3752 1405 1645 562
+3753 1381 2062 535
+3754 820 1731 1426
+3755 1390 2015 593
+3756 2024 2069 810
+3757 206 2029 1606
+3758 798 1733 1369
+3759 1370 1734 799
+3760 1628 2042 286
+3761 1433 1671 577
+3762 1606 2029 777
+3763 580 1990 1632
+3764 1666 1667 782
+3765 546 1667 1666
+3766 507 1833 1462
+3767 596 1837 1543
+3768 1543 1837 840
+3769 1601 1828 660
+3770 806 1663 1424
+3771 691 1828 1601
+3772 1424 1663 511
+3773 409 2046 1631
+3774 1631 2046 793
+3775 1262 1934 399
+3776 1428 1648 532
+3777 712 1876 1802
+3778 1641 1941 804
+3779 1300 1817 446
+3780 319 1960 1271
+3781 1330 1778 477
+3782 1235 2044 239
+3783 669 1704 1378
+3784 219 1985 1732
+3785 1732 1985 808
+3786 680 1771 1692
+3787 581 1644 1444
+3788 1449 1643 684
+3789 1304 1986 482
+3790 999 2001 1457
+3791 1721 1722 721
+3792 570 1722 1721
+3793 571 2023 1489
+3794 1351 1759 855
+3795 741 1605 1581
+3796 224 1931 1834
+3797 295 1671 1433
+3798 1834 1931 829
+3799 1369 1733 634
+3800 635 1734 1370
+3801 697 2004 1534
+3802 1535 2003 696
+3803 1534 2004 802
+3804 801 2003 1535
+3805 628 2048 1350
+3806 1452 1662 540
+3807 1509 1965 529
+3808 1313 1845 694
+3809 792 1740 1451
+3810 894 1975 1963
+3811 1963 1975 689
+3812 1761 2011 676
+3813 675 2012 1760
+3814 831 2011 1761
+3815 1760 2012 830
+3816 277 1828 1633
+3817 1633 1828 691
+3818 1500 1738 541
+3819 190 1843 1574
+3820 1560 1967 893
+3821 287 1967 1560
+3822 260 2005 1334
+3823 861 1997 1471
+3824 458 1870 1332
+3825 1332 1870 587
+3826 1259 2054 555
+3827 1442 2024 810
+3828 235 2062 1381
+3829 857 1989 1526
+3830 1456 1778 583
+3831 85 1939 1292
+3832 1293 1940 92
+3833 1692 1771 211
+3834 845 1890 1492
+3835 1623 1777 995
+3836 708 2027 1273
+3837 294 1777 1623
+3838 1696 1882 724
+3839 1503 1972 844
+3840 1581 1605 547
+3841 814 1938 1393
+3842 1390 1796 327
+3843 593 1796 1390
+3844 1507 1744 324
+3845 480 1912 1314
+3846 615 1744 1507
+3847 898 2081 1863
+3848 1864 2082 899
+3849 1863 2081 649
+3850 650 2082 1864
+3851 1525 1650 603
+3852 1328 1894 609
+3853 610 1895 1329
+3854 558 1856 1636
+3855 1036 1866 1481
+3856 1637 1802 559
+3857 587 1872 1342
+3858 1342 1872 383
+3859 1418 2080 472
+3860 1347 1844 564
+3861 721 1843 1721
+3862 1721 1843 190
+3863 1856 1875 711
+3864 1981 2075 948
+3865 655 2075 1981
+3866 343 1819 1619
+3867 1305 1969 188
+3868 525 1845 1485
+3869 1619 1819 679
+3870 510 1936 1782
+3871 743 1617 1616
+3872 1616 1617 555
+3873 1808 1810 826
+3874 574 1810 1808
+3875 1437 1958 376
+3876 577 1671 1613
+3877 191 1875 1354
+3878 1355 1876 192
+3879 788 1817 1413
+3880 1376 1813 561
+3881 1427 1902 207
+3882 629 1902 1427
+3883 772 1652 1651
+3884 1651 1652 554
+3885 601 2022 1303
+3886 1303 2022 183
+3887 1303 1995 601
+3888 1346 1899 621
+3889 1324 1955 490
+3890 1545 1747 872
+3891 1705 1748 623
+3892 1536 1677 543
+3893 1661 1700 653
+3894 621 1700 1661
+3895 611 2055 1290
+3896 1701 1703 549
+3897 1354 2081 191
+3898 192 2082 1355
+3899 891 1703 1701
+3900 649 2081 1354
+3901 1355 2082 650
+3902 1345 1932 538
+3903 1708 1954 394
+3904 526 2002 1338
+3905 740 1954 1708
+3906 479 2076 1287
+3907 535 2062 1592
+3908 1613 1671 677
+3909 1852 1937 607
+3910 609 2025 1328
+3911 1329 2026 610
+3912 1328 2025 274
+3913 275 2026 1329
+3914 1360 1907 597
+3915 598 1908 1361
+3916 807 1937 1852
+3917 1431 2070 433
+3918 279 1971 1944
+3919 1682 1896 732
+3920 814 2091 1938
+3921 658 1896 1682
+3922 1414 2017 757
+3923 642 1831 1713
+3924 1713 1831 698
+3925 599 1926 1551
+3926 1552 1927 600
+3927 586 1983 1443
+3928 269 2017 1414
+3929 1349 1952 627
+3930 258 2024 1316
+3931 1443 1866 586
+3932 452 1957 1353
+3933 1392 1991 352
+3934 351 1992 1391
+3935 635 1991 1392
+3936 1391 1992 634
+3937 1636 1857 558
+3938 559 1858 1637
+3939 182 2057 1412
+3940 1499 1909 276
+3941 1307 2080 562
+3942 1319 2036 542
+3943 568 1968 1530
+3944 1447 1981 193
+3945 655 1981 1447
+3946 629 2032 1327
+3947 1467 1942 643
+3948 199 1942 1467
+3949 268 1964 1375
+3950 588 1766 1512
+3951 1599 1785 128
+3952 1512 1766 935
+3953 165 2064 1896
+3954 16 1758 1523
+3955 482 1986 1446
+3956 593 2037 1339
+3957 657 1748 1705
+3958 1804 1999 817
+3959 661 1999 1804
+3960 724 1974 1696
+3961 1696 1974 319
+3962 623 1748 1688
+3963 937 2083 1774
+3964 239 1747 1545
+3965 1393 1938 387
+3966 1498 1963 294
+3967 1462 1833 754
+3968 10 1765 1530
+3969 894 1963 1498
+3970 1363 2016 927
+3971 225 1836 1563
+3972 1563 1836 648
+3973 258 2069 2024
+3974 181 2007 1389
+3975 1389 2007 617
+3976 1767 1942 722
+3977 193 1889 1447
+3978 374 2035 1565
+3979 1565 2035 694
+3980 587 1998 1379
+3981 1609 2023 773
+3982 398 2023 1609
+3983 663 2090 1347
+3984 911 2044 1510
+3985 861 1983 1653
+3986 827 2009 1906
+3987 1906 2009 454
+3988 666 1865 1517
+3989 1517 1865 534
+3990 1786 1956 674
+3991 1481 1866 465
+3992 133 2047 1694
+3993 1946 2028 373
+3994 711 1875 1788
+3995 1789 1876 712
+3996 1600 1816 606
+3997 849 2028 1946
+3998 1788 1875 191
+3999 192 1876 1789
+4000 1445 2071 917
+4001 703 1913 1764
+4002 732 2064 1819
+4003 49 1816 1600
+4004 1567 1893 515
+4005 734 1966 1795
+4006 602 2073 1680
+4007 524 2015 1390
+4008 639 2034 1383
+4009 605 1785 1599
+4010 1393 2059 967
+4011 580 1958 1437
+4012 1384 2041 643
+4013 1466 1945 864
+4014 1938 2091 713
+4015 1472 1917 585
+4016 1653 1983 586
+4017 1412 2057 624
+4018 1688 1748 271
+4019 433 2070 1672
+4020 387 2059 1393
+4021 1443 1983 346
+4022 665 1754 1739
+4023 538 1932 1510
+4024 1446 1986 770
+4025 626 1891 1548
+4026 319 2060 1696
+4027 1711 2048 628
+4028 700 1956 1786
+4029 1548 1891 329
+4030 1556 2049 590
+4031 591 2050 1557
+4032 869 1872 1870
+4033 1870 1872 587
+4034 1457 2001 448
+4035 599 1873 1576
+4036 1575 1874 600
+4037 1739 1754 659
+4038 1564 2018 620
+4039 774 2067 1877
+4040 309 1919 1558
+4041 979 1893 1567
+4042 185 2016 1449
+4043 1521 1954 820
+4044 761 1965 1509
+4045 1507 1971 615
+4046 1813 1880 561
+4047 394 1954 1521
+4048 620 2018 1603
+4049 1476 2007 181
+4050 1527 1968 568
+4051 1505 2002 526
+4052 393 2071 1445
+4053 1809 1852 422
+4054 807 1852 1809
+4055 1489 2023 398
+4056 1505 2020 904
+4057 1796 1798 809
+4058 593 1798 1796
+4059 343 1982 1819
+4060 1819 1982 732
+4061 852 2061 1840
+4062 1840 2061 336
+4063 1543 2038 596
+4064 765 1891 1814
+4065 1877 2033 774
+4066 228 2033 1877
+4067 604 1882 1696
+4068 341 2030 1705
+4069 623 2072 1705
+4070 327 2065 1647
+4071 786 1902 1901
+4072 1901 1902 629
+4073 281 2018 1564
+4074 1587 2005 723
+4075 1760 1904 675
+4076 676 1905 1761
+4077 73 1904 1760
+4078 1761 1905 104
+4079 1697 2077 288
+4080 705 2077 1697
+4081 1584 2017 269
+4082 1632 1990 13
+4083 1783 2042 626
+4084 1814 1891 626
+4085 674 1956 1834
+4086 752 1880 1813
+4087 1764 1913 654
+4088 1696 2060 604
+4089 819 1984 1860
+4090 1705 2072 341
+4091 1592 2062 913
+4092 643 1942 1767
+4093 764 2042 1628
+4094 664 2066 1673
+4095 1782 1936 881
+4096 1621 2058 611
+4097 1883 2072 623
+4098 1922 2008 710
+4099 1647 2065 646
+4100 1673 2066 210
+4101 1795 1966 651
+4102 148 2089 1975
+4103 604 2060 1807
+4104 1985 2065 808
+4105 646 2065 1985
+4106 1705 2030 657
+4107 1672 2070 795
+4108 1834 1956 224
+4109 1694 2047 612
+4110 333 2048 1711
+4111 702 1943 1933
+4112 1933 1943 706
+4113 2086 2087 1048
+4114 625 2087 2086
+4115 1860 1984 386
+4116 2008 2085 710
+4117 1807 2060 766
+4118 590 2049 1820
+4119 1821 2050 591
+4120 707 2008 1922
+4121 1819 2064 679
+4122 1877 2067 673
+4123 835 2072 1883
+4124 2014 2066 664
+4125 902 2066 2014
+4126 1975 2089 689
+4127 227 2085 2008
$EndElements
diff --git a/examples/python/stiffness_matrix/stiffness_matrix.py b/examples/python/stiffness_matrix/stiffness_matrix.py
index 827666fa3..9c13c37b8 100644
--- a/examples/python/stiffness_matrix/stiffness_matrix.py
+++ b/examples/python/stiffness_matrix/stiffness_matrix.py
@@ -1,51 +1,39 @@
#!/usr/bin/env python3
-
-import akantu
-import numpy as np
-
+import akantu as aka
def getStiffnessMatrix(material_file, mesh_file, traction):
- akantu.parseInput(material_file)
+ aka.parseInput(material_file)
spatial_dimension = 2
- ################################################################
+ # --------------------------------------------------------------------------
# Initialization
- ################################################################
- mesh = akantu.Mesh(spatial_dimension)
+ # --------------------------------------------------------------------------
+ mesh = aka.Mesh(spatial_dimension)
mesh.read(mesh_file)
- model = akantu.SolidMechanicsModel(mesh)
- model.initFull(akantu._static)
+ model = aka.SolidMechanicsModel(mesh)
+ model.initFull(_analysis_method=aka._static)
+
model.assembleStiffnessMatrix()
K = model.getDOFManager().getMatrix('K')
- stiff = akantu.AkantuSparseMatrix(K).toarray()
- return stiff
+ stiff = aka.AkantuSparseMatrix(K).toarray()
-################################################################
-# main
-################################################################
+ return stiff
+# --------------------------------------------------------------------------
+# main
+# --------------------------------------------------------------------------
def main():
-
- import os
mesh_file = 'plate.msh'
- # if mesh was not created the calls gmsh to generate it
- if not os.path.isfile(mesh_file):
- import subprocess
- ret = subprocess.call(
- 'gmsh -format msh2 -2 plate.geo {0}'.format(mesh_file), shell=True)
- if not ret == 0:
- raise Exception(
- 'execution of GMSH failed: do you have it installed ?')
-
material_file = 'material.dat'
traction = 1.
mat = getStiffnessMatrix(material_file, mesh_file, traction)
print(mat)
-################################################################
+
+# --------------------------------------------------------------------------
if __name__ == "__main__":
main()
diff --git a/extra_packages/extra-materials/src/material_FE2/material_FE2.cc b/extra_packages/extra-materials/src/material_FE2/material_FE2.cc
index afa105c00..781d413fd 100644
--- a/extra_packages/extra-materials/src/material_FE2/material_FE2.cc
+++ b/extra_packages/extra-materials/src/material_FE2/material_FE2.cc
@@ -1,199 +1,200 @@
/**
* @file material_FE2.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @brief Material for multi-scale simulations. It stores an
* underlying RVE on each integration point of the material.
*
* @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 "material_FE2.hh"
#include "communicator.hh"
#include "solid_mechanics_model_RVE.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialFE2<spatial_dimension>::MaterialFE2(SolidMechanicsModel & model,
const ID & id)
: Parent(model, id), C("material_stiffness", *this) {
AKANTU_DEBUG_IN();
this->C.initialize(voigt_h::size * voigt_h::size);
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialFE2<spatial_dimension>::~MaterialFE2() = default;
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialFE2<dim>::initialize() {
this->registerParam("element_type", el_type, _triangle_3,
_pat_parsable | _pat_modifiable,
"element type in RVE mesh");
this->registerParam("mesh_file", mesh_file, _pat_parsable | _pat_modifiable,
"the mesh file for the RVE");
this->registerParam("nb_gel_pockets", nb_gel_pockets,
_pat_parsable | _pat_modifiable,
"the number of gel pockets in each RVE");
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialFE2<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
Parent::initMaterial();
/// create a Mesh and SolidMechanicsModel on each integration point of the
/// material
auto C_it = this->C(this->el_type).begin(voigt_h::size, voigt_h::size);
for (auto && data :
enumerate(make_view(C(this->el_type), voigt_h::size, voigt_h::size))) {
auto q = std::get<0>(data);
auto & C = std::get<1>(data);
meshes.emplace_back(std::make_unique<Mesh>(
spatial_dimension, "RVE_mesh_" + std::to_string(q), q + 1));
auto & mesh = *meshes.back();
mesh.read(mesh_file);
RVEs.emplace_back(std::make_unique<SolidMechanicsModelRVE>(
mesh, true, this->nb_gel_pockets, _all_dimensions,
"SMM_RVE_" + std::to_string(q), q + 1));
auto & RVE = *RVEs.back();
RVE.initFull(_analysis_method = _static);
/// compute intial stiffness of the RVE
RVE.homogenizeStiffness(C);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialFE2<spatial_dimension>::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
// Compute thermal stresses first
Parent::computeStress(el_type, ghost_type);
Array<Real>::const_scalar_iterator sigma_th_it =
this->sigma_th(el_type, ghost_type).begin();
// Wikipedia convention:
// 2*eps_ij (i!=j) = voigt_eps_I
// http://en.wikipedia.org/wiki/Voigt_notation
Array<Real>::const_matrix_iterator C_it =
this->C(el_type, ghost_type).begin(voigt_h::size, voigt_h::size);
// create vectors to store stress and strain in Voigt notation
// for efficient computation of stress
Vector<Real> voigt_strain(voigt_h::size);
Vector<Real> voigt_stress(voigt_h::size);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
const Matrix<Real> & C_mat = *C_it;
const Real & sigma_th = *sigma_th_it;
/// copy strains in Voigt notation
for (UInt I = 0; I < voigt_h::size; ++I) {
/// copy stress in
Real voigt_factor = voigt_h::factors[I];
UInt i = voigt_h::vec[I][0];
UInt j = voigt_h::vec[I][1];
voigt_strain(I) = voigt_factor * (grad_u(i, j) + grad_u(j, i)) / 2.;
}
// compute stresses in Voigt notation
voigt_stress.mul<false>(C_mat, voigt_strain);
/// copy stresses back in full vectorised notation
for (UInt I = 0; I < voigt_h::size; ++I) {
UInt i = voigt_h::vec[I][0];
UInt j = voigt_h::vec[I][1];
sigma(i, j) = sigma(j, i) = voigt_stress(I) + (i == j) * sigma_th;
}
++C_it;
++sigma_th_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialFE2<spatial_dimension>::computeTangentModuli(
const ElementType & el_type, Array<Real> & tangent_matrix,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Array<Real>::const_matrix_iterator C_it =
this->C(el_type, ghost_type).begin(voigt_h::size, voigt_h::size);
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
tangent.copy(*C_it);
++C_it;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialFE2<spatial_dimension>::advanceASR(
const Matrix<Real> & prestrain) {
AKANTU_DEBUG_IN();
for (auto && data :
- zip(RVEs, make_view(this->gradu(this->el_type), spatial_dimension,
- spatial_dimension),
+ zip(RVEs,
+ make_view(this->gradu(this->el_type), spatial_dimension,
+ spatial_dimension),
make_view(this->eigengradu(this->el_type), spatial_dimension,
spatial_dimension),
make_view(this->C(this->el_type), voigt_h::size, voigt_h::size),
this->delta_T(this->el_type))) {
auto & RVE = *(std::get<0>(data));
/// apply boundary conditions based on the current macroscopic displ.
/// gradient
RVE.applyBoundaryConditions(std::get<1>(data));
/// apply homogeneous temperature field to each RVE to obtain thermoelastic
/// effect
RVE.applyHomogeneousTemperature(std::get<4>(data));
/// advance the ASR in every RVE
RVE.advanceASR(prestrain);
/// compute the average eigen_grad_u
RVE.homogenizeEigenGradU(std::get<2>(data));
/// compute the new effective stiffness of the RVE
RVE.homogenizeStiffness(std::get<3>(data));
}
AKANTU_DEBUG_OUT();
}
INSTANTIATE_MATERIAL(material_FE2, MaterialFE2);
} // namespace akantu
diff --git a/extra_packages/extra-materials/src/material_FE2/solid_mechanics_model_RVE.cc b/extra_packages/extra-materials/src/material_FE2/solid_mechanics_model_RVE.cc
index 0f840ef5d..5ca9cfa2a 100644
--- a/extra_packages/extra-materials/src/material_FE2/solid_mechanics_model_RVE.cc
+++ b/extra_packages/extra-materials/src/material_FE2/solid_mechanics_model_RVE.cc
@@ -1,604 +1,604 @@
/**
* @file solid_mechanics_model_RVE.cc
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Wed Jan 13 15:32:35 2016
*
* @brief Implementation of SolidMechanicsModelRVE
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_RVE.hh"
#include "element_group.hh"
#include "material_damage_iterative.hh"
#include "node_group.hh"
#include "non_linear_solver.hh"
+#include "non_local_manager.hh"
#include "parser.hh"
#include "sparse_matrix.hh"
+/* -------------------------------------------------------------------------- */
#include <string>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
SolidMechanicsModelRVE::SolidMechanicsModelRVE(Mesh & mesh,
bool use_RVE_mat_selector,
UInt nb_gel_pockets, UInt dim,
const ID & id,
const MemoryID & memory_id)
: SolidMechanicsModel(mesh, dim, id, memory_id), volume(0.),
use_RVE_mat_selector(use_RVE_mat_selector),
nb_gel_pockets(nb_gel_pockets), nb_dumps(0) {
AKANTU_DEBUG_IN();
/// find the four corner nodes of the RVE
findCornerNodes();
/// remove the corner nodes from the surface node groups:
/// This most be done because corner nodes a not periodic
mesh.getElementGroup("top").removeNode(corner_nodes(2));
mesh.getElementGroup("top").removeNode(corner_nodes(3));
mesh.getElementGroup("left").removeNode(corner_nodes(3));
mesh.getElementGroup("left").removeNode(corner_nodes(0));
mesh.getElementGroup("bottom").removeNode(corner_nodes(1));
mesh.getElementGroup("bottom").removeNode(corner_nodes(0));
mesh.getElementGroup("right").removeNode(corner_nodes(2));
mesh.getElementGroup("right").removeNode(corner_nodes(1));
const auto & bottom = mesh.getElementGroup("bottom").getNodeGroup();
bottom_nodes.insert(bottom.begin(), bottom.end());
const auto & left = mesh.getElementGroup("left").getNodeGroup();
left_nodes.insert(left.begin(), left.end());
// /// enforce periodicity on the displacement fluctuations
// auto surface_pair_1 = std::make_pair("top", "bottom");
// auto surface_pair_2 = std::make_pair("right", "left");
// SurfacePairList surface_pairs_list;
// surface_pairs_list.push_back(surface_pair_1);
// surface_pairs_list.push_back(surface_pair_2);
// TODO: To Nicolas correct the PBCs
// this->setPBC(surface_pairs_list);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SolidMechanicsModelRVE::~SolidMechanicsModelRVE() = default;
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::initFullImpl(const ModelOptions & options) {
AKANTU_DEBUG_IN();
auto options_cp(options);
options_cp.analysis_method = AnalysisMethod::_static;
SolidMechanicsModel::initFullImpl(options_cp);
// this->initMaterials();
auto & fem = this->getFEEngine("SolidMechanicsFEEngine");
/// compute the volume of the RVE
GhostType gt = _not_ghost;
for (auto element_type :
this->mesh.elementTypes(spatial_dimension, gt, _ek_not_defined)) {
Array<Real> Volume(this->mesh.getNbElement(element_type) *
fem.getNbIntegrationPoints(element_type),
1, 1.);
this->volume = fem.integrate(Volume, element_type);
}
std::cout << "The volume of the RVE is " << this->volume << std::endl;
/// dumping
std::stringstream base_name;
base_name << this->id; // << this->memory_id - 1;
this->setBaseName(base_name.str());
this->addDumpFieldVector("displacement");
this->addDumpField("stress");
this->addDumpField("grad_u");
this->addDumpField("eigen_grad_u");
this->addDumpField("blocked_dofs");
this->addDumpField("material_index");
this->addDumpField("damage");
this->addDumpField("Sc");
this->addDumpField("external_force");
this->addDumpField("equivalent_stress");
this->addDumpField("internal_force");
this->addDumpField("delta_T");
this->dump();
this->nb_dumps += 1;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::applyBoundaryConditions(
const Matrix<Real> & displacement_gradient) {
AKANTU_DEBUG_IN();
/// get the position of the nodes
const Array<Real> & pos = mesh.getNodes();
/// storage for the coordinates of a given node and the displacement that will
/// be applied
Vector<Real> x(spatial_dimension);
Vector<Real> appl_disp(spatial_dimension);
/// fix top right node
UInt node = this->corner_nodes(2);
x(0) = pos(node, 0);
x(1) = pos(node, 1);
appl_disp.mul<false>(displacement_gradient, x);
(*this->blocked_dofs)(node, 0) = true;
(*this->displacement)(node, 0) = appl_disp(0);
(*this->blocked_dofs)(node, 1) = true;
(*this->displacement)(node, 1) = appl_disp(1);
// (*this->blocked_dofs)(node,0) = true; (*this->displacement)(node,0) = 0.;
// (*this->blocked_dofs)(node,1) = true; (*this->displacement)(node,1) = 0.;
/// apply Hx at all the other corner nodes; H: displ. gradient
node = this->corner_nodes(0);
x(0) = pos(node, 0);
x(1) = pos(node, 1);
appl_disp.mul<false>(displacement_gradient, x);
(*this->blocked_dofs)(node, 0) = true;
(*this->displacement)(node, 0) = appl_disp(0);
(*this->blocked_dofs)(node, 1) = true;
(*this->displacement)(node, 1) = appl_disp(1);
node = this->corner_nodes(1);
x(0) = pos(node, 0);
x(1) = pos(node, 1);
appl_disp.mul<false>(displacement_gradient, x);
(*this->blocked_dofs)(node, 0) = true;
(*this->displacement)(node, 0) = appl_disp(0);
(*this->blocked_dofs)(node, 1) = true;
(*this->displacement)(node, 1) = appl_disp(1);
node = this->corner_nodes(3);
x(0) = pos(node, 0);
x(1) = pos(node, 1);
appl_disp.mul<false>(displacement_gradient, x);
(*this->blocked_dofs)(node, 0) = true;
(*this->displacement)(node, 0) = appl_disp(0);
(*this->blocked_dofs)(node, 1) = true;
(*this->displacement)(node, 1) = appl_disp(1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::applyHomogeneousTemperature(
const Real & temperature) {
for (UInt m = 0; m < this->getNbMaterials(); ++m) {
Material & mat = this->getMaterial(m);
const ElementTypeMapArray<UInt> & filter_map = mat.getElementFilter();
- Mesh::type_iterator type_it = filter_map.firstType(spatial_dimension);
- Mesh::type_iterator type_end = filter_map.lastType(spatial_dimension);
// Loop over all element types
- for (; type_it != type_end; ++type_it) {
- const Array<UInt> & filter = filter_map(*type_it);
+ for (auto && type : filter_map.elementTypes(spatial_dimension)) {
+ const Array<UInt> & filter = filter_map(type);
if (filter.size() == 0)
continue;
- Array<Real> & delta_T = mat.getArray<Real>("delta_T", *type_it);
+ Array<Real> & delta_T = mat.getArray<Real>("delta_T", type);
Array<Real>::scalar_iterator delta_T_it = delta_T.begin();
Array<Real>::scalar_iterator delta_T_end = delta_T.end();
for (; delta_T_it != delta_T_end; ++delta_T_it) {
*delta_T_it = temperature;
}
}
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::findCornerNodes() {
AKANTU_DEBUG_IN();
// find corner nodes
const auto & position = mesh.getNodes();
const auto & lower_bounds = mesh.getLowerBounds();
const auto & upper_bounds = mesh.getUpperBounds();
AKANTU_DEBUG_ASSERT(spatial_dimension == 2, "This is 2D only!");
corner_nodes.resize(4);
corner_nodes.set(UInt(-1));
for (auto && data : enumerate(make_view(position, spatial_dimension))) {
auto node = std::get<0>(data);
const auto & X = std::get<1>(data);
auto distance = X.distance(lower_bounds);
// node 1
if (Math::are_float_equal(distance, 0)) {
corner_nodes(0) = node;
}
// node 2
else if (Math::are_float_equal(X(_x), upper_bounds(_x)) &&
Math::are_float_equal(X(_y), lower_bounds(_y))) {
corner_nodes(1) = node;
}
// node 3
else if (Math::are_float_equal(X(_x), upper_bounds(_x)) &&
Math::are_float_equal(X(_y), upper_bounds(_y))) {
corner_nodes(2) = node;
}
// node 4
else if (Math::are_float_equal(X(_x), lower_bounds(_x)) &&
Math::are_float_equal(X(_y), upper_bounds(_y))) {
corner_nodes(3) = node;
}
}
for (UInt i = 0; i < corner_nodes.size(); ++i) {
if (corner_nodes(i) == UInt(-1))
AKANTU_ERROR("The corner node " << i + 1 << " wasn't found");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::advanceASR(const Matrix<Real> & prestrain) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(spatial_dimension == 2, "This is 2D only!");
/// apply the new eigenstrain
for (auto element_type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_not_defined)) {
Array<Real> & prestrain_vect =
const_cast<Array<Real> &>(this->getMaterial("gel").getInternal<Real>(
"eigen_grad_u")(element_type));
auto prestrain_it =
prestrain_vect.begin(spatial_dimension, spatial_dimension);
auto prestrain_end =
prestrain_vect.end(spatial_dimension, spatial_dimension);
for (; prestrain_it != prestrain_end; ++prestrain_it)
(*prestrain_it) = prestrain;
}
/// advance the damage
MaterialDamageIterative<2> & mat_paste =
dynamic_cast<MaterialDamageIterative<2> &>(*this->materials[1]);
MaterialDamageIterative<2> & mat_aggregate =
dynamic_cast<MaterialDamageIterative<2> &>(*this->materials[0]);
UInt nb_damaged_elements = 0;
Real max_eq_stress_aggregate = 0;
Real max_eq_stress_paste = 0;
auto & solver = this->getNonLinearSolver();
solver.set("max_iterations", 2);
solver.set("threshold", 1e-6);
solver.set("convergence_type", SolveConvergenceCriteria::_solution);
do {
this->solveStep();
/// compute damage
max_eq_stress_aggregate = mat_aggregate.getNormMaxEquivalentStress();
max_eq_stress_paste = mat_paste.getNormMaxEquivalentStress();
nb_damaged_elements = 0;
if (max_eq_stress_aggregate > max_eq_stress_paste)
nb_damaged_elements = mat_aggregate.updateDamage();
else if (max_eq_stress_aggregate < max_eq_stress_paste)
nb_damaged_elements = mat_paste.updateDamage();
else
nb_damaged_elements =
(mat_paste.updateDamage() + mat_aggregate.updateDamage());
std::cout << "the number of damaged elements is " << nb_damaged_elements
<< std::endl;
} while (nb_damaged_elements);
if (this->nb_dumps % 10 == 0) {
this->dump();
}
this->nb_dumps += 1;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModelRVE::averageTensorField(UInt row_index, UInt col_index,
const ID & field_type) {
AKANTU_DEBUG_IN();
auto & fem = this->getFEEngine("SolidMechanicsFEEngine");
Real average = 0;
GhostType gt = _not_ghost;
for (auto element_type :
mesh.elementTypes(spatial_dimension, gt, _ek_not_defined)) {
if (field_type == "stress") {
for (UInt m = 0; m < this->materials.size(); ++m) {
const auto & stress_vec = this->materials[m]->getStress(element_type);
const auto & elem_filter =
this->materials[m]->getElementFilter(element_type);
Array<Real> int_stress_vec(elem_filter.size(),
spatial_dimension * spatial_dimension,
"int_of_stress");
fem.integrate(stress_vec, int_stress_vec,
spatial_dimension * spatial_dimension, element_type,
_not_ghost, elem_filter);
for (UInt k = 0; k < elem_filter.size(); ++k)
- average += int_stress_vec(
- k, row_index * spatial_dimension + col_index); // 3 is the value
- // for the yy (in
- // 3D, the value is
- // 4)
+ average += int_stress_vec(k, row_index * spatial_dimension +
+ col_index); // 3 is the value
+ // for the yy (in
+ // 3D, the value is
+ // 4)
}
} else if (field_type == "strain") {
for (UInt m = 0; m < this->materials.size(); ++m) {
const auto & gradu_vec = this->materials[m]->getGradU(element_type);
const auto & elem_filter =
this->materials[m]->getElementFilter(element_type);
Array<Real> int_gradu_vec(elem_filter.size(),
spatial_dimension * spatial_dimension,
"int_of_gradu");
fem.integrate(gradu_vec, int_gradu_vec,
spatial_dimension * spatial_dimension, element_type,
_not_ghost, elem_filter);
for (UInt k = 0; k < elem_filter.size(); ++k)
/// averaging is done only for normal components, so stress and strain
/// are equal
average +=
0.5 *
(int_gradu_vec(k, row_index * spatial_dimension + col_index) +
int_gradu_vec(k, col_index * spatial_dimension + row_index));
}
} else if (field_type == "eigen_grad_u") {
for (UInt m = 0; m < this->materials.size(); ++m) {
const auto & eigen_gradu_vec =
this->materials[m]->getInternal<Real>("eigen_grad_u")(element_type);
const auto & elem_filter =
this->materials[m]->getElementFilter(element_type);
Array<Real> int_eigen_gradu_vec(elem_filter.size(),
spatial_dimension * spatial_dimension,
"int_of_gradu");
fem.integrate(eigen_gradu_vec, int_eigen_gradu_vec,
spatial_dimension * spatial_dimension, element_type,
_not_ghost, elem_filter);
for (UInt k = 0; k < elem_filter.size(); ++k)
/// averaging is done only for normal components, so stress and strain
/// are equal
average +=
int_eigen_gradu_vec(k, row_index * spatial_dimension + col_index);
}
} else {
AKANTU_ERROR("Averaging not implemented for this field!!!");
}
}
return average / this->volume;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::homogenizeStiffness(Matrix<Real> & C_macro) {
AKANTU_DEBUG_IN();
const UInt dim = 2;
AKANTU_DEBUG_ASSERT(this->spatial_dimension == dim,
"Is only implemented for 2D!!!");
/// apply three independent loading states to determine C
/// 1. eps_el = (1;0;0) 2. eps_el = (0,1,0) 3. eps_el = (0,0,0.5)
/// clear the eigenstrain
Matrix<Real> zero_eigengradu(dim, dim, 0.);
GhostType gt = _not_ghost;
for (auto element_type : mesh.elementTypes(dim, gt, _ek_not_defined)) {
auto & prestrain_vect =
const_cast<Array<Real> &>(this->getMaterial("gel").getInternal<Real>(
"eigen_grad_u")(element_type));
auto prestrain_it =
prestrain_vect.begin(spatial_dimension, spatial_dimension);
auto prestrain_end =
prestrain_vect.end(spatial_dimension, spatial_dimension);
for (; prestrain_it != prestrain_end; ++prestrain_it)
(*prestrain_it) = zero_eigengradu;
}
/// storage for results of 3 different loading states
UInt voigt_size = VoigtHelper<dim>::size;
Matrix<Real> stresses(voigt_size, voigt_size, 0.);
Matrix<Real> strains(voigt_size, voigt_size, 0.);
Matrix<Real> H(dim, dim, 0.);
/// save the damage state before filling up cracks
// ElementTypeMapReal saved_damage("saved_damage");
// saved_damage.initialize(getFEEngine(), _nb_component = 1, _default_value =
// 0);
// this->fillCracks(saved_damage);
/// virtual test 1:
H(0, 0) = 0.01;
this->performVirtualTesting(H, stresses, strains, 0);
/// virtual test 2:
H.clear();
H(1, 1) = 0.01;
this->performVirtualTesting(H, stresses, strains, 1);
/// virtual test 3:
H.clear();
H(0, 1) = 0.01;
this->performVirtualTesting(H, stresses, strains, 2);
/// drain cracks
// this->drainCracks(saved_damage);
/// compute effective stiffness
Matrix<Real> eps_inverse(voigt_size, voigt_size);
eps_inverse.inverse(strains);
C_macro.mul<false, false>(stresses, eps_inverse);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::performVirtualTesting(const Matrix<Real> & H,
Matrix<Real> & eff_stresses,
Matrix<Real> & eff_strains,
const UInt test_no) {
AKANTU_DEBUG_IN();
this->applyBoundaryConditions(H);
auto & solver = this->getNonLinearSolver();
solver.set("max_iterations", 2);
solver.set("threshold", 1e-6);
solver.set("convergence_type", SolveConvergenceCriteria::_solution);
this->solveStep();
/// get average stress and strain
eff_stresses(0, test_no) = this->averageTensorField(0, 0, "stress");
eff_strains(0, test_no) = this->averageTensorField(0, 0, "strain");
eff_stresses(1, test_no) = this->averageTensorField(1, 1, "stress");
eff_strains(1, test_no) = this->averageTensorField(1, 1, "strain");
eff_stresses(2, test_no) = this->averageTensorField(1, 0, "stress");
eff_strains(2, test_no) = 2. * this->averageTensorField(1, 0, "strain");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::homogenizeEigenGradU(
Matrix<Real> & eigen_gradu_macro) {
AKANTU_DEBUG_IN();
eigen_gradu_macro(0, 0) = this->averageTensorField(0, 0, "eigen_grad_u");
eigen_gradu_macro(1, 1) = this->averageTensorField(1, 1, "eigen_grad_u");
eigen_gradu_macro(0, 1) = this->averageTensorField(0, 1, "eigen_grad_u");
eigen_gradu_macro(1, 0) = this->averageTensorField(1, 0, "eigen_grad_u");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::initMaterials() {
AKANTU_DEBUG_IN();
// make sure the material are instantiated
if (!are_materials_instantiated)
instantiateMaterials();
if (use_RVE_mat_selector) {
const Vector<Real> & lowerBounds = mesh.getLowerBounds();
const Vector<Real> & upperBounds = mesh.getUpperBounds();
Real bottom = lowerBounds(1);
Real top = upperBounds(1);
Real box_size = std::abs(top - bottom);
Real eps = box_size * 1e-6;
auto tmp = std::make_shared<GelMaterialSelector>(*this, box_size, "gel",
this->nb_gel_pockets, eps);
tmp->setFallback(material_selector);
material_selector = tmp;
}
this->assignMaterialToElements();
// synchronize the element material arrays
this->synchronize(SynchronizationTag::_material_id);
for (auto & material : materials) {
/// init internals properties
const auto type = material->getID();
if (type.find("material_FE2") != std::string::npos)
continue;
material->initMaterial();
}
this->synchronize(SynchronizationTag::_smm_init_mat);
if (this->non_local_manager) {
this->non_local_manager->initialize();
}
// SolidMechanicsModel::initMaterials();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::fillCracks(ElementTypeMapReal & saved_damage) {
const auto & mat_gel = this->getMaterial("gel");
Real E_gel = mat_gel.get("E");
Real E_homogenized = 0.;
for (auto && mat : materials) {
if (mat->getName() == "gel" || mat->getName() == "FE2_mat")
continue;
Real E = mat->get("E");
auto & damage = mat->getInternal<Real>("damage");
for (auto && type : damage.elementTypes()) {
const auto & elem_filter = mat->getElementFilter(type);
auto nb_integration_point = getFEEngine().getNbIntegrationPoints(type);
auto sav_dam_it =
make_view(saved_damage(type), nb_integration_point).begin();
for (auto && data :
zip(elem_filter, make_view(damage(type), nb_integration_point))) {
auto el = std::get<0>(data);
auto & dam = std::get<1>(data);
Vector<Real> sav_dam = sav_dam_it[el];
sav_dam = dam;
for (auto q : arange(dam.size())) {
E_homogenized = (E_gel - E) * dam(q) + E;
dam(q) = 1. - (E_homogenized / E);
}
}
}
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelRVE::drainCracks(
const ElementTypeMapReal & saved_damage) {
for (auto && mat : materials) {
if (mat->getName() == "gel" || mat->getName() == "FE2_mat")
continue;
auto & damage = mat->getInternal<Real>("damage");
for (auto && type : damage.elementTypes()) {
const auto & elem_filter = mat->getElementFilter(type);
auto nb_integration_point = getFEEngine().getNbIntegrationPoints(type);
auto sav_dam_it =
make_view(saved_damage(type), nb_integration_point).begin();
for (auto && data :
zip(elem_filter, make_view(damage(type), nb_integration_point))) {
auto el = std::get<0>(data);
auto & dam = std::get<1>(data);
Vector<Real> sav_dam = sav_dam_it[el];
dam = sav_dam;
}
}
}
}
} // namespace akantu
diff --git a/extra_packages/extra-materials/src/material_damage/material_brittle_inline_impl.cc b/extra_packages/extra-materials/src/material_damage/material_brittle_inline_impl.cc
index d88ce1ac9..1ca80ea60 100644
--- a/extra_packages/extra-materials/src/material_damage/material_brittle_inline_impl.cc
+++ b/extra_packages/extra-materials/src/material_damage/material_brittle_inline_impl.cc
@@ -1,101 +1,102 @@
/**
* @file material_brittle_inline_impl.cc
*
* @author Aranda Ruiz Josue <josue.arandaruiz@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
*
*
* @brief Implementation of the inline functions of the material brittle
*
* @section LICENSE
*
* Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
*/
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialBrittle<spatial_dimension>::computeStressOnQuad(
Matrix<Real> & grad_u, Matrix<Real> & grad_v, Matrix<Real> & sigma,
Real & dam, Real & sigma_equivalent, Real & fracture_stress) {
MaterialElastic<spatial_dimension>::computeStressOnQuad(grad_u, sigma);
Real equiv_strain_rate = 0.;
Real volume_change_rate = grad_v.trace();
if (spatial_dimension == 2) {
equiv_strain_rate += 2. / 3. * pow(volume_change_rate / 3., 2.);
}
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j)
- equiv_strain_rate += 2. / 3. * pow(0.5 * (grad_v(i, j) + grad_v(j, i)) -
- (i == j) * volume_change_rate / 3.,
- 2.);
+ equiv_strain_rate += 2. / 3. *
+ pow(0.5 * (grad_v(i, j) + grad_v(j, i)) -
+ (i == j) * volume_change_rate / 3.,
+ 2.);
equiv_strain_rate = sqrt(equiv_strain_rate);
fracture_stress = S_0;
if (equiv_strain_rate > E_0)
fracture_stress = A;
Vector<Real> principal_stress(spatial_dimension);
sigma.eig(principal_stress);
sigma_equivalent = principal_stress(0);
for (UInt i = 1; i < spatial_dimension; ++i)
sigma_equivalent = std::max(sigma_equivalent, principal_stress(i));
if (!this->is_non_local) {
computeDamageAndStressOnQuad(sigma, dam, sigma_equivalent, fracture_stress);
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialBrittle<spatial_dimension>::computeDamageAndStressOnQuad(
Matrix<Real> & sigma, Real & dam, Real & sigma_c, Real & fracture_stress) {
if (sigma_c > fracture_stress)
dam = 1.;
dam = std::min(dam, 1.);
sigma *= 1 - dam;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline UInt MaterialBrittle<spatial_dimension>::getNbData(
const Array<Element> & elements, const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = MaterialDamage<spatial_dimension>::getNbData(elements, tag);
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialBrittle<spatial_dimension>::packData(
CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
MaterialDamage<spatial_dimension>::packData(buffer, elements, tag);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void
MaterialBrittle<spatial_dimension>::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
MaterialDamage<spatial_dimension>::unpackData(buffer, elements, tag);
AKANTU_DEBUG_OUT();
}
diff --git a/extra_packages/extra-materials/src/material_damage/material_damage_iterative.cc b/extra_packages/extra-materials/src/material_damage/material_damage_iterative.cc
index 76c1e14b8..58612f76f 100644
--- a/extra_packages/extra-materials/src/material_damage/material_damage_iterative.cc
+++ b/extra_packages/extra-materials/src/material_damage/material_damage_iterative.cc
@@ -1,255 +1,255 @@
/**
* @file material_damage_iterative.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief Specialization of the class material damage to damage only one gauss
* point at a time and propagate damage in a linear way. Max principal stress
* criterion is used as a failure criterion.
*
* @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 "material_damage_iterative.hh"
#include "communicator.hh"
#include "data_accessor.hh"
#include "solid_mechanics_model_RVE.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialDamageIterative<spatial_dimension>::MaterialDamageIterative(
SolidMechanicsModel & model, const ID & id)
: MaterialDamage<spatial_dimension>(model, id), Sc("Sc", *this),
reduction_step("damage_step", *this),
equivalent_stress("equivalent_stress", *this), max_reductions(0),
norm_max_equivalent_stress(0) {
AKANTU_DEBUG_IN();
this->registerParam("Sc", Sc, _pat_parsable, "critical stress threshold");
this->registerParam("prescribed_dam", prescribed_dam, 0.1,
_pat_parsable | _pat_modifiable, "prescribed damage");
this->registerParam(
"dam_threshold", dam_threshold, 0.8, _pat_parsable | _pat_modifiable,
"damage threshold at which damage damage will be set to 1");
this->registerParam(
"dam_tolerance", dam_tolerance, 0.01, _pat_parsable | _pat_modifiable,
"damage tolerance to decide if quadrature point will be damageed");
this->registerParam("max_damage", max_damage, 0.99999,
_pat_parsable | _pat_modifiable, "maximum damage value");
this->registerParam("max_reductions", max_reductions, UInt(10),
_pat_parsable | _pat_modifiable, "max reductions");
this->use_previous_stress = true;
this->use_previous_gradu = true;
this->Sc.initialize(1);
this->equivalent_stress.initialize(1);
this->reduction_step.initialize(1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialDamageIterative<spatial_dimension>::
computeNormalizedEquivalentStress(const Array<Real> & grad_u,
ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// Vector to store eigenvalues of current stress tensor
Vector<Real> eigenvalues(spatial_dimension);
auto Sc_it = Sc(el_type, ghost_type).begin();
auto equivalent_stress_it = equivalent_stress(el_type, ghost_type).begin();
Array<Real>::const_matrix_iterator grad_u_it =
grad_u.begin(spatial_dimension, spatial_dimension);
Array<Real>::const_matrix_iterator grad_u_end =
grad_u.end(spatial_dimension, spatial_dimension);
Real * dam = this->damage(el_type, ghost_type).storage();
Matrix<Real> sigma(spatial_dimension, spatial_dimension);
for (; grad_u_it != grad_u_end; ++grad_u_it) {
sigma.clear();
MaterialElastic<spatial_dimension>::computeStressOnQuad(*grad_u_it, sigma,
0.);
computeDamageAndStressOnQuad(sigma, *dam);
/// compute eigenvalues
sigma.eig(eigenvalues);
/// find max eigenvalue and normalize by tensile strength
*equivalent_stress_it =
*(std::max_element(eigenvalues.storage(),
eigenvalues.storage() + spatial_dimension)) /
*(Sc_it);
++Sc_it;
++equivalent_stress_it;
++dam;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialDamageIterative<spatial_dimension>::computeAllStresses(
GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// reset normalized maximum equivalent stress
if (ghost_type == _not_ghost)
norm_max_equivalent_stress = 0;
MaterialDamage<spatial_dimension>::computeAllStresses(ghost_type);
/// find global Gauss point with highest stress
auto rve_model = dynamic_cast<SolidMechanicsModelRVE *>(&this->model);
if (rve_model == NULL) {
/// is no RVE model
const auto & comm = this->model.getMesh().getCommunicator();
comm.allReduce(norm_max_equivalent_stress, SynchronizerOperation::_max);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialDamageIterative<spatial_dimension>::
findMaxNormalizedEquivalentStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
if (ghost_type == _not_ghost) {
// const Array<Real> & e_stress = equivalent_stress(el_type);
// if (e_stress.begin() != e_stress.end() ) {
// auto equivalent_stress_it_max =
// std::max_element(e_stress.begin(),e_stress.end());
// /// check if max equivalent stress for this element type is greater
// than the current norm_max_eq_stress
// if (*equivalent_stress_it_max > norm_max_equivalent_stress)
// norm_max_equivalent_stress = *equivalent_stress_it_max;
// }
const Array<Real> & e_stress = equivalent_stress(el_type);
auto equivalent_stress_it = e_stress.begin();
auto equivalent_stress_end = e_stress.end();
Array<Real> & dam = this->damage(el_type);
auto dam_it = dam.begin();
for (; equivalent_stress_it != equivalent_stress_end;
++equivalent_stress_it, ++dam_it) {
/// check if max equivalent stress for this element type is greater than
/// the current norm_max_eq_stress and if the element is not already fully
/// damaged
if (*equivalent_stress_it > norm_max_equivalent_stress &&
*dam_it < max_damage) {
norm_max_equivalent_stress = *equivalent_stress_it;
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialDamageIterative<spatial_dimension>::computeStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
MaterialDamage<spatial_dimension>::computeStress(el_type, ghost_type);
Real * dam = this->damage(el_type, ghost_type).storage();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeDamageAndStressOnQuad(sigma, *dam);
++dam;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
computeNormalizedEquivalentStress(this->gradu(el_type, ghost_type), el_type,
ghost_type);
norm_max_equivalent_stress = 0;
findMaxNormalizedEquivalentStress(el_type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
UInt MaterialDamageIterative<spatial_dimension>::updateDamage() {
UInt nb_damaged_elements = 0;
AKANTU_DEBUG_ASSERT(prescribed_dam > 0.,
"Your prescribed damage must be greater than zero");
if (norm_max_equivalent_stress >= 1.) {
AKANTU_DEBUG_IN();
/// update the damage only on non-ghosts elements! Doesn't make sense to
/// update on ghost.
GhostType ghost_type = _not_ghost;
;
Mesh::type_iterator it = this->model.getFEEngine().getMesh().firstType(
spatial_dimension, ghost_type);
Mesh::type_iterator last_type =
this->model.getFEEngine().getMesh().lastType(spatial_dimension,
ghost_type);
for (; it != last_type; ++it) {
ElementType el_type = *it;
const Array<Real> & e_stress = equivalent_stress(el_type);
auto equivalent_stress_it = e_stress.begin();
auto equivalent_stress_end = e_stress.end();
Array<Real> & dam = this->damage(el_type);
auto dam_it = dam.begin();
auto reduction_it = this->reduction_step(el_type, ghost_type).begin();
for (; equivalent_stress_it != equivalent_stress_end;
++equivalent_stress_it, ++dam_it, ++reduction_it) {
/// check if damage occurs
if (*equivalent_stress_it >=
(1 - dam_tolerance) * norm_max_equivalent_stress) {
/// check if this element can still be damaged
if (*reduction_it == this->max_reductions)
continue;
*reduction_it += 1;
if (*reduction_it == this->max_reductions) {
*dam_it = max_damage;
} else {
*dam_it += prescribed_dam;
}
nb_damaged_elements += 1;
}
}
}
}
auto * rve_model = dynamic_cast<SolidMechanicsModelRVE *>(&this->model);
if (rve_model == NULL) {
const auto & comm = this->model.getMesh().getCommunicator();
comm.allReduce(nb_damaged_elements, SynchronizerOperation::_sum);
}
AKANTU_DEBUG_OUT();
return nb_damaged_elements;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialDamageIterative<spatial_dimension>::updateEnergiesAfterDamage(
- ElementType el_type, GhostType ghost_type) {
- MaterialDamage<spatial_dimension>::updateEnergies(el_type, ghost_type);
+ ElementType el_type) {
+ MaterialDamage<spatial_dimension>::updateEnergies(el_type);
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(damage_iterative, MaterialDamageIterative);
} // namespace akantu
diff --git a/extra_packages/extra-materials/src/material_damage/material_damage_iterative.hh b/extra_packages/extra-materials/src/material_damage/material_damage_iterative.hh
index acd902544..b5ef98296 100644
--- a/extra_packages/extra-materials/src/material_damage/material_damage_iterative.hh
+++ b/extra_packages/extra-materials/src/material_damage/material_damage_iterative.hh
@@ -1,147 +1,146 @@
/**
* @file material_damage_iterative.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief Specialization of the class material damage to damage only one gauss
* point at a time and propagate damage in a linear way. Max principal stress
* criterion is used as a failure criterion.
*
* @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 "aka_common.hh"
#include "material.hh"
#include "material_damage.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_DAMAGE_ITERATIVE_HH__
#define __AKANTU_MATERIAL_DAMAGE_ITERATIVE_HH__
namespace akantu {
/**
* Material damage iterative
*
* parameters in the material files :
* - Sc
*/
template <UInt spatial_dimension>
class MaterialDamageIterative : public MaterialDamage<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialDamageIterative(SolidMechanicsModel & model, const ID & id = "");
virtual ~MaterialDamageIterative(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// virtual void updateInternalParameters();
virtual void computeAllStresses(GhostType ghost_type = _not_ghost);
/// update internal field damage
virtual UInt updateDamage();
UInt updateDamage(UInt quad_index, const Real eq_stress,
const ElementType & el_type, const GhostType & ghost_type);
/// update energies after damage has been updated
- virtual void updateEnergiesAfterDamage(ElementType el_type,
- GhostType ghost_typ);
+ virtual void updateEnergiesAfterDamage(ElementType el_type);
/// compute the equivalent stress on each Gauss point (i.e. the max prinicpal
/// stress) and normalize it by the tensile strength
virtual void
computeNormalizedEquivalentStress(const Array<Real> & grad_u,
ElementType el_type,
GhostType ghost_type = _not_ghost);
/// find max normalized equivalent stress
void findMaxNormalizedEquivalentStress(ElementType el_type,
GhostType ghost_type = _not_ghost);
protected:
/// constitutive law for all element of a type
virtual void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost);
inline void computeDamageAndStressOnQuad(Matrix<Real> & sigma, Real & dam);
/* ------------------------------------------------------------------------ */
/* DataAccessor inherited members */
/* ------------------------------------------------------------------------ */
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get max normalized equivalent stress
AKANTU_GET_MACRO(NormMaxEquivalentStress, norm_max_equivalent_stress, Real);
/// get a non-const reference to the max normalized equivalent stress
AKANTU_GET_MACRO_NOT_CONST(NormMaxEquivalentStress,
norm_max_equivalent_stress, Real &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// resistance to damage
RandomInternalField<Real> Sc;
/// the reduction
InternalField<UInt> reduction_step;
/// internal field to store equivalent stress on each Gauss point
InternalField<Real> equivalent_stress;
/// the number of total reductions steps until complete failure
UInt max_reductions;
/// damage increment
Real prescribed_dam;
/// maximum equivalent stress
Real norm_max_equivalent_stress;
/// deviation from max stress at which Gauss point will still get damaged
Real dam_tolerance;
/// define damage threshold at which damage will be set to 1
Real dam_threshold;
/// maximum damage value
Real max_damage;
};
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "material_damage_iterative_inline_impl.cc"
#endif /* __AKANTU_MATERIAL_DAMAGE_ITERATIVE_HH__ */
diff --git a/extra_packages/extra-materials/src/material_damage/material_damage_iterative_inline_impl.cc b/extra_packages/extra-materials/src/material_damage/material_damage_iterative_inline_impl.cc
index f5cb063de..092bbb4b3 100644
--- a/extra_packages/extra-materials/src/material_damage/material_damage_iterative_inline_impl.cc
+++ b/extra_packages/extra-materials/src/material_damage/material_damage_iterative_inline_impl.cc
@@ -1,92 +1,92 @@
/**
* @file material_damage_iterative_inline_impl.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief Implementation of inline functions of the material damage iterative
*
* @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 "material_damage_iterative.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void
MaterialDamageIterative<spatial_dimension>::computeDamageAndStressOnQuad(
Matrix<Real> & sigma, Real & dam) {
sigma *= 1 - dam;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
UInt MaterialDamageIterative<spatial_dimension>::updateDamage(
UInt quad_index, const Real /*eq_stress*/, const ElementType & el_type,
const GhostType & ghost_type) {
AKANTU_DEBUG_ASSERT(prescribed_dam > 0.,
"Your prescribed damage must be greater than zero");
Array<Real> & dam = this->damage(el_type, ghost_type);
Real & dam_on_quad = dam(quad_index);
/// check if damage occurs
if (equivalent_stress(el_type, ghost_type)(quad_index) >=
(1 - dam_tolerance) * norm_max_equivalent_stress) {
if (dam_on_quad < dam_threshold)
dam_on_quad += prescribed_dam;
else
dam_on_quad = max_damage;
return 1;
}
return 0;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline UInt MaterialDamageIterative<spatial_dimension>::getNbData(
const Array<Element> & elements, const SynchronizationTag & tag) const {
if (tag == SynchronizationTag::_user_2) {
return sizeof(Real) * this->getModel().getNbIntegrationPoints(elements);
}
return MaterialDamage<spatial_dimension>::getNbData(elements, tag);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialDamageIterative<spatial_dimension>::packData(
CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const {
if (tag == SynchronizationTag::_user_2) {
DataAccessor<Element>::packElementalDataHelper(
this->damage, buffer, elements, true, this->damage.getFEEngine());
}
return MaterialDamage<spatial_dimension>::packData(buffer, elements, tag);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialDamageIterative<spatial_dimension>::unpackData(
CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) {
if (tag == SynchronizationTag::_user_2) {
DataAccessor<Element>::unpackElementalDataHelper(
this->damage, buffer, elements, true, this->damage.getFEEngine());
}
return MaterialDamage<spatial_dimension>::unpackData(buffer, elements, tag);
}
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
diff --git a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage.hh b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage.hh
index afd4555ce..69261f49a 100644
--- a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage.hh
+++ b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage.hh
@@ -1,147 +1,147 @@
/**
* @file material_orthotropic_damage.hh
* @author Aurelia Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Sun Mar 8 12:49:56 2015
*
* @brief Material for orthotropic damage
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material_elastic.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ORTHOTROPIC_DAMAGE_HH__
#define __AKANTU_MATERIAL_ORTHOTROPIC_DAMAGE_HH__
namespace akantu {
template <UInt spatial_dimension,
template <UInt> class Parent = MaterialElastic>
class MaterialOrthotropicDamage : public Parent<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialOrthotropicDamage(SolidMechanicsModel & model, const ID & id = "");
virtual ~MaterialOrthotropicDamage(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
virtual void initMaterial();
/// compute the tangent stiffness matrix for an element type
virtual void computeTangentModuli(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost);
protected:
/// update the dissipated energy, must be called after the stress have been
/// computed
- virtual void updateEnergies(ElementType el_type, GhostType ghost_type);
+ void updateEnergies(ElementType el_type) override;
/// compute the tangent stiffness matrix for a given quadrature point
inline void computeTangentModuliOnQuad(
Matrix<Real> & tangent, const Matrix<Real> C, const Matrix<Real> & dam,
const Matrix<Real> & dam_directions, Matrix<Real> & O_prime,
Matrix<Real> & S_prime, Matrix<Real> & O, Matrix<Real> & S,
Matrix<Real> & rotation_tmp);
inline void computeDamageAndStressOnQuad(Matrix<Real> & sigma,
Matrix<Real> & one_minus_D,
Matrix<Real> & root_one_minus_D,
Matrix<Real> & damage,
Matrix<Real> & first_term,
Matrix<Real> & third_term);
/// rotate a Matrix of size dim*dim into the coordinate system of the FE
/// computation
inline void rotateIntoComputationFrame(const Matrix<Real> & to_rotate,
Matrix<Real> & rotated,
const Matrix<Real> & damage_directions,
Matrix<Real> & rotation_tmp);
/// rotate a Matrix of size dim*dim into the coordinate system of the damage
inline void rotateIntoNewFrame(const Matrix<Real> & to_rotate,
Matrix<Real> & rotated,
const Matrix<Real> & damage_directions,
Matrix<Real> & rotation_tmp);
/// compute (1-D)
inline void computeOneMinusD(Matrix<Real> & one_minus_D,
const Matrix<Real> & damage);
/// compute (1-D)^(1/2)
inline void computeSqrtOneMinusD(const Matrix<Real> & one_minus_D,
Matrix<Real> & sqrt_one_minus_D);
/* ------------------------------------------------------------------------ */
/* DataAccessor inherited members */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// give the dissipated energy for the time step
Real getDissipatedEnergy() const;
// virtual Real getEnergy(std::string type);
// virtual Real getEnergy(std::string energy_id, ElementType type, UInt index)
// {
// return Parent<spatial_dimension>::getEnergy(energy_id, type, index);
// };
AKANTU_GET_MACRO_NOT_CONST(Damage, damage, ElementTypeMapArray<Real> &);
AKANTU_GET_MACRO(Damage, damage, const ElementTypeMapArray<Real> &);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Damage, damage, Real)
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// damage internal variable
InternalField<Real> damage;
/// dissipated energy
InternalField<Real> dissipated_energy;
/// contain the current value of @f$ \int_0^{\epsilon}\sigma(\omega)d\omega
/// @f$ the dissipated energy
InternalField<Real> int_sigma;
/// direction vectors for the damage frame
InternalField<Real> damage_dir_vecs;
Real eta;
/// maximum damage value
Real max_damage;
};
} // namespace akantu
#include "material_orthotropic_damage_tmpl.hh"
#endif /* __AKANTU_MATERIAL_ORTHOTROPIC_DAMAGE_HH__ */
diff --git a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.cc b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.cc
index 73d3cc282..2f67f7d40 100644
--- a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.cc
+++ b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.cc
@@ -1,378 +1,376 @@
/**
* @file material_damage_iterative.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @date Sun Mar 8 12:54:30 2015
*
* @brief Specialization of the class material damage to damage only one gauss
* point at a time and propagate damage in a linear way. Max principal stress
* criterion is used as a failure criterion.
*
* @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 "material_orthotropic_damage_iterative.hh"
#include "communicator.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialOrthotropicDamageIterative<spatial_dimension>::
MaterialOrthotropicDamageIterative(SolidMechanicsModel & model,
const ID & id)
: MaterialOrthotropicDamage<spatial_dimension>(model, id), Sc("Sc", *this),
equivalent_stress("equivalent_stress", *this),
stress_dir("equiv_stress_dir", *this), norm_max_equivalent_stress(0) {
AKANTU_DEBUG_IN();
this->registerParam("Sc", Sc, _pat_parsable, "critical stress threshold");
this->registerParam("prescribed_dam", prescribed_dam, 0.1,
_pat_parsable | _pat_modifiable,
"increase of damage in every step");
this->registerParam(
"dam_threshold", dam_threshold, 0.8, _pat_parsable | _pat_modifiable,
"damage threshold at which damage damage will be set to 1");
this->use_previous_stress = true;
this->use_previous_gradu = true;
this->Sc.initialize(1);
this->equivalent_stress.initialize(1);
this->stress_dir.initialize(spatial_dimension * spatial_dimension);
/// the Gauss point with the highest stress can only be of type _not_ghost
q_max.ghost_type = _not_ghost;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialOrthotropicDamageIterative<spatial_dimension>::
computeNormalizedEquivalentStress(const Array<Real> & grad_u,
ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// Vector to store eigenvalues of current stress tensor
Vector<Real> eigenvalues(spatial_dimension);
auto Sc_it = Sc(el_type).begin();
auto equivalent_stress_it = equivalent_stress(el_type).begin();
Array<Real>::const_matrix_iterator grad_u_it =
grad_u.begin(spatial_dimension, spatial_dimension);
Array<Real>::const_matrix_iterator grad_u_end =
grad_u.end(spatial_dimension, spatial_dimension);
Array<Real>::matrix_iterator stress_dir_it =
this->stress_dir(el_type).begin(spatial_dimension, spatial_dimension);
/// initialize matrix to store the stress for the criterion (only different in
/// non-local)
Matrix<Real> sigma(spatial_dimension, spatial_dimension);
Array<Real>::matrix_iterator damage_iterator =
this->damage(el_type, ghost_type)
.begin(this->spatial_dimension, this->spatial_dimension);
Array<Real>::matrix_iterator damage_dir_it =
this->damage_dir_vecs(el_type, ghost_type)
.begin(this->spatial_dimension, this->spatial_dimension);
/// for the computation of the Cauchy stress the matrices (1-D) and
/// (1-D)^(1/2) are needed. For the formulation see Engineering
/// Damage Mechanics by Lemaitre and Desmorat.
Matrix<Real> one_minus_D(this->spatial_dimension, this->spatial_dimension);
Matrix<Real> sqrt_one_minus_D(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> one_minus_D_rotated(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> sqrt_one_minus_D_rotated(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> rotation_tmp(this->spatial_dimension, this->spatial_dimension);
/// create matrix to store the first term of the computation of the
/// Cauchy stress
Matrix<Real> first_term(this->spatial_dimension, this->spatial_dimension);
Matrix<Real> third_term(this->spatial_dimension, this->spatial_dimension);
for (; grad_u_it != grad_u_end;
++Sc_it, ++equivalent_stress_it, ++stress_dir_it, ++grad_u_it) {
sigma.clear();
MaterialOrthotropicDamage<spatial_dimension>::computeStressOnQuad(
*grad_u_it, sigma, 0.);
/// rotate the tensors from the damage principal coordinate system to the CS
/// of the computation
if (!(Math::are_float_equal((*damage_iterator).trace(), 0))) {
/// compute (1-D) and (1-D)^1/2
this->computeOneMinusD(one_minus_D, *damage_iterator);
this->computeSqrtOneMinusD(one_minus_D, sqrt_one_minus_D);
this->rotateIntoComputationFrame(one_minus_D, one_minus_D_rotated,
*damage_dir_it, rotation_tmp);
this->rotateIntoComputationFrame(sqrt_one_minus_D,
sqrt_one_minus_D_rotated, *damage_dir_it,
rotation_tmp);
} else {
this->computeOneMinusD(one_minus_D_rotated, *damage_iterator);
this->computeSqrtOneMinusD(one_minus_D_rotated, sqrt_one_minus_D_rotated);
}
computeDamageAndStressOnQuad(sigma, one_minus_D_rotated,
sqrt_one_minus_D_rotated, *damage_iterator,
first_term, third_term);
/// compute the maximum principal stresses and their directions
sigma.eig(eigenvalues, *stress_dir_it);
*equivalent_stress_it = eigenvalues(0) / *(Sc_it);
++damage_dir_it;
++damage_iterator;
}
// for(;sigma_it != sigma_end; ++sigma_it,
// ++Sc_it, ++equivalent_stress_it, ++stress_dir_it) {
// /// compute the maximum principal stresses and their directions
// (*sigma_it).eig(eigenvalues, *stress_dir_it);
// *equivalent_stress_it = eigenvalues(0) / *(Sc_it);
// }
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialOrthotropicDamageIterative<spatial_dimension>::computeAllStresses(
GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// reset normalized maximum equivalent stress
if (ghost_type == _not_ghost)
norm_max_equivalent_stress = 0;
MaterialOrthotropicDamage<spatial_dimension>::computeAllStresses(ghost_type);
/// find global Gauss point with highest stress
this->model.getMesh().getCommunicator().allReduce(
norm_max_equivalent_stress, SynchronizerOperation::_max);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialOrthotropicDamageIterative<spatial_dimension>::
findMaxNormalizedEquivalentStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
if (ghost_type == _not_ghost) {
/// initialize the iterators for the equivalent stress and the damage
const Array<Real> & e_stress = equivalent_stress(el_type);
auto equivalent_stress_it = e_stress.begin();
auto equivalent_stress_end = e_stress.end();
Array<Real> & dam = this->damage(el_type);
auto dam_it = dam.begin(this->spatial_dimension, this->spatial_dimension);
auto damage_directions_it =
this->damage_dir_vecs(el_type, _not_ghost)
.begin(this->spatial_dimension, this->spatial_dimension);
auto stress_dir_it = this->stress_dir(el_type, _not_ghost)
.begin(spatial_dimension, spatial_dimension);
/// initialize the matrices for damage rotation results
Matrix<Real> tmp(spatial_dimension, spatial_dimension);
Matrix<Real> dam_in_computation_frame(spatial_dimension, spatial_dimension);
Matrix<Real> dam_in_stress_frame(spatial_dimension, spatial_dimension);
for (; equivalent_stress_it != equivalent_stress_end;
++equivalent_stress_it, ++dam_it, ++damage_directions_it,
++stress_dir_it) {
/// check if max equivalent stress for this element type is greater than
/// the current norm_max_eq_stress
if (*equivalent_stress_it > norm_max_equivalent_stress &&
(spatial_dimension * this->max_damage - (*dam_it).trace() >
Math::getTolerance())) {
if (Math::are_float_equal((*dam_it).trace(), 0)) {
/// gauss point has not been damaged yet
norm_max_equivalent_stress = *equivalent_stress_it;
q_max.type = el_type;
q_max.global_num = equivalent_stress_it - e_stress.begin();
}
else {
/// find the damage increment on this Gauss point
/// rotate damage into stress frame
this->rotateIntoComputationFrame(*dam_it, dam_in_computation_frame,
*damage_directions_it, tmp);
this->rotateIntoNewFrame(dam_in_computation_frame,
dam_in_stress_frame, *stress_dir_it, tmp);
/// add damage increment
dam_in_stress_frame(0, 0) += prescribed_dam;
/// find new principal directions of damage
Vector<Real> dam_eigenvalues(spatial_dimension);
dam_in_stress_frame.eig(dam_eigenvalues);
bool limit_reached = false;
for (UInt i = 0; i < spatial_dimension; ++i) {
if (dam_eigenvalues(i) + Math::getTolerance() > this->max_damage)
limit_reached = true;
}
if (!limit_reached) {
norm_max_equivalent_stress = *equivalent_stress_it;
q_max.type = el_type;
q_max.global_num = equivalent_stress_it - e_stress.begin();
}
}
} /// end if equiv_stress > max_equiv_stress
} /// end loop over all gauss points of this element type
} // end if(_not_ghost)
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialOrthotropicDamageIterative<spatial_dimension>::computeStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
MaterialOrthotropicDamage<spatial_dimension>::computeStress(el_type,
ghost_type);
auto damage_iterator =
this->damage(el_type, ghost_type)
.begin(this->spatial_dimension, this->spatial_dimension);
auto damage_dir_it =
this->damage_dir_vecs(el_type, ghost_type)
.begin(this->spatial_dimension, this->spatial_dimension);
/// for the computation of the Cauchy stress the matrices (1-D) and
/// (1-D)^(1/2) are needed. For the formulation see Engineering
/// Damage Mechanics by Lemaitre and Desmorat.
Matrix<Real> one_minus_D(this->spatial_dimension, this->spatial_dimension);
Matrix<Real> sqrt_one_minus_D(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> one_minus_D_rotated(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> sqrt_one_minus_D_rotated(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> rotation_tmp(this->spatial_dimension, this->spatial_dimension);
/// create matrix to store the first term of the computation of the
/// Cauchy stress
Matrix<Real> first_term(this->spatial_dimension, this->spatial_dimension);
Matrix<Real> third_term(this->spatial_dimension, this->spatial_dimension);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
/// rotate the tensors from the damage principal coordinate system to the CS
/// of the computation
if (!(Math::are_float_equal((*damage_iterator).trace(), 0))) {
/// compute (1-D) and (1-D)^1/2
this->computeOneMinusD(one_minus_D, *damage_iterator);
this->computeSqrtOneMinusD(one_minus_D, sqrt_one_minus_D);
this->rotateIntoComputationFrame(one_minus_D, one_minus_D_rotated,
*damage_dir_it, rotation_tmp);
this->rotateIntoComputationFrame(sqrt_one_minus_D, sqrt_one_minus_D_rotated,
*damage_dir_it, rotation_tmp);
} else {
this->computeOneMinusD(one_minus_D_rotated, *damage_iterator);
this->computeSqrtOneMinusD(one_minus_D_rotated, sqrt_one_minus_D_rotated);
}
computeDamageAndStressOnQuad(sigma, one_minus_D_rotated,
sqrt_one_minus_D_rotated, *damage_iterator,
first_term, third_term);
++damage_dir_it;
++damage_iterator;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
computeNormalizedEquivalentStress(this->gradu(el_type, ghost_type), el_type,
ghost_type);
norm_max_equivalent_stress = 0;
findMaxNormalizedEquivalentStress(el_type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
UInt MaterialOrthotropicDamageIterative<spatial_dimension>::updateDamage() {
UInt nb_damaged_elements = 0;
AKANTU_DEBUG_ASSERT(prescribed_dam > 0.,
"Your prescribed damage must be greater than zero");
if (norm_max_equivalent_stress >= 1.) {
AKANTU_DEBUG_IN();
/// get the arrays and iterators for the element_type of the highest
/// quadrature point
ElementType el_type = q_max.type;
UInt q_global_num = q_max.global_num;
Array<Real> & dam = this->damage(el_type, _not_ghost);
auto dam_it = dam.begin(this->spatial_dimension, this->spatial_dimension);
auto damage_directions_it =
this->damage_dir_vecs(el_type, _not_ghost)
.begin(this->spatial_dimension, this->spatial_dimension);
auto stress_dir_it = this->stress_dir(el_type, _not_ghost)
.begin(spatial_dimension, spatial_dimension);
/// initialize the matrices for damage rotation results
Matrix<Real> tmp(spatial_dimension, spatial_dimension);
Matrix<Real> dam_in_computation_frame(spatial_dimension, spatial_dimension);
Matrix<Real> dam_in_stress_frame(spatial_dimension, spatial_dimension);
/// references to damage and directions of highest Gauss point
Matrix<Real> q_dam = dam_it[q_global_num];
Matrix<Real> q_dam_dir = damage_directions_it[q_global_num];
Matrix<Real> q_stress_dir = stress_dir_it[q_global_num];
/// increment damage
/// find the damage increment on this Gauss point
/// rotate damage into stress frame
this->rotateIntoComputationFrame(q_dam, dam_in_computation_frame, q_dam_dir,
tmp);
this->rotateIntoNewFrame(dam_in_computation_frame, dam_in_stress_frame,
q_stress_dir, tmp);
/// add damage increment
dam_in_stress_frame(0, 0) += prescribed_dam;
/// find new principal directions of damage
Vector<Real> dam_eigenvalues(spatial_dimension);
dam_in_stress_frame.eig(dam_eigenvalues, q_dam_dir);
for (UInt i = 0; i < spatial_dimension; ++i) {
q_dam(i, i) = dam_eigenvalues(i);
if (q_dam(i, i) + Math::getTolerance() >= dam_threshold)
q_dam(i, i) = this->max_damage;
}
nb_damaged_elements += 1;
}
this->model.getMesh().getCommunicator().allReduce(
nb_damaged_elements, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
return nb_damaged_elements;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialOrthotropicDamageIterative<
- spatial_dimension>::updateEnergiesAfterDamage(ElementType el_type,
- GhostType ghost_type) {
- MaterialOrthotropicDamage<spatial_dimension>::updateEnergies(el_type,
- ghost_type);
+ spatial_dimension>::updateEnergiesAfterDamage(ElementType el_type) {
+ MaterialOrthotropicDamage<spatial_dimension>::updateEnergies(el_type);
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(orthotropic_damage_iterative,
MaterialOrthotropicDamageIterative);
} // namespace akantu
diff --git a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.hh b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.hh
index 55837e443..58e2b11a1 100644
--- a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.hh
+++ b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_iterative.hh
@@ -1,129 +1,128 @@
/**
* @file material_orthtropic_damage_iterative.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @date Sun Mar 8 12:54:30 2015
*
* @brief Specialization of the class material orthotropic damage to
* damage only one gauss point at a time and propagate damage in a
* linear way. Max principal stress criterion is used as a failure
* criterion.
*
* @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 "aka_common.hh"
#include "material.hh"
#include "material_orthotropic_damage.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ORTHOTROPIC_DAMAGE_ITERATIVE_HH__
#define __AKANTU_MATERIAL_ORTHOTROPIC_DAMAGE_ITERATIVE_HH__
namespace akantu {
/**
* Material damage iterative
*
* parameters in the material files :
* - Sc
*/
template <UInt spatial_dimension>
class MaterialOrthotropicDamageIterative
: public MaterialOrthotropicDamage<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialOrthotropicDamageIterative(SolidMechanicsModel & model,
const ID & id = "");
virtual ~MaterialOrthotropicDamageIterative(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// virtual void updateInternalParameters();
virtual void computeAllStresses(GhostType ghost_type = _not_ghost);
/// update internal field damage
UInt updateDamage();
/// update energies after damage has been updated
- virtual void updateEnergiesAfterDamage(ElementType el_type,
- GhostType ghost_typ);
+ virtual void updateEnergiesAfterDamage(ElementType el_type);
protected:
/// constitutive law for all element of a type
virtual void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost);
/// compute the equivalent stress on each Gauss point (i.e. the max prinicpal
/// stress) and normalize it by the tensile strength
void computeNormalizedEquivalentStress(const Array<Real> & grad_u,
ElementType el_type,
GhostType ghost_type = _not_ghost);
/// find max normalized equivalent stress
void findMaxNormalizedEquivalentStress(ElementType el_type,
GhostType ghost_type = _not_ghost);
inline void computeDamageAndStressOnQuad(Matrix<Real> & sigma,
Matrix<Real> & one_minus_D,
Matrix<Real> & root_one_minus_D,
Matrix<Real> & damage,
Matrix<Real> & first_term,
Matrix<Real> & third_term);
/* ------------------------------------------------------------------------ */
/* DataAccessor inherited members */
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get max normalized equivalent stress
AKANTU_GET_MACRO(NormMaxEquivalentStress, norm_max_equivalent_stress, Real);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// resistance to damage
RandomInternalField<Real> Sc;
/// internal field to store equivalent stress on each Gauss point
InternalField<Real> equivalent_stress;
/// internal field to store the direction of the current damage frame
InternalField<Real> stress_dir;
/// damage increment
Real prescribed_dam;
/// maximum equivalent stress
Real norm_max_equivalent_stress;
/// define damage threshold at which damage will be set to 1
Real dam_threshold;
/// quadrature point with highest equivalent Stress
IntegrationPoint q_max;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "material_orthotropic_damage_iterative_inline_impl.cc"
} // namespace akantu
#endif /* __AKANTU_MATERIAL_ORTHOTROPIC_DAMAGE_ITERATIVE_HH__ */
diff --git a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_tmpl.hh b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_tmpl.hh
index 91a98795a..d7d6ef35c 100644
--- a/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_tmpl.hh
+++ b/extra_packages/extra-materials/src/material_damage/material_orthotropic_damage_tmpl.hh
@@ -1,322 +1,322 @@
/**
* @file material_orthotropic_damage_tmpl.hh
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Sun Mar 8 12:54:30 2015
*
* @brief Specialization of the material class for the orthotropic
* damage material
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_orthotropic_damage.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
MaterialOrthotropicDamage<spatial_dimension, Parent>::MaterialOrthotropicDamage(
SolidMechanicsModel & model, const ID & id)
: Parent<spatial_dimension>(model, id), damage("damage", *this),
dissipated_energy("damage dissipated energy", *this),
int_sigma("integral of sigma", *this),
damage_dir_vecs("damage_principal_directions", *this) {
AKANTU_DEBUG_IN();
this->registerParam("eta", eta, 2., _pat_parsable | _pat_modifiable,
"Damage sensitivity parameter");
this->registerParam("max_damage", max_damage, 0.99999,
_pat_parsable | _pat_modifiable, "maximum damage value");
this->is_non_local = false;
this->use_previous_stress = true;
this->use_previous_gradu = true;
/// use second order tensor for description of damage state
this->damage.initialize(spatial_dimension * spatial_dimension);
this->dissipated_energy.initialize(1);
this->int_sigma.initialize(1);
this->damage_dir_vecs.initialize(spatial_dimension * spatial_dimension);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialOrthotropicDamage<spatial_dimension, Parent>::initMaterial() {
AKANTU_DEBUG_IN();
Parent<spatial_dimension>::initMaterial();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Compute the dissipated energy in each element by a trapezoidal approximation
* of
* @f$ Ed = \int_0^{\epsilon}\sigma(\omega)d\omega -
* \frac{1}{2}\sigma:\epsilon@f$
*/
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialOrthotropicDamage<spatial_dimension, Parent>::updateEnergies(
- ElementType el_type, GhostType ghost_type) {
- Parent<spatial_dimension>::updateEnergies(el_type, ghost_type);
+ ElementType el_type) {
+ Parent<spatial_dimension>::updateEnergies(el_type);
- this->computePotentialEnergy(el_type, ghost_type);
+ this->computePotentialEnergy(el_type);
- auto epsilon_p = this->gradu.previous(el_type, ghost_type)
- .begin(spatial_dimension, spatial_dimension);
- auto sigma_p = this->stress.previous(el_type, ghost_type)
- .begin(spatial_dimension, spatial_dimension);
+ auto epsilon_p =
+ this->gradu.previous(el_type).begin(spatial_dimension, spatial_dimension);
+ auto sigma_p = this->stress.previous(el_type).begin(spatial_dimension,
+ spatial_dimension);
- auto epot = this->potential_energy(el_type, ghost_type).begin();
+ auto epot = this->potential_energy(el_type).begin();
- auto ints = this->int_sigma(el_type, ghost_type).begin();
- auto ed = this->dissipated_energy(el_type, ghost_type).begin();
+ auto ints = this->int_sigma(el_type).begin();
+ auto ed = this->dissipated_energy(el_type).begin();
- MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
+ MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
- Matrix<Real> delta_gradu_it(*gradu_it);
+ Matrix<Real> delta_gradu_it(grad_u);
delta_gradu_it -= *epsilon_p;
Matrix<Real> sigma_h(sigma);
sigma_h += *sigma_p;
Real dint = .5 * sigma_h.doubleDot(delta_gradu_it);
*ints += dint;
*ed = *ints - *epot;
++epsilon_p;
++sigma_p;
++epot;
++ints;
++ed;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialOrthotropicDamage<spatial_dimension, Parent>::computeTangentModuli(
const ElementType & el_type, Array<Real> & tangent_matrix,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Parent<spatial_dimension>::computeTangentModuli(el_type, tangent_matrix,
ghost_type);
/// get the damage array for current element type
Array<Real> & dam = this->damage(el_type);
auto dam_it = dam.begin(this->spatial_dimension, this->spatial_dimension);
/// get the directions of damage for the current element type
Array<Real> & dam_dirs = this->damage_dir_vecs(el_type);
auto damage_directions_it =
dam_dirs.begin(this->spatial_dimension, this->spatial_dimension);
/// for the computation of the Cauchy stress the matrices (1-D) and
/// (1-D)^(1/2) are needed. For the formulation see Engineering
/// Damage Mechanics by Lemaitre and Desmorat.
Matrix<Real> one_minus_D(this->spatial_dimension, this->spatial_dimension);
Matrix<Real> sqrt_one_minus_D(this->spatial_dimension,
this->spatial_dimension);
Matrix<Real> one_minus_D_rot(spatial_dimension, spatial_dimension);
Matrix<Real> sqrt_one_minus_D_rot(spatial_dimension, spatial_dimension);
Matrix<Real> rotation_tmp(spatial_dimension, spatial_dimension);
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
if (!(Math::are_float_equal((*dam_it).trace(), 0)))
computeTangentModuliOnQuad(tangent, tangent, *dam_it, *damage_directions_it,
one_minus_D, sqrt_one_minus_D, one_minus_D_rot,
sqrt_one_minus_D_rot, rotation_tmp);
++dam_it;
++damage_directions_it;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialOrthotropicDamage<spatial_dimension, Parent>::
computeTangentModuliOnQuad(Matrix<Real> & tangent, const Matrix<Real> C,
const Matrix<Real> & dam,
const Matrix<Real> & dam_directions,
Matrix<Real> & O_prime, Matrix<Real> & S_prime,
Matrix<Real> & O, Matrix<Real> & S,
Matrix<Real> & rotation_tmp) {
/// effect of damage on stiffness matrix: See Ragueneau et al. 2008, p. 423,
/// ep. 7
Real trace_D = dam.trace();
this->computeOneMinusD(O_prime, dam);
this->computeSqrtOneMinusD(O_prime, S_prime);
this->rotateIntoComputationFrame(O_prime, O, dam_directions, rotation_tmp);
this->rotateIntoComputationFrame(S_prime, S, dam_directions, rotation_tmp);
/// compute new stiffness matrix in damage coordinate system
if (spatial_dimension == 1)
tangent *= (1 - dam(0, 0));
if (spatial_dimension == 2) {
Real min_val =
std::min((this->eta / spatial_dimension * trace_D), this->max_damage);
/// first row
tangent(0, 0) =
(C(0, 0) * S(0, 0) * S(0, 0) + C(1, 0) * S(0, 1) * S(0, 1) -
(min_val / 2. - 1. / 2) * (C(0, 0) + C(1, 0)) +
(O(0, 0) * (C(0, 0) * O(0, 0) + C(1, 0) * O(1, 1))) / (trace_D - 2.));
tangent(0, 1) =
(C(0, 1) * S(0, 0) * S(0, 0) + C(1, 1) * S(0, 1) * S(0, 1) -
(min_val / 2. - 1. / 2) * (C(0, 1) + C(1, 1)) +
(O(0, 0) * (C(0, 1) * O(0, 0) + C(1, 1) * O(1, 1))) / (trace_D - 2.));
tangent(0, 2) = (2. * C(2, 2) * S(0, 0) * S(0, 1) +
(2. * C(2, 2) * O(0, 0) * O(0, 1)) / (trace_D - 2.));
/// second row
tangent(1, 0) =
(C(0, 0) * S(0, 1) * S(0, 1) + C(1, 0) * S(1, 1) * S(1, 1) -
(min_val / 2. - 1. / 2) * (C(0, 0) + C(1, 0)) +
(O(1, 1) * (C(0, 0) * O(0, 0) + C(1, 0) * O(1, 1))) / (trace_D - 2.));
tangent(1, 1) =
(C(0, 1) * S(0, 1) * S(0, 1) + C(1, 1) * S(1, 1) * S(1, 1) -
(min_val / 2. - 1. / 2) * (C(0, 1) + C(1, 1)) +
(O(1, 1) * (C(0, 1) * O(0, 0) + C(1, 1) * O(1, 1))) / (trace_D - 2.));
tangent(1, 2) = (2. * C(2, 2) * S(0, 1) * S(1, 1) +
(2. * C(2, 2) * O(0, 1) * O(1, 1)) / (trace_D - 2.));
/// third row
tangent(2, 0) =
((O(0, 1) * (C(0, 0) * O(0, 0) + C(1, 0) * O(1, 1))) / (trace_D - 2.) +
C(0, 0) * S(0, 0) * S(0, 1) + C(1, 0) * S(0, 1) * S(1, 1));
tangent(2, 1) =
((O(0, 1) * (C(0, 1) * O(0, 0) + C(1, 1) * O(1, 1))) / (trace_D - 2.) +
C(0, 1) * S(0, 0) * S(0, 1) + C(1, 1) * S(0, 1) * S(1, 1));
tangent(2, 2) = ((2. * C(2, 2) * O(0, 1) * O(0, 1)) / (trace_D - 2.) +
C(2, 2) * S(0, 1) * S(0, 1) + C(2, 2) * S(0, 0) * S(1, 1));
}
if (spatial_dimension == 3) {
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
inline void MaterialOrthotropicDamage<spatial_dimension, Parent>::
computeDamageAndStressOnQuad(Matrix<Real> & sigma,
Matrix<Real> & one_minus_D,
Matrix<Real> & sqrt_one_minus_D,
Matrix<Real> & damage,
Matrix<Real> & first_term,
Matrix<Real> & third_term) {
/// Definition of Cauchy stress based on second order damage tensor:
/// "Anisotropic damage modelling of biaxial behaviour and rupture
/// of concrete strucutres", Ragueneau et al., 2008, Eq. 7
first_term.mul<false, false>(sqrt_one_minus_D, sigma);
first_term *= sqrt_one_minus_D;
Real second_term = 0;
for (UInt i = 0; i < this->spatial_dimension; ++i) {
for (UInt j = 0; j < this->spatial_dimension; ++j)
second_term += sigma(i, j) * one_minus_D(i, j);
}
second_term /= (this->spatial_dimension - damage.trace());
one_minus_D *= second_term;
third_term.eye(1. / this->spatial_dimension * sigma.trace() *
(1 - eta / (this->spatial_dimension) * damage.trace()));
sigma.copy(first_term);
sigma -= one_minus_D;
sigma += third_term;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
inline void MaterialOrthotropicDamage<spatial_dimension, Parent>::
rotateIntoComputationFrame(const Matrix<Real> & to_rotate,
Matrix<Real> & rotated,
const Matrix<Real> & damage_directions,
Matrix<Real> & rotation_tmp) {
rotation_tmp.mul<false, true>(to_rotate, damage_directions);
rotated.mul<false, false>(damage_directions, rotation_tmp);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
inline void
MaterialOrthotropicDamage<spatial_dimension, Parent>::rotateIntoNewFrame(
const Matrix<Real> & to_rotate, Matrix<Real> & rotated,
const Matrix<Real> & damage_directions, Matrix<Real> & rotation_tmp) {
rotation_tmp.mul<false, false>(to_rotate, damage_directions);
rotated.mul<true, false>(damage_directions, rotation_tmp);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
inline void
MaterialOrthotropicDamage<spatial_dimension, Parent>::computeOneMinusD(
Matrix<Real> & one_minus_D, const Matrix<Real> & damage) {
/// compute one minus
one_minus_D.eye();
one_minus_D -= damage;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
inline void
MaterialOrthotropicDamage<spatial_dimension, Parent>::computeSqrtOneMinusD(
const Matrix<Real> & one_minus_D, Matrix<Real> & sqrt_one_minus_D) {
/// To compute (1-D)^1/2 we need to check that we are in the
/// principal coordinate system of the damage
#ifndef AKANTU_NDEBUG
for (UInt i = 0; i < this->spatial_dimension; ++i) {
for (UInt j = 0; j < this->spatial_dimension; ++j) {
if (i != j)
AKANTU_DEBUG_ASSERT(Math::are_float_equal(one_minus_D(i, j), 0),
"The damage tensor has off-diagonal parts");
}
}
#endif // AKANTU_NDEBUG
/// compute (1-D)^1/2
sqrt_one_minus_D.copy(one_minus_D);
for (UInt i = 0; i < this->spatial_dimension; ++i)
sqrt_one_minus_D(i, i) = std::sqrt(sqrt_one_minus_D(i, i));
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/extra_packages/extra-materials/src/material_damage/material_vreepeerlings_inline_impl.cc b/extra_packages/extra-materials/src/material_damage/material_vreepeerlings_inline_impl.cc
index c261a91fa..09a601b19 100644
--- a/extra_packages/extra-materials/src/material_damage/material_vreepeerlings_inline_impl.cc
+++ b/extra_packages/extra-materials/src/material_damage/material_vreepeerlings_inline_impl.cc
@@ -1,185 +1,185 @@
/**
* @file material_vreepeerlings_inline_impl.cc
*
* @author Cyprien Wolff <cyprien.wolff@epfl.ch>
*
*
* @brief Specialization of the material class for the VreePeerlings material
*
* @section LICENSE
*
* Copyright (©) 2010-2012, 2014 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class MatParent>
inline void
MaterialVreePeerlings<spatial_dimension, MatParent>::computeStressOnQuad(
Matrix<Real> & grad_u, Matrix<Real> & sigma, Real & dam, Real & Equistrain,
Real & Equistrain_rate, Real & Kapaq, Real dt,
Matrix<Real> & strain_rate_vrplgs, Real & FullDam_ValStrain,
Real & FullDam_ValStrain_rate, Real & Nb_damage) {
Real I1 = 0.; /// trace initialization of the strain tensor
Real J2 = 0.; /// J2 [J2=1/6(3 strain:strain - I1*I1)] initialization
Real I1rate = 0.; /// trace initialization of the strain rate tensor
Real J2rate =
0.; /// J2 [J2=1/3(3 strain:strainrate - I1*I1rate)] initialization
if (spatial_dimension == 1) {
I1 = grad_u.trace();
J2 = .5 * grad_u(0, 0) * grad_u(0, 0) - I1 * I1 / 6.;
I1rate = strain_rate_vrplgs.trace();
J2rate = grad_u(0, 0) * strain_rate_vrplgs(0, 0) - I1 * I1rate / 6.;
} else {
// if(this->plane_stress) {
// Real tmp = this->nu/(this->nu - 1);
// tmp *= tmp;
// I1 = (grad_u(0,0) + grad_u(1,1))*(1 - 2*this->nu)/(1 - this->nu);
// J2 = .5*(grad_u(0,0)*grad_u(0,0) +
// grad_u(1,1)*grad_u(1,1) +
// tmp*(grad_u(0,0) + grad_u(1,1))*(grad_u(0,0) + grad_u(1,1)) +
// .5*(grad_u(0,1) + grad_u(1,0))*(grad_u(0,1) + grad_u(1,0))) -
// I1*I1/6.;
// I1rate = (strain_rate_vrplgs(0,0) + strain_rate_vrplgs(1,1))*(1 -
// 2*this->nu)/(1 - this->nu);
// J2rate = (grad_u(0,0)*strain_rate_vrplgs(0,0) +
// grad_u(1,1)*strain_rate_vrplgs(1,1) +
// tmp*(grad_u(0,0) + grad_u(1,1))*(strain_rate_vrplgs(0,0) +
// strain_rate_vrplgs(1,1)) +
// (grad_u(0,1)*strain_rate_vrplgs(1,0)) +
// (grad_u(0,1)*strain_rate_vrplgs(1,0))) -
// I1*I1rate/3.;
// }
// else {
I1 = grad_u.trace();
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = i; j < spatial_dimension; ++j)
J2 += 0.5 * ((i == j) * grad_u(i, i) * grad_u(i, i) +
- 0.5 * (1 - (i == j)) * ((grad_u(i, j) + grad_u(j, i)) *
- (grad_u(i, j) + grad_u(j, i))));
+ 0.5 * (1 - (i == j)) *
+ ((grad_u(i, j) + grad_u(j, i)) *
+ (grad_u(i, j) + grad_u(j, i))));
J2 -= I1 * I1 / 6.;
I1rate = strain_rate_vrplgs.trace();
bool is3D = spatial_dimension == 3;
J2rate = (grad_u(0, 0) * strain_rate_vrplgs(0, 0) +
grad_u(1, 1) * strain_rate_vrplgs(1, 1) +
is3D * grad_u(2, 2) * strain_rate_vrplgs(2, 2) +
(grad_u(0, 1) * strain_rate_vrplgs(1, 0)) +
(grad_u(0, 1) * strain_rate_vrplgs(1, 0)) +
is3D * (grad_u(1, 2) * strain_rate_vrplgs(2, 1)) +
is3D * (grad_u(1, 2) * strain_rate_vrplgs(2, 1)) +
is3D * (grad_u(2, 0) * strain_rate_vrplgs(0, 2)) +
is3D * (grad_u(2, 0) * strain_rate_vrplgs(0, 2))) -
I1 * I1rate / 3.;
// }
}
Real tmp_1 = (Kct - 1) / (1 - 2 * this->nu);
Real tmp_2 = (12 * Kct) / ((1 + this->nu) * (1 + this->nu));
Equistrain = tmp_1 * I1 / (2 * Kct) +
1. / (2 * Kct) * std::sqrt(tmp_1 * tmp_1 * I1 * I1 + tmp_2 * J2);
if (I1 * I1rate > 0 || J2rate > 0) {
Equistrain_rate = tmp_1 * std::abs(I1rate) / (2 * Kct) +
1. / (4 * Kct) *
(2 * tmp_1 * tmp_1 * I1 * I1rate + tmp_2 * J2rate) /
std::sqrt(tmp_1 * tmp_1 * I1 * I1 + tmp_2 * J2);
} else {
AKANTU_ERROR("This instruction here was commented but has to be checked");
// Equistrain_rate = Equistrain_rate;
}
if (!this->is_non_local) {
computeDamageAndStressOnQuad(sigma, dam, Equistrain, Equistrain_rate, Kapaq,
dt, FullDam_ValStrain, FullDam_ValStrain_rate,
Nb_damage);
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class MatParent>
inline void MaterialVreePeerlings<spatial_dimension, MatParent>::
computeDamageAndStressOnQuad(Matrix<Real> & sigma, Real & dam,
Real & Equistrain, Real & Equistrain_rate,
Real & Kapaq, Real dt,
Real & FullDam_ValStrain,
Real & FullDam_ValStrain_rate,
Real & Nb_damage) {
//---------------------------------------------------------------------------------------
// rate-dependence model
//
//---------------------------------------------------------------------------------------
Real Kapao = Crate *
(1. + (std::pow(std::abs(Equistrain_rate) * Arate, Brate))) *
(1. - Kapao_randomness) +
Kapao_randomness * Kapaq;
Real Kapac_99 = Kapac * .99;
Real Kapaodyn = 0;
if (Kapao > Kapaoi) {
if (Kapao < Kapac_99) {
Kapaodyn = Kapao;
} else {
Kapaodyn = Kapac_99;
}
} else {
Kapaodyn = Kapaoi;
}
Real Fd1 = Equistrain - Kapaoi;
if (Fd1 > 0) {
- Real dam1 =
- 1. -
- Kapaodyn / Equistrain * ((Kapac - Equistrain) / (Kapac - Kapaodyn));
+ Real dam1 = 1. - Kapaodyn / Equistrain *
+ ((Kapac - Equistrain) / (Kapac - Kapaodyn));
if (dam1 > dam) {
dam = std::min(dam1, 1.);
Nb_damage = Nb_damage + 1.;
if (dam >= 1.) {
FullDam_ValStrain = Equistrain;
FullDam_ValStrain_rate = Equistrain_rate;
}
}
}
//---------------------------------------------------------------------------------------
// delayed damage (see Marions thesis page 68)
//---------------------------------------------------------------------------------------
// Real viscosity = 10.;
// Real damRateInfini = 10000000.;
// Real gequi = 1. - Kapaq/Equistrain * ((Kapac-Equistrain)/(Kapac -
// Kapaq));
// if (gequi - dam > 0){
//
// Real damRate = damRateInfini * (1. - std::exp(-1*viscosity * (gequi -
// dam)));
// if (damrate > 0){
//
// if (dam < 1.){
// dam = dam + damRate*dt;
// } else {
// dam = 1.;
// }
// }
// }
//
//---------------------------------------------------------------------------------------
sigma *= 1 - dam;
}
/* -------------------------------------------------------------------------- */
diff --git a/extra_packages/extra-materials/src/material_plastic/material_viscoplastic.cc b/extra_packages/extra-materials/src/material_plastic/material_viscoplastic.cc
index 48b476fb9..8d1b0a2bc 100644
--- a/extra_packages/extra-materials/src/material_plastic/material_viscoplastic.cc
+++ b/extra_packages/extra-materials/src/material_plastic/material_viscoplastic.cc
@@ -1,108 +1,108 @@
/**
* @file material_viscoplastic.cc
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
*
*
* @brief Specialization of the material class for isotropic viscoplastic
* (small deformation)
*
* @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 "material_viscoplastic.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim>
MaterialViscoPlastic<dim>::MaterialViscoPlastic(SolidMechanicsModel & model,
const ID & id)
: MaterialPlastic<dim>(model, id) {
AKANTU_DEBUG_IN();
this->registerParam("rate", rate, 0., _pat_parsable | _pat_modifiable,
"Rate sensitivity component");
this->registerParam("edot0", edot0, 0., _pat_parsable | _pat_modifiable,
"Reference strain rate");
this->registerParam("ts", ts, 0., _pat_parsable | _pat_modifiable,
"Time Step");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialViscoPlastic<dim>::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Real * iso_hardening = this->iso_hardening(el_type, ghost_type).storage();
auto previous_grad_u_it =
this->gradu.previous(el_type, ghost_type).begin(dim, dim);
auto previous_sigma_it =
this->stress.previous(el_type, ghost_type).begin(dim, dim);
auto inelastic_strain_it =
this->inelastic_strain(el_type, ghost_type).begin(dim, dim);
auto previous_inelastic_strain_it =
this->inelastic_strain.previous(el_type, ghost_type).begin(dim, dim);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeStressOnQuad(grad_u, *previous_grad_u_it, sigma, *previous_sigma_it,
*inelastic_strain_it, *previous_inelastic_strain_it,
*iso_hardening);
++inelastic_strain_it;
++iso_hardening;
++previous_grad_u_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialViscoPlastic<dim>::computeTangentModuli(
__attribute__((unused)) const ElementType & el_type,
Array<Real> & tangent_matrix,
__attribute__((unused)) GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto previous_sigma_it =
this->stress.previous(el_type, ghost_type).begin(dim, dim);
auto previous_strain_it =
this->gradu.previous(el_type, ghost_type).begin(dim, dim);
Real * iso_hardening = this->iso_hardening(el_type, ghost_type).storage();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
Matrix<Real> & previous_grad_u = *previous_strain_it;
Matrix<Real> & previous_sigma_tensor = *previous_sigma_it;
- computeTangentModuliOnQuad(tangent, grad_u, previous_grad_u, sigma_tensor,
+ computeTangentModuliOnQuad(tangent, grad_u, previous_grad_u, sigma,
previous_sigma_tensor, *iso_hardening);
++previous_sigma_it;
++previous_strain_it;
++iso_hardening;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
INSTANTIATE_MATERIAL(visco_plastic, MaterialViscoPlastic);
} // namespace akantu
diff --git a/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_parallel.cc b/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_parallel.cc
index 1c4381a3b..7d29c93e8 100644
--- a/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_parallel.cc
+++ b/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_parallel.cc
@@ -1,360 +1,360 @@
/**
* @file test_material_damage_iterative_non_local_parallel.cc
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Thu Nov 26 12:20:15 2015
*
* @brief test the material damage iterative non local in parallel
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_damage_iterative.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
bool checkDisplacement(SolidMechanicsModel & model, ElementType type,
std::ofstream & error_output, UInt step,
bool barycenters);
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
debug::setDebugLevel(dblWarning);
ElementType element_type = _triangle_3;
initialize("two_materials.dat", argc, argv);
const UInt spatial_dimension = 2;
StaticCommunicator & comm =
akantu::StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// read the mesh and partion it
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
mesh.read("one_circular_inclusion.msh");
/// partition the mesh
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModel model(mesh);
model.initParallel(partition);
delete partition;
/// assign the material
MeshDataMaterialSelector<std::string> * mat_selector;
mat_selector =
new MeshDataMaterialSelector<std::string>("physical_names", model);
model.setMaterialSelector(*mat_selector);
mesh.createGroupsFromMeshData<std::string>(
"physical_names"); // creates groups from mesh names
/// initialization of the model
model.initFull(SolidMechanicsModelOptions(_static));
/// boundary conditions
/// Dirichlet BC
model.applyBC(BC::Dirichlet::FixedValue(0, _x), "left");
model.applyBC(BC::Dirichlet::FixedValue(0, _y), "bottom");
model.applyBC(BC::Dirichlet::FixedValue(2., _y), "top");
/// add fields that should be dumped
model.setBaseName("material_damage_iterative_test");
model.addDumpFieldVector("displacement");
;
model.addDumpField("stress");
model.addDumpField("blocked_dofs");
model.addDumpField("residual");
model.addDumpField("grad_u");
model.addDumpField("damage");
model.addDumpField("partitions");
model.addDumpField("material_index");
model.addDumpField("Sc");
model.addDumpField("force");
model.addDumpField("equivalent_stress");
model.dump();
std::stringstream error_stream;
error_stream << "error"
<< ".csv";
std::ofstream error_output;
error_output.open(error_stream.str().c_str());
error_output << "# Step, Average, Max, Min" << std::endl;
checkDisplacement(model, element_type, error_output, 0, true);
MaterialDamageIterative<spatial_dimension> & aggregate =
dynamic_cast<MaterialDamageIterative<spatial_dimension> &>(
model.getMaterial(0));
MaterialDamageIterative<spatial_dimension> & paste =
dynamic_cast<MaterialDamageIterative<spatial_dimension> &>(
model.getMaterial(1));
Real error;
bool converged = false;
UInt nb_damaged_elements = 0;
Real max_eq_stress_agg = 0;
Real max_eq_stress_paste = 0;
/// solve the system
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-12, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-12, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
if (!checkDisplacement(model, element_type, error_output, 1, false)) {
finalize();
return EXIT_FAILURE;
}
model.dump();
/// get the maximum equivalent stress in both materials
max_eq_stress_agg = aggregate.getNormMaxEquivalentStress();
max_eq_stress_paste = paste.getNormMaxEquivalentStress();
nb_damaged_elements = 0;
if (max_eq_stress_agg > max_eq_stress_paste)
nb_damaged_elements = aggregate.updateDamage();
else
nb_damaged_elements = paste.updateDamage();
if (prank == 0 && nb_damaged_elements)
std::cout << nb_damaged_elements << " elements damaged" << std::endl;
/// resolve the system
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-12, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-12, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
if (!checkDisplacement(model, element_type, error_output, 2, false)) {
finalize();
return EXIT_FAILURE;
}
model.dump();
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
bool checkDisplacement(SolidMechanicsModel & model, ElementType type,
std::ofstream & error_output, UInt step,
bool barycenters) {
Mesh & mesh = model.getMesh();
UInt spatial_dimension = mesh.getSpatialDimension();
const Array<UInt> & connectivity = mesh.getConnectivity(type);
const Array<Real> & displacement = model.getDisplacement();
UInt nb_element = mesh.getNbElement(type);
UInt nb_nodes_per_elem = Mesh::getNbNodesPerElement(type);
StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
if (psize == 1) {
std::stringstream displacement_file;
displacement_file << "displacement/displacement_" << std::setfill('0')
<< std::setw(6) << step;
std::ofstream displacement_output;
displacement_output.open(displacement_file.str().c_str());
for (UInt el = 0; el < nb_element; ++el) {
for (UInt n = 0; n < nb_nodes_per_elem; ++n) {
UInt node = connectivity(el, n);
for (UInt dim = 0; dim < spatial_dimension; ++dim) {
displacement_output << std::setprecision(15)
<< displacement(node, dim) << " ";
}
displacement_output << std::endl;
}
}
displacement_output.close();
if (barycenters) {
std::stringstream barycenter_file;
barycenter_file << "displacement/barycenters";
std::ofstream barycenter_output;
barycenter_output.open(barycenter_file.str().c_str());
Element element(type, 0);
Vector<Real> bary(spatial_dimension);
for (UInt el = 0; el < nb_element; ++el) {
element.element = el;
mesh.getBarycenter(element, bary);
for (UInt dim = 0; dim < spatial_dimension; ++dim) {
barycenter_output << std::setprecision(15) << bary(dim) << " ";
}
barycenter_output << std::endl;
}
barycenter_output.close();
}
} else {
if (barycenters)
return true;
/// read data
std::stringstream displacement_file;
displacement_file << "displacement/displacement_" << std::setfill('0')
<< std::setw(6) << step;
std::ifstream displacement_input;
displacement_input.open(displacement_file.str().c_str());
Array<Real> displacement_serial(0, spatial_dimension);
Vector<Real> disp_tmp(spatial_dimension);
while (displacement_input.good()) {
for (UInt i = 0; i < spatial_dimension; ++i)
displacement_input >> disp_tmp(i);
displacement_serial.push_back(disp_tmp);
}
std::stringstream barycenter_file;
barycenter_file << "displacement/barycenters";
std::ifstream barycenter_input;
barycenter_input.open(barycenter_file.str().c_str());
Array<Real> barycenter_serial(0, spatial_dimension);
while (barycenter_input.good()) {
for (UInt dim = 0; dim < spatial_dimension; ++dim)
barycenter_input >> disp_tmp(dim);
barycenter_serial.push_back(disp_tmp);
}
Element element(type, 0);
Vector<Real> bary(spatial_dimension);
Array<Real>::iterator<Vector<Real>> it;
Array<Real>::iterator<Vector<Real>> begin =
barycenter_serial.begin(spatial_dimension);
Array<Real>::iterator<Vector<Real>> end =
barycenter_serial.end(spatial_dimension);
Array<Real>::const_iterator<Vector<Real>> disp_it;
Array<Real>::iterator<Vector<Real>> disp_serial_it;
Vector<Real> difference(spatial_dimension);
Array<Real> error;
/// compute error
for (UInt el = 0; el < nb_element; ++el) {
element.element = el;
mesh.getBarycenter(element, bary);
/// find element
for (it = begin; it != end; ++it) {
UInt matched_dim = 0;
while (matched_dim < spatial_dimension &&
Math::are_float_equal(bary(matched_dim), (*it)(matched_dim)))
++matched_dim;
if (matched_dim == spatial_dimension)
break;
}
if (it == end) {
std::cout << "Element barycenter not found!" << std::endl;
return false;
}
UInt matched_el = it - begin;
disp_serial_it = displacement_serial.begin(spatial_dimension) +
matched_el * nb_nodes_per_elem;
for (UInt n = 0; n < nb_nodes_per_elem; ++n, ++disp_serial_it) {
UInt node = connectivity(el, n);
if (!mesh.isLocalOrMasterNode(node))
continue;
disp_it = displacement.begin(spatial_dimension) + node;
difference = *disp_it;
difference -= *disp_serial_it;
error.push_back(difference.norm());
}
}
/// compute average error
Real average_error = std::accumulate(error.begin(), error.end(), 0.);
comm.allReduce(&average_error, 1, _so_sum);
UInt error_size = error.getSize();
comm.allReduce(&error_size, 1, _so_sum);
average_error /= error_size;
/// compute maximum and minimum
Real max_error = *std::max_element(error.begin(), error.end());
comm.allReduce(&max_error, 1, _so_max);
Real min_error = *std::min_element(error.begin(), error.end());
comm.allReduce(&min_error, 1, _so_min);
/// output data
if (prank == 0) {
error_output << step << ", " << average_error << ", " << max_error << ", "
<< min_error << std::endl;
}
if (max_error > 1.e-9) {
std::cout << "Displacement error of " << max_error << " is too big!"
<< std::endl;
return false;
}
}
return true;
}
diff --git a/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_serial.cc b/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_serial.cc
index 7e0e0bdab..2a4215124 100644
--- a/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_serial.cc
+++ b/extra_packages/extra-materials/test/test_material_damage/test_material_damage_iterative_non_local_serial.cc
@@ -1,236 +1,236 @@
/**
* @file test_material_damage_iterative_non_local_serial.cc
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Thu Nov 26 12:20:15 2015
*
* @brief test the material damage iterative non local in serial
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_damage_iterative_non_local.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
Math::setTolerance(1e-13);
debug::setDebugLevel(dblWarning);
initialize("material_non_local.dat", argc, argv);
const UInt spatial_dimension = 2;
ElementType element_type = _triangle_3;
/// read the mesh and partion it
Mesh mesh(spatial_dimension);
mesh.read("plate.msh");
/// model creation
SolidMechanicsModel model(mesh);
/// initialization of the model
model.initFull(SolidMechanicsModelOptions(_static));
/// boundary conditions
/// Dirichlet BC
mesh.createGroupsFromMeshData<std::string>(
"physical_names"); // creates groups from mesh names
model.applyBC(BC::Dirichlet::FixedValue(0, _x), "left");
model.applyBC(BC::Dirichlet::FixedValue(0, _y), "bottom");
model.applyBC(BC::Dirichlet::FixedValue(2., _y), "top");
/// add fields that should be dumped
model.setBaseName("material_damage_iterative_test");
model.addDumpFieldVector("displacement");
;
model.addDumpField("stress");
model.addDumpField("blocked_dofs");
model.addDumpField("residual");
model.addDumpField("grad_u");
model.addDumpField("grad_u non local");
model.addDumpField("damage");
model.addDumpField("partitions");
model.addDumpField("material_index");
model.addDumpField("Sc");
model.addDumpField("force");
model.addDumpField("equivalent_stress");
model.dump();
MaterialDamageIterativeNonLocal<spatial_dimension> & material =
dynamic_cast<MaterialDamageIterativeNonLocal<spatial_dimension> &>(
model.getMaterial(0));
Real error;
bool converged = false;
Real max_eq_stress = 0;
/// solve the system
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-4, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-4, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
model.dump();
/// check the non-local grad_u: since grad_u is constant everywhere
/// also the grad_u non-local has to be constant
Array<Real> & grad_u_nl =
material.getInternal<Real>("grad_u non local")(element_type, _not_ghost);
Array<Real>::const_matrix_iterator grad_u_nl_it =
grad_u_nl.begin(spatial_dimension, spatial_dimension);
Array<Real>::const_matrix_iterator grad_u_nl_end =
grad_u_nl.end(spatial_dimension, spatial_dimension);
Real diff = 0.;
Matrix<Real> diff_matrix(spatial_dimension, spatial_dimension);
Matrix<Real> const_grad_u(spatial_dimension, spatial_dimension, 0.);
const_grad_u(1, 1) = 1.;
for (; grad_u_nl_it != grad_u_nl_end; ++grad_u_nl_it) {
diff_matrix = (*grad_u_nl_it) - const_grad_u;
diff += diff_matrix.norm<L_2>();
}
if (diff > 10.e-13) {
std::cout << "Error in the non-local grad_u computation" << std::endl;
return EXIT_FAILURE;
}
/// change the displacement in one node to modify grad_u
Array<Real> & displ = model.getDisplacement();
displ(0, 1) = 2.6;
/// compute stresses: this will average grad_u and compute the max. eq. stress
model.updateResidual();
model.dump();
/// due to the change in the displacement element 33 and 37 will
/// have a grad_u different then one
const Array<Real> & grad_u =
material.getInternal<Real>("grad_u")(element_type, _not_ghost);
Array<Real>::const_matrix_iterator grad_u_it =
grad_u.begin(spatial_dimension, spatial_dimension);
Array<Real>::const_matrix_iterator grad_u_end =
grad_u.end(spatial_dimension, spatial_dimension);
diff = 0.;
diff_matrix.clear();
UInt counter = 0;
for (; grad_u_it != grad_u_end; ++grad_u_it) {
diff_matrix = (*grad_u_it) - const_grad_u;
if (counter == 34 || counter == 38) {
if ((diff_matrix.norm<L_2>()) < 0.1) {
std::cout << "Error in the grad_u computation" << std::endl;
return EXIT_FAILURE;
}
} else
diff += diff_matrix.norm<L_2>();
++counter;
}
if (diff > 10.e-13) {
std::cout << "Error in the grad_u computation" << std::endl;
return EXIT_FAILURE;
}
/// check that the non-local grad_u
diff = 0.;
diff_matrix.clear();
Real nl_radius = 1.0; /// same values as in material file
grad_u_nl_it = grad_u_nl.begin(spatial_dimension, spatial_dimension);
ElementTypeMapReal quad_coords("quad_coords");
mesh.initElementTypeMapArray(quad_coords, spatial_dimension,
spatial_dimension, false, _ek_regular, true);
model.getFEEngine().computeIntegrationPointsCoordinates(quad_coords);
UInt nb_elements = mesh.getNbElement(element_type, _not_ghost);
UInt nb_quads = model.getFEEngine().getNbIntegrationPoints(element_type);
Array<Real> & coords = quad_coords(element_type, _not_ghost);
auto coord_it = coords.begin(spatial_dimension);
Vector<Real> q1(spatial_dimension);
Vector<Real> q2(spatial_dimension);
q1 = coord_it[34];
q2 = coord_it[38];
for (UInt e = 0; e < nb_elements; ++e) {
for (UInt q = 0; q < nb_quads; ++q, ++coord_it, ++grad_u_nl_it) {
diff_matrix = (*grad_u_nl_it) - const_grad_u;
if ((q1.distance(*coord_it) <= (nl_radius + Math::getTolerance())) ||
(q2.distance(*coord_it) <= (nl_radius + Math::getTolerance()))) {
if ((diff_matrix.norm<L_2>()) < 1.e-6) {
std::cout << (diff_matrix.norm<L_2>()) << std::endl;
std::cout << "Error in the non-local grad_u computation" << std::endl;
return EXIT_FAILURE;
}
} else
diff += diff_matrix.norm<L_2>();
}
}
if (diff > 10.e-13) {
std::cout << "Error in the non-local grad_u computation" << std::endl;
return EXIT_FAILURE;
}
/// make sure that the normalized equivalent stress is based on the
/// non-local grad_u for this test check the elements that have the
/// constant stress of 1 but different non-local gradu because they
/// are in the neighborhood of the modified elements
coord_it = coords.begin(spatial_dimension);
const Array<Real> & eq_stress =
material.getInternal<Real>("equivalent_stress")(element_type, _not_ghost);
Array<Real>::const_scalar_iterator eq_stress_it = eq_stress.begin();
counter = 0;
for (UInt e = 0; e < nb_elements; ++e) {
for (UInt q = 0; q < nb_quads;
++q, ++coord_it, ++grad_u_nl_it, ++eq_stress_it) {
if (counter == 34 || counter == 38)
continue;
if (((q1.distance(*coord_it) <= (nl_radius + Math::getTolerance())) ||
(q2.distance(*coord_it) <= (nl_radius + Math::getTolerance()))) &&
Math::are_float_equal(*eq_stress_it, 0.1)) {
std::cout << "the normalized equivalent stress is most likely based on "
"the local, not the non-local grad_u!!!!"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
++counter;
}
}
max_eq_stress = material.getNormMaxEquivalentStress();
if (!Math::are_float_equal(max_eq_stress, 0.1311267235941873)) {
std::cout << "the maximum equivalent stress is wrong" << std::endl;
finalize();
return EXIT_FAILURE;
}
model.dump();
finalize();
return EXIT_SUCCESS;
}
diff --git a/extra_packages/igfem/src/element_class_igfem.hh b/extra_packages/igfem/src/element_class_igfem.hh
index 4b197cf56..861c45300 100644
--- a/extra_packages/igfem/src/element_class_igfem.hh
+++ b/extra_packages/igfem/src/element_class_igfem.hh
@@ -1,339 +1,340 @@
/**
* @file element_class_igfem.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
*
* @brief Specialization for interface-enriched finite elements
*
* @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 "aka_common.hh"
__BEGIN_AKANTU__
/* -------------------------------------------------------------------------- */
#define AKANTU_DEFINE_IGFEM_INTERPOLATION_TYPE_PROPERTY( \
itp_type, itp_kind, nb_nodes, ndim, parent_itp_type, sub_itp_type_1, \
sub_itp_type_2) \
template <> struct InterpolationPorperty<itp_type> { \
static const InterpolationKind kind = itp_kind; \
static const UInt nb_nodes_per_element = nb_nodes; \
static const UInt natural_space_dimension = ndim; \
static const InterpolationType parent_interpolation_type = \
parent_itp_type; \
static const InterpolationType sub_iterpolation_type_1 = sub_itp_type_1; \
static const InterpolationType sub_interpolation_type_2 = sub_itp_type_2; \
}
/* -------------------------------------------------------------------------- */
template <InterpolationType interpolation_type>
class InterpolationElement<interpolation_type, _itk_igfem> {
public:
typedef InterpolationPorperty<interpolation_type> interpolation_property;
/* --------------------------------------------------------------------------
*/
/* Member functions */
/* --------------------------------------------------------------------------
*/
public:
static void assembleShapes(const Vector<Real> & parent_interpolation,
const Vector<Real> & sub_interpolation,
Vector<Real> & interpolation,
UInt sub_element = 0) {
/// N1, N2, N3 of parent triangle
UInt nb_nodes_parent = InterpolationElement<
interpolation_property::parent_interpolation_type>::getShapeSize();
for (UInt i = 0; i < nb_nodes_parent; ++i) {
interpolation(i) = parent_interpolation(i);
}
/// add the enrichment
UInt * enriched_node = enrichments[sub_element];
for (UInt e = 0; e < nb_enrichments; ++e) {
interpolation(nb_nodes_parent + e) = sub_interpolation(enriched_node[e]);
}
}
static void
assembleShapeDerivatives(const Matrix<Real> & parent_interpolation,
const Matrix<Real> & sub_interpolation,
Matrix<Real> & interpolation, UInt sub_element = 0) {
/// N1, N2, N3 of parent triangle
UInt nb_nodes_parent = InterpolationElement<
interpolation_property::parent_interpolation_type>::getShapeSize();
for (UInt i = 0; i < nb_nodes_parent; ++i) {
Vector<Real> ip(interpolation(i));
ip = parent_interpolation(i);
}
/// add the enrichment
UInt * enriched_node = enrichments[sub_element];
for (UInt e = 0; e < nb_enrichments; ++e) {
Vector<Real> ip(interpolation(nb_nodes_parent + e));
ip = sub_interpolation(enriched_node[e]);
}
}
static void interpolate(const Matrix<Real> & nodal_values,
const Vector<Real> & shapes,
Vector<Real> & interpolated) {
Matrix<Real> interpm(interpolated.storage(), nodal_values.rows(), 1);
Matrix<Real> shapesm(
shapes.storage(),
InterpolationPorperty<interpolation_type>::nb_nodes_per_element, 1);
interpm.mul<false, false>(nodal_values, shapesm);
}
public:
static AKANTU_GET_MACRO_NOT_CONST(
ShapeSize, interpolation_property::nb_nodes_per_element, UInt);
static AKANTU_GET_MACRO_NOT_CONST(
- ShapeDerivativesSize, (interpolation_property::nb_nodes_per_element *
- interpolation_property::natural_space_dimension),
+ ShapeDerivativesSize,
+ (interpolation_property::nb_nodes_per_element *
+ interpolation_property::natural_space_dimension),
UInt);
static AKANTU_GET_MACRO_NOT_CONST(
NaturalSpaceDimension, interpolation_property::natural_space_dimension,
UInt);
static AKANTU_GET_MACRO_NOT_CONST(
NbNodesPerInterpolationElement,
InterpolationPorperty<interpolation_type>::nb_nodes_per_element, UInt);
static AKANTU_GET_MACRO_NOT_CONST(NbSubElements, nb_sub_elements, UInt);
static UInt * getSubElementConnectivity(UInt t = 0) {
return sub_element_connectivity[t];
};
static UInt getNbEnrichments() { return nb_enrichments; };
static UInt * getSubElementEnrichments(UInt t = 0) { return enrichments[t]; };
protected:
/// storage of the subelement local connectivity
static UInt sub_element_connectivity_vect[];
/// local connectivity of subelements
static UInt * sub_element_connectivity[];
/// nb of subelements
static UInt nb_sub_elements;
/// storage of enrichments
static UInt enrichment_vect[];
static UInt * enrichments[];
static UInt nb_enrichments;
};
#if defined(AKANTU_IGFEM)
#include "interpolation_element_igfem_tmpl.hh"
#endif
/* -------------------------------------------------------------------------- */
#define AKANTU_DEFINE_IGFEM_ELEMENT_CLASS_PROPERTY( \
elem_type, geom_type, interp_type, parent_el_type, sub_el_type_1, \
sub_el_type_2, elem_kind, sp, min_int_order) \
template <> struct ElementClassProperty<elem_type> { \
static const GeometricalType geometrical_type = geom_type; \
static const InterpolationType interpolation_type = interp_type; \
static const ElementType parent_element_type = parent_el_type; \
static const ElementType sub_element_type_1 = sub_el_type_1; \
static const ElementType sub_element_type_2 = sub_el_type_2; \
static const ElementKind element_kind = elem_kind; \
static const UInt spatial_dimension = sp; \
static const UInt minimal_integration_order = min_int_order; \
}
/* -------------------------------------------------------------------------- */
// // template <ElementType type, UInt sub_element>
// struct return_sub_element_type {
// enum { value = _not_defined };
// };
// /// specializations
// template<ElementType type>
// struct return_sub_element_type<type, 0> {
// enum { value = ElementClassProperty<type>::sub_element_type_1 };
// };
// template<ElementType type>
// struct return_sub_element_type<type, 1> {
// enum { value = ElementClassProperty<type>::sub_element_type_2 };
// };
/* -------------------------------------------------------------------------- */
template <ElementType element_type>
class ElementClass<element_type, _ek_igfem>
: public GeometricalElement<
ElementClassProperty<element_type>::geometrical_type>,
public InterpolationElement<
ElementClassProperty<element_type>::interpolation_type> {
protected:
typedef GeometricalElement<
ElementClassProperty<element_type>::geometrical_type>
geometrical_element;
typedef InterpolationElement<
ElementClassProperty<element_type>::interpolation_type>
interpolation_element;
typedef ElementClass<ElementClassProperty<element_type>::parent_element_type>
parent_element;
typedef ElementClassProperty<element_type> element_property;
typedef typename interpolation_element::interpolation_property
interpolation_property;
/* --------------------------------------------------------------------------
*/
/* Member functions */
/* --------------------------------------------------------------------------
*/
public:
// static const ElementType getSubElementType(const UInt sub_element) {
// switch(sub_element) {
// case 0: return return_sub_element_type<element_type, 0>(); break;
// case 1: return return_sub_element_type<element_type, 1>(); break;
// default: return _not_defined;
// }
// }
static void getSubElementCoords(const Matrix<Real> & element_coords,
Matrix<Real> & sub_coords,
const UInt sub_element) {
/// get the sub_element_type
/// constexrp ElementType sub_el_type = getSubElementType(sub_element);
UInt nb_nodes_sub_el = 0;
switch (sub_element) {
case 0:
nb_nodes_sub_el =
ElementClass<ElementClassProperty<element_type>::sub_element_type_1>::
getNbNodesPerInterpolationElement();
break;
case 1:
nb_nodes_sub_el =
ElementClass<ElementClassProperty<element_type>::sub_element_type_2>::
getNbNodesPerInterpolationElement();
break;
}
for (UInt i = 0; i < nb_nodes_sub_el; ++i) {
UInt lc = InterpolationElement<
ElementClassProperty<element_type>::interpolation_type>::
sub_element_connectivity[sub_element][i];
Vector<Real> sub_c(sub_coords(i));
sub_c = element_coords(lc);
}
}
static void getParentCoords(const Matrix<Real> & element_coords,
Matrix<Real> & parent_coords) {
const ElementType parent_type =
ElementClassProperty<element_type>::parent_element_type;
UInt nb_nodes_parent_el =
ElementClass<parent_type>::getNbNodesPerInterpolationElement();
for (UInt i = 0; i < nb_nodes_parent_el; ++i) {
Vector<Real> parent_c(parent_coords(i));
parent_c = element_coords(i);
}
}
/// map the points from the reference domain of the subelement to the physical
/// domain
static void mapToPhysicalDomain(const Matrix<Real> & element_coords,
Matrix<Real> & sub_coords,
Matrix<Real> & sub_shapes,
Matrix<Real> & physical_points,
UInt sub_element = 0) {
/// get the sub_element_type
getSubElementCoords(element_coords, sub_coords, sub_element);
/// map the points of the subelements in the physical domain
switch (sub_element) {
case 0:
ElementClass<ElementClassProperty<element_type>::sub_element_type_1>::
interpolate(sub_coords, sub_shapes, physical_points);
break;
case 1:
ElementClass<ElementClassProperty<element_type>::sub_element_type_2>::
interpolate(sub_coords, sub_shapes, physical_points);
break;
}
}
/// map the points from the physical domain to the parent reference domain
static void mapToParentRefDomain(const Matrix<Real> & element_coords,
Matrix<Real> & parent_coords,
Matrix<Real> & physical_points,
Matrix<Real> & natural_coords) {
const ElementType parent_type =
ElementClassProperty<element_type>::parent_element_type;
getParentCoords(element_coords, parent_coords);
/// map the points from the physical domain into the parent reference domain
ElementClass<parent_type>::inverseMap(physical_points, parent_coords,
natural_coords);
}
/// map the points from the subelement reference domain to the parent
/// reference domain
static void mapFromSubRefToParentRef(const Matrix<Real> & element_coords,
Matrix<Real> & parent_coords,
Matrix<Real> & sub_coords,
Matrix<Real> & sub_shapes,
Matrix<Real> & physical_points,
Matrix<Real> & natural_points,
UInt nb_points, UInt sub_element) {
mapToPhysicalDomain(element_coords, sub_coords, sub_shapes, physical_points,
sub_element);
mapToParentRefDomain(element_coords, parent_coords, physical_points,
natural_points);
}
static void mapFromSubRefToParentRef(const Matrix<Real> & element_coords,
Matrix<Real> & sub_coords,
Matrix<Real> & parent_coords,
Matrix<Real> & sub_shapes,
Matrix<Real> & physical_points,
Matrix<Real> & parent_el_natural_coords,
UInt sub_element) {
mapToPhysicalDomain(element_coords, sub_coords, sub_shapes, physical_points,
sub_element);
mapToParentRefDomain(element_coords, parent_coords, physical_points,
parent_el_natural_coords);
}
/// compute the normal of a surface defined by the function f
static inline void
computeNormalsOnNaturalCoordinates(const Matrix<Real> & coord,
Matrix<Real> & f, Matrix<Real> & normals) {
AKANTU_DEBUG_TO_IMPLEMENT();
}
/// determine orientation of the element with respect to the interface
static inline UInt getOrientation(const Vector<bool> & is_inside);
/* --------------------------------------------------------------------------
*/
/* Accessors */
/* --------------------------------------------------------------------------
*/
public:
static AKANTU_GET_MACRO_NOT_CONST(Kind, _ek_igfem, ElementKind);
static ElementType getP1ElementType() { AKANTU_DEBUG_TO_IMPLEMENT(); };
static AKANTU_GET_MACRO_NOT_CONST(
SpatialDimension, ElementClassProperty<element_type>::spatial_dimension,
UInt);
static ElementType & getFacetType(UInt t = 0) { AKANTU_DEBUG_TO_IMPLEMENT(); }
static ElementType * getFacetTypeInternal() { AKANTU_DEBUG_TO_IMPLEMENT(); }
private:
/// Type of the facet elements
/// static ElementType facet_type[];
/// type of element P1 associated
/// static ElementType p1_type;
};
#include "element_classes_igfem/element_class_igfem_segment_3_inline_impl.cc"
#include "element_classes_igfem/element_class_igfem_triangle_4_inline_impl.cc"
#include "element_classes_igfem/element_class_igfem_triangle_5_inline_impl.cc"
__END_AKANTU__
diff --git a/extra_packages/igfem/src/igfem_enrichment.cc b/extra_packages/igfem/src/igfem_enrichment.cc
index 04234b782..508020ca2 100644
--- a/extra_packages/igfem/src/igfem_enrichment.cc
+++ b/extra_packages/igfem/src/igfem_enrichment.cc
@@ -1,101 +1,101 @@
/**
* @file igfem_enrichment.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief Implementation of IGFEM enrichment
*
* @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 "igfem_enrichment.hh"
__BEGIN_AKANTU__
/* -------------------------------------------------------------------------- */
IGFEMEnrichment::IGFEMEnrichment(Mesh & mesh) : intersector_sphere(mesh) {}
/* -------------------------------------------------------------------------- */
void IGFEMEnrichment::initialize() { intersector_sphere.init(); }
/* -------------------------------------------------------------------------- */
void IGFEMEnrichment::update(ID domain) {
if (domain == "")
domain = default_geometry;
Geometry & geometry = getGeometry(domain);
intersector_sphere.buildIGFEMMeshFromSpheres(geometry);
}
/* -------------------------------------------------------------------------- */
void IGFEMEnrichment::unRegisterGeometryObject(const ID & domain) {
GeometryMap::iterator it = geometries.find(domain);
- AKANTU_DEBUG_ASSERT(it != geometries.end(),
- "Geometry object with domain " << domain
- << " was not found");
+ AKANTU_DEBUG_ASSERT(it != geometries.end(), "Geometry object with domain "
+ << domain
+ << " was not found");
geometries.erase(it);
if (!geometries.empty())
default_geometry = (*geometries.begin()).first;
}
/* -------------------------------------------------------------------------- */
void IGFEMEnrichment::registerGeometryObject(Geometry & geometry,
const ID & domain) {
if (geometries.size() == 0)
default_geometry = domain;
#ifndef AKANTU_NDEBUG
GeometryMap::iterator it = geometries.find(domain);
- AKANTU_DEBUG_ASSERT(it == geometries.end(),
- "Geometry object with domain " << domain
- << " was already created");
+ AKANTU_DEBUG_ASSERT(it == geometries.end(), "Geometry object with domain "
+ << domain
+ << " was already created");
#endif
std::stringstream sstr;
sstr << "geometry:" << domain;
geometries[domain] = &geometry;
}
/* -------------------------------------------------------------------------- */
IGFEMEnrichment::Geometry & IGFEMEnrichment::getGeometry(ID & domain) const {
AKANTU_DEBUG_IN();
if (domain == "")
domain = default_geometry;
GeometryMap::const_iterator it = geometries.find(domain);
AKANTU_DEBUG_ASSERT(it != geometries.end(),
"The geometry " << domain << " is not registered");
AKANTU_DEBUG_OUT();
return *(it->second);
}
/* -------------------------------------------------------------------------- */
void IGFEMEnrichment::moveInterface(Real new_position, ID domain) {
if (domain == "")
domain = default_geometry;
Geometry & geometry = getGeometry(domain);
/// for this type of IGFEM enrichment the geometry consists of a list of
/// spheres
/// -> need to loop over spheres and change their radius,
/// which specifies the position of interfaces
Geometry::const_iterator query_it = geometry.begin();
Geometry sphere_list;
for (; query_it != geometry.end(); ++query_it) {
SK::Sphere_3 sphere(query_it->center(), new_position * new_position);
sphere_list.push_back(sphere);
}
geometry.clear();
geometry = sphere_list;
this->update(domain);
}
__END_AKANTU__
diff --git a/extra_packages/igfem/src/material_igfem/material_igfem_elastic.cc b/extra_packages/igfem/src/material_igfem/material_igfem_elastic.cc
index e6f6f2c3c..da8d3ce29 100644
--- a/extra_packages/igfem/src/material_igfem/material_igfem_elastic.cc
+++ b/extra_packages/igfem/src/material_igfem/material_igfem_elastic.cc
@@ -1,243 +1,242 @@
/**
* @file material_igfem_elastic.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief Specializaton of material class for the igfem elastic material
*
* @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 "material_igfem_elastic.hh"
#include "material_elastic.hh"
__BEGIN_AKANTU__
/* -------------------------------------------------------------------------- */
template <UInt dim>
MaterialIGFEMElastic<dim>::MaterialIGFEMElastic(SolidMechanicsModel & model,
const ID & id)
: Material(model, id), Parent(model, id), lambda("lambda", *this),
mu("mu", *this), kpa("kappa", *this) {
AKANTU_DEBUG_IN();
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialIGFEMElastic<dim>::initialize() {
this->lambda.initialize(1);
this->mu.initialize(1);
this->kpa.initialize(1);
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialIGFEMElastic<dim>::initMaterial() {
AKANTU_DEBUG_IN();
Parent::initMaterial();
/// insert the sub_material names into the map
this->sub_material_names[0] = this->name_sub_mat_1;
this->sub_material_names[1] = this->name_sub_mat_2;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialIGFEMElastic<spatial_dimension>::updateElasticInternals(
const Array<Element> & element_list) {
/// compute the Lamé constants for both sub-materials
Vector<Real> lambda_per_sub_mat(this->nb_sub_materials);
Vector<Real> mu_per_sub_mat(this->nb_sub_materials);
Vector<Real> kpa_per_sub_mat(this->nb_sub_materials);
for (UInt i = 0; i < this->nb_sub_materials; ++i) {
ID mat_name = this->sub_material_names[i];
const MaterialElastic<spatial_dimension> & mat =
dynamic_cast<MaterialElastic<spatial_dimension> &>(
this->model->getMaterial(mat_name));
lambda_per_sub_mat(i) = mat.getLambda();
mu_per_sub_mat(i) = mat.getMu();
kpa_per_sub_mat(i) = mat.getKappa();
}
for (ghost_type_t::iterator g = ghost_type_t::begin();
g != ghost_type_t::end(); ++g) {
GhostType ghost_type = *g;
/// loop over all types in the material
typedef ElementTypeMapArray<UInt>::type_iterator iterator;
iterator it = this->element_filter.firstType(spatial_dimension, ghost_type,
_ek_igfem);
iterator last_type =
this->element_filter.lastType(spatial_dimension, ghost_type, _ek_igfem);
/// loop over all types in the filter
for (; it != last_type; ++it) {
ElementType el_type = *it;
if (el_type == _igfem_triangle_4)
this->template setSubMaterial<_igfem_triangle_4>(element_list,
ghost_type);
else if (el_type == _igfem_triangle_5)
this->template setSubMaterial<_igfem_triangle_5>(element_list,
ghost_type);
else
- AKANTU_ERROR(
- "There is currently no other IGFEM type implemented");
+ AKANTU_ERROR("There is currently no other IGFEM type implemented");
UInt nb_element = this->element_filter(el_type, ghost_type).getSize();
UInt nb_quads = this->fem->getNbIntegrationPoints(el_type);
/// get pointer to internals for given type
Real * lambda_ptr = this->lambda(el_type, ghost_type).storage();
Real * mu_ptr = this->mu(el_type, ghost_type).storage();
Real * kpa_ptr = this->kpa(el_type, ghost_type).storage();
UInt * sub_mat_ptr = this->sub_material(el_type, ghost_type).storage();
for (UInt q = 0; q < nb_element * nb_quads;
++q, ++lambda_ptr, ++mu_ptr, ++kpa_ptr, ++sub_mat_ptr) {
UInt index = *sub_mat_ptr;
*lambda_ptr = lambda_per_sub_mat(index);
*mu_ptr = mu_per_sub_mat(index);
*kpa_ptr = kpa_per_sub_mat(index);
}
}
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialIGFEMElastic<spatial_dimension>::computeStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Parent::computeStress(el_type, ghost_type);
if (!this->finite_deformation) {
/// get pointer to internals
Real * lambda_ptr = this->lambda(el_type, ghost_type).storage();
Real * mu_ptr = this->mu(el_type, ghost_type).storage();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
this->computeStressOnQuad(grad_u, sigma, *lambda_ptr, *mu_ptr);
++lambda_ptr;
++mu_ptr;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
} else {
AKANTU_DEBUG_TO_IMPLEMENT();
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialIGFEMElastic<spatial_dimension>::computeTangentModuli(
__attribute__((unused)) const ElementType & el_type,
Array<Real> & tangent_matrix,
__attribute__((unused)) GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// get pointer to internals
Real * lambda_ptr = this->lambda(el_type, ghost_type).storage();
Real * mu_ptr = this->mu(el_type, ghost_type).storage();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
this->computeTangentModuliOnQuad(tangent, *lambda_ptr, *mu_ptr);
++lambda_ptr;
++mu_ptr;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialIGFEMElastic<spatial_dimension>::computePotentialEnergy(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
// MaterialThermal<spatial_dimension>::computePotentialEnergy(el_type,
// ghost_type);
// if(ghost_type != _not_ghost) return;
// Array<Real>::scalar_iterator epot = this->potential_energy(el_type,
// ghost_type).begin();
// if (!this->finite_deformation) {
// MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
// this->computePotentialEnergyOnQuad(grad_u, sigma, *epot);
// ++epot;
// MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
// } else {
// Matrix<Real> E(spatial_dimension, spatial_dimension);
// MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
// this->template gradUToGreenStrain<spatial_dimension>(grad_u, E);
// this->computePotentialEnergyOnQuad(E, sigma, *epot);
// ++epot;
// MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
// }
AKANTU_DEBUG_TO_IMPLEMENT();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialIGFEMElastic<spatial_dimension>::computePotentialEnergyByElement(
ElementType type, UInt index, Vector<Real> & epot_on_quad_points) {
// Array<Real>::matrix_iterator gradu_it =
// this->gradu(type).begin(spatial_dimension,
// spatial_dimension);
// Array<Real>::matrix_iterator gradu_end =
// this->gradu(type).begin(spatial_dimension,
// spatial_dimension);
// Array<Real>::matrix_iterator stress_it =
// this->stress(type).begin(spatial_dimension,
// spatial_dimension);
// if (this->finite_deformation)
// stress_it = this->piola_kirchhoff_2(type).begin(spatial_dimension,
// spatial_dimension);
// UInt nb_quadrature_points =
// this->model->getFEEngine().getNbQuadraturePoints(type);
// gradu_it += index*nb_quadrature_points;
// gradu_end += (index+1)*nb_quadrature_points;
// stress_it += index*nb_quadrature_points;
// Real * epot_quad = epot_on_quad_points.storage();
// Matrix<Real> grad_u(spatial_dimension, spatial_dimension);
// for(;gradu_it != gradu_end; ++gradu_it, ++stress_it, ++epot_quad) {
// if (this->finite_deformation)
// this->template gradUToGreenStrain<spatial_dimension>(*gradu_it,
// grad_u);
// else
// grad_u.copy(*gradu_it);
// this->computePotentialEnergyOnQuad(grad_u, *stress_it, *epot_quad);
// }
AKANTU_DEBUG_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialIGFEMElastic<spatial_dimension>::onElementsAdded(
const Array<Element> & element_list, const NewElementsEvent & event) {
Parent::onElementsAdded(element_list, event);
updateElasticInternals(element_list);
};
INSTANTIATE_MATERIAL(MaterialIGFEMElastic);
__END_AKANTU__
diff --git a/extra_packages/igfem/src/mesh_igfem_spherical_growing_gel_tmpl.hh b/extra_packages/igfem/src/mesh_igfem_spherical_growing_gel_tmpl.hh
index 4f68e9ad5..a0c1334c0 100644
--- a/extra_packages/igfem/src/mesh_igfem_spherical_growing_gel_tmpl.hh
+++ b/extra_packages/igfem/src/mesh_igfem_spherical_growing_gel_tmpl.hh
@@ -1,532 +1,532 @@
/**
* @file mesh_igfem_spherical_growing_gel.cc
* @author Marco Vocialta <marco.vocialta@epfl.ch>
* @date Mon Sep 21 12:42:11 2015
*
* @brief Implementation of the functions of MeshIgfemSphericalGrowingGel
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_utils.hh"
#include <algorithm>
__BEGIN_AKANTU__
/* -------------------------------------------------------------------------- */
template <UInt dim>
MeshIgfemSphericalGrowingGel<dim>::MeshIgfemSphericalGrowingGel(Mesh & mesh)
: mesh(mesh), nb_nodes_fem(mesh.getNbNodes()), nb_enriched_nodes(0),
synchronizer(NULL) {}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MeshIgfemSphericalGrowingGel<dim>::init() {
nb_nodes_fem = mesh.getNbNodes();
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
GhostType ghost_type = *gt;
Mesh::type_iterator tit = mesh.firstType(dim, ghost_type);
Mesh::type_iterator tend = mesh.lastType(dim, ghost_type);
for (; tit != tend;
++tit) { // loop to add corresponding IGFEM element types
if (*tit == _triangle_3) {
mesh.addConnectivityType(_igfem_triangle_4, ghost_type);
mesh.addConnectivityType(_igfem_triangle_5, ghost_type);
} else
AKANTU_ERROR("Not ready for mesh type " << *tit);
}
tit = mesh.firstType(dim, ghost_type, _ek_not_defined);
tend = mesh.lastType(dim, ghost_type, _ek_not_defined);
for (; tit != tend; ++tit) {
AKANTU_BOOST_LIST_SWITCH(INSTANTIATOR, ELEMENT_LIST, *tit);
}
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MeshIgfemSphericalGrowingGel<dim>::computeMeshQueryListIntersectionPoint(
const std::list<SK::Sphere_3> & query_list) {
/// store number of currently enriched nodes
this->nb_enriched_nodes = mesh.getNbNodes() - nb_nodes_fem;
UInt nb_old_nodes = mesh.getNbNodes();
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
GhostType ghost_type = *gt;
Mesh::type_iterator iit = mesh.firstType(dim, ghost_type, _ek_not_defined);
Mesh::type_iterator iend = mesh.lastType(dim, ghost_type, _ek_not_defined);
for (; iit != iend; ++iit) {
MeshAbstractIntersector<SK::Sphere_3> & intersector =
*intersectors(*iit, ghost_type);
intersector.constructData(ghost_type);
intersector.computeMeshQueryListIntersectionPoint(query_list,
nb_old_nodes);
const Array<Real> intersection_points_current_type =
*(intersector.getIntersectionPoints());
const Array<UInt> & new_node_per_elem = intersector.getNewNodePerElem();
/// Send the new node event
UInt new_points = intersection_points_current_type.getSize();
StaticCommunicator::getStaticCommunicator().allReduce(&new_points, 1,
_so_sum);
if (new_points > 0) {
Array<Real> & nodes = this->mesh.getNodes();
UInt nb_node = nodes.getSize();
Array<Real>::const_vector_iterator intersec_p_it =
intersection_points_current_type.begin(dim);
NewIGFEMNodesEvent new_nodes_event;
for (UInt in = 0; in < intersection_points_current_type.getSize();
++in, ++intersec_p_it) {
nodes.push_back(*intersec_p_it);
new_nodes_event.getList().push_back(nb_node + in);
}
new_nodes_event.setNewNodePerElem(new_node_per_elem);
new_nodes_event.setType(*iit);
new_nodes_event.setGhostType(ghost_type);
this->mesh.sendEvent(new_nodes_event);
}
}
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MeshIgfemSphericalGrowingGel<dim>::removeAdditionalNodes() {
AKANTU_DEBUG_IN();
UInt total_nodes = this->mesh.getNbNodes();
UInt nb_new_enriched_nodes =
total_nodes - this->nb_enriched_nodes - this->nb_nodes_fem;
UInt old_total_nodes = this->nb_nodes_fem + this->nb_enriched_nodes;
UInt total_new_nodes = nb_new_enriched_nodes;
StaticCommunicator::getStaticCommunicator().allReduce(&total_new_nodes, 1,
_so_sum);
if (total_new_nodes == 0)
return;
RemovedNodesEvent remove_nodes(this->mesh);
Array<UInt> & nodes_removed = remove_nodes.getList();
Array<UInt> & new_numbering = remove_nodes.getNewNumbering();
for (UInt nnod = 0; nnod < this->nb_nodes_fem; ++nnod) {
new_numbering(nnod) = nnod;
}
for (UInt nnod = nb_nodes_fem; nnod < old_total_nodes; ++nnod) {
new_numbering(nnod) = UInt(-1);
nodes_removed.push_back(nnod);
}
for (UInt nnod = 0; nnod < nb_new_enriched_nodes; ++nnod) {
new_numbering(nnod + old_total_nodes) = this->nb_nodes_fem + nnod;
}
if (nb_new_enriched_nodes > 0) {
for (UInt gt = _not_ghost; gt <= _ghost; ++gt) {
GhostType ghost_type = (GhostType)gt;
Mesh::type_iterator it =
mesh.firstType(_all_dimensions, ghost_type, _ek_not_defined);
Mesh::type_iterator end =
mesh.lastType(_all_dimensions, ghost_type, _ek_not_defined);
for (; it != end; ++it) {
ElementType type = *it;
Array<UInt> & connectivity_array =
mesh.getConnectivity(type, ghost_type);
UInt nb_nodes_per_element = connectivity_array.getNbComponent();
Array<UInt>::vector_iterator conn_it =
connectivity_array.begin(nb_nodes_per_element);
Array<UInt>::vector_iterator conn_end =
connectivity_array.end(nb_nodes_per_element);
for (; conn_it != conn_end; ++conn_it) {
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
(*conn_it)(n) = new_numbering((*conn_it)(n));
}
}
}
}
}
this->mesh.sendEvent(remove_nodes);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MeshIgfemSphericalGrowingGel<dim>::buildIGFEMMesh() {
AKANTU_DEBUG_IN();
NewIGFEMElementsEvent new_elements_event;
UInt total_new_elements = 0;
Array<Element> & new_elements_list = new_elements_event.getList();
Array<Element> & old_elements_list = new_elements_event.getOldElementsList();
RemovedElementsEvent removed_elements_event(this->mesh);
ChangedElementsEvent changed_elements_event(this->mesh);
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
GhostType ghost_type = *gt;
mesh.initElementTypeMapArray(removed_elements_event.getNewNumbering(), 1,
dim, ghost_type, false, _ek_not_defined);
mesh.initElementTypeMapArray(changed_elements_event.getNewNumbering(), 1,
dim, ghost_type, false, _ek_not_defined);
/// loop over all types in the mesh for a given ghost type
Mesh::type_iterator iit = mesh.firstType(dim, ghost_type, _ek_not_defined);
Mesh::type_iterator iend = mesh.lastType(dim, ghost_type, _ek_not_defined);
for (; iit != iend; ++iit) {
ElementType type = *iit;
MeshAbstractIntersector<SK::Sphere_3> & intersector =
*intersectors(type, ghost_type);
const Array<UInt> & new_node_per_elem = intersector.getNewNodePerElem();
UInt n_new_el = 0;
Array<UInt> & connectivity = this->mesh.getConnectivity(type, ghost_type);
/// get the connectivities of all types that that may transform
Array<UInt> & connec_igfem_tri_4 =
this->mesh.getConnectivity(_igfem_triangle_4, ghost_type);
Array<UInt> & connec_igfem_tri_5 =
this->mesh.getConnectivity(_igfem_triangle_5, ghost_type);
Array<UInt> & connec_tri_3 =
this->mesh.getConnectivity(_triangle_3, ghost_type);
/// create elements to store the newly generated elements
Element el_tri_3(_triangle_3, 0, ghost_type, _ek_regular);
Element el_igfem_tri_4(_igfem_triangle_4, 0, ghost_type, _ek_igfem);
Element el_igfem_tri5(_igfem_triangle_5, 0, ghost_type, _ek_igfem);
Array<UInt> & new_numbering =
removed_elements_event.getNewNumbering(type, ghost_type);
new_numbering.resize(connectivity.getSize());
/// container for element to be removed
Element old_element(type, 0, ghost_type, Mesh::getKind(type));
for (UInt nel = 0; nel != new_node_per_elem.getSize(); ++nel) {
/// a former IGFEM triangle is transformed into a regular triangle
if ((type != _triangle_3) && (new_node_per_elem(nel, 0) == 0)) {
Vector<UInt> connec_new_elem(3);
connec_new_elem(0) = connectivity(nel, 0);
connec_new_elem(1) = connectivity(nel, 1);
connec_new_elem(2) = connectivity(nel, 2);
/// add the new element in the mesh
UInt nb_triangles_3 = connec_tri_3.getSize();
connec_tri_3.push_back(connec_new_elem);
el_tri_3.element = nb_triangles_3;
new_elements_list.push_back(el_tri_3);
/// the number of the old element in the mesh
old_element.element = nel;
old_elements_list.push_back(old_element);
new_numbering(nel) = UInt(-1);
++n_new_el;
}
/// element is enriched
else if (new_node_per_elem(nel, 0) != 0) {
switch (new_node_per_elem(nel, 0)) {
/// new element is of type igfem_triangle_4
case 1: {
Vector<UInt> connec_new_elem(4);
switch (new_node_per_elem(nel, 2)) {
case 0:
connec_new_elem(0) = connectivity(nel, 2);
connec_new_elem(1) = connectivity(nel, 0);
connec_new_elem(2) = connectivity(nel, 1);
break;
case 1:
connec_new_elem(0) = connectivity(nel, 0);
connec_new_elem(1) = connectivity(nel, 1);
connec_new_elem(2) = connectivity(nel, 2);
break;
case 2:
connec_new_elem(0) = connectivity(nel, 1);
connec_new_elem(1) = connectivity(nel, 2);
connec_new_elem(2) = connectivity(nel, 0);
break;
default:
AKANTU_ERROR("A triangle has only 3 segments not "
- << new_node_per_elem(nel, 2));
+ << new_node_per_elem(nel, 2));
break;
}
connec_new_elem(3) = new_node_per_elem(nel, 1);
UInt nb_igfem_triangles_4 = connec_igfem_tri_4.getSize();
connec_igfem_tri_4.push_back(connec_new_elem);
el_igfem_tri_4.element = nb_igfem_triangles_4;
new_elements_list.push_back(el_igfem_tri_4);
break;
}
/// new element is of type igfem_triangle_5
case 2: {
Vector<UInt> connec_new_elem(5);
if ((new_node_per_elem(nel, 2) == 0) &&
(new_node_per_elem(nel, 4) == 1)) {
connec_new_elem(0) = connectivity(nel, 1);
connec_new_elem(1) = connectivity(nel, 2);
connec_new_elem(2) = connectivity(nel, 0);
connec_new_elem(3) = new_node_per_elem(nel, 3);
connec_new_elem(4) = new_node_per_elem(nel, 1);
} else if ((new_node_per_elem(nel, 2) == 0) &&
(new_node_per_elem(nel, 4) == 2)) {
connec_new_elem(0) = connectivity(nel, 0);
connec_new_elem(1) = connectivity(nel, 1);
connec_new_elem(2) = connectivity(nel, 2);
connec_new_elem(3) = new_node_per_elem(nel, 1);
connec_new_elem(4) = new_node_per_elem(nel, 3);
} else if ((new_node_per_elem(nel, 2) == 1) &&
(new_node_per_elem(nel, 4) == 2)) {
connec_new_elem(0) = connectivity(nel, 2);
connec_new_elem(1) = connectivity(nel, 0);
connec_new_elem(2) = connectivity(nel, 1);
connec_new_elem(3) = new_node_per_elem(nel, 3);
connec_new_elem(4) = new_node_per_elem(nel, 1);
} else if ((new_node_per_elem(nel, 2) == 1) &&
(new_node_per_elem(nel, 4) == 0)) {
connec_new_elem(0) = connectivity(nel, 1);
connec_new_elem(1) = connectivity(nel, 2);
connec_new_elem(2) = connectivity(nel, 0);
connec_new_elem(3) = new_node_per_elem(nel, 1);
connec_new_elem(4) = new_node_per_elem(nel, 3);
} else if ((new_node_per_elem(nel, 2) == 2) &&
(new_node_per_elem(nel, 4) == 0)) {
connec_new_elem(0) = connectivity(nel, 0);
connec_new_elem(1) = connectivity(nel, 1);
connec_new_elem(2) = connectivity(nel, 2);
connec_new_elem(3) = new_node_per_elem(nel, 3);
connec_new_elem(4) = new_node_per_elem(nel, 1);
} else if ((new_node_per_elem(nel, 2) == 2) &&
(new_node_per_elem(nel, 4) == 1)) {
connec_new_elem(0) = connectivity(nel, 2);
connec_new_elem(1) = connectivity(nel, 0);
connec_new_elem(2) = connectivity(nel, 1);
connec_new_elem(3) = new_node_per_elem(nel, 1);
connec_new_elem(4) = new_node_per_elem(nel, 3);
} else
AKANTU_ERROR("A triangle has only 3 segments (0 to 2) not "
- << new_node_per_elem(nel, 2) << "and"
- << new_node_per_elem(nel, 4));
+ << new_node_per_elem(nel, 2) << "and"
+ << new_node_per_elem(nel, 4));
UInt nb_igfem_triangles_5 = connec_igfem_tri_5.getSize();
connec_igfem_tri_5.push_back(connec_new_elem);
el_igfem_tri5.element = nb_igfem_triangles_5;
new_elements_list.push_back(el_igfem_tri5);
break;
}
default:
AKANTU_ERROR("IGFEM cannot add " << new_node_per_elem(nel, 0)
- << " nodes to triangles");
+ << " nodes to triangles");
break;
}
old_element.element = nel;
old_elements_list.push_back(old_element);
new_numbering(nel) = UInt(-1);
++n_new_el;
}
}
total_new_elements += n_new_el;
}
}
/// update new numbering
for (ghost_type_t::iterator gt = ghost_type_t::begin();
gt != ghost_type_t::end(); ++gt) {
GhostType ghost_type = *gt;
/// loop over all types in the mesh for a given ghost type
Mesh::type_iterator iit = mesh.firstType(dim, ghost_type, _ek_not_defined);
Mesh::type_iterator iend = mesh.lastType(dim, ghost_type, _ek_not_defined);
for (; iit != iend; ++iit) {
ElementType type = *iit;
Array<UInt> & new_numbering =
removed_elements_event.getNewNumbering(type, ghost_type);
UInt el_index = 0;
UInt nb_element = this->mesh.getNbElement(type, ghost_type);
new_numbering.resize(nb_element);
for (UInt e = 0; e < nb_element; ++e) {
if (new_numbering(e) != UInt(-1)) {
new_numbering(e) = el_index;
++el_index;
}
}
changed_elements_event.getNewNumbering(type, ghost_type)
.copy(new_numbering);
}
}
StaticCommunicator::getStaticCommunicator().allReduce(&total_new_elements, 1,
_so_sum);
if (total_new_elements > 0) {
changed_elements_event.getListOld().copy(
new_elements_event.getOldElementsList());
changed_elements_event.getListNew().copy(new_elements_event.getList());
this->mesh.sendEvent(changed_elements_event);
this->mesh.sendEvent(new_elements_event);
Array<Element> & removed_list = removed_elements_event.getList();
removed_list.copy(new_elements_event.getOldElementsList());
this->mesh.sendEvent(removed_elements_event);
}
removeAdditionalNodes();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MeshIgfemSphericalGrowingGel<dim>::buildSegmentConnectivityToNodeType() {
Mesh mesh_facets(mesh.initMeshFacets());
MeshUtils::buildSegmentToNodeType(mesh, mesh_facets, synchronizer);
// only the ghost elements are considered
for (UInt g = _not_ghost; g <= _ghost; ++g) {
GhostType ghost_type = (GhostType)g;
Mesh::type_iterator it = mesh_facets.firstType(1, ghost_type);
Mesh::type_iterator end = mesh_facets.lastType(1, ghost_type);
for (; it != end; ++it) {
ElementType type = *it;
const Array<Int> & segment_to_nodetype =
mesh_facets.getData<Int>("segment_to_nodetype", type, ghost_type);
const Array<UInt> & segment_connectivity =
mesh_facets.getConnectivity(type, ghost_type);
// looping over all the segments
Array<UInt>::const_vector_iterator conn_it =
segment_connectivity.begin(segment_connectivity.getNbComponent());
Array<UInt>::const_vector_iterator conn_end =
segment_connectivity.end(segment_connectivity.getNbComponent());
UInt seg_index = 0;
UInt n[2];
for (; conn_it != conn_end; ++conn_it, ++seg_index) {
Int seg_type = segment_to_nodetype(seg_index);
n[0] = (*conn_it)(0);
n[1] = (*conn_it)(1);
if ((mesh.isMasterNode(n[0]) || mesh.isSlaveNode(n[0])) &&
(mesh.isMasterNode(n[1]) || mesh.isSlaveNode(n[1]))) {
std::sort(n, n + 2);
segment_conn_to_node_type[std::make_pair(n[0], n[1])] = seg_type;
}
}
}
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MeshIgfemSphericalGrowingGel<dim>::updateNodeType(
const Array<UInt> & nodes_list, const Array<UInt> & new_node_per_elem,
ElementType type, GhostType ghost_type) {
Array<Int> & nodes_type = mesh.getNodesType();
UInt old_nodes = nodes_type.getSize();
UInt new_nodes = nodes_list.getSize();
// exit this function if the simulation in run in serial
if (old_nodes == 0 || new_nodes == 0)
return;
nodes_type.resize(old_nodes + new_nodes);
Array<bool> checked_node(new_nodes, 1, false);
UInt nb_prim_by_el = 0;
if ((type == _triangle_3) || (type == _igfem_triangle_4) ||
(type == _igfem_triangle_5)) {
nb_prim_by_el = 3;
} else {
AKANTU_ERROR("Not ready for mesh type " << type);
}
// determine the node type for the local, master and slave nodes
const Array<UInt> & connectivity = mesh.getConnectivity(type, ghost_type);
unordered_map<std::pair<UInt, UInt>, Int>::type::iterator seg_type_it;
unordered_map<std::pair<UInt, UInt>, Int>::type::iterator seg_type_end =
segment_conn_to_node_type.end();
for (UInt el = 0; el < new_node_per_elem.getSize(); ++el) {
UInt nb_nodes = new_node_per_elem(el, 0);
for (UInt n = 0; n < nb_nodes; ++n) {
UInt node_index = new_node_per_elem(el, 2 * n + 1);
if (node_index < old_nodes || checked_node(node_index - old_nodes))
continue;
// get the elemental connectivity of the segment associated to the node
UInt segment_index = new_node_per_elem(el, 2 * n + 2);
UInt extreme_nodes[2];
extreme_nodes[0] = segment_index;
extreme_nodes[1] = segment_index + 1;
if (extreme_nodes[1] == nb_prim_by_el)
extreme_nodes[1] = 0;
// get the connectivity of the segment
extreme_nodes[0] = connectivity(el, extreme_nodes[0]);
extreme_nodes[1] = connectivity(el, extreme_nodes[1]);
// if one extreme nodes is pure ghost, then also the new node is pure
// ghost
if (mesh.isPureGhostNode(extreme_nodes[0]) ||
mesh.isPureGhostNode(extreme_nodes[1]))
nodes_type(node_index) = -3;
// if on of the two extreme nodes is local, then also the new node is
// local
else if (mesh.isLocalNode(extreme_nodes[0]) ||
mesh.isLocalNode(extreme_nodes[1]))
nodes_type(node_index) = -1;
// otherwise use the value stored in the map
else {
std::sort(extreme_nodes, extreme_nodes + 2);
seg_type_it = segment_conn_to_node_type.find(
std::make_pair(extreme_nodes[0], extreme_nodes[1]));
AKANTU_DEBUG_ASSERT(seg_type_it != seg_type_end, "Segment not found");
nodes_type(node_index) = seg_type_it->second;
}
checked_node(node_index - old_nodes) = true;
}
}
AKANTU_DEBUG_ASSERT(std::accumulate(checked_node.begin(), checked_node.end(),
0) == Int(checked_node.getSize()),
"Not all new nodes were assigned a node type");
}
__END_AKANTU__
diff --git a/extra_packages/igfem/test/patch_tests/test_igfem_triangle_4.cc b/extra_packages/igfem/test/patch_tests/test_igfem_triangle_4.cc
index 8fdf1596b..24a63394a 100644
--- a/extra_packages/igfem/test/patch_tests/test_igfem_triangle_4.cc
+++ b/extra_packages/igfem/test/patch_tests/test_igfem_triangle_4.cc
@@ -1,265 +1,266 @@
/**
* @file test_igfem_triangle_4.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief patch tests with elements of type _igfem_triangle_4
*
* @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 "dumpable_inline_impl.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
class StraightInterfaceMatSelector
: public MeshDataMaterialSelector<std::string> {
public:
StraightInterfaceMatSelector(const ID & id, SolidMechanicsModelIGFEM & model)
: MeshDataMaterialSelector<std::string>(id, model) {}
UInt operator()(const Element & elem) {
if (Mesh::getKind(elem.type) == _ek_igfem)
/// choose IGFEM material
return 2;
return MeshDataMaterialSelector<std::string>::operator()(elem);
}
};
Real computeL2Error(SolidMechanicsModelIGFEM & model);
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
/// create a mesh and read the regular elements from the mesh file
/// mesh creation
const UInt spatial_dimension = 2;
Mesh mesh(spatial_dimension);
mesh.read("test_mesh.msh");
/// model creation
SolidMechanicsModelIGFEM model(mesh);
/// creation of material selector
MeshDataMaterialSelector<std::string> * mat_selector;
mat_selector = new StraightInterfaceMatSelector("physical_names", model);
model.setMaterialSelector(*mat_selector);
model.initFull();
/// add fields that should be dumped
model.setBaseName("regular_elements");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpField("material_index");
model.addDumpFieldVector("displacement");
model.addDumpField("blocked_dofs");
model.addDumpField("stress");
model.addDumpFieldToDumper("igfem elements", "lambda");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
model.addDumpFieldVectorToDumper("igfem elements", "real_displacement");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldToDumper("igfem elements", "stress");
/// dump mesh before the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// create the interace: the bi-material interface is a straight line
/// since the SMMIGFEM has only a sphere intersector we generate a large
/// sphere so that the intersection points with the mesh lie almost along
/// the straight line x = 0.25. We then move the interface nodes to correct
/// their position and make them lie exactly along the line. This is a
/// workaround to generate a straight line with the sphere intersector.
/// Ideally, there should be a new type of IGFEM enrichment implemented to
/// generate straight lines
std::list<SK::Sphere_3> sphere_list;
SK::Sphere_3 sphere_1(SK::Point_3(1000000000.5, 0., 0.),
1000000000. * 1000000000);
sphere_list.push_back(sphere_1);
model.registerGeometryObject(sphere_list, "inside");
model.update();
if ((mesh.getNbElement(_igfem_triangle_4) != 4) ||
(mesh.getNbElement(_igfem_triangle_5) != 0)) {
std::cout << "something went wrong in the interface creation" << std::endl;
finalize();
return EXIT_FAILURE;
}
/// dump mesh after the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// apply the boundary conditions: left and bottom side on rollers
/// imposed displacement along right side
mesh.computeBoundingBox();
const Vector<Real> & lower_bounds = mesh.getLowerBounds();
const Vector<Real> & upper_bounds = mesh.getUpperBounds();
Real bottom = lower_bounds(1);
Real left = lower_bounds(0);
Real right = upper_bounds(0);
Real eps = std::abs((right - left) * 1e-6);
const Array<Real> & pos = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & boun = model.getBlockedDOFs();
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (std::abs(pos(i, 1) - bottom) < eps) {
boun(i, 1) = true;
disp(i, 1) = 0.0;
}
if (std::abs(pos(i, 0) - left) < eps) {
boun(i, 0) = true;
disp(i, 0) = 0.0;
}
if (std::abs(pos(i, 0) - right) < eps) {
boun(i, 0) = true;
disp(i, 0) = 1.0;
}
}
/// compute the volume of the mesh
Real int_volume = 0.;
std::map<ElementKind, FEEngine *> fe_engines = model.getFEEnginesPerKind();
std::map<ElementKind, FEEngine *>::const_iterator fe_it = fe_engines.begin();
for (; fe_it != fe_engines.end(); ++fe_it) {
ElementKind kind = fe_it->first;
FEEngine & fe_engine = *(fe_it->second);
Mesh::type_iterator it =
mesh.firstType(spatial_dimension, _not_ghost, kind);
Mesh::type_iterator last_type =
mesh.lastType(spatial_dimension, _not_ghost, kind);
for (; it != last_type; ++it) {
ElementType type = *it;
Array<Real> Volume(mesh.getNbElement(type) *
fe_engine.getNbIntegrationPoints(type),
1, 1.);
int_volume += fe_engine.integrate(Volume, type);
}
}
if (!Math::are_float_equal(int_volume, 4)) {
std::cout << "Error in area computation of the 2D mesh" << std::endl;
return EXIT_FAILURE;
}
std::cout << "the area of the mesh is: " << int_volume << std::endl;
/// solve the system
model.assembleStiffnessMatrix();
Real error = 0;
bool converged = false;
bool factorize = false;
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-12, error, 2, factorize);
if (!converged) {
std::cout << "The solver did not converge!!! The error is: " << error
<< std::endl;
finalize();
return EXIT_FAILURE;
}
/// dump the deformed mesh
model.dump();
model.dump("igfem elements");
Real L2_error = computeL2Error(model);
std::cout << "Error: " << L2_error << std::endl;
if (L2_error > 1e-14) {
finalize();
std::cout << "The patch test did not pass!!!!" << std::endl;
return EXIT_FAILURE;
}
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
Real computeL2Error(SolidMechanicsModelIGFEM & model) {
/// store the error on each element for visualization
ElementTypeMapReal error_per_element("error_per_element");
Real error = 0;
Real normalization = 0;
/// Young's moduli for the two materials
Real E_1 = 10.;
Real E_2 = 1.;
Mesh & mesh = model.getMesh();
UInt spatial_dimension = mesh.getSpatialDimension();
mesh.addDumpFieldExternal("error_per_element", error_per_element,
spatial_dimension, _not_ghost, _ek_regular);
mesh.addDumpFieldExternalToDumper("igfem elements", "error_per_element",
error_per_element, spatial_dimension,
_not_ghost, _ek_igfem);
ElementTypeMapReal quad_coords("quad_coords");
GhostType ghost_type = _not_ghost;
const std::map<ElementKind, FEEngine *> & fe_engines =
model.getFEEnginesPerKind();
std::map<ElementKind, FEEngine *>::const_iterator fe_it = fe_engines.begin();
for (; fe_it != fe_engines.end(); ++fe_it) {
ElementKind kind = fe_it->first;
FEEngine & fe_engine = *(fe_it->second);
mesh.initElementTypeMapArray(quad_coords, spatial_dimension,
spatial_dimension, false, kind, true);
mesh.initElementTypeMapArray(error_per_element, 1, spatial_dimension, false,
kind, true);
fe_engine.computeIntegrationPointsCoordinates(quad_coords);
Mesh::type_iterator it =
mesh.firstType(spatial_dimension, ghost_type, kind);
Mesh::type_iterator last_type =
mesh.lastType(spatial_dimension, ghost_type, kind);
for (; it != last_type; ++it) {
ElementType type = *it;
UInt nb_elements = mesh.getNbElement(type, ghost_type);
UInt nb_quads = fe_engine.getNbIntegrationPoints(type);
/// interpolate the displacement at the quadrature points
Array<Real> displ_on_quads(nb_quads * nb_elements, spatial_dimension,
"displ_on_quads");
Array<Real> quad_coords(nb_quads * nb_elements, spatial_dimension,
"quad_coords");
fe_engine.interpolateOnIntegrationPoints(
model.getDisplacement(), displ_on_quads, spatial_dimension, type);
fe_engine.computeIntegrationPointsCoordinates(quad_coords, type,
ghost_type);
Array<Real> & el_error = error_per_element(type, ghost_type);
Array<Real>::const_vector_iterator displ_it =
displ_on_quads.begin(spatial_dimension);
Array<Real>::const_vector_iterator coord_it =
quad_coords.begin(spatial_dimension);
Vector<Real> error_vec(spatial_dimension);
for (UInt e = 0; e < nb_elements; ++e) {
Vector<Real> error_per_quad(nb_quads);
Vector<Real> normalization_per_quad(nb_quads);
for (UInt q = 0; q < nb_quads; ++q, ++displ_it, ++coord_it) {
Real exact = 0.;
Real x = (*coord_it)(0);
if (x < 0.5)
exact = (2. * x * E_2) / (E_1 + 3. * E_2) +
(2. * E_2) / (E_1 + 3. * E_2);
else
exact = 2. * x * E_1 / (E_1 + 3. * E_2) -
(E_1 - 3. * E_2) / (E_1 + 3. * E_2);
error_vec = *displ_it;
error_vec(0) -= exact;
error_per_quad(q) = error_vec.dot(error_vec);
normalization_per_quad(q) = std::abs(exact) * std::abs(exact);
std::cout << error_vec << std::endl;
}
/// integrate the error in the element and the corresponding
/// normalization
Real int_error =
fe_engine.integrate(error_per_quad, type, e, ghost_type);
error += int_error;
el_error(e) = std::sqrt(int_error);
normalization +=
fe_engine.integrate(normalization_per_quad, type, e, ghost_type);
}
}
}
model.dump();
model.dump("igfem elements");
return (std::sqrt(error) / std::sqrt(normalization));
}
diff --git a/extra_packages/igfem/test/patch_tests/test_igfem_triangle_5.cc b/extra_packages/igfem/test/patch_tests/test_igfem_triangle_5.cc
index 1e9454e75..a49913b6b 100644
--- a/extra_packages/igfem/test/patch_tests/test_igfem_triangle_5.cc
+++ b/extra_packages/igfem/test/patch_tests/test_igfem_triangle_5.cc
@@ -1,275 +1,276 @@
/**
* @file test_igfem_triangle_5.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief patch tests with elements of type _igfem_triangle_5
*
* @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 "dumpable_inline_impl.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
class StraightInterfaceMatSelector
: public MeshDataMaterialSelector<std::string> {
public:
StraightInterfaceMatSelector(const ID & id, SolidMechanicsModelIGFEM & model)
: MeshDataMaterialSelector<std::string>(id, model) {}
UInt operator()(const Element & elem) {
if (Mesh::getKind(elem.type) == _ek_igfem)
/// choose IGFEM material
return 2;
return MeshDataMaterialSelector<std::string>::operator()(elem);
}
};
Real computeL2Error(SolidMechanicsModelIGFEM & model);
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
/// create a mesh and read the regular elements from the mesh file
/// mesh creation
const UInt spatial_dimension = 2;
Mesh mesh(spatial_dimension);
mesh.read("plate.msh");
/// model creation
SolidMechanicsModelIGFEM model(mesh);
/// creation of material selector
MeshDataMaterialSelector<std::string> * mat_selector;
mat_selector = new StraightInterfaceMatSelector("physical_names", model);
model.setMaterialSelector(*mat_selector);
model.initFull();
/// add fields that should be dumped
model.setBaseName("regular_elements");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpField("material_index");
model.addDumpFieldVector("displacement");
model.addDumpField("blocked_dofs");
model.addDumpField("stress");
model.addDumpFieldToDumper("igfem elements", "lambda");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
model.addDumpFieldVectorToDumper("igfem elements", "real_displacement");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldToDumper("igfem elements", "stress");
/// dump mesh before the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// create the interace: the bi-material interface is a straight line
/// since the SMMIGFEM has only a sphere intersector we generate a large
/// sphere so that the intersection points with the mesh lie almost along
/// the straight line x = 0.25. We then move the interface nodes to correct
/// their position and make them lie exactly along the line. This is a
/// workaround to generate a straight line with the sphere intersector.
/// Ideally, there should be a new type of IGFEM enrichment implemented to
/// generate straight lines
std::list<SK::Sphere_3> sphere_list;
SK::Sphere_3 sphere_1(SK::Point_3(6.57, 0., 0.), 6.32 * 6.32);
sphere_list.push_back(sphere_1);
model.registerGeometryObject(sphere_list, "inside");
UInt nb_regular_nodes = mesh.getNbNodes();
model.update();
UInt nb_igfem_nodes = mesh.getNbNodes() - nb_regular_nodes;
/// adjust the positions of the node to have an exact straight line
Array<Real> & nodes = const_cast<Array<Real> &>(mesh.getNodes());
Array<Real>::vector_iterator nodes_it = nodes.begin(spatial_dimension);
nodes_it += nb_regular_nodes;
for (UInt i = 0; i < nb_igfem_nodes; ++i, ++nodes_it) {
Vector<Real> & node_coords = *nodes_it;
node_coords(0) = 0.25;
Int multiplier = std::round(node_coords(1) / 0.25);
node_coords(1) = 0.25 * multiplier;
}
/// reinitialize the shape functions because node coordinates have changed
model.getFEEngine("IGFEMFEEngine").initShapeFunctions(_not_ghost);
model.getFEEngine("IGFEMFEEngine").initShapeFunctions(_ghost);
/// dump mesh after the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// apply the boundary conditions: left and bottom side on rollers
/// imposed displacement along right side
mesh.computeBoundingBox();
const Vector<Real> & lower_bounds = mesh.getLowerBounds();
const Vector<Real> & upper_bounds = mesh.getUpperBounds();
Real bottom = lower_bounds(1);
Real left = lower_bounds(0);
Real right = upper_bounds(0);
Real eps = std::abs((right - left) * 1e-6);
const Array<Real> & pos = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & boun = model.getBlockedDOFs();
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (std::abs(pos(i, 1) - bottom) < eps) {
boun(i, 1) = true;
disp(i, 1) = 0.0;
}
if (std::abs(pos(i, 0) - left) < eps) {
boun(i, 0) = true;
disp(i, 0) = 0.0;
}
if (std::abs(pos(i, 0) - right) < eps) {
boun(i, 0) = true;
disp(i, 0) = 1.0;
}
}
/// compute the volume of the mesh
Real int_volume = 0.;
std::map<ElementKind, FEEngine *> fe_engines = model.getFEEnginesPerKind();
std::map<ElementKind, FEEngine *>::const_iterator fe_it = fe_engines.begin();
for (; fe_it != fe_engines.end(); ++fe_it) {
ElementKind kind = fe_it->first;
FEEngine & fe_engine = *(fe_it->second);
Mesh::type_iterator it =
mesh.firstType(spatial_dimension, _not_ghost, kind);
Mesh::type_iterator last_type =
mesh.lastType(spatial_dimension, _not_ghost, kind);
for (; it != last_type; ++it) {
ElementType type = *it;
Array<Real> Volume(mesh.getNbElement(type) *
fe_engine.getNbIntegrationPoints(type),
1, 1.);
int_volume += fe_engine.integrate(Volume, type);
}
}
if (!Math::are_float_equal(int_volume, 4)) {
std::cout << "Error in area computation of the 2D mesh" << std::endl;
return EXIT_FAILURE;
}
std::cout << "the area of the mesh is: " << int_volume << std::endl;
/// solve the system
model.assembleStiffnessMatrix();
Real error = 0;
bool converged = false;
bool factorize = false;
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-12, error, 2, factorize);
if (!converged) {
std::cout << "The solver did not converge!!! The error is: " << error
<< std::endl;
finalize();
return EXIT_FAILURE;
}
/// dump the deformed mesh
model.dump();
model.dump("igfem elements");
Real L2_error = computeL2Error(model);
std::cout << "Error: " << L2_error << std::endl;
if (L2_error > 1e-12) {
finalize();
std::cout << "The patch test did not pass!!!!" << std::endl;
return EXIT_FAILURE;
}
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
Real computeL2Error(SolidMechanicsModelIGFEM & model) {
/// store the error on each element for visualization
ElementTypeMapReal error_per_element("error_per_element");
Real error = 0;
Real normalization = 0;
/// Young's moduli for the two materials
Real E_1 = 10.;
Real E_2 = 1.;
Mesh & mesh = model.getMesh();
UInt spatial_dimension = mesh.getSpatialDimension();
mesh.addDumpFieldExternal("error_per_element", error_per_element,
spatial_dimension, _not_ghost, _ek_regular);
mesh.addDumpFieldExternalToDumper("igfem elements", "error_per_element",
error_per_element, spatial_dimension,
_not_ghost, _ek_igfem);
ElementTypeMapReal quad_coords("quad_coords");
GhostType ghost_type = _not_ghost;
const std::map<ElementKind, FEEngine *> & fe_engines =
model.getFEEnginesPerKind();
std::map<ElementKind, FEEngine *>::const_iterator fe_it = fe_engines.begin();
for (; fe_it != fe_engines.end(); ++fe_it) {
ElementKind kind = fe_it->first;
FEEngine & fe_engine = *(fe_it->second);
mesh.initElementTypeMapArray(quad_coords, spatial_dimension,
spatial_dimension, false, kind, true);
mesh.initElementTypeMapArray(error_per_element, 1, spatial_dimension, false,
kind, true);
fe_engine.computeIntegrationPointsCoordinates(quad_coords);
Mesh::type_iterator it =
mesh.firstType(spatial_dimension, ghost_type, kind);
Mesh::type_iterator last_type =
mesh.lastType(spatial_dimension, ghost_type, kind);
for (; it != last_type; ++it) {
ElementType type = *it;
UInt nb_elements = mesh.getNbElement(type, ghost_type);
UInt nb_quads = fe_engine.getNbIntegrationPoints(type);
/// interpolate the displacement at the quadrature points
Array<Real> displ_on_quads(nb_quads * nb_elements, spatial_dimension,
"displ_on_quads");
Array<Real> quad_coords(nb_quads * nb_elements, spatial_dimension,
"quad_coords");
fe_engine.interpolateOnIntegrationPoints(
model.getDisplacement(), displ_on_quads, spatial_dimension, type);
fe_engine.computeIntegrationPointsCoordinates(quad_coords, type,
ghost_type);
Array<Real> & el_error = error_per_element(type, ghost_type);
Array<Real>::const_vector_iterator displ_it =
displ_on_quads.begin(spatial_dimension);
Array<Real>::const_vector_iterator coord_it =
quad_coords.begin(spatial_dimension);
Vector<Real> error_vec(spatial_dimension);
for (UInt e = 0; e < nb_elements; ++e) {
Vector<Real> error_per_quad(nb_quads);
Vector<Real> normalization_per_quad(nb_quads);
for (UInt q = 0; q < nb_quads; ++q, ++displ_it, ++coord_it) {
Real exact = 0.;
Real x = (*coord_it)(0);
if (x < 0.25)
exact = (4. * x * E_2) / (3. * E_1 + 5. * E_2) +
(4. * E_2) / (3. * E_1 + 5. * E_2);
else
exact = 4. * x * E_1 / (3. * E_1 + 5. * E_2) -
(E_1 - 5. * E_2) / (3. * E_1 + 5. * E_2);
error_vec = *displ_it;
error_vec(0) -= exact;
error_per_quad(q) = error_vec.dot(error_vec);
normalization_per_quad(q) = std::abs(exact) * std::abs(exact);
std::cout << error_vec << std::endl;
}
/// integrate the error in the element and the corresponding
/// normalization
Real int_error =
fe_engine.integrate(error_per_quad, type, e, ghost_type);
error += int_error;
el_error(e) = std::sqrt(int_error);
normalization +=
fe_engine.integrate(normalization_per_quad, type, e, ghost_type);
}
}
}
model.dump();
model.dump("igfem elements");
return (std::sqrt(error) / std::sqrt(normalization));
}
diff --git a/extra_packages/igfem/test/patch_tests/test_interface_position.cc b/extra_packages/igfem/test/patch_tests/test_interface_position.cc
index 2fef81c19..a09d1649f 100644
--- a/extra_packages/igfem/test/patch_tests/test_interface_position.cc
+++ b/extra_packages/igfem/test/patch_tests/test_interface_position.cc
@@ -1,348 +1,351 @@
/**
* @file test_interface_position.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief patch test for interface close to standard nodes
*
* @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 "dumpable_inline_impl.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
Real computeL2Error(SolidMechanicsModelIGFEM & model,
ElementTypeMapReal & error_per_element);
int main(int argc, char * argv[]) {
initialize("material_test_interface_position.dat", argc, argv);
StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// create a mesh and read the regular elements from the mesh file
/// mesh creation
const UInt spatial_dimension = 2;
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
mesh.read("test_interface_position.msh");
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModelIGFEM model(mesh);
model.initParallel(partition);
delete partition;
model.initFull();
/// add fields that should be dumped
model.setBaseName("regular_elements");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpField("material_index");
model.addDumpFieldVector("displacement");
model.addDumpField("blocked_dofs");
model.addDumpField("stress");
model.addDumpField("partitions");
model.addDumpFieldToDumper("igfem elements", "lambda");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
model.addDumpFieldVectorToDumper("igfem elements", "real_displacement");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldToDumper("igfem elements", "stress");
model.addDumpFieldToDumper("igfem elements", "partitions");
/// dump mesh before the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// create the interace:
UInt nb_standard_nodes = mesh.getNbNodes();
std::list<SK::Sphere_3> sphere_list;
SK::Sphere_3 sphere_1(SK::Point_3(0., 0., 0.), 0.25 * 0.25);
sphere_list.push_back(sphere_1);
model.registerGeometryObject(sphere_list, "inside");
model.update();
/// dump mesh after the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// apply the boundary conditions: left and bottom side on rollers
/// imposed displacement along right side
mesh.computeBoundingBox();
const Vector<Real> & lower_bounds = mesh.getLowerBounds();
const Vector<Real> & upper_bounds = mesh.getUpperBounds();
Real bottom = lower_bounds(1);
Real left = lower_bounds(0);
Real right = upper_bounds(0);
Real eps = std::abs((right - left) * 1e-6);
const Array<Real> & pos = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & boun = model.getBlockedDOFs();
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (std::abs(pos(i, 1) - bottom) < eps) {
boun(i, 1) = true;
disp(i, 1) = 0.0;
}
if (std::abs(pos(i, 0) - left) < eps) {
boun(i, 0) = true;
disp(i, 0) = 0.0;
}
if (std::abs(pos(i, 0) - right) < eps) {
boun(i, 0) = true;
disp(i, 0) = 1.0;
}
}
/// compute the volume of the mesh
Real int_volume = 0.;
std::map<ElementKind, FEEngine *> fe_engines = model.getFEEnginesPerKind();
std::map<ElementKind, FEEngine *>::const_iterator fe_it = fe_engines.begin();
for (; fe_it != fe_engines.end(); ++fe_it) {
ElementKind kind = fe_it->first;
FEEngine & fe_engine = *(fe_it->second);
Mesh::type_iterator it =
mesh.firstType(spatial_dimension, _not_ghost, kind);
Mesh::type_iterator last_type =
mesh.lastType(spatial_dimension, _not_ghost, kind);
for (; it != last_type; ++it) {
ElementType type = *it;
Array<Real> Volume(mesh.getNbElement(type) *
fe_engine.getNbIntegrationPoints(type),
1, 1.);
int_volume += fe_engine.integrate(Volume, type);
}
}
comm.allReduce(&int_volume, 1, _so_sum);
if (prank == 0)
if (!Math::are_float_equal(int_volume, 4)) {
finalize();
std::cout << "Error in area computation of the 2D mesh" << std::endl;
return EXIT_FAILURE;
}
/// solve the system
model.assembleStiffnessMatrix();
Real error = 0;
bool converged = false;
bool factorize = false;
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-12, error, 2, factorize);
if (!converged) {
std::cout << "The solver did not converge!!! The error is: " << error
<< std::endl;
finalize();
return EXIT_FAILURE;
}
/// store the error on each element for visualization
ElementTypeMapReal error_per_element("error_per_element");
mesh.addDumpFieldExternal("error_per_element", error_per_element,
spatial_dimension, _not_ghost, _ek_regular);
mesh.addDumpFieldExternalToDumper("igfem elements", "error_per_element",
error_per_element, spatial_dimension,
_not_ghost, _ek_igfem);
mesh.initElementTypeMapArray(error_per_element, 1, spatial_dimension, false,
_ek_regular, true);
mesh.initElementTypeMapArray(error_per_element, 1, spatial_dimension, false,
_ek_igfem, true);
Real L2_error = computeL2Error(model, error_per_element);
comm.allReduce(&L2_error, 1, _so_sum);
if (prank == 0) {
std::cout << "Error: " << L2_error << std::endl;
if (L2_error > 1e-13) {
finalize();
std::cout << "The patch test did not pass!!!!" << std::endl;
return EXIT_FAILURE;
}
}
/// dump the deformed mesh
model.dump();
model.dump("igfem elements");
/* --------------------------------------------------------------------------
*/
/// move the interface very close the standard nodes, but far enough
/// to not cut trough the standard nodes
model.moveInterface(0.5 * (1 - 1e-9));
model.dump();
model.dump("igfem elements");
UInt nb_igfem_triangle_4 = mesh.getNbElement(_igfem_triangle_4, _not_ghost);
UInt nb_igfem_triangle_5 = mesh.getNbElement(_igfem_triangle_5, _not_ghost);
comm.allReduce(&nb_igfem_triangle_4, 1, _so_sum);
comm.allReduce(&nb_igfem_triangle_5, 1, _so_sum);
if (prank == 0) {
if ((nb_igfem_triangle_4 != 0) || (nb_igfem_triangle_5 != 8)) {
std::cout << "something went wrong in the interface creation"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
}
if ((psize == 0) && (mesh.getNbNodes() - nb_standard_nodes != 8)) {
std::cout << "something went wrong in the interface node creation"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-12, error, 2, factorize);
if (!converged) {
std::cout << "The solver did not converge!!! The error is: " << error
<< std::endl;
finalize();
return EXIT_FAILURE;
}
L2_error = computeL2Error(model, error_per_element);
comm.allReduce(&L2_error, 1, _so_sum);
if (prank == 0) {
std::cout << "Error: " << L2_error << std::endl;
if (L2_error > 1e-13) {
finalize();
std::cout << "The patch test did not pass!!!!" << std::endl;
return EXIT_FAILURE;
}
}
/// dump the new interface
model.dump();
model.dump("igfem elements");
/* --------------------------------------------------------------------------
*/
/// move the interface so that it cuts through the standard nodes
model.moveInterface((0.5 * (1 - 1e-10)));
nb_igfem_triangle_4 = mesh.getNbElement(_igfem_triangle_4, _not_ghost);
nb_igfem_triangle_5 = mesh.getNbElement(_igfem_triangle_5, _not_ghost);
comm.allReduce(&nb_igfem_triangle_4, 1, _so_sum);
comm.allReduce(&nb_igfem_triangle_5, 1, _so_sum);
if (prank == 0) {
if ((nb_igfem_triangle_4 != 8) || (nb_igfem_triangle_5 != 0)) {
std::cout << "something went wrong in the interface creation"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
}
if ((psize == 0) && (mesh.getNbNodes() - nb_standard_nodes != 4)) {
std::cout << "something went wrong in the interface node creation"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-12, error, 2, factorize);
if (!converged) {
std::cout << "The solver did not converge!!! The error is: " << error
<< std::endl;
finalize();
return EXIT_FAILURE;
}
L2_error = computeL2Error(model, error_per_element);
comm.allReduce(&L2_error, 1, _so_sum);
if (prank == 0) {
std::cout << "Error: " << L2_error << std::endl;
if (L2_error > 1e-13) {
finalize();
std::cout << "The patch test did not pass!!!!" << std::endl;
return EXIT_FAILURE;
}
}
/// dump the new interface
model.dump();
model.dump("igfem elements");
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
Real computeL2Error(SolidMechanicsModelIGFEM & model,
ElementTypeMapReal & error_per_element) {
Real error = 0;
Real normalization = 0;
Mesh & mesh = model.getMesh();
UInt spatial_dimension = mesh.getSpatialDimension();
ElementTypeMapReal quad_coords("quad_coords");
GhostType ghost_type = _not_ghost;
const std::map<ElementKind, FEEngine *> & fe_engines =
model.getFEEnginesPerKind();
std::map<ElementKind, FEEngine *>::const_iterator fe_it = fe_engines.begin();
for (; fe_it != fe_engines.end(); ++fe_it) {
ElementKind kind = fe_it->first;
FEEngine & fe_engine = *(fe_it->second);
mesh.initElementTypeMapArray(quad_coords, spatial_dimension,
spatial_dimension, false, kind, true);
fe_engine.computeIntegrationPointsCoordinates(quad_coords);
Mesh::type_iterator it =
mesh.firstType(spatial_dimension, ghost_type, kind);
Mesh::type_iterator last_type =
mesh.lastType(spatial_dimension, ghost_type, kind);
for (; it != last_type; ++it) {
ElementType type = *it;
UInt nb_elements = mesh.getNbElement(type, ghost_type);
UInt nb_quads = fe_engine.getNbIntegrationPoints(type);
/// interpolate the displacement at the quadrature points
Array<Real> displ_on_quads(nb_quads * nb_elements, spatial_dimension,
"displ_on_quads");
Array<Real> quad_coords(nb_quads * nb_elements, spatial_dimension,
"quad_coords");
fe_engine.interpolateOnIntegrationPoints(
model.getDisplacement(), displ_on_quads, spatial_dimension, type);
fe_engine.computeIntegrationPointsCoordinates(quad_coords, type,
ghost_type);
Array<Real> & el_error = error_per_element(type, ghost_type);
el_error.resize(nb_elements);
Array<Real>::const_vector_iterator displ_it =
displ_on_quads.begin(spatial_dimension);
Array<Real>::const_vector_iterator coord_it =
quad_coords.begin(spatial_dimension);
Vector<Real> error_vec(spatial_dimension);
for (UInt e = 0; e < nb_elements; ++e) {
Vector<Real> error_per_quad(nb_quads);
Vector<Real> normalization_per_quad(nb_quads);
for (UInt q = 0; q < nb_quads; ++q, ++displ_it, ++coord_it) {
Real exact = 0.5 * (*coord_it)(0) + 0.5;
error_vec = *displ_it;
error_vec(0) -= exact;
error_per_quad(q) = error_vec.dot(error_vec);
normalization_per_quad(q) = std::abs(exact) * std::abs(exact);
/// std::cout << error_vec << std::endl;
}
/// integrate the error in the element and the corresponding
/// normalization
Real int_error =
fe_engine.integrate(error_per_quad, type, e, ghost_type);
error += int_error;
el_error(e) = std::sqrt(int_error);
normalization +=
fe_engine.integrate(normalization_per_quad, type, e, ghost_type);
}
}
}
return (std::sqrt(error) / std::sqrt(normalization));
}
diff --git a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_ASR_damage.cc b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_ASR_damage.cc
index e9c08e99c..b7f571bb1 100644
--- a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_ASR_damage.cc
+++ b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_ASR_damage.cc
@@ -1,210 +1,211 @@
/**
* @file test_ASR_damage.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief test the solidmechancis model for IGFEM analysis
*
* @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 "aka_common.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
#include "material_damage_iterative.hh"
#include "material_igfem_saw_tooth_damage.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/// function declaration
void applyBoundaryConditions(SolidMechanicsModelIGFEM & model);
class ASRMaterialSelector : public MaterialSelector {
public:
ASRMaterialSelector(SolidMechanicsModelIGFEM & model) : model(model) {}
UInt operator()(const Element & elem) {
if (Mesh::getKind(elem.type) == _ek_igfem)
/// choose IGFEM material
return 2;
const Mesh & mesh = model.getMesh();
UInt spatial_dimension = model.getSpatialDimension();
Vector<Real> barycenter(spatial_dimension);
mesh.getBarycenter(elem, barycenter);
if (model.isInside(barycenter))
return 1;
return 0;
}
protected:
SolidMechanicsModelIGFEM & model;
};
typedef Spherical SK;
int main(int argc, char * argv[]) {
initialize("material_ASR.dat", argc, argv);
/// problem dimension
const UInt spatial_dimension = 2;
StaticCommunicator & comm =
akantu::StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// mesh creation
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
mesh.read("one_inclusion.msh");
/// partition the mesh
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModelIGFEM model(mesh);
model.initParallel(partition);
delete partition;
/// register the gel pocket list in the model
std::list<SK::Sphere_3> gel_pocket_list;
model.registerGeometryObject(gel_pocket_list, "gel");
ASRMaterialSelector * mat_selector;
mat_selector = new ASRMaterialSelector(model);
model.setMaterialSelector(*mat_selector);
model.initFull();
/// add fields that should be dumped
model.setBaseName("regular_elements");
model.addDumpField("material_index");
model.addDumpField("damage");
model.addDumpField("Sc");
model.addDumpField("partitions");
model.addDumpField("eigen_grad_u");
model.addDumpField("blocked_dofs");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldToDumper("igfem elements", "Sc");
model.addDumpFieldToDumper("igfem elements", "damage");
model.addDumpFieldToDumper("igfem elements", "lambda");
model.addDumpFieldToDumper("igfem elements", "eigen_grad_u");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
/// dump before the interface generation
model.dump();
model.dump("igfem elements");
/// weaken one element to enforce damage there
Array<Real> & Sc =
model.getMaterial(0).getInternal<Real>("Sc")(_triangle_3, _not_ghost);
Sc(11) = 1;
/// create the gel pocket
Real initial_gel_radius = 0.1;
SK::Sphere_3 sphere_1(SK::Point_3(0., 0., 0.),
initial_gel_radius * initial_gel_radius);
gel_pocket_list.push_back(sphere_1);
/// create the interface
model.update("gel");
/// apply eigenstrain the eigenstrain in the inclusions
Matrix<Real> prestrain(spatial_dimension, spatial_dimension, 0.);
for (UInt i = 0; i < spatial_dimension; ++i)
prestrain(i, i) = 0.05;
model.applyEigenGradU(prestrain, "gel", _not_ghost);
applyBoundaryConditions(model);
/// dump
model.dump("igfem elements");
model.dump();
/// Instantiate objects of class MyDamageso
MaterialDamageIterative<spatial_dimension> & mat_aggregate =
dynamic_cast<MaterialDamageIterative<spatial_dimension> &>(
model.getMaterial(0));
MaterialIGFEMSawToothDamage<spatial_dimension> & mat_igfem =
dynamic_cast<MaterialIGFEMSawToothDamage<spatial_dimension> &>(
model.getMaterial(2));
bool factorize = false;
bool converged = false;
Real error;
UInt nb_damaged_elements = 0;
Real max_eq_stress_aggregate = 0;
Real max_igfem = 0;
const Array<Real> & stress =
model.getMaterial(2).getStress(_igfem_triangle_5, _not_ghost);
Array<Real>::const_matrix_iterator stress_it =
stress.begin(spatial_dimension, spatial_dimension);
do {
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-6, error, 2, factorize);
/// compute damage
max_eq_stress_aggregate = mat_aggregate.getNormMaxEquivalentStress();
max_igfem = mat_igfem.getNormMaxEquivalentStress();
if (max_eq_stress_aggregate > max_igfem)
nb_damaged_elements = mat_aggregate.updateDamage();
else
nb_damaged_elements = mat_igfem.updateDamage();
std::cout << "damaged elements: " << nb_damaged_elements << std::endl;
for (UInt i = 0; i < 5; ++i) {
std::cout << *stress_it << std::endl;
++stress_it;
}
model.dump();
model.dump("igfem elements");
} while (nb_damaged_elements);
model.dump();
model.dump("igfem elements");
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
void applyBoundaryConditions(SolidMechanicsModelIGFEM & model) {
/// boundary conditions
Mesh & mesh = model.getMesh();
mesh.computeBoundingBox();
const Vector<Real> & lowerBounds = mesh.getLowerBounds();
const Vector<Real> & upperBounds = mesh.getUpperBounds();
Real bottom = lowerBounds(1);
Real top = upperBounds(1);
Real left = lowerBounds(0);
// Real right = upperBounds(0);
Real eps = std::abs((top - bottom) * 1e-12);
const Array<Real> & pos = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & boun = model.getBlockedDOFs();
disp.clear();
boun.clear();
/// free expansion
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (std::abs(pos(i, 1) - bottom) < eps) {
boun(i, 1) = true;
disp(i, 1) = 0.0;
}
if (std::abs(pos(i, 0) - left) < eps) {
boun(i, 0) = true;
disp(i, 0) = 0.0;
}
}
}
diff --git a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction.cc b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction.cc
index 27434d8cd..69172da16 100644
--- a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction.cc
+++ b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction.cc
@@ -1,412 +1,412 @@
/**
* @file test_material_igfem_iterative_strength_reduction.cc
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Thu Nov 26 12:20:15 2015
*
* @brief test the material iterative stiffness reduction
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_damage_iterative.hh"
#include "material_igfem_saw_tooth_damage.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/// function declaration
bool checkDamageState(UInt step, const SolidMechanicsModelIGFEM & model,
bool igfem_analysis);
class TestMaterialSelector : public MaterialSelector {
public:
TestMaterialSelector(SolidMechanicsModelIGFEM & model)
: MaterialSelector(), model(model),
spatial_dimension(model.getSpatialDimension()) {}
UInt operator()(const Element & element) {
if (Mesh::getKind(element.type) == _ek_igfem)
return 2;
else {
/// regular elements
const Mesh & mesh = model.getMesh();
Vector<Real> barycenter(this->spatial_dimension);
mesh.getBarycenter(element, barycenter);
/// check if element belongs to ASR gel
if (model.isInside(barycenter))
return 1;
}
return 0;
}
protected:
SolidMechanicsModelIGFEM & model;
UInt spatial_dimension;
};
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
Math::setTolerance(1e-13);
debug::setDebugLevel(dblWarning);
initialize("material_stiffness_reduction.dat", argc, argv);
bool igfem_analysis;
std::string action(argv[1]);
if (action == "igfem") {
igfem_analysis = true;
} else if (action == "standard_fem") {
igfem_analysis = false;
} else {
std::cerr << "invalid option" << std::endl;
}
const UInt spatial_dimension = 2;
StaticCommunicator & comm =
akantu::StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// read the mesh and partion it
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
if (igfem_analysis)
mesh.read("igfem_mesh.msh");
else
mesh.read("regular_mesh.msh");
/// partition the mesh
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModelIGFEM model(mesh);
model.initParallel(partition);
delete partition;
Math::setTolerance(1.e-14);
/// intialize the geometry and set the material selector
std::list<SK::Sphere_3> inclusions_list;
model.registerGeometryObject(inclusions_list, "inclusion");
Real val = 1000000000;
Real radius_squared = val * val;
Vector<Real> center(spatial_dimension);
center(0) = 0;
center(1) = val;
SK::Sphere_3 sphere(SK::Point_3(center(0), center(1), 0.), radius_squared);
inclusions_list.push_back(sphere);
TestMaterialSelector * mat_selector = new TestMaterialSelector(model);
model.setMaterialSelector(*mat_selector);
/// initialization of the model
model.initFull();
/// create the interface
if (igfem_analysis)
model.update("inclusion");
/// boundary conditions
mesh.computeBoundingBox();
const Vector<Real> & lowerBounds = mesh.getLowerBounds();
const Vector<Real> & upperBounds = mesh.getUpperBounds();
Real bottom = lowerBounds(1);
Real top = upperBounds(1);
Real left = lowerBounds(0);
Real eps = std::abs((top - bottom) * 1e-6);
const Array<Real> & pos = mesh.getNodes();
Array<bool> & boun = model.getBlockedDOFs();
Array<Real> & disp = model.getDisplacement();
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (std::abs(pos(n, 1) - bottom) < eps) {
boun(n, 1) = true;
disp(n, 1) = 0.;
}
if (std::abs(pos(n, 1) - top) < eps) {
boun(n, 1) = true;
disp(n, 1) = 1.e-3;
}
if (std::abs(pos(n, 0) - left) < eps) {
boun(n, 0) = true;
disp(n, 0) = 0.;
}
}
/// add fields that should be dumped
model.setBaseName("regular");
model.addDumpField("material_index");
model.addDumpFieldVector("displacement");
;
model.addDumpField("stress");
model.addDumpField("blocked_dofs");
model.addDumpField("residual");
model.addDumpField("grad_u");
model.addDumpField("damage");
model.addDumpField("partitions");
model.addDumpField("Sc");
model.addDumpField("force");
model.addDumpField("equivalent_stress");
model.addDumpField("ultimate_strain");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
;
model.addDumpFieldToDumper("igfem elements", "stress");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
model.addDumpFieldToDumper("igfem elements", "residual");
model.addDumpFieldToDumper("igfem elements", "grad_u");
model.addDumpFieldToDumper("igfem elements", "damage");
model.addDumpFieldToDumper("igfem elements", "partitions");
model.addDumpFieldToDumper("igfem elements", "Sc");
model.addDumpFieldToDumper("igfem elements", "force");
model.addDumpFieldToDumper("igfem elements", "equivalent_stress");
model.addDumpFieldToDumper("igfem elements", "ultimate_strain");
model.dump();
model.dump("igfem elements");
/// get a reference to the damage materials
MaterialDamageIterative<spatial_dimension> & material =
dynamic_cast<MaterialDamageIterative<spatial_dimension> &>(
model.getMaterial(0));
MaterialIGFEMSawToothDamage<spatial_dimension> & igfem_material =
dynamic_cast<MaterialIGFEMSawToothDamage<spatial_dimension> &>(
model.getMaterial(2));
Real error;
bool converged = false;
UInt nb_damaged_elements = 0;
Real max_eq_stress_regular = 0;
Real max_eq_stress_igfem = 0;
/// solve the system
// counter for the damage steps
UInt s = 0;
do {
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-12, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-12, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
/// compute damage
max_eq_stress_regular = material.getNormMaxEquivalentStress();
max_eq_stress_igfem = igfem_material.getNormMaxEquivalentStress();
if (max_eq_stress_regular > max_eq_stress_igfem)
nb_damaged_elements = material.updateDamage();
else if (max_eq_stress_regular == max_eq_stress_igfem) {
nb_damaged_elements = material.updateDamage();
nb_damaged_elements += igfem_material.updateDamage();
} else
nb_damaged_elements = igfem_material.updateDamage();
model.dump();
model.dump("igfem elements");
/// check the current damage state
if (!checkDamageState(s, model, igfem_analysis)) {
std::cout << "error in the damage compuation" << std::endl;
finalize();
return EXIT_FAILURE;
}
s++;
} while (nb_damaged_elements);
std::cout << action << " passed!!" << std::endl;
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
bool checkDamageState(UInt step, const SolidMechanicsModelIGFEM & model,
bool igfem_analysis) {
bool test_result = true;
const UInt spatial_dimension = model.getSpatialDimension();
const Mesh & mesh = model.getMesh();
if (!igfem_analysis) {
const ElementType element_type = _triangle_3;
/// prepare output: compute barycenters for elements that can be damaged
const Array<UInt> & element_filter =
model.getMaterial(0).getElementFilter(element_type, _not_ghost);
Array<Real> barycenters(element_filter.getSize(), spatial_dimension);
Array<Real>::vector_iterator bary_it = barycenters.begin(spatial_dimension);
for (UInt e = 0; e < element_filter.getSize(); ++e, ++bary_it) {
UInt global_el_idx = element_filter(e);
mesh.getBarycenter(global_el_idx, element_type, bary_it->storage(),
_not_ghost);
}
const Array<Real> & damage = model.getMaterial(0).getInternal<Real>(
"damage")(element_type, _not_ghost);
const Array<Real> & Sc =
model.getMaterial(0).getInternal<Real>("Sc")(element_type, _not_ghost);
std::ostringstream file_name;
file_name << "step_" << std::setfill('0') << std::setw(3) << step << ".txt";
std::ofstream file_output;
file_output.open(file_name.str());
file_output << std::setprecision(14);
for (UInt e = 0; e < barycenters.getSize(); ++e)
file_output << barycenters(e, 0) << " " << barycenters(e, 1) << " "
<< damage(e) << " " << Sc(e) << std::endl;
}
else {
/// read data
Real default_tolerance = Math::getTolerance();
Math::setTolerance(1.e-10);
std::stringstream results_file;
results_file << "step_" << std::setfill('0') << std::setw(3) << step
<< ".txt";
std::ifstream damage_input;
damage_input.open(results_file.str().c_str());
Array<Real> damage_result(0, 1);
Array<Real> Sc_result(0, 1);
Array<Real> bary_regular(0, spatial_dimension);
Vector<Real> bary(spatial_dimension);
Real dam = 0.;
Real strength = 0;
while (damage_input.good()) {
damage_input >> bary(0) >> bary(1) >> dam >> strength;
bary_regular.push_back(bary);
damage_result.push_back(dam);
Sc_result.push_back(strength);
}
/// compare the results
Array<Real>::const_vector_iterator bary_it;
Array<Real>::const_vector_iterator bary_begin =
bary_regular.begin(spatial_dimension);
Array<Real>::const_vector_iterator bary_end =
bary_regular.end(spatial_dimension);
/// compare the regular elements
ElementType element_type = _triangle_3;
const Array<UInt> & element_filter =
model.getMaterial(0).getElementFilter(element_type, _not_ghost);
const Array<Real> & damage_regular_el =
model.getMaterial(0).getInternal<Real>("damage")(element_type,
_not_ghost);
const Array<Real> & Sc_regular_el =
model.getMaterial(0).getInternal<Real>("Sc")(element_type, _not_ghost);
for (UInt e = 0; e < element_filter.getSize(); ++e) {
UInt global_el_idx = element_filter(e);
mesh.getBarycenter(global_el_idx, element_type, bary.storage(),
_not_ghost);
/// find element
for (bary_it = bary_begin; bary_it != bary_end; ++bary_it) {
UInt matched_dim = 0;
while (
matched_dim < spatial_dimension &&
Math::are_float_equal(bary(matched_dim), (*bary_it)(matched_dim)))
++matched_dim;
if (matched_dim == spatial_dimension)
break;
}
if (bary_it == bary_end) {
std::cout << "Element barycenter not found!" << std::endl;
return false;
}
UInt matched_el = bary_it - bary_begin;
if (std::abs(damage_result(matched_el) - damage_regular_el(e)) > 1.e-12 ||
std::abs(Sc_result(matched_el) - Sc_regular_el(e)) > 1.e-4) {
test_result = false;
break;
}
}
/// compare the IGFEM elements
UInt nb_sub_elements = 2;
element_type = _igfem_triangle_4;
const Array<UInt> & element_filter_igfem =
model.getMaterial(2).getElementFilter(element_type, _not_ghost);
const Array<Real> & damage_regular_el_igfem =
model.getMaterial(2).getInternal<Real>("damage")(element_type,
_not_ghost);
const Array<Real> & Sc_regular_el_igfem =
model.getMaterial(2).getInternal<Real>("Sc")(element_type, _not_ghost);
UInt * sub_el_ptr =
model.getMaterial(2)
.getInternal<UInt>("sub_material")(element_type, _not_ghost)
.storage();
for (UInt e = 0; e < element_filter_igfem.getSize(); ++e) {
UInt global_el_idx = element_filter_igfem(e);
for (UInt s = 0; s < nb_sub_elements; ++s, ++sub_el_ptr) {
if (*sub_el_ptr)
model.getSubElementBarycenter(global_el_idx, s, element_type, bary,
_not_ghost);
else
continue;
/// find element
for (bary_it = bary_begin; bary_it != bary_end; ++bary_it) {
UInt matched_dim = 0;
while (
matched_dim < spatial_dimension &&
Math::are_float_equal(bary(matched_dim), (*bary_it)(matched_dim)))
++matched_dim;
if (matched_dim == spatial_dimension)
break;
}
if (bary_it == bary_end) {
std::cout << "Element barycenter not found!" << std::endl;
return false;
}
UInt matched_el = bary_it - bary_begin;
if (std::abs(damage_result(matched_el) -
damage_regular_el_igfem(e * nb_sub_elements + s)) >
1.e-12 ||
std::abs(Sc_result(matched_el) -
Sc_regular_el_igfem(e * nb_sub_elements + s)) > 1.e-4) {
test_result = false;
break;
}
}
}
Math::setTolerance(default_tolerance);
}
return test_result;
}
diff --git a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_damage_step_transfer.cc b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_damage_step_transfer.cc
index 9f3a24768..f2d1afee5 100644
--- a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_damage_step_transfer.cc
+++ b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_damage_step_transfer.cc
@@ -1,364 +1,363 @@
/**
* @file
* test_material_igfem_iterative_stiffness_reduction_damage_step_transfer.cc
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Thu Nov 26 12:20:15 2015
*
* @brief test the damage step transfer for the material iterative
* stiffness reduction
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_igfem_saw_tooth_damage.hh"
#include "material_iterative_stiffness_reduction.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
class TestMaterialSelector : public MaterialSelector {
public:
TestMaterialSelector(SolidMechanicsModelIGFEM & model)
: MaterialSelector(), model(model),
spatial_dimension(model.getSpatialDimension()) {}
UInt operator()(const Element & element) {
if (Mesh::getKind(element.type) == _ek_igfem)
return 2;
else {
/// regular elements
const Mesh & mesh = model.getMesh();
Vector<Real> barycenter(this->spatial_dimension);
mesh.getBarycenter(element, barycenter);
/// check if element belongs to ASR gel
if (model.isInside(barycenter))
return 1;
}
return 0;
}
protected:
SolidMechanicsModelIGFEM & model;
UInt spatial_dimension;
};
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
Math::setTolerance(1e-13);
debug::setDebugLevel(dblWarning);
initialize("material_stiffness_reduction_2.dat", argc, argv);
const UInt spatial_dimension = 2;
StaticCommunicator & comm =
akantu::StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// read the mesh and partion it
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
mesh.read("test_damage_transfer.msh");
/// partition the mesh
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModelIGFEM model(mesh);
model.initParallel(partition);
delete partition;
Math::setTolerance(1.e-14);
/// intialize the geometry and set the material selector
std::list<SK::Sphere_3> inclusions_list;
model.registerGeometryObject(inclusions_list, "inclusion");
Real val = 1000000000;
Real radius_squared = (val - 0.6) * (val - 0.6);
Vector<Real> center(spatial_dimension);
center(0) = 0;
center(1) = val;
SK::Sphere_3 sphere(SK::Point_3(center(0), center(1), 0.), radius_squared);
inclusions_list.push_back(sphere);
TestMaterialSelector * mat_selector = new TestMaterialSelector(model);
model.setMaterialSelector(*mat_selector);
/// initialization of the model
model.initFull();
/// boundary conditions
mesh.computeBoundingBox();
const Vector<Real> & lowerBounds = mesh.getLowerBounds();
const Vector<Real> & upperBounds = mesh.getUpperBounds();
Real bottom = lowerBounds(1);
Real top = upperBounds(1);
Real left = lowerBounds(0);
Real eps = std::abs((top - bottom) * 1e-6);
const Array<Real> & pos = mesh.getNodes();
Array<bool> & boun = model.getBlockedDOFs();
Array<Real> & disp = model.getDisplacement();
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (std::abs(pos(n, 1) - bottom) < eps) {
boun(n, 1) = true;
disp(n, 1) = 0.;
}
if (std::abs(pos(n, 1) - top) < eps) {
boun(n, 1) = true;
disp(n, 1) = 1.e-3;
}
if (std::abs(pos(n, 0) - left) < eps) {
boun(n, 0) = true;
disp(n, 0) = 0.;
}
}
/// add fields that should be dumped
model.setBaseName("regular");
model.addDumpField("material_index");
model.addDumpFieldVector("displacement");
;
model.addDumpField("stress");
model.addDumpField("blocked_dofs");
model.addDumpField("residual");
model.addDumpField("grad_u");
model.addDumpField("damage");
model.addDumpField("partitions");
model.addDumpField("Sc");
model.addDumpField("force");
model.addDumpField("equivalent_stress");
model.addDumpField("ultimate_strain");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
;
model.addDumpFieldToDumper("igfem elements", "stress");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
model.addDumpFieldToDumper("igfem elements", "residual");
model.addDumpFieldToDumper("igfem elements", "grad_u");
model.addDumpFieldToDumper("igfem elements", "damage");
model.addDumpFieldToDumper("igfem elements", "partitions");
model.addDumpFieldToDumper("igfem elements", "Sc");
model.addDumpFieldToDumper("igfem elements", "force");
model.addDumpFieldToDumper("igfem elements", "equivalent_stress");
model.addDumpFieldToDumper("igfem elements", "ultimate_strain");
model.dump();
model.dump("igfem elements");
/// get a reference to the damage materials
MaterialIterativeStiffnessReduction<spatial_dimension> & material =
dynamic_cast<MaterialIterativeStiffnessReduction<spatial_dimension> &>(
model.getMaterial(0));
MaterialIGFEMSawToothDamage<spatial_dimension> & igfem_material =
dynamic_cast<MaterialIGFEMSawToothDamage<spatial_dimension> &>(
model.getMaterial(2));
Real error;
bool converged = false;
UInt nb_damaged_elements = 0;
Real max_eq_stress_regular = 0;
Real max_eq_stress_igfem = 0;
/// solve the system
// counter for the damage steps
UInt regular_steps = 15;
for (UInt s = 0; s < regular_steps; ++s) {
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-12, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-12, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
/// compute damage
max_eq_stress_regular = material.getNormMaxEquivalentStress();
max_eq_stress_igfem = igfem_material.getNormMaxEquivalentStress();
if (max_eq_stress_regular > max_eq_stress_igfem)
nb_damaged_elements = material.updateDamage();
else if (max_eq_stress_regular == max_eq_stress_igfem) {
nb_damaged_elements = material.updateDamage();
nb_damaged_elements += igfem_material.updateDamage();
} else
nb_damaged_elements = igfem_material.updateDamage();
if (!nb_damaged_elements)
break;
model.dump();
model.dump("igfem elements");
}
const Array<UInt> & reduction_step_regular =
material.getInternal<UInt>("damage_step")(_triangle_3, _not_ghost);
UInt reduction_step_el_27 = reduction_step_regular(27);
UInt reduction_step_el_19 = reduction_step_regular(19);
/// create the interface
Real new_radius = (val - 0.1);
model.moveInterface(new_radius);
model.dump();
model.dump("igfem elements");
/// check that the damage reduction step has been correctly computed
/// regular element id -> igfem element id
/// 27 -> 7; 19 -> 5
const Array<UInt> & reduction_step_igfem = igfem_material.getInternal<UInt>(
"damage_step")(_igfem_triangle_5, _not_ghost);
Array<UInt>::const_scalar_iterator step_it = reduction_step_igfem.begin();
/// check the igfem elements
UInt nb_igfem_elements = mesh.getNbElement(_igfem_triangle_5, _not_ghost);
UInt nb_quads = model.getFEEngine("IGFEMFEEngine")
.getNbIntegrationPoints(_igfem_triangle_5, _not_ghost);
const Array<UInt> & sub_material = igfem_material.getInternal<UInt>(
"sub_material")(_igfem_triangle_5, _not_ghost);
Array<UInt>::const_scalar_iterator sub_it = sub_material.begin();
for (UInt e = 0; e < nb_igfem_elements; ++e) {
for (UInt q = 0; q < nb_quads; ++q, ++sub_it, ++step_it) {
if (!*sub_it) {
if (!Math::are_float_equal(*step_it, 0.)) {
std::cout
<< "the reduction step for an elastic sub-element must be zero!!"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
} else {
if (e == 7) {
if (!Math::are_float_equal(*step_it, reduction_step_el_27)) {
std::cout << "error in computation of damage step!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
} else if (e == 5) {
if (!Math::are_float_equal(*step_it, reduction_step_el_19)) {
std::cout << "error in computation of damage step!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
} else {
if (!Math::are_float_equal(*step_it, 0.)) {
std::cout << "error in computation of damage step!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
}
}
}
}
//// force the next damage event
const Array<Real> & dam_igfem =
igfem_material.getInternal<Real>("damage")(_igfem_triangle_5, _not_ghost);
Array<Real> old_damage(dam_igfem);
for (UInt s = 0; s < 1; ++s) {
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-12, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-12, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
/// compute damage
max_eq_stress_regular = material.getNormMaxEquivalentStress();
max_eq_stress_igfem = igfem_material.getNormMaxEquivalentStress();
if (max_eq_stress_regular > max_eq_stress_igfem)
nb_damaged_elements = material.updateDamage();
else if (max_eq_stress_regular == max_eq_stress_igfem) {
nb_damaged_elements = material.updateDamage();
nb_damaged_elements += igfem_material.updateDamage();
} else
nb_damaged_elements = igfem_material.updateDamage();
if (!nb_damaged_elements)
break;
model.dump();
model.dump("igfem elements");
}
/// check that damage has been simultanously been updated on all the
/// the integration points of one sub-element
const Array<Real> & new_dam_igfem =
igfem_material.getInternal<Real>("damage")(_igfem_triangle_5, _not_ghost);
sub_it = sub_material.begin();
Array<Real>::const_scalar_iterator new_dam_it = new_dam_igfem.begin();
Array<Real>::const_scalar_iterator old_dam_it = old_damage.begin();
step_it = reduction_step_igfem.begin();
UInt reduction_constant = material.getParam<Real>("reduction_constant");
for (UInt e = 0; e < nb_igfem_elements; ++e) {
for (UInt q = 0; q < nb_quads;
++q, ++sub_it, ++step_it, ++new_dam_it, ++old_dam_it) {
if (!*sub_it) {
if (!Math::are_float_equal(*step_it, 0.) ||
!Math::are_float_equal(*new_dam_it, 0.)) {
std::cout << "the reduction step and damagefor an elastic "
"sub-element must be zero!!"
<< std::endl;
finalize();
return EXIT_FAILURE;
}
} else {
if (e == 7) {
if (!Math::are_float_equal(*step_it, reduction_step_el_27 + 1) ||
!Math::are_float_equal(
- *new_dam_it,
- 1 - (1. / std::pow(reduction_constant,
- reduction_step_el_27 + 1)))) {
+ *new_dam_it, 1 - (1. / std::pow(reduction_constant,
+ reduction_step_el_27 + 1)))) {
std::cout << "error in computation of damage step!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
} else if (e == 5) {
if (!Math::are_float_equal(*step_it, reduction_step_el_19) ||
!Math::are_float_equal(*new_dam_it, *old_dam_it)) {
std::cout << "error in computation of damage step!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
} else {
if (!Math::are_float_equal(*step_it, 0.) ||
!Math::are_float_equal(*new_dam_it, 0.)) {
std::cout << "error in computation of damage step!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
}
}
}
}
finalize();
return EXIT_SUCCESS;
}
diff --git a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_parallel.cc b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_parallel.cc
index e9d493e5f..4fc8896c0 100644
--- a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_parallel.cc
+++ b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_material_igfem_iterative_stiffness_reduction_parallel.cc
@@ -1,437 +1,437 @@
/**
* @file test_material_igfem_iterative_stiffness_reduction_parallel.cc
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @date Thu Nov 26 12:20:15 2015
*
* @brief test the material iterative stiffness reduction in parallel
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_igfem_saw_tooth_damage.hh"
#include "material_iterative_stiffness_reduction.hh"
#include "solid_mechanics_model_igfem.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/// function declaration
bool checkDamageState(UInt step, const SolidMechanicsModelIGFEM & model);
class TestMaterialSelector : public MaterialSelector {
public:
TestMaterialSelector(SolidMechanicsModelIGFEM & model)
: MaterialSelector(), model(model),
spatial_dimension(model.getSpatialDimension()) {}
UInt operator()(const Element & element) {
if (Mesh::getKind(element.type) == _ek_igfem)
return 2;
else {
/// regular elements
const Mesh & mesh = model.getMesh();
Vector<Real> barycenter(this->spatial_dimension);
mesh.getBarycenter(element, barycenter);
/// check if element belongs to ASR gel
if (model.isInside(barycenter))
return 1;
}
return 0;
}
protected:
SolidMechanicsModelIGFEM & model;
UInt spatial_dimension;
};
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
Math::setTolerance(1e-13);
debug::setDebugLevel(dblWarning);
initialize("material_stiffness_reduction_2.dat", argc, argv);
const UInt spatial_dimension = 2;
StaticCommunicator & comm =
akantu::StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// read the mesh and partion it
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
mesh.read("test_damage_transfer.msh");
/// partition the mesh
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModelIGFEM model(mesh);
model.initParallel(partition);
delete partition;
Math::setTolerance(1.e-14);
/// intialize the geometry and set the material selector
std::list<SK::Sphere_3> inclusions_list;
model.registerGeometryObject(inclusions_list, "inclusion");
Real radius = 0.125;
;
Vector<Real> center(spatial_dimension);
center(0) = 0.;
center(1) = 0.;
SK::Sphere_3 sphere(SK::Point_3(center(0), center(1), 0.), radius * radius);
inclusions_list.push_back(sphere);
TestMaterialSelector * mat_selector = new TestMaterialSelector(model);
model.setMaterialSelector(*mat_selector);
/// initialization of the model
model.initFull();
/// boundary conditions
mesh.computeBoundingBox();
const Vector<Real> & lowerBounds = mesh.getLowerBounds();
const Vector<Real> & upperBounds = mesh.getUpperBounds();
Real bottom = lowerBounds(1);
Real top = upperBounds(1);
Real left = lowerBounds(0);
Real eps = std::abs((top - bottom) * 1e-6);
const Array<Real> & pos = mesh.getNodes();
Array<bool> & boun = model.getBlockedDOFs();
Array<Real> & disp = model.getDisplacement();
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (std::abs(pos(n, 1) - bottom) < eps) {
boun(n, 1) = true;
disp(n, 1) = 0.;
}
if (std::abs(pos(n, 1) - top) < eps) {
boun(n, 1) = true;
disp(n, 1) = 1.e-3;
}
if (std::abs(pos(n, 0) - left) < eps) {
boun(n, 0) = true;
disp(n, 0) = 0.;
}
}
/// add fields that should be dumped
model.setBaseName("regular");
model.addDumpField("material_index");
model.addDumpFieldVector("displacement");
;
model.addDumpField("stress");
model.addDumpField("blocked_dofs");
model.addDumpField("residual");
model.addDumpField("grad_u");
model.addDumpField("damage");
model.addDumpField("partitions");
model.addDumpField("Sc");
model.addDumpField("force");
model.addDumpField("equivalent_stress");
model.addDumpField("ultimate_strain");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
;
model.addDumpFieldToDumper("igfem elements", "stress");
model.addDumpFieldToDumper("igfem elements", "blocked_dofs");
model.addDumpFieldToDumper("igfem elements", "residual");
model.addDumpFieldToDumper("igfem elements", "grad_u");
model.addDumpFieldToDumper("igfem elements", "damage");
model.addDumpFieldToDumper("igfem elements", "partitions");
model.addDumpFieldToDumper("igfem elements", "Sc");
model.addDumpFieldToDumper("igfem elements", "force");
model.addDumpFieldToDumper("igfem elements", "equivalent_stress");
model.addDumpFieldToDumper("igfem elements", "ultimate_strain");
model.dump();
model.dump("igfem elements");
/// create the interface
model.update("inclusion");
/// get a reference to the damage materials
MaterialIterativeStiffnessReduction<spatial_dimension> & material =
dynamic_cast<MaterialIterativeStiffnessReduction<spatial_dimension> &>(
model.getMaterial(0));
MaterialIGFEMSawToothDamage<spatial_dimension> & igfem_material =
dynamic_cast<MaterialIGFEMSawToothDamage<spatial_dimension> &>(
model.getMaterial(2));
Real error;
bool converged = false;
UInt nb_damaged_elements = 0;
Real max_eq_stress_regular = 0;
Real max_eq_stress_igfem = 0;
/// solve the system
UInt s = 0;
do {
converged =
- model.solveStep<_scm_newton_raphson_tangent_modified, SolveConvergenceCriteria::_increment>(
- 1e-12, error, 2);
+ model.solveStep<_scm_newton_raphson_tangent_modified,
+ SolveConvergenceCriteria::_increment>(1e-12, error, 2);
if (converged == false) {
std::cout << "The error is: " << error << std::endl;
AKANTU_DEBUG_ASSERT(converged, "Did not converge");
}
/// compute damage
max_eq_stress_regular = material.getNormMaxEquivalentStress();
max_eq_stress_igfem = igfem_material.getNormMaxEquivalentStress();
if (max_eq_stress_regular > max_eq_stress_igfem)
nb_damaged_elements = material.updateDamage();
else if (max_eq_stress_regular == max_eq_stress_igfem) {
nb_damaged_elements = material.updateDamage();
nb_damaged_elements += igfem_material.updateDamage();
} else
nb_damaged_elements = igfem_material.updateDamage();
model.dump();
model.dump("igfem elements");
/// check the current damage state
if (!checkDamageState(s, model)) {
std::cout << "error in the damage compuation" << std::endl;
finalize();
return EXIT_FAILURE;
}
s++;
} while (nb_damaged_elements);
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
bool checkDamageState(UInt step, const SolidMechanicsModelIGFEM & model) {
bool test_result = true;
const UInt spatial_dimension = model.getSpatialDimension();
const Mesh & mesh = model.getMesh();
StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
if (psize == 1) {
const ElementType element_type = _triangle_3;
/// prepare output: compute barycenters for elements that can be damaged
const Array<UInt> & element_filter =
model.getMaterial(0).getElementFilter(element_type, _not_ghost);
Array<Real> barycenters(element_filter.getSize(), spatial_dimension);
Array<Real>::vector_iterator bary_it = barycenters.begin(spatial_dimension);
for (UInt e = 0; e < element_filter.getSize(); ++e, ++bary_it) {
UInt global_el_idx = element_filter(e);
mesh.getBarycenter(global_el_idx, element_type, bary_it->storage(),
_not_ghost);
}
const Array<Real> & damage = model.getMaterial(0).getInternal<Real>(
"damage")(element_type, _not_ghost);
const Array<Real> & Sc =
model.getMaterial(0).getInternal<Real>("Sc")(element_type, _not_ghost);
std::ostringstream file_name;
file_name << "step_" << std::setfill('0') << std::setw(3) << step << ".txt";
std::ofstream file_output;
file_output.open(file_name.str());
file_output << std::setprecision(14);
for (UInt e = 0; e < barycenters.getSize(); ++e)
file_output << barycenters(e, 0) << " " << barycenters(e, 1) << " "
<< damage(e) << " " << Sc(e) << std::endl;
/// igfem elements
const ElementType element_type_igfem = _igfem_triangle_5;
/// prepare output: compute barycenters for elements that can be damaged
UInt nb_igfem_elements = mesh.getNbElement(_igfem_triangle_5, _not_ghost);
UInt nb_sub_elements = 2;
Array<Real> barycenters_igfem(nb_sub_elements * nb_igfem_elements,
spatial_dimension);
bary_it = barycenters_igfem.begin(spatial_dimension);
for (UInt e = 0; e < nb_igfem_elements; ++e) {
/// note global index is local index because there is only one igfem
/// material
for (UInt s = 0; s < nb_sub_elements; ++s, ++bary_it)
model.getSubElementBarycenter(e, s, element_type_igfem, *bary_it,
_not_ghost);
}
const Array<Real> & damage_igfem = model.getMaterial(2).getInternal<Real>(
"damage")(element_type_igfem, _not_ghost);
Array<Real>::const_scalar_iterator dam_it = damage_igfem.begin();
const Array<Real> & Sc_igfem = model.getMaterial(2).getInternal<Real>("Sc")(
element_type_igfem, _not_ghost);
Array<Real>::const_scalar_iterator Sc_it = Sc_igfem.begin();
for (UInt e = 0; e < nb_igfem_elements; ++e) {
for (UInt s = 0; s < nb_sub_elements; ++s)
if (IGFEMHelper::getSubElementType(element_type_igfem, s) ==
_triangle_3) {
file_output << barycenters_igfem(e * nb_sub_elements + s, 0) << " "
<< barycenters_igfem(e * nb_sub_elements + s, 1) << " "
<< *dam_it << " " << *Sc_it << std::endl;
++dam_it;
++Sc_it;
} else if (IGFEMHelper::getSubElementType(element_type_igfem, s) ==
_quadrangle_4) {
file_output << barycenters_igfem(e * nb_sub_elements + s, 0) << " "
<< barycenters_igfem(e * nb_sub_elements + s, 1) << " "
<< *dam_it << " " << *Sc_it << std::endl;
dam_it += 4;
Sc_it += 4;
}
}
}
else {
/// read data
Real default_tolerance = Math::getTolerance();
Math::setTolerance(1.e-10);
std::stringstream results_file;
results_file << "step_" << std::setfill('0') << std::setw(3) << step
<< ".txt";
std::ifstream damage_input;
damage_input.open(results_file.str().c_str());
Array<Real> damage_result(0, 1);
Array<Real> Sc_result(0, 1);
Array<Real> bary_regular(0, spatial_dimension);
Vector<Real> bary(spatial_dimension);
Real dam = 0.;
Real strength = 0;
while (damage_input.good()) {
damage_input >> bary(0) >> bary(1) >> dam >> strength;
bary_regular.push_back(bary);
damage_result.push_back(dam);
Sc_result.push_back(strength);
}
/// compare the results
Array<Real>::const_vector_iterator bary_it;
Array<Real>::const_vector_iterator bary_begin =
bary_regular.begin(spatial_dimension);
Array<Real>::const_vector_iterator bary_end =
bary_regular.end(spatial_dimension);
/// compare the regular elements
ElementType element_type = _triangle_3;
const Array<UInt> & element_filter =
model.getMaterial(0).getElementFilter(element_type, _not_ghost);
const Array<Real> & damage_regular_el =
model.getMaterial(0).getInternal<Real>("damage")(element_type,
_not_ghost);
const Array<Real> & Sc_regular_el =
model.getMaterial(0).getInternal<Real>("Sc")(element_type, _not_ghost);
for (UInt e = 0; e < element_filter.getSize(); ++e) {
UInt global_el_idx = element_filter(e);
mesh.getBarycenter(global_el_idx, element_type, bary.storage(),
_not_ghost);
/// find element
for (bary_it = bary_begin; bary_it != bary_end; ++bary_it) {
UInt matched_dim = 0;
while (
matched_dim < spatial_dimension &&
Math::are_float_equal(bary(matched_dim), (*bary_it)(matched_dim)))
++matched_dim;
if (matched_dim == spatial_dimension)
break;
}
if (bary_it == bary_end) {
std::cout << "Element barycenter not found!" << std::endl;
return false;
}
UInt matched_el = bary_it - bary_begin;
if (std::abs(damage_result(matched_el) - damage_regular_el(e)) > 1.e-12 ||
std::abs(Sc_result(matched_el) - Sc_regular_el(e)) > 1.e-4) {
test_result = false;
break;
}
}
/// compare the IGFEM elements
UInt nb_sub_elements = 2;
element_type = _igfem_triangle_5;
const Array<UInt> & element_filter_igfem =
model.getMaterial(2).getElementFilter(element_type, _not_ghost);
const Array<Real> & damage_regular_el_igfem =
model.getMaterial(2).getInternal<Real>("damage")(element_type,
_not_ghost);
Array<Real>::const_scalar_iterator dam_igfem_it =
damage_regular_el_igfem.begin();
const Array<Real> & Sc_regular_el_igfem =
model.getMaterial(2).getInternal<Real>("Sc")(element_type, _not_ghost);
Array<Real>::const_scalar_iterator Sc_igfem_it =
Sc_regular_el_igfem.begin();
for (UInt e = 0; e < element_filter_igfem.getSize(); ++e) {
UInt global_el_idx = element_filter_igfem(e);
for (UInt s = 0; s < nb_sub_elements; ++s) {
model.getSubElementBarycenter(global_el_idx, s, element_type, bary,
_not_ghost);
/// find element
for (bary_it = bary_begin; bary_it != bary_end; ++bary_it) {
UInt matched_dim = 0;
while (
matched_dim < spatial_dimension &&
Math::are_float_equal(bary(matched_dim), (*bary_it)(matched_dim)))
++matched_dim;
if (matched_dim == spatial_dimension)
break;
}
if (bary_it == bary_end) {
std::cout << "Sub-element barycenter not found!" << std::endl;
return false;
}
UInt matched_el = bary_it - bary_begin;
if (std::abs(damage_result(matched_el) - *dam_igfem_it) > 1.e-12 ||
std::abs(Sc_result(matched_el) - *Sc_igfem_it) > 1.e-4) {
test_result = false;
break;
}
if (IGFEMHelper::getSubElementType(element_type, s) == _triangle_3) {
++Sc_igfem_it;
++dam_igfem_it;
} else if (IGFEMHelper::getSubElementType(element_type, s) ==
_quadrangle_4) {
Sc_igfem_it += 4;
dam_igfem_it += 4;
}
}
}
Math::setTolerance(default_tolerance);
}
return test_result;
}
diff --git a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_solid_mechanics_model_igfem.cc b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_solid_mechanics_model_igfem.cc
index 578406397..e213467ab 100644
--- a/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_solid_mechanics_model_igfem.cc
+++ b/extra_packages/igfem/test/test_solid_mechanics_model_igfem/test_solid_mechanics_model_igfem.cc
@@ -1,337 +1,338 @@
/**
* @file test_solid_mechanics_model_igfem.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
*
* @brief test the solidmechancis model for IGFEM analysis
*
* @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 "aka_common.hh"
#include "dumper_paraview.hh"
#include "material_elastic.hh"
#include "mesh_geom_common.hh"
#include "solid_mechanics_model_igfem.hh"
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <math.h>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
void outputArray(const Mesh & mesh, const Array<Real> & array) {
StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
Int prank = comm.whoAmI();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_global_nodes = mesh.getNbGlobalNodes();
Array<Real> solution(nb_global_nodes, spatial_dimension, 0.);
Array<Real>::vector_iterator solution_begin =
solution.begin(spatial_dimension);
Array<Real>::const_vector_iterator array_it = array.begin(spatial_dimension);
for (UInt n = 0; n < mesh.getNbNodes(); ++n, ++array_it) {
if (mesh.isLocalOrMasterNode(n))
solution_begin[mesh.getNodeGlobalId(n)] = *array_it;
}
comm.allReduce(solution.storage(),
solution.getSize() * solution.getNbComponent(), _so_sum);
std::cout << std::fixed;
std::cout << std::setprecision(6);
if (prank == 0) {
Array<Real>::const_vector_iterator sol_it =
solution.begin(spatial_dimension);
for (UInt n = 0; n < nb_global_nodes; ++n, ++sol_it)
// Print absolute values to avoid parasite negative sign in machine
// precision zeros
std::cout << std::abs((*sol_it)(0)) << "," << std::abs((*sol_it)(1))
<< std::endl;
}
}
/* -------------------------------------------------------------------------- */
class Sphere {
public:
Sphere(const Vector<Real> & center, Real radius, Real tolerance = 0.)
: center(center), radius(radius), tolerance(tolerance) {}
bool isInside(const Vector<Real> & point) const {
return (point.distance(center) < radius + tolerance);
}
const Vector<Real> & getCenter() const { return center; }
Real & getRadius() { return radius; }
protected:
Vector<Real> center;
Real radius, tolerance;
};
void growGel(std::list<SK::Sphere_3> & query_list, Real new_radius) {
std::list<SK::Sphere_3>::const_iterator query_it = query_list.begin(),
query_end = query_list.end();
std::list<SK::Sphere_3> sphere_list;
for (; query_it != query_end; ++query_it) {
SK::Sphere_3 sphere(query_it->center(), new_radius * new_radius);
sphere_list.push_back(sphere);
}
query_list.clear();
query_list = sphere_list;
}
Real computeAlpha(Real inner_radius, Real outer_radius,
const Vector<Real> & lambda, const Vector<Real> & mu) {
Real alpha = (lambda(1) + mu(1) + mu(0)) * outer_radius * outer_radius /
((lambda(0) + mu(0)) * inner_radius * inner_radius +
(lambda(1) + mu(1)) * (outer_radius * outer_radius -
inner_radius * inner_radius) +
(mu(0) * outer_radius * outer_radius));
return alpha;
}
void applyBoundaryConditions(SolidMechanicsModelIGFEM & model,
Real inner_radius, Real outer_radius,
const Vector<Real> & lambda,
const Vector<Real> & mu) {
/// boundary conditions for circular inclusion:
Real alpha = computeAlpha(inner_radius, outer_radius, lambda, mu);
Mesh & mesh = model.getMesh();
mesh.computeBoundingBox();
const Vector<Real> & lowerBounds = mesh.getLowerBounds();
const Vector<Real> & upperBounds = mesh.getUpperBounds();
Real bottom = lowerBounds(1);
Real top = upperBounds(1);
Real left = lowerBounds(0);
Real right = upperBounds(0);
Real eps = std::abs((top - bottom) * 1e-12);
const Array<Real> & pos = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & boun = model.getBlockedDOFs();
Real radius = 0;
Real phi = 0;
disp.clear();
boun.clear();
/// absolute confinement
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (std::abs(pos(i, 0) - left) < eps) {
radius = std::sqrt(pos(i, 0) * pos(i, 0) + pos(i, 1) * pos(i, 1));
phi = std::atan2(pos(i, 1), pos(i, 0));
boun(i, 0) = true;
disp(i, 0) = cos(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
boun(i, 1) = true;
disp(i, 1) = sin(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
}
if (std::abs(pos(i, 0) - right) < eps) {
radius = std::sqrt(pos(i, 0) * pos(i, 0) + pos(i, 1) * pos(i, 1));
phi = std::atan2(pos(i, 1), pos(i, 0));
boun(i, 0) = true;
disp(i, 0) = cos(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
boun(i, 1) = true;
disp(i, 1) = sin(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
}
if (std::abs(pos(i, 1) - top) < eps) {
radius = std::sqrt(pos(i, 0) * pos(i, 0) + pos(i, 1) * pos(i, 1));
phi = std::atan2(pos(i, 1), pos(i, 0));
boun(i, 0) = true;
disp(i, 0) = cos(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
boun(i, 1) = true;
disp(i, 1) = sin(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
}
if (std::abs(pos(i, 1) - bottom) < eps) {
radius = std::sqrt(pos(i, 0) * pos(i, 0) + pos(i, 1) * pos(i, 1));
phi = std::atan2(pos(i, 1), pos(i, 0));
boun(i, 0) = true;
disp(i, 0) = cos(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
boun(i, 1) = true;
disp(i, 1) = sin(phi) * ((radius - 4. / radius) * alpha + 4. / radius);
}
}
}
class SphereMaterialSelector : public DefaultMaterialIGFEMSelector {
public:
SphereMaterialSelector(std::vector<Sphere> & sphere_list,
SolidMechanicsModelIGFEM & model)
: DefaultMaterialIGFEMSelector(model), model(model),
spheres(sphere_list) {}
UInt operator()(const Element & elem) {
if (Mesh::getKind(elem.type) == _ek_igfem)
return this->fallback_value_igfem;
// return 2;//2model.getMaterialIndex(2);
const Mesh & mesh = model.getMesh();
UInt spatial_dimension = model.getSpatialDimension();
Vector<Real> barycenter(spatial_dimension);
mesh.getBarycenter(elem, barycenter);
std::vector<Sphere>::const_iterator iit = spheres.begin();
std::vector<Sphere>::const_iterator eit = spheres.end();
for (; iit != eit; ++iit) {
const Sphere & sp = *iit;
if (sp.isInside(barycenter)) {
return 1; // model.getMaterialIndex("inside");;
}
}
return 0;
// return DefaultMaterialSelector::operator()(elem);
}
void update(Real new_radius) {
std::vector<Sphere>::iterator iit = spheres.begin();
std::vector<Sphere>::iterator eit = spheres.end();
for (; iit != eit; ++iit) {
Real & radius = iit->getRadius();
radius = new_radius;
}
}
protected:
SolidMechanicsModelIGFEM & model;
std::vector<Sphere> spheres;
};
typedef Spherical SK;
/// the following modeling problem is explained in:
/// T.-P. Fries "A corrected XFEM approximation without problems in blending
/// elements", 2008
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
/// problem dimension
const UInt spatial_dimension = 2;
StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// mesh creation
Mesh mesh(spatial_dimension);
akantu::MeshPartition * partition = NULL;
if (prank == 0) {
mesh.read("plate.msh");
partition = new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
}
/// model creation
SolidMechanicsModelIGFEM model(mesh);
model.initParallel(partition);
delete partition;
Math::setTolerance(1e-14);
/// geometry of IGFEM interface: circular inclusion
Real radius_inclusion = 0.401;
Vector<Real> center(spatial_dimension, 0.);
/// @todo: Simplify this: need to create two type of spheres:
/// one for the geometry and one for the material selector
SK::Sphere_3 sphere(SK::Point_3(center(0), center(1), 0),
radius_inclusion * radius_inclusion);
std::list<SK::Sphere_3> sphere_list;
sphere_list.push_back(sphere);
ID domain_name = "gel";
SphereMaterialSelector * mat_selector;
/// set material selector and initialize the model completely
std::vector<Sphere> spheres;
spheres.push_back(Sphere(center, radius_inclusion, 1.e-12));
mat_selector = new SphereMaterialSelector(spheres, model);
model.setMaterialSelector(*mat_selector);
model.initFull();
/// register the sphere list in the model
model.registerGeometryObject(sphere_list, domain_name);
/// add fields that should be dumped
model.setBaseName("regular_elements");
model.setBaseNameToDumper("igfem elements", "igfem elements");
model.addDumpField("material_index");
model.addDumpField("partitions");
model.addDumpFieldVector("displacement");
model.addDumpField("blocked_dofs");
model.addDumpField("stress");
model.addDumpFieldToDumper("igfem elements", "lambda");
model.addDumpFieldVectorToDumper("igfem elements", "real_displacement");
model.addDumpFieldVectorToDumper("igfem elements", "displacement");
model.addDumpFieldToDumper("igfem elements", "material_index");
model.addDumpFieldToDumper("igfem elements", "stress");
model.addDumpFieldToDumper("igfem elements", "partitions");
/// dump mesh before the IGFEM interface is created
model.dump();
model.dump("igfem elements");
/// create the interface
model.update(domain_name);
/* --------------------------------------------------------------------------
*/
/// apply exact solution for the displacement along the outer boundary
Real outer_radius = 2.0;
/// get the Lame constants for the two non-igfem materials (frist two
/// materials in the material file):
/// Needed for compuation of boundary conditions
Vector<Real> lambda(2);
Vector<Real> mu(2);
for (UInt m = 0; m < 2; ++m) {
MaterialElastic<spatial_dimension> & mat =
dynamic_cast<MaterialElastic<spatial_dimension> &>(
model.getMaterial(m));
lambda(m) = mat.getLambda();
mu(m) = mat.getMu();
}
applyBoundaryConditions(model, radius_inclusion, outer_radius, lambda, mu);
/// dump the mesh after the IGFEM interface has been created
model.dump();
model.dump("igfem elements");
/// solve the system
bool factorize = false;
bool converged = false;
Real error;
- converged = model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ converged = model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
1e-12, error, 2, factorize);
if (!converged) {
std::cout << "Solving step did not yield a converged solution, error: "
<< error << std::endl;
return EXIT_FAILURE;
}
/// dump the solution
model.dump();
model.dump("igfem elements");
/// output the displacement in parallel
outputArray(mesh, model.getDisplacement());
finalize();
return EXIT_SUCCESS;
}
diff --git a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh
index 014e6959f..47be2aa6e 100644
--- a/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh
+++ b/extra_packages/traction-at-split-node-contact/src/boundary_conditions/force_based_dirichlet.hh
@@ -1,128 +1,129 @@
/**
* @file force_based_dirichlet.hh
*
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief dirichlet boundary condition that tries
* to keep the force at a given value
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_FORCE_BASED_DIRICHLET_HH__
#define __AST_FORCE_BASED_DIRICHLET_HH__
// akantu
#include "aka_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class ForceBasedDirichlet : public BC::Dirichlet::IncrementValue {
protected:
typedef const Array<Real> * RealArrayPtr;
typedef const Array<Int> * 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() {
this->total_residual = 0.;
for (auto && subboundary : this->subboundaries) {
- this->total_residual += integrateResidual(subboundary, this->model, this->axis);
+ this->total_residual +=
+ integrateResidual(subboundary, 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();
for (auto && subboundary : this->subboundaries) {
this->model.applyBC(*this, subboundary);
}
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<std::string> SubBoundarySet;
protected:
SolidMechanicsModel & model;
SubBoundarySet subboundaries;
Real mass;
Real velocity;
Real target_force;
Real total_residual;
};
} // namespace akantu
#endif /* __AST_FORCE_BASED_DIRICHLET_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc
index 26e97e945..89b234669 100644
--- a/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc
+++ b/extra_packages/traction-at-split-node-contact/src/common/synchronized_array.cc
@@ -1,245 +1,244 @@
/**
* @file synchronized_array.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of synchronized array function
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// std
#include <fstream>
#include <iostream>
// simtools
#include "synchronized_array.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class T>
SynchronizedArray<T>::SynchronizedArray(
UInt size, UInt nb_component, SynchronizedArray<T>::const_reference value,
const ID & id, SynchronizedArray<T>::const_reference default_value,
const std::string restart_name)
: SynchronizedArrayBase(), Array<T>(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 <class T>
void SynchronizedArray<T>::syncElements(SyncChoice sync_choice) {
AKANTU_DEBUG_IN();
if (sync_choice == _deleted) {
std::vector<SynchronizedArrayBase *>::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<SynchronizedArrayBase *>::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 <class T>
UInt SynchronizedArray<T>::syncDeletedElements(
std::vector<UInt> & 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<UInt>::const_iterator it;
for (it = del_elements.begin(); it != del_elements.end(); ++it) {
erase(*it);
}
syncElements(_deleted);
AKANTU_DEBUG_OUT();
return this->size_;
}
/* -------------------------------------------------------------------------- */
template <class T>
UInt SynchronizedArray<T>::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; i < nb_add_elements; ++i) {
push_back(this->default_value);
}
syncElements(_added);
AKANTU_DEBUG_OUT();
return this->size_;
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::registerDependingArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->depending_arrays.push_back(&array);
array.syncAddedElements(this->size_);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::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<UInt>::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<SynchronizedArrayBase *>::const_iterator it =
this->depending_arrays.begin();
it != this->depending_arrays.end(); ++it)
stream << (*it)->getID() << " ";
stream << std::endl;
Array<T>::printself(stream, indent + 1);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::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; i < size_comp; ++i)
out_restart << std::setprecision(12) << this->values[i] << " ";
// out_restart << std::hex << std::setprecision(12) << this->values[i] << "
// ";
out_restart << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SynchronizedArray<T>::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);
+ 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; i < this->size_ * 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<Real>;
template class SynchronizedArray<UInt>;
template class SynchronizedArray<Int>;
template class SynchronizedArray<bool>;
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc b/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc
index 72530f60e..4f9ae6707 100644
--- a/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc
+++ b/extra_packages/traction-at-split-node-contact/src/functions/boundary_functions.cc
@@ -1,76 +1,72 @@
/**
* @file boundary_functions.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "boundary_functions.hh"
#include "communicator.hh"
#include "element_group.hh"
#include "node_group.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace 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<Real> & residual = model.getInternalForce();
const ElementGroup & boundary = mesh.getElementGroup(sub_boundary_name);
for (auto & node : boundary.getNodeGroup().getNodes()) {
bool is_local_node = mesh.isLocalOrMasterNode(node);
if (is_local_node) {
int_res += residual(node, dir);
}
}
mesh.getCommunicator().allReduce(int_res, SynchronizerOperation::_sum);
return int_res;
}
/* -------------------------------------------------------------------------- */
void boundaryFix(Mesh & mesh,
const std::vector<std::string> & sub_boundary_names) {
-
- std::vector<std::string>::const_iterator it = sub_boundary_names.begin();
- std::vector<std::string>::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
+ for (auto && eg : sub_boundary_names) {
+ if (mesh.elementGroupExists(eg)) {
+ mesh.createElementGroup(eg, mesh.getSpatialDimension() -
+ 1); // empty element group
}
}
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
index 112f9fe4c..c56ba8bbe 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_coulomb_tmpl.hh
@@ -1,168 +1,168 @@
/**
* @file ntn_friclaw_coulomb_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of coulomb friction
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_nodal_field.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawCoulomb<Regularisation>::NTNFricLawCoulomb(NTNBaseContact & contact,
const ID & 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 <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
// get contact arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
const SynchronizedArray<Real> & pressure = this->internalGetContactPressure();
// array to fill
SynchronizedArray<Real> & strength = this->internalGetFrictionalStrength();
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
strength(n) = 0.;
// node pair is in contact
else {
// compute frictional strength
strength(n) = this->mu(n) * pressure(n);
}
}
Regularisation::computeFrictionalStrength();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->mu.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::dumpRestart(
const std::string & file_name) const {
AKANTU_DEBUG_IN();
this->mu.dumpRestartFile(file_name);
Regularisation::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::readRestart(
const std::string & file_name) {
AKANTU_DEBUG_IN();
this->mu.readRestartFile(file_name);
Regularisation::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::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 <class Regularisation>
void NTNFricLawCoulomb<Regularisation>::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "mu") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->mu.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->mu.getArray()));
}
/*
else if (field_id == "frictional_contact_pressure") {
this->internalAddDumpFieldToDumper(dumper_name,
field_id,
new
DumperIOHelper::NodalField<Real>(this->frictional_contact_pressure.getArray()));
}
*/
else {
Regularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
index 724a9cd79..e61f4d243 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_cohesive_tmpl.hh
@@ -1,189 +1,189 @@
/**
* @file ntn_friclaw_linear_cohesive_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of linear cohesive law
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
//#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawLinearCohesive<Regularisation>::NTNFricLawLinearCohesive(
NTNBaseContact & contact, const ID & 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 <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
// get arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
// const SynchronizedArray<Real> & slip = this->internalGetSlip();
const SynchronizedArray<Real> & slip = this->internalGetCumulativeSlip();
// array to fill
SynchronizedArray<Real> & strength = this->internalGetFrictionalStrength();
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
strength(n) = 0.;
// node pair is in contact
else {
if (this->G_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
}
}
}
Regularisation::computeFrictionalStrength();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->G_c.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::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 <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::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 <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::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 <class Regularisation>
void NTNFricLawLinearCohesive<Regularisation>::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "G_c") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->G_c.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->G_c.getArray()));
} else if (field_id == "tau_c") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->tau_c.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->tau_c.getArray()));
} else if (field_id == "tau_r") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->tau_r.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->tau_r.getArray()));
} else {
Regularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
index 2341d348b..790a3d928 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
@@ -1,87 +1,86 @@
/**
* @file ntn_friclaw_linear_slip_weakening_no_healing_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of linear slip weakening
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawLinearSlipWeakeningNoHealing<Regularisation>::
NTNFricLawLinearSlipWeakeningNoHealing(NTNBaseContact & contact,
const ID & id,
const MemoryID & memory_id)
: NTNFricLawLinearSlipWeakening<Regularisation>(contact, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakeningNoHealing<
Regularisation>::computeFrictionCoefficient() {
AKANTU_DEBUG_IN();
// get arrays
const SynchronizedArray<Real> & slip = this->internalGetCumulativeSlip();
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
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));
+ 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 <class Regularisation>
void NTNFricLawLinearSlipWeakeningNoHealing<Regularisation>::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 << "NTNFricLawLinearSlipWeakeningNoHealing [" << std::endl;
NTNFricLawLinearSlipWeakening<Regularisation>::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
index c92037880..f03bec6ed 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_laws/ntn_friclaw_linear_slip_weakening_tmpl.hh
@@ -1,191 +1,190 @@
/**
* @file ntn_friclaw_linear_slip_weakening_tmpl.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of linear slip weakening
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Regularisation>
NTNFricLawLinearSlipWeakening<Regularisation>::NTNFricLawLinearSlipWeakening(
NTNBaseContact & contact, const ID & id, const MemoryID & memory_id)
: NTNFricLawCoulomb<Regularisation>(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<Regularisation>::registerSynchronizedArray(this->mu_s);
NTNFricLawCoulomb<Regularisation>::registerSynchronizedArray(this->mu_k);
NTNFricLawCoulomb<Regularisation>::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->setParameterAccessType("mu", _pat_readable);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<
Regularisation>::computeFrictionalStrength() {
AKANTU_DEBUG_IN();
computeFrictionCoefficient();
NTNFricLawCoulomb<Regularisation>::computeFrictionalStrength();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<
Regularisation>::computeFrictionCoefficient() {
AKANTU_DEBUG_IN();
// get arrays
const SynchronizedArray<bool> & stick = this->internalGetIsSticking();
const SynchronizedArray<Real> & slip = this->internalGetSlip();
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (stick(n)) {
this->mu(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));
+ 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 <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::registerSynchronizedArray(
SynchronizedArrayBase & array) {
AKANTU_DEBUG_IN();
this->mu_s.registerDependingArray(array);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::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<Regularisation>::dumpRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::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<Regularisation>::readRestart(file_name);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::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<Regularisation>::printself(stream, ++indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Regularisation>
void NTNFricLawLinearSlipWeakening<Regularisation>::addDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id) {
AKANTU_DEBUG_IN();
#ifdef AKANTU_USE_IOHELPER
// const SynchronizedArray<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "mu_s") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->mu_s.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->mu_s.getArray()));
} else if (field_id == "mu_k") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->mu_k.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->mu_k.getArray()));
} else if (field_id == "d_c") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->d_c.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->d_c.getArray()));
} else {
NTNFricLawCoulomb<Regularisation>::addDumpFieldToDumper(dumper_name,
field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
index 323e4cae3..22ce9d46f 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_no_regularisation.cc
@@ -1,168 +1,168 @@
/**
* @file ntn_fricreg_no_regularisation.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of no regularisation
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNFricRegNoRegularisation::NTNFricRegNoRegularisation(
NTNBaseContact & contact, const ID & 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<Real> &
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<bool> & is_in_contact =
this->internalGetIsInContact();
const Array<Real> & pressure = this->contact.getContactPressure().getArray();
Array<Real>::const_iterator<Vector<Real>> it = pressure.begin(dim);
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
this->frictional_contact_pressure(n) = 0.;
// node pair is in contact
else {
// compute frictional contact pressure
const Vector<Real> & 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<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "frictional_contact_pressure") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(
+ std::make_unique<dumper::NodalField<Real>>(
this->frictional_contact_pressure.getArray()));
} else {
NTNBaseFriction::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
index 57c2d4ade..66dfccbc5 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_rubin_ampuero.cc
@@ -1,176 +1,176 @@
/**
* @file ntn_fricreg_rubin_ampuero.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of no regularisation
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_rubin_ampuero.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNFricRegRubinAmpuero::NTNFricRegRubinAmpuero(NTNBaseContact & contact,
const ID & 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<Real> &
NTNFricRegRubinAmpuero::internalGetContactPressure() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact.getModel();
UInt dim = model.getSpatialDimension();
Real delta_t = model.getTimeStep();
// get contact arrays
const SynchronizedArray<bool> & is_in_contact =
this->internalGetIsInContact();
const Array<Real> & pressure = this->contact.getContactPressure().getArray();
Array<Real>::const_iterator<Vector<Real>> it = pressure.begin(dim);
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// node pair is NOT in contact
if (!is_in_contact(n))
this->frictional_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<Real> & 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<Real> & 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<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "t_star") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->t_star.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->t_star.getArray()));
} else {
NTNFricRegNoRegularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
index 74a8e7cf5..619d3f85a 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.cc
@@ -1,163 +1,163 @@
/**
* @file ntn_fricreg_simplified_prakash_clifton.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of simplified prakash clifton with one parameter
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_simplified_prakash_clifton.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNFricRegSimplifiedPrakashClifton::NTNFricRegSimplifiedPrakashClifton(
NTNBaseContact & contact, const ID & 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; n < nb_contact_nodes; ++n) {
Real alpha = delta_t / this->t_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; n < nb_contact_nodes; ++n) {
this->frictional_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<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "t_star") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->t_star.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->t_star.getArray()));
} else {
NTNFricRegNoRegularisation::addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
index 2d7519352..5d623f856 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/friction_regularisations/ntn_fricreg_simplified_prakash_clifton.hh
@@ -1,114 +1,113 @@
/**
* @file ntn_fricreg_simplified_prakash_clifton.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Fri Feb 23 2018
*
* @brief regularisation that regularizes the frictional strength with one
* parameter
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__
#define __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_fricreg_no_regularisation.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
class NTNFricRegSimplifiedPrakashClifton : public NTNFricRegNoRegularisation {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNFricRegSimplifiedPrakashClifton(
- NTNBaseContact & contact,
- const ID & id = "simplified_prakash_clifton",
+ NTNBaseContact & contact, const ID & 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<Real> & internalGetFrictionalStrength() {
return this->spc_internal;
};
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
SynchronizedArray<Real> t_star;
// to get the incremental frictional strength
SynchronizedArray<Real> 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;
}
} // namespace akantu
#endif /* __AST_NTN_FRICREG_SIMPLIFIED_PRAKASH_CLIFTON_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc
index 76b19cdd8..83e29affb 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/mIIasym_contact.cc
@@ -1,120 +1,120 @@
/**
* @file mIIasym_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "mIIasym_contact.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
-MIIASYMContact::MIIASYMContact(SolidMechanicsModel & model,
- const ID & id, const MemoryID & memory_id)
+MIIASYMContact::MIIASYMContact(SolidMechanicsModel & model, const ID & id,
+ const MemoryID & memory_id)
: NTRFContact(model, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::updateImpedance() {
AKANTU_DEBUG_IN();
NTRFContact::updateImpedance();
for (UInt i = 0; i < this->impedance.size(); ++i) {
this->impedance(i) *= 0.5;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/// WARNING: this is only valid for the acceleration in equilibrium
void MIIASYMContact::computeRelativeNormalField(
const Array<Real> & field, Array<Real> & rel_normal_field) const {
AKANTU_DEBUG_IN();
NTRFContact::computeRelativeNormalField(field, rel_normal_field);
for (auto it_rtfield = rel_normal_field.begin();
it_rtfield != rel_normal_field.end(); ++it_rtfield) {
// in the anti-symmetric case
*it_rtfield *= 2.;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::computeRelativeTangentialField(
const Array<Real> & field, Array<Real> & rel_tang_field) const {
AKANTU_DEBUG_IN();
NTRFContact::computeRelativeTangentialField(field, rel_tang_field);
UInt dim = this->model.getSpatialDimension();
for (Array<Real>::iterator<Vector<Real>> it_rtfield =
rel_tang_field.begin(dim);
it_rtfield != rel_tang_field.end(dim); ++it_rtfield) {
// in the anti-symmetric case, the tangential fields become twice as large
*it_rtfield *= 2.;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::computeContactPressureInEquilibrium() {
AKANTU_DEBUG_IN();
NTRFContact::computeContactPressure();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MIIASYMContact::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 << "MIIASYMContact [" << std::endl;
NTRFContact::printself(stream, indent);
stream << space << "]" << std::endl;
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc
index 0eba3cd57..affbcd1e7 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.cc
@@ -1,555 +1,569 @@
/**
* @file ntn_base_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of ntn base contact
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "ntn_base_contact.hh"
#include "dof_manager_default.hh"
#include "dumpable_inline_impl.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
#include "element_synchronizer.hh"
#include "mesh_utils.hh"
#include "non_linear_solver_lumped.hh"
/* -------------------------------------------------------------------------- */
namespace 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; n < nb_nodes; ++n) {
// UInt nn = this->connectivity(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 ID & id,
const MemoryID & memory_id)
: Memory(id, memory_id), Dumpable(), model(model),
slaves(0, 1, 0, id + ":slaves", std::numeric_limits<UInt>::quiet_NaN(),
"slaves"),
normals(0, model.getSpatialDimension(), 0, id + ":normals",
std::numeric_limits<Real>::quiet_NaN(), "normals"),
contact_pressure(
0, model.getSpatialDimension(), 0, id + ":contact_pressure",
std::numeric_limits<Real>::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<Real>::quiet_NaN(),
"lumped_boundary_slaves"),
impedance(0, 1, 0, id + ":impedance",
std::numeric_limits<Real>::quiet_NaN(), "impedance"),
contact_surfaces(), slave_elements("slave_elements", id, memory_id),
node_to_elements() {
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();
this->slave_elements.initialize(mesh,
_spatial_dimension = spatial_dimension - 1);
MeshUtils::buildNode2Elements(mesh, this->node_to_elements,
spatial_dimension - 1);
this->registerDumper<DumperText>("text_all", id, true);
this->addDumpFilteredMesh(mesh, slave_elements, slaves.getArray(),
spatial_dimension - 1, _not_ghost, _ek_regular);
// parallelisation
this->synch_registry = std::make_unique<SynchronizerRegistry>();
this->synch_registry->registerDataAccessor(*this);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
NTNBaseContact::~NTNBaseContact() = default;
/* -------------------------------------------------------------------------- */
void NTNBaseContact::initParallel() {
AKANTU_DEBUG_IN();
this->synchronizer = std::make_unique<ElementSynchronizer>(
this->model.getMesh().getElementSynchronizer());
this->synchronizer->filterScheme([&](auto && element) {
// loop over all nodes of this element
Vector<UInt> conn = const_cast<const Mesh &>(this->model.getMesh())
.getConnectivity(element);
for (auto & node : conn) {
// if one nodes is in this contact, we need this element
if (this->getNodeIndex(node) >= 0) {
return true;
}
}
return false;
});
this->synch_registry->registerSynchronizer(*(this->synchronizer),
SynchronizationTag::_cf_nodal);
this->synch_registry->registerSynchronizer(*(this->synchronizer),
SynchronizationTag::_cf_incr);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseContact::findBoundaryElements(
const Array<UInt> & interface_nodes, ElementTypeMapArray<UInt> & elements) {
AKANTU_DEBUG_IN();
// add connected boundary elements that have all nodes on this contact
for (const auto & node : interface_nodes) {
for (const auto & element : this->node_to_elements.getRow(node)) {
Vector<UInt> conn = const_cast<const Mesh &>(this->model.getMesh())
.getConnectivity(element);
auto nb_nodes = conn.size();
decltype(nb_nodes) nb_found_nodes = 0;
for (auto & nn : conn) {
if (interface_nodes.find(nn) != UInt(-1)) {
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(element.type, element.ghost_type).find(element.element) ==
UInt(-1))) {
elements(element.type, element.ghost_type).push_back(element.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<Real>::quiet_NaN());
this->impedance.push_back(std::numeric_limits<Real>::quiet_NaN());
this->lumped_boundary_slaves.push_back(
std::numeric_limits<Real>::quiet_NaN());
Vector<Real> nan_normal(dim, std::numeric_limits<Real>::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 = mesh.isPeriodicSlave(this->slaves(n));
if (is_local_node && !is_pbc_slave_node && this->is_in_contact(n)) {
nb_contact++;
}
}
mesh.getCommunicator().allReduce(nb_contact, SynchronizerOperation::_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<UInt> & nodes, const ElementTypeMapArray<UInt> & elements,
SynchronizedArray<Real> & 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(auto ghost_type : ghost_types) {
+ for (auto ghost_type : ghost_types) {
for (auto & type : mesh.elementTypes(dim - 1, ghost_type)) {
UInt nb_elements = mesh.getNbElement(type, ghost_type);
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
const Array<UInt> & connectivity = mesh.getConnectivity(type, ghost_type);
// get shapes and compute integral
const Array<Real> & shapes = boundary_fem.getShapes(type, ghost_type);
Array<Real> area(nb_elements, nb_nodes_per_element);
- boundary_fem.integrate(shapes, area, nb_nodes_per_element, type, ghost_type);
+ boundary_fem.integrate(shapes, area, nb_nodes_per_element, type,
+ ghost_type);
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<UInt>::const_iterator<UInt> elem_it = (elements)(type, ghost_type).begin();
+ Array<UInt>::const_iterator<UInt> elem_it =
+ (elements)(type, ghost_type).begin();
Array<UInt>::const_iterator<UInt> elem_it_end =
(elements)(type, ghost_type).end();
// loop over contact nodes
for (; elem_it != elem_it_end; ++elem_it) {
for (UInt q = 0; q < nb_nodes_per_element; ++q) {
UInt node = connectivity(*elem_it, q);
UInt node_index = nodes.find(node);
AKANTU_DEBUG_ASSERT(node_index != UInt(-1), "Could not find node "
<< node
<< " in the array!");
Real area_to_add = area(*elem_it, q);
boundary(node_index) += area_to_add;
}
}
}
}
AKANTU_DEBUG_OUT();
}
+/* -------------------------------------------------------------------------- */
+void NTNBaseContact::computeAcceleration(Array<Real> & acceleration) const {
+ auto && dof_manager =
+ dynamic_cast<DOFManagerDefault &>(model.getDOFManager());
+ const auto & b = dof_manager.getResidual();
+ acceleration.resize(b.size());
+ const auto & blocked_dofs = dof_manager.getGlobalBlockedDOFs();
+ const auto & A = dof_manager.getLumpedMatrix("M");
+
+ Array<bool> blocked_dofs_bool(blocked_dofs.size());
+ for (auto && data : zip(blocked_dofs, blocked_dofs_bool)) {
+ std::get<1>(data) = std::get<0>(data);
+ }
+
+ // pre-compute the acceleration
+ // (not increment acceleration, because residual is still Kf)
+ NonLinearSolverLumped::solveLumped(A, acceleration, b, this->model.getF_M2A(),
+ blocked_dofs_bool);
+}
+
/* -------------------------------------------------------------------------- */
void NTNBaseContact::computeContactPressure() {
AKANTU_DEBUG_IN();
UInt dim = this->model.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(SynchronizationTag::_cf_nodal);
- auto && dof_manager =
- dynamic_cast<DOFManagerDefault &>(model.getDOFManager());
- const auto & b = dof_manager.getResidual();
- Array<Real> acceleration(b.size(), dim);
- const auto & blocked_dofs = dof_manager.getGlobalBlockedDOFs();
- const auto & A = dof_manager.getLumpedMatrix("M");
-
- // pre-compute the acceleration
- // (not increment acceleration, because residual is still Kf)
- NonLinearSolverLumped::solveLumped(A, acceleration, b, blocked_dofs,
- this->model.getF_M2A());
+ Array<Real> acceleration(0, dim);
+ this->computeAcceleration(acceleration);
// compute relative normal fields of displacement, velocity and acceleration
Array<Real> r_disp(0, 1);
Array<Real> r_velo(0, 1);
Array<Real> r_acce(0, 1);
Array<Real> 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.size() == nb_contact_nodes,
"computeRelativeNormalField does not give back arrays "
<< "size == nb_contact_nodes. nb_contact_nodes = "
<< nb_contact_nodes
<< " | array size = " << r_disp.size());
// compute gap array for all nodes
Array<Real> 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 < nb_contact_nodes; ++i) {
*gap_p = *r_disp_p + delta_t * *r_velo_p + delta_t * delta_t * *r_acce_p -
0.5 * delta_t * delta_t * *r_old_acce_p;
// increment pointers
gap_p++;
r_disp_p++;
r_velo_p++;
r_acce_p++;
r_old_acce_p++;
}
// check if gap is negative -> is in contact
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (gap(n) <= 0.) {
for (UInt d = 0; d < dim; ++d) {
this->contact_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; d < dim; ++d)
this->contact_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<Real> & residual = this->model.getInternalForce();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt slave = this->slaves(n);
for (UInt d = 0; d < dim; ++d) {
// residual(master,d) += this->lumped_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 {
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<UInt> & nodal_filter = this->slaves.getArray();
#define ADD_FIELD(field_id, field, type) \
internalAddDumpFieldToDumper( \
dumper_name, field_id, \
- new dumper::NodalField<type, true, Array<type>, Array<UInt>>( \
+ std::make_unique< \
+ dumper::NodalField<type, true, Array<type>, Array<UInt>>>( \
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 == "external_force") {
ADD_FIELD(field_id, this->model.getForce(), Real);
} else if (field_id == "internal_force") {
ADD_FIELD(field_id, this->model.getInternalForce(), 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<Real>(this->normals.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->normals.getArray()));
} else if (field_id == "contact_pressure") {
- internalAddDumpFieldToDumper(
- dumper_name, field_id,
- new dumper::NodalField<Real>(this->contact_pressure.getArray()));
+ internalAddDumpFieldToDumper(dumper_name, field_id,
+ std::make_unique<dumper::NodalField<Real>>(
+ this->contact_pressure.getArray()));
} else if (field_id == "is_in_contact") {
- internalAddDumpFieldToDumper(
- dumper_name, field_id,
- new dumper::NodalField<bool>(this->is_in_contact.getArray()));
+ internalAddDumpFieldToDumper(dumper_name, field_id,
+ std::make_unique<dumper::NodalField<bool>>(
+ this->is_in_contact.getArray()));
} else if (field_id == "lumped_boundary_slave") {
- internalAddDumpFieldToDumper(
- dumper_name, field_id,
- new dumper::NodalField<Real>(this->lumped_boundary_slaves.getArray()));
+ internalAddDumpFieldToDumper(dumper_name, field_id,
+ std::make_unique<dumper::NodalField<Real>>(
+ this->lumped_boundary_slaves.getArray()));
} else if (field_id == "impedance") {
internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->impedance.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(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();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh
index 347375c35..fd628880e 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_contact.hh
@@ -1,250 +1,253 @@
/**
* @file ntn_base_contact.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief base contact for ntn and ntrf contact
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_BASE_CONTACT_HH__
#define __AST_NTN_BASE_CONTACT_HH__
/* -------------------------------------------------------------------------- */
// akantu
#include "aka_csr.hh"
#include "solid_mechanics_model.hh"
// simtools
#include "synchronized_array.hh"
namespace 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<UInt> & connectivity;
// };
/* -------------------------------------------------------------------------- */
class NTNBaseContact : protected Memory,
public DataAccessor<Element>,
public Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNBaseContact(SolidMechanicsModel & model, const ID & 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<Real> & 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<Real> & field,
Array<Real> & rel_normal_field) const = 0;
/// compute relative tangential field (complet array)
/// relative to master nodes
virtual void
computeRelativeTangentialField(const Array<Real> & field,
Array<Real> & rel_tang_field) const = 0;
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
+ /// computes the acceleration
+ void computeAcceleration(Array<Real> & acceleration) const;
+
protected:
/// updateLumpedBoundary
virtual void
internalUpdateLumpedBoundary(const Array<UInt> & nodes,
const ElementTypeMapArray<UInt> & elements,
SynchronizedArray<Real> & boundary);
// to find the slave_elements or master_elements
virtual void findBoundaryElements(const Array<UInt> & interface_nodes,
ElementTypeMapArray<UInt> & elements);
/// synchronize arrays
virtual void syncArrays(SyncChoice sync_choice);
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* 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<UInt> &)
AKANTU_GET_MACRO(Normals, normals, const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(ContactPressure, contact_pressure,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(LumpedBoundarySlaves, lumped_boundary_slaves,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(Impedance, impedance, const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(IsInContact, is_in_contact, const SynchronizedArray<bool> &)
AKANTU_GET_MACRO(SlaveElements, slave_elements,
const ElementTypeMapArray<UInt> &)
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.size(); }
bool isNTNContact() const { return this->is_ntn_contact; }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
typedef std::set<const ElementGroup *> SurfacePtrSet;
SolidMechanicsModel & model;
/// array of slave nodes
SynchronizedArray<UInt> slaves;
/// array of normals
SynchronizedArray<Real> normals;
/// array indicating if nodes are in contact
SynchronizedArray<Real> contact_pressure;
/// array indicating if nodes are in contact
SynchronizedArray<bool> is_in_contact;
/// boundary matrix for slave nodes
SynchronizedArray<Real> lumped_boundary_slaves;
/// impedance matrix
SynchronizedArray<Real> impedance;
/// contact surface
SurfacePtrSet contact_surfaces;
/// element list for dump and lumped_boundary
ElementTypeMapArray<UInt> slave_elements;
CSR<Element> node_to_elements;
/// parallelisation
std::unique_ptr<SynchronizerRegistry> synch_registry;
std::unique_ptr<ElementSynchronizer> synchronizer;
bool is_ntn_contact{true};
};
/* -------------------------------------------------------------------------- */
/* 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;
}
} // namespace akantu
#endif /* __AST_NTN_BASE_CONTACT_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc
index 0c3206abc..80388e572 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.cc
@@ -1,383 +1,381 @@
/**
* @file ntn_base_friction.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of ntn base friction
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_friction.hh"
#include "dof_manager_default.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
#include "non_linear_solver_lumped.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNBaseFriction::NTNBaseFriction(NTNBaseContact & contact, const ID & id,
const MemoryID & memory_id)
: Memory(id, memory_id), Parsable(ParserType::_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);
- this->registerExternalDumper(contact.getDumper(),
+ this->registerExternalDumper(contact.getDumper().shared_from_this(),
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(SynchronizationTag::_cf_incr);
+ this->contact.getSynchronizerRegistry().synchronize(
+ SynchronizationTag::_cf_incr);
Array<Real> rel_tan_incr(0, dim);
this->contact.computeRelativeTangentialField(model.getIncrement(),
- rel_tan_incr);
+ rel_tan_incr);
Array<Real>::const_iterator<Vector<Real>> it = rel_tan_incr.begin(dim);
UInt nb_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_nodes; ++n) {
if (this->is_sticking(n)) {
this->slip(n) = 0.;
} else {
const Vector<Real> & 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<bool> & is_in_contact =
this->contact.getIsInContact();
Array<Real> & traction =
const_cast<Array<Real> &>(this->friction_traction.getArray());
Array<Real>::iterator<Vector<Real>> 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 < nb_contact_nodes; ++n) {
// node pair is in contact
if (is_in_contact(n)) {
Vector<Real> 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<Real> & impedance = this->contact.getImpedance();
const SynchronizedArray<bool> & is_in_contact =
this->contact.getIsInContact();
- auto && dof_manager =
- dynamic_cast<DOFManagerDefault &>(model.getDOFManager());
- const auto & b = dof_manager.getResidual();
- Array<Real> acceleration(b.size(), dim);
- const auto & blocked_dofs = dof_manager.getGlobalBlockedDOFs();
- const auto & A = dof_manager.getLumpedMatrix("M");
-
- // pre-compute the acceleration
- // (not increment acceleration, because residual is still Kf)
- NonLinearSolverLumped::solveLumped(A, acceleration, b, blocked_dofs,
- model.getF_M2A());
+ Array<Real> acceleration(0, dim);
+ this->contact.computeAcceleration(acceleration);
// compute relative normal fields of velocity and acceleration
Array<Real> r_velo(0, dim);
Array<Real> r_acce(0, dim);
Array<Real> 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);
+ r_old_acce);
AKANTU_DEBUG_ASSERT(r_velo.size() == nb_contact_nodes,
"computeRelativeNormalField does not give back arrays "
<< "size == nb_contact_nodes. nb_contact_nodes = "
<< nb_contact_nodes
<< " | array size = " << r_velo.size());
// compute tangential gap_dot array for all nodes
Array<Real> gap_dot(nb_contact_nodes, dim);
for (auto && data : zip(make_view(gap_dot), make_view(r_velo),
make_view(r_acce), make_view(r_old_acce))) {
auto & gap_dot = std::get<0>(data);
auto & r_velo = std::get<1>(data);
auto & r_acce = std::get<2>(data);
auto & r_old_acce = std::get<3>(data);
gap_dot = r_velo + delta_t * r_acce - 1. / 2. * delta_t * r_old_acce;
}
// compute friction traction to stop sliding
Array<Real> & traction =
const_cast<Array<Real> &>(this->friction_traction.getArray());
auto it_fric_trac = traction.begin(dim);
for (UInt n = 0; n < nb_contact_nodes; ++n) {
Vector<Real> 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; d < dim; ++d)
fric_trac(d) = impedance(n) * gap_dot(n, d) / 2.;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNBaseFriction::applyFrictionTraction() {
AKANTU_DEBUG_IN();
SolidMechanicsModel & model = this->contact.getModel();
Array<Real> & residual = model.getInternalForce();
UInt dim = model.getSpatialDimension();
const SynchronizedArray<UInt> & slaves = this->contact.getSlaves();
const SynchronizedArray<Real> & lumped_boundary_slaves =
this->contact.getLumpedBoundarySlaves();
UInt nb_contact_nodes = this->contact.getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt slave = slaves(n);
for (UInt d = 0; d < dim; ++d) {
residual(slave, d) -=
lumped_boundary_slaves(n) * this->friction_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<Real> & array = this->get(name).get<SynchronizedArray<Real>>();
+ SynchronizedArray<Real> & array =
+ this->get(name).get<SynchronizedArray<Real>>();
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<UInt> & nodes = this->contact.getSlaves();
const SynchronizedArray<bool> & 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 = mesh.isPeriodicSlave(nodes(n));
if (is_local_node && !is_pbc_slave_node && is_in_contact(n) &&
this->is_sticking(n)) {
nb_stick++;
}
}
mesh.getCommunicator().allReduce(nb_stick, SynchronizerOperation::_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<UInt> * nodal_filter =
// &(this->contact.getSlaves());
if (field_id == "is_sticking") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<bool>(this->is_sticking.getArray()));
+ std::make_unique<dumper::NodalField<bool>>(
+ this->is_sticking.getArray()));
} else if (field_id == "frictional_strength") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->frictional_strength.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(
+ this->frictional_strength.getArray()));
} else if (field_id == "friction_traction") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->friction_traction.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(
+ this->friction_traction.getArray()));
} else if (field_id == "slip") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->slip.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(this->slip.getArray()));
} else if (field_id == "cumulative_slip") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->cumulative_slip.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(
+ this->cumulative_slip.getArray()));
} else if (field_id == "slip_velocity") {
this->internalAddDumpFieldToDumper(
dumper_name, field_id,
- new dumper::NodalField<Real>(this->slip_velocity.getArray()));
+ std::make_unique<dumper::NodalField<Real>>(
+ this->slip_velocity.getArray()));
} else {
this->contact.addDumpFieldToDumper(dumper_name, field_id);
}
#endif
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh
index 6053b29eb..8341b1515 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_base_friction.hh
@@ -1,179 +1,178 @@
/**
* @file ntn_base_friction.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief base class for ntn and ntrf friction
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AST_NTN_BASE_FRICTION_HH__
#define __AST_NTN_BASE_FRICTION_HH__
/* -------------------------------------------------------------------------- */
// akantu
#include "parsable.hh"
// simtools
#include "ntn_base_contact.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
-
/* -------------------------------------------------------------------------- */
template <>
-inline void
-ParameterTyped<akantu::SynchronizedArray<Real>>::setAuto(const ParserParameter & in_param) {
+inline void ParameterTyped<akantu::SynchronizedArray<Real>>::setAuto(
+ const ParserParameter & in_param) {
Parameter::setAuto(in_param);
Real r = in_param;
param.setAndChangeDefault(r);
}
/* -------------------------------------------------------------------------- */
template <>
template <>
inline void ParameterTyped<akantu::SynchronizedArray<Real>>::setTyped<Real>(
const Real & value) {
param.setAndChangeDefault(value);
}
/* -------------------------------------------------------------------------- */
class NTNBaseFriction : protected Memory, public Parsable, public Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NTNBaseFriction(NTNBaseContact & contact, const ID & id = "friction",
const MemoryID & memory_id = 0);
virtual ~NTNBaseFriction() = default;
/* ------------------------------------------------------------------------ */
/* 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_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<bool> &)
AKANTU_GET_MACRO(FrictionalStrength, frictional_strength,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(FrictionTraction, friction_traction,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(Slip, slip, const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(CumulativeSlip, cumulative_slip,
const SynchronizedArray<Real> &)
AKANTU_GET_MACRO(SlipVelocity, slip_velocity, const SynchronizedArray<Real> &)
/// 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_ERROR("Friction does not know the following parameter: " <<
// param);
// };
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
NTNBaseContact & contact;
// if node is sticking
SynchronizedArray<bool> is_sticking;
// frictional strength
SynchronizedArray<Real> frictional_strength;
// friction force
SynchronizedArray<Real> friction_traction;
// slip
SynchronizedArray<Real> slip;
SynchronizedArray<Real> cumulative_slip;
// slip velocity (tangential vector)
SynchronizedArray<Real> 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;
}
} // namespace akantu
#endif /* __AST_NTN_BASE_FRICTION_HH__ */
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc
index 28e6d7f65..b30cb596c 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_contact.cc
@@ -1,554 +1,556 @@
/**
* @file ntn_contact.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Dec 02 2014
* @date last modification: Fri Feb 23 2018
*
* @brief implementation of ntn_contact
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_contact.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
NTNContact::NTNContact(SolidMechanicsModel & model, const ID & id,
const MemoryID & memory_id)
: NTNBaseContact(model, id, memory_id),
masters(0, 1, 0, id + ":masters", std::numeric_limits<UInt>::quiet_NaN(),
"masters"),
lumped_boundary_masters(0, 1, 0, id + ":lumped_boundary_masters",
std::numeric_limits<Real>::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();
this->master_elements.initialize(mesh, _nb_component = 1,
_spatial_dimension = 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<UInt> & 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
Vector<UInt> offset(dim - 1);
for (UInt i = 0, j = 0; i < dim; ++i) {
if (surface_normal_dir != i) {
offset(j) = i;
++j;
}
}
// find projected node coordinates
const Array<Real> & coordinates = mesh.getNodes();
// find slave nodes
Array<Real> proj_slave_coord(slave_boundary.getNbNodes(), dim - 1, 0.);
Array<UInt> slave_nodes(slave_boundary.getNbNodes());
UInt n(0);
for (auto && slave_node : slave_boundary.getNodeGroup().getNodes()) {
for (UInt d = 0; d < dim - 1; ++d) {
proj_slave_coord(n, d) = coordinates(slave_node, offset[d]);
slave_nodes(n) = slave_node;
}
++n;
}
// find master nodes
Array<Real> proj_master_coord(master_boundary.getNbNodes(), dim - 1, 0.);
Array<UInt> master_nodes(master_boundary.getNbNodes());
n = 0;
for (auto && master_node : master_boundary.getNodeGroup().getNodes()) {
for (UInt d = 0; d < dim - 1; ++d) {
proj_master_coord(n, d) = coordinates(master_node, offset[d]);
master_nodes(n) = master_node;
}
++n;
}
// find minimum distance between slave nodes to define tolerance
Real min_dist = std::numeric_limits<Real>::max();
for (UInt i = 0; i < proj_slave_coord.size(); ++i) {
for (UInt j = i + 1; j < proj_slave_coord.size(); ++j) {
Real dist = 0.;
for (UInt d = 0; d < dim - 1; ++d) {
dist += (proj_slave_coord(i, d) - proj_slave_coord(j, d)) *
(proj_slave_coord(i, d) - proj_slave_coord(j, d));
}
if (dist < min_dist) {
min_dist = dist;
}
}
}
min_dist = std::sqrt(min_dist);
Real local_tol = 0.1 * min_dist;
// find master slave node pairs
for (UInt i = 0; i < proj_slave_coord.size(); ++i) {
for (UInt j = 0; j < proj_master_coord.size(); ++j) {
Real dist = 0.;
for (UInt d = 0; d < dim - 1; ++d) {
dist += (proj_slave_coord(i, d) - proj_master_coord(j, d)) *
(proj_slave_coord(i, d) - proj_master_coord(j, d));
}
dist = std::sqrt(dist);
if (dist < local_tol) { // it is a pair
Vector<UInt> pair(2);
pair[0] = slave_nodes(i);
pair[1] = master_nodes(j);
pairs.push_back(pair);
continue; // found master do not need to search further for this slave
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::addSurfacePair(const ID & slave, const ID & master,
UInt surface_normal_dir) {
AKANTU_DEBUG_IN();
const Mesh & mesh = this->model.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<UInt> 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<UInt> pairs_no_PBC_slaves(0, 2);
Array<UInt>::const_vector_iterator it = pairs.begin(2);
Array<UInt>::const_vector_iterator end = pairs.end(2);
for (; it != end; ++it) {
const Vector<UInt> & pair = *it;
if (not mesh.isPeriodicSlave(pair(0)) and
not mesh.isPeriodicSlave(pair(1))) {
pairs_no_PBC_slaves.push_back(pair);
}
}
this->addNodePairs(pairs_no_PBC_slaves);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NTNContact::addNodePairs(const Array<UInt> & 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.size();
for (UInt n = 0; n < nb_pairs; ++n) {
this->addSplitNode(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<UInt> & 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; n < nb_pairs; ++n) {
Vector<UInt> pair{this->slaves(n), 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<Real>::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(SynchronizationTag::_cf_nodal); // synchronize current pos
+ this->synch_registry->synchronize(
+ SynchronizationTag::_cf_nodal); // synchronize current pos
const Array<Real> & cur_pos = this->model.getCurrentPosition();
FEEngine & boundary_fem = this->model.getFEEngineBoundary();
const Mesh & mesh = this->model.getMesh();
- for (auto ghost_type: ghost_types) {
+ for (auto ghost_type : ghost_types) {
for (auto & type : mesh.elementTypes(dim - 1, ghost_type)) {
// compute the normals
Array<Real> quad_normals(0, dim);
- boundary_fem.computeNormalsOnIntegrationPoints(cur_pos, quad_normals, type,
- ghost_type);
+ boundary_fem.computeNormalsOnIntegrationPoints(cur_pos, quad_normals,
+ type, ghost_type);
- UInt nb_quad_points = boundary_fem.getNbIntegrationPoints(type, ghost_type);
+ UInt nb_quad_points =
+ boundary_fem.getNbIntegrationPoints(type, ghost_type);
// new version: compute normals only based on master elements (and not all
// boundary elements)
// -------------------------------------------------------------------------------------
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
const Array<UInt> & connectivity = mesh.getConnectivity(type, ghost_type);
// loop over contact nodes
for (auto & element : (this->master_elements)(type, ghost_type)) {
for (UInt q = 0; q < nb_nodes_per_element; ++q) {
UInt node = connectivity(element, q);
UInt node_index = this->masters.find(node);
AKANTU_DEBUG_ASSERT(node_index != UInt(-1), "Could not find node "
<< node
<< " in the array!");
for (UInt q = 0; q < nb_quad_points; ++q) {
// add quad normal to master normal
for (UInt d = 0; d < dim; ++d) {
this->normals(node_index, d) +=
quad_normals(element * nb_quad_points + q, d);
}
}
}
}
}
}
Real * master_normals = this->normals.storage();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
if (dim == 2)
Math::normalize2(&(master_normals[n * dim]));
else if (dim == 3)
Math::normalize3(&(master_normals[n * dim]));
}
// // normalize normals
// auto nit = this->normals.begin();
// auto 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<Real> & mass = this->model.getMass();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
UInt master = this->masters(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<Real> & residual = this->model.getInternalForce();
for (UInt n = 0; n < nb_ntn_pairs; ++n) {
UInt master = this->masters(n);
UInt slave = this->slaves(n);
for (UInt d = 0; d < dim; ++d) {
residual(master, d) +=
this->lumped_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<Real> & field, Array<Real> & rel_tang_field) const {
AKANTU_DEBUG_IN();
// resize arrays to zero
rel_tang_field.resize(0);
UInt dim = this->model.getSpatialDimension();
auto it_field = field.begin(dim);
auto it_normal = this->normals.getArray().begin(dim);
Vector<Real> rfv(dim);
Vector<Real> np_rfv(dim);
UInt nb_contact_nodes = this->slaves.size();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt slave = this->slaves(n);
UInt master = this->masters(n);
// relative field vector (slave - master)
rfv = Vector<Real>(it_field[slave]);
rfv -= Vector<Real>(it_field[master]);
// normal projection of relative field
const Vector<Real> 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<Real> & field, Array<Real> & 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<Real>::const_iterator<Vector<Real>> it_field = field.begin(dim);
Array<Real>::const_iterator<Vector<Real>> it_normal =
this->normals.getArray().begin(dim);
Vector<Real> rfv(dim);
UInt nb_contact_nodes = this->getNbContactNodes();
for (UInt n = 0; n < nb_contact_nodes; ++n) {
// nodes
UInt slave = this->slaves(n);
UInt master = this->masters(n);
// relative field vector (slave - master)
rfv = Vector<Real>(it_field[slave]);
rfv -= Vector<Real>(it_field[master]);
// length of normal projection of relative field
const Vector<Real> 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<UInt> & nodal_filter = this->slaves.getArray();
#define ADD_FIELD(field_id, field, type) \
internalAddDumpFieldToDumper(dumper_name, \
field_id, \
new DumperIOHelper::NodalField< type, true, \
Array<type>, \
Array<UInt> >(field, 0, 0, &nodal_filter))
*/
if (field_id == "lumped_boundary_master") {
- internalAddDumpFieldToDumper(
- dumper_name, field_id,
- new dumper::NodalField<Real>(this->lumped_boundary_masters.getArray()));
+ internalAddDumpFieldToDumper(dumper_name, field_id,
+ std::make_unique<dumper::NodalField<Real>>(
+ this->lumped_boundary_masters.getArray()));
} else {
NTNBaseContact::addDumpFieldToDumper(dumper_name, field_id);
}
/*
#undef ADD_FIELD
#endif
*/
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh
index 92c909bad..55b00be87 100644
--- a/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh
+++ b/extra_packages/traction-at-split-node-contact/src/ntn_contact/ntn_initiation_function.hh
@@ -1,45 +1,47 @@
/**
* @file ntn_initiation_function.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Fri Feb 23 2018
*
* @brief initiation ntn and ntrf friction
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// simtools
#include "ntn_base_friction.hh"
#include "ntrf_contact.hh"
#include "parameter_reader.hh"
namespace akantu {
-std::unique_ptr<NTNBaseFriction> initializeNTNFriction(NTNBaseContact & contact);
+std::unique_ptr<NTNBaseFriction>
+initializeNTNFriction(NTNBaseContact & contact);
-std::unique_ptr<NTNBaseFriction> initializeNTNFriction(NTNBaseContact & contact,
- const std::string & friction_law,
- const std::string & friction_reg);
+std::unique_ptr<NTNBaseFriction>
+initializeNTNFriction(NTNBaseContact & contact,
+ const std::string & friction_law,
+ const std::string & friction_reg);
} // namespace akantu
diff --git a/packages/core.cmake b/packages/core.cmake
index d87812324..d5878fa9c 100644
--- a/packages/core.cmake
+++ b/packages/core.cmake
@@ -1,529 +1,530 @@
#===============================================================================
# @file core.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Nov 21 2011
# @date last modification: Mon Jan 18 2016
#
# @brief package description for core
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
package_declare(core NOT_OPTIONAL
DESCRIPTION "core package for Akantu"
FEATURES_PUBLIC cxx_strong_enums cxx_defaulted_functions
cxx_deleted_functions cxx_auto_type cxx_decltype_auto
FEATURES_PRIVATE cxx_lambdas cxx_nullptr cxx_range_for
cxx_delegating_constructors
DEPENDS INTERFACE Boost)
package_declare_sources(core
common/aka_array.cc
common/aka_array.hh
common/aka_array_tmpl.hh
+ common/aka_array_printer.hh
common/aka_bbox.hh
common/aka_blas_lapack.hh
common/aka_circular_array.hh
common/aka_circular_array_inline_impl.cc
common/aka_common.cc
common/aka_common.hh
common/aka_common_inline_impl.cc
common/aka_csr.hh
common/aka_element_classes_info_inline_impl.cc
common/aka_enum_macros.hh
common/aka_error.cc
common/aka_error.hh
common/aka_event_handler_manager.hh
common/aka_extern.cc
common/aka_factory.hh
common/aka_fwd.hh
common/aka_grid_dynamic.hh
common/aka_math.cc
common/aka_math.hh
common/aka_math_tmpl.hh
common/aka_memory.cc
common/aka_memory.hh
common/aka_memory_inline_impl.cc
common/aka_named_argument.hh
common/aka_random_generator.hh
common/aka_safe_enum.hh
common/aka_static_memory.cc
common/aka_static_memory.hh
common/aka_static_memory_inline_impl.cc
common/aka_static_memory_tmpl.hh
common/aka_typelist.hh
common/aka_types.hh
common/aka_visitor.hh
common/aka_voigthelper.hh
common/aka_voigthelper_tmpl.hh
common/aka_voigthelper.cc
common/aka_warning.hh
common/aka_warning_restore.hh
common/aka_iterators.hh
common/aka_static_if.hh
common/aka_compatibilty_with_cpp_standard.hh
fe_engine/element_class.hh
fe_engine/element_class_tmpl.hh
fe_engine/element_classes/element_class_hexahedron_8_inline_impl.cc
fe_engine/element_classes/element_class_hexahedron_20_inline_impl.cc
fe_engine/element_classes/element_class_pentahedron_6_inline_impl.cc
fe_engine/element_classes/element_class_pentahedron_15_inline_impl.cc
fe_engine/element_classes/element_class_point_1_inline_impl.cc
fe_engine/element_classes/element_class_quadrangle_4_inline_impl.cc
fe_engine/element_classes/element_class_quadrangle_8_inline_impl.cc
fe_engine/element_classes/element_class_segment_2_inline_impl.cc
fe_engine/element_classes/element_class_segment_3_inline_impl.cc
fe_engine/element_classes/element_class_tetrahedron_10_inline_impl.cc
fe_engine/element_classes/element_class_tetrahedron_4_inline_impl.cc
fe_engine/element_classes/element_class_triangle_3_inline_impl.cc
fe_engine/element_classes/element_class_triangle_6_inline_impl.cc
fe_engine/element_type_conversion.hh
fe_engine/fe_engine.cc
fe_engine/fe_engine.hh
fe_engine/fe_engine_inline_impl.cc
fe_engine/fe_engine_template.hh
fe_engine/fe_engine_template_tmpl_field.hh
fe_engine/fe_engine_template_tmpl.hh
fe_engine/geometrical_element_property.hh
fe_engine/geometrical_element_property.cc
fe_engine/gauss_integration.cc
fe_engine/gauss_integration_tmpl.hh
fe_engine/integrator.hh
fe_engine/integrator_gauss.hh
fe_engine/integrator_gauss_inline_impl.cc
fe_engine/interpolation_element_tmpl.hh
fe_engine/integration_point.hh
fe_engine/shape_functions.hh
fe_engine/shape_functions.cc
fe_engine/shape_functions_inline_impl.cc
fe_engine/shape_lagrange_base.cc
fe_engine/shape_lagrange_base.hh
fe_engine/shape_lagrange_base_inline_impl.cc
fe_engine/shape_lagrange.hh
fe_engine/shape_lagrange_inline_impl.cc
fe_engine/element.hh
io/dumper/dumpable.hh
io/dumper/dumpable.cc
io/dumper/dumpable_dummy.hh
io/dumper/dumpable_inline_impl.hh
io/dumper/dumper_field.hh
io/dumper/dumper_material_padders.hh
io/dumper/dumper_filtered_connectivity.hh
io/dumper/dumper_element_partition.hh
io/mesh_io.cc
io/mesh_io.hh
io/mesh_io/mesh_io_diana.cc
io/mesh_io/mesh_io_diana.hh
io/mesh_io/mesh_io_msh.cc
io/mesh_io/mesh_io_msh.hh
#io/model_io.cc
#io/model_io.hh
io/parser/algebraic_parser.hh
io/parser/input_file_parser.hh
io/parser/parsable.cc
io/parser/parsable.hh
io/parser/parser.cc
io/parser/parser_real.cc
io/parser/parser_random.cc
io/parser/parser_types.cc
io/parser/parser_input_files.cc
io/parser/parser.hh
io/parser/parser_tmpl.hh
io/parser/parser_grammar_tmpl.hh
io/parser/cppargparse/cppargparse.hh
io/parser/cppargparse/cppargparse.cc
io/parser/cppargparse/cppargparse_tmpl.hh
io/parser/parameter_registry.cc
io/parser/parameter_registry.hh
io/parser/parameter_registry_tmpl.hh
mesh/element_group.cc
mesh/element_group.hh
mesh/element_group_inline_impl.cc
mesh/element_type_map.cc
mesh/element_type_map.hh
mesh/element_type_map_tmpl.hh
mesh/element_type_map_filter.hh
mesh/group_manager.cc
mesh/group_manager.hh
mesh/group_manager_inline_impl.cc
mesh/mesh.cc
mesh/mesh.hh
mesh/mesh_periodic.cc
mesh/mesh_accessor.hh
mesh/mesh_events.hh
mesh/mesh_filter.hh
mesh/mesh_global_data_updater.hh
mesh/mesh_data.cc
mesh/mesh_data.hh
mesh/mesh_data_tmpl.hh
mesh/mesh_inline_impl.cc
mesh/node_group.cc
mesh/node_group.hh
mesh/node_group_inline_impl.cc
mesh/mesh_iterators.hh
mesh_utils/mesh_partition.cc
mesh_utils/mesh_partition.hh
mesh_utils/mesh_partition/mesh_partition_mesh_data.cc
mesh_utils/mesh_partition/mesh_partition_mesh_data.hh
mesh_utils/mesh_partition/mesh_partition_scotch.hh
mesh_utils/mesh_utils_pbc.cc
mesh_utils/mesh_utils.cc
mesh_utils/mesh_utils.hh
mesh_utils/mesh_utils_distribution.cc
mesh_utils/mesh_utils_distribution.hh
mesh_utils/mesh_utils.hh
mesh_utils/mesh_utils_inline_impl.cc
mesh_utils/global_ids_updater.hh
mesh_utils/global_ids_updater.cc
mesh_utils/global_ids_updater_inline_impl.cc
model/common/boundary_condition/boundary_condition.hh
model/common/boundary_condition/boundary_condition_functor.hh
model/common/boundary_condition/boundary_condition_functor_inline_impl.cc
model/common/boundary_condition/boundary_condition_tmpl.hh
model/common/non_local_toolbox/neighborhood_base.hh
model/common/non_local_toolbox/neighborhood_base.cc
model/common/non_local_toolbox/neighborhood_base_inline_impl.cc
model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.hh
model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.cc
model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion_inline_impl.cc
model/common/non_local_toolbox/non_local_manager.hh
model/common/non_local_toolbox/non_local_manager.cc
model/common/non_local_toolbox/non_local_manager_inline_impl.cc
model/common/non_local_toolbox/non_local_manager_callback.hh
model/common/non_local_toolbox/non_local_neighborhood_base.hh
model/common/non_local_toolbox/non_local_neighborhood_base.cc
model/common/non_local_toolbox/non_local_neighborhood.hh
model/common/non_local_toolbox/non_local_neighborhood_tmpl.hh
model/common/non_local_toolbox/non_local_neighborhood_inline_impl.cc
model/common/non_local_toolbox/base_weight_function.hh
model/common/non_local_toolbox/base_weight_function_inline_impl.cc
model/common/model_solver.cc
model/common/model_solver.hh
model/common/solver_callback.hh
model/common/solver_callback.cc
model/common/dof_manager/dof_manager.cc
model/common/dof_manager/dof_manager.hh
model/common/dof_manager/dof_manager_default.cc
model/common/dof_manager/dof_manager_default.hh
model/common/dof_manager/dof_manager_default_inline_impl.cc
model/common/dof_manager/dof_manager_inline_impl.cc
model/common/non_linear_solver/non_linear_solver.cc
model/common/non_linear_solver/non_linear_solver.hh
model/common/non_linear_solver/non_linear_solver_default.hh
model/common/non_linear_solver/non_linear_solver_lumped.cc
model/common/non_linear_solver/non_linear_solver_lumped.hh
model/common/time_step_solvers/time_step_solver.hh
model/common/time_step_solvers/time_step_solver.cc
model/common/time_step_solvers/time_step_solver_default.cc
model/common/time_step_solvers/time_step_solver_default.hh
model/common/time_step_solvers/time_step_solver_default_explicit.hh
model/common/integration_scheme/generalized_trapezoidal.cc
model/common/integration_scheme/generalized_trapezoidal.hh
model/common/integration_scheme/integration_scheme.cc
model/common/integration_scheme/integration_scheme.hh
model/common/integration_scheme/integration_scheme_1st_order.cc
model/common/integration_scheme/integration_scheme_1st_order.hh
model/common/integration_scheme/integration_scheme_2nd_order.cc
model/common/integration_scheme/integration_scheme_2nd_order.hh
model/common/integration_scheme/newmark-beta.cc
model/common/integration_scheme/newmark-beta.hh
model/common/integration_scheme/pseudo_time.cc
model/common/integration_scheme/pseudo_time.hh
model/model.cc
model/model.hh
model/model_inline_impl.cc
model/model_options.hh
solver/solver_vector.hh
solver/solver_vector_default.cc
solver/solver_vector_default.hh
solver/solver_vector_default_tmpl.hh
solver/solver_vector_distributed.cc
solver/solver_vector_distributed.hh
solver/sparse_matrix.cc
solver/sparse_matrix.hh
solver/sparse_matrix_aij.cc
solver/sparse_matrix_aij.hh
solver/sparse_matrix_aij_inline_impl.cc
solver/sparse_matrix_inline_impl.cc
solver/sparse_solver.cc
solver/sparse_solver.hh
solver/sparse_solver_inline_impl.cc
solver/terms_to_assemble.hh
synchronizer/communication_buffer_inline_impl.cc
synchronizer/communication_descriptor.hh
synchronizer/communication_descriptor_tmpl.hh
synchronizer/communication_request.hh
synchronizer/communication_tag.hh
synchronizer/communications.hh
synchronizer/communications_tmpl.hh
synchronizer/communicator.cc
synchronizer/communicator.hh
synchronizer/communicator_dummy_inline_impl.cc
synchronizer/communicator_event_handler.hh
synchronizer/communicator_inline_impl.hh
synchronizer/data_accessor.cc
synchronizer/data_accessor.hh
synchronizer/dof_synchronizer.cc
synchronizer/dof_synchronizer.hh
synchronizer/dof_synchronizer_inline_impl.cc
synchronizer/element_info_per_processor.cc
synchronizer/element_info_per_processor.hh
synchronizer/element_info_per_processor_tmpl.hh
synchronizer/element_synchronizer.cc
synchronizer/element_synchronizer.hh
synchronizer/facet_synchronizer.cc
synchronizer/facet_synchronizer.hh
synchronizer/facet_synchronizer_inline_impl.cc
synchronizer/grid_synchronizer.cc
synchronizer/grid_synchronizer.hh
synchronizer/grid_synchronizer_tmpl.hh
synchronizer/master_element_info_per_processor.cc
synchronizer/node_info_per_processor.cc
synchronizer/node_info_per_processor.hh
synchronizer/node_synchronizer.cc
synchronizer/node_synchronizer.hh
synchronizer/periodic_node_synchronizer.cc
synchronizer/periodic_node_synchronizer.hh
synchronizer/slave_element_info_per_processor.cc
synchronizer/synchronizer.cc
synchronizer/synchronizer.hh
synchronizer/synchronizer_impl.hh
synchronizer/synchronizer_impl_tmpl.hh
synchronizer/synchronizer_registry.cc
synchronizer/synchronizer_registry.hh
synchronizer/synchronizer_tmpl.hh
synchronizer/communication_buffer.hh
)
set(AKANTU_SPIRIT_SOURCES
io/mesh_io/mesh_io_abaqus.cc
io/parser/parser_real.cc
io/parser/parser_random.cc
io/parser/parser_types.cc
io/parser/parser_input_files.cc
PARENT_SCOPE
)
package_declare_elements(core
ELEMENT_TYPES
_point_1
_segment_2
_segment_3
_triangle_3
_triangle_6
_quadrangle_4
_quadrangle_8
_tetrahedron_4
_tetrahedron_10
_pentahedron_6
_pentahedron_15
_hexahedron_8
_hexahedron_20
KIND regular
GEOMETRICAL_TYPES
_gt_point
_gt_segment_2
_gt_segment_3
_gt_triangle_3
_gt_triangle_6
_gt_quadrangle_4
_gt_quadrangle_8
_gt_tetrahedron_4
_gt_tetrahedron_10
_gt_hexahedron_8
_gt_hexahedron_20
_gt_pentahedron_6
_gt_pentahedron_15
INTERPOLATION_TYPES
_itp_lagrange_point_1
_itp_lagrange_segment_2
_itp_lagrange_segment_3
_itp_lagrange_triangle_3
_itp_lagrange_triangle_6
_itp_lagrange_quadrangle_4
_itp_serendip_quadrangle_8
_itp_lagrange_tetrahedron_4
_itp_lagrange_tetrahedron_10
_itp_lagrange_hexahedron_8
_itp_serendip_hexahedron_20
_itp_lagrange_pentahedron_6
_itp_lagrange_pentahedron_15
GEOMETRICAL_SHAPES
_gst_point
_gst_triangle
_gst_square
_gst_prism
GAUSS_INTEGRATION_TYPES
_git_point
_git_segment
_git_triangle
_git_tetrahedron
_git_pentahedron
INTERPOLATION_KIND _itk_lagrangian
FE_ENGINE_LISTS
gradient_on_integration_points
interpolate_on_integration_points
interpolate
compute_normals_on_integration_points
inverse_map
contains
compute_shapes
compute_shapes_derivatives
get_shapes_derivatives
lagrange_base
)
package_declare_documentation_files(core
manual.sty
manual.cls
manual.tex
manual-macros.sty
manual-titlepages.tex
manual-authors.tex
manual-changelog.tex
manual-introduction.tex
manual-gettingstarted.tex
manual-io.tex
manual-feengine.tex
manual-elements.tex
manual-appendix-elements.tex
manual-appendix-packages.tex
manual-backmatter.tex
manual-bibliography.bib
manual-bibliographystyle.bst
figures/bc_and_ic_example.pdf
figures/boundary.pdf
figures/boundary.svg
figures/dirichlet.pdf
figures/dirichlet.svg
# figures/doc_wheel.pdf
# figures/doc_wheel.svg
figures/hot-point-1.png
figures/hot-point-2.png
figures/insertion.pdf
figures/interpolate.pdf
figures/interpolate.svg
figures/vectors.pdf
figures/vectors.svg
figures/elements/hexahedron_8.pdf
figures/elements/hexahedron_8.svg
figures/elements/quadrangle_4.pdf
figures/elements/quadrangle_4.svg
figures/elements/quadrangle_8.pdf
figures/elements/quadrangle_8.svg
figures/elements/segment_2.pdf
figures/elements/segment_2.svg
figures/elements/segment_3.pdf
figures/elements/segment_3.svg
figures/elements/tetrahedron_10.pdf
figures/elements/tetrahedron_10.svg
figures/elements/tetrahedron_4.pdf
figures/elements/tetrahedron_4.svg
figures/elements/triangle_3.pdf
figures/elements/triangle_3.svg
figures/elements/triangle_6.pdf
figures/elements/triangle_6.svg
figures/elements/xtemp.pdf
)
package_declare_documentation(core
"This package is the core engine of \\akantu. It depends on:"
"\\begin{itemize}"
"\\item A C++ compiler (\\href{http://gcc.gnu.org/}{GCC} >= 4, or \\href{https://software.intel.com/en-us/intel-compilers}{Intel})."
"\\item The cross-platform, open-source \\href{http://www.cmake.org/}{CMake} build system."
"\\item The \\href{http://www.boost.org/}{Boost} C++ portable libraries."
"\\item The \\href{http://www.zlib.net/}{zlib} compression library."
"\\end{itemize}"
""
"Under Ubuntu (14.04 LTS) the installation can be performed using the commands:"
"\\begin{command}"
" > sudo apt-get install cmake libboost-dev zlib1g-dev g++"
"\\end{command}"
""
"Under Mac OS X the installation requires the following steps:"
"\\begin{itemize}"
"\\item Install Xcode"
"\\item Install the command line tools."
"\\item Install the MacPorts project which allows to automatically"
"download and install opensource packages."
"\\end{itemize}"
"Then the following commands should be typed in a terminal:"
"\\begin{command}"
" > sudo port install cmake gcc48 boost"
"\\end{command}"
)
find_program(READLINK_COMMAND readlink)
find_program(ADDR2LINE_COMMAND addr2line)
find_program(PATCH_COMMAND patch)
mark_as_advanced(READLINK_COMMAND)
mark_as_advanced(ADDR2LINE_COMMAND)
package_declare_extra_files_to_package(core
SOURCES
common/aka_element_classes_info.hh.in
common/aka_config.hh.in
)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.9))
package_set_compile_flags(core CXX "-Wno-undefined-var-template")
endif()
if(DEFINED AKANTU_CXX11_FLAGS)
package_declare(core_cxx11 NOT_OPTIONAL
DESCRIPTION "C++ 11 additions for Akantu core"
COMPILE_FLAGS CXX "${AKANTU_CXX11_FLAGS}")
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.6")
set(AKANTU_CORE_CXX11 OFF CACHE BOOL "C++ 11 additions for Akantu core - not supported by the selected compiler" FORCE)
endif()
endif()
package_declare_documentation(core_cxx11
"This option activates some features of the C++11 standard. This is usable with GCC>=4.7 or Intel>=13.")
else()
if(CMAKE_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Since version 3.0 Akantu requires at least c++11 capable compiler")
endif()
endif()
diff --git a/packages/solid_mechanics.cmake b/packages/solid_mechanics.cmake
index 9d51e1e4b..145a65785 100644
--- a/packages/solid_mechanics.cmake
+++ b/packages/solid_mechanics.cmake
@@ -1,131 +1,134 @@
#===============================================================================
# @file solid_mechanics.cmake
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Mon Nov 21 2011
# @date last modification: Mon Jan 18 2016
#
# @brief package description for core
#
# @section LICENSE
#
# Copyright (©) 2010-2012, 2014, 2015 EPFL (Ecole Polytechnique Fédérale de
# Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des
# Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
package_declare(solid_mechanics DEFAULT ON
DESCRIPTION "Solid mechanics model"
DEPENDS core lapack
)
package_declare_sources(solid_mechanics
model/solid_mechanics/material.cc
model/solid_mechanics/material.hh
model/solid_mechanics/material_inline_impl.cc
model/solid_mechanics/material_selector.hh
model/solid_mechanics/material_selector_tmpl.hh
model/solid_mechanics/materials/internal_field.hh
model/solid_mechanics/materials/internal_field_tmpl.hh
model/solid_mechanics/materials/random_internal_field.hh
model/solid_mechanics/materials/random_internal_field_tmpl.hh
model/solid_mechanics/solid_mechanics_model.cc
model/solid_mechanics/solid_mechanics_model.hh
model/solid_mechanics/solid_mechanics_model_inline_impl.cc
model/solid_mechanics/solid_mechanics_model_io.cc
model/solid_mechanics/solid_mechanics_model_mass.cc
model/solid_mechanics/solid_mechanics_model_material.cc
model/solid_mechanics/solid_mechanics_model_tmpl.hh
model/solid_mechanics/solid_mechanics_model_event_handler.hh
model/solid_mechanics/materials/plane_stress_toolbox.hh
model/solid_mechanics/materials/plane_stress_toolbox_tmpl.hh
model/solid_mechanics/materials/material_core_includes.hh
model/solid_mechanics/materials/material_elastic.cc
model/solid_mechanics/materials/material_elastic.hh
model/solid_mechanics/materials/material_elastic_inline_impl.cc
model/solid_mechanics/materials/material_thermal.cc
model/solid_mechanics/materials/material_thermal.hh
model/solid_mechanics/materials/material_elastic_linear_anisotropic.cc
model/solid_mechanics/materials/material_elastic_linear_anisotropic.hh
model/solid_mechanics/materials/material_elastic_linear_anisotropic_inline_impl.cc
model/solid_mechanics/materials/material_elastic_orthotropic.cc
model/solid_mechanics/materials/material_elastic_orthotropic.hh
+ model/solid_mechanics/materials/material_damage/material_anisotropic_damage.hh
+ model/solid_mechanics/materials/material_damage/material_anisotropic_damage.cc
+ model/solid_mechanics/materials/material_damage/material_anisotropic_damage_tmpl.hh
model/solid_mechanics/materials/material_damage/material_damage.hh
model/solid_mechanics/materials/material_damage/material_damage_tmpl.hh
model/solid_mechanics/materials/material_damage/material_marigo.cc
model/solid_mechanics/materials/material_damage/material_marigo.hh
model/solid_mechanics/materials/material_damage/material_marigo_inline_impl.cc
model/solid_mechanics/materials/material_damage/material_mazars.cc
model/solid_mechanics/materials/material_damage/material_mazars.hh
model/solid_mechanics/materials/material_damage/material_mazars_inline_impl.cc
model/solid_mechanics/materials/material_finite_deformation/material_neohookean.cc
model/solid_mechanics/materials/material_finite_deformation/material_neohookean.hh
model/solid_mechanics/materials/material_finite_deformation/material_neohookean_inline_impl.cc
model/solid_mechanics/materials/material_plastic/material_plastic.cc
model/solid_mechanics/materials/material_plastic/material_plastic.hh
model/solid_mechanics/materials/material_plastic/material_plastic_inline_impl.cc
model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.cc
model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.hh
model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening_inline_impl.cc
model/solid_mechanics/materials/material_viscoelastic/material_standard_linear_solid_deviatoric.cc
model/solid_mechanics/materials/material_viscoelastic/material_standard_linear_solid_deviatoric.hh
model/solid_mechanics/materials/material_viscoelastic/material_viscoelastic_maxwell.cc
model/solid_mechanics/materials/material_viscoelastic/material_viscoelastic_maxwell.hh
model/solid_mechanics/materials/material_non_local.hh
model/solid_mechanics/materials/material_non_local_tmpl.hh
model/solid_mechanics/materials/material_non_local_includes.hh
)
package_declare_material_infos(solid_mechanics
LIST AKANTU_CORE_MATERIAL_LIST
INCLUDE material_core_includes.hh
)
package_declare_documentation_files(solid_mechanics
manual-solidmechanicsmodel.tex
manual-constitutive-laws.tex
manual-lumping.tex
manual-appendix-materials.tex
figures/dynamic_analysis.png
figures/explicit_dynamic.pdf
figures/explicit_dynamic.svg
figures/static.pdf
figures/static.svg
figures/hooke_law.pdf
figures/implicit_dynamic.pdf
figures/implicit_dynamic.svg
figures/problemDomain.pdf_tex
figures/problemDomain.pdf
figures/static_analysis.png
figures/stress_strain_el.pdf
figures/tangent.pdf
figures/tangent.svg
figures/stress_strain_neo.pdf
figures/visco_elastic_law.pdf
figures/isotropic_hardening_plasticity.pdf
figures/stress_strain_visco.pdf
)
package_declare_extra_files_to_package(solid_mechanics
SOURCES
model/solid_mechanics/material_list.hh.in
)
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index 887cb79b8..97fa8dfbf 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -1,91 +1,92 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Nicolas Richart <nicolas.richart@epfl.ch>
#
# @date creation: Fri Dec 12 2014
# @date last modification: Mon Jan 18 2016
#
# @brief CMake file for the python wrapping of akantu
#
# @section LICENSE
#
# Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory
# (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
set(PYAKANTU_SRCS
py_aka_common.cc
py_aka_error.cc
py_akantu.cc
py_boundary_conditions.cc
py_fe_engine.cc
py_group_manager.cc
py_mesh.cc
py_model.cc
py_parser.cc
)
package_is_activated(iohelper _is_activated)
if (_is_activated)
list(APPEND PYAKANTU_SRCS
py_dumpable.cc
)
endif()
package_is_activated(solid_mechanics _is_activated)
if (_is_activated)
list(APPEND PYAKANTU_SRCS
py_solid_mechanics_model.cc
py_material.cc
)
endif()
package_is_activated(cohesive_element _is_activated)
if (_is_activated)
list(APPEND PYAKANTU_SRCS
py_solid_mechanics_model_cohesive.cc
)
endif()
package_is_activated(heat_transfer _is_activated)
if (_is_activated)
list(APPEND PYAKANTU_SRCS
py_heat_transfer_model.cc
)
endif()
package_is_activated(contact_mechanics _is_activated)
if(_is_activated)
list(APPEND PYAKANTU_SRCS
py_contact_mechanics_model.cc
)
endif()
package_is_activated(model_couplers _is_activated)
if(_is_activated)
list(APPEND PYAKANTU_SRCS
py_model_couplers.cc
)
endif()
pybind11_add_module(py11_akantu ${PYAKANTU_SRCS})
target_link_libraries(py11_akantu PRIVATE akantu pybind11)
target_include_directories(py11_akantu INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
+
set_target_properties(py11_akantu PROPERTIES DEBUG_POSTFIX "")
diff --git a/python/py11_akantu.cc b/python/py11_akantu.cc
new file mode 100644
index 000000000..60c98300b
--- /dev/null
+++ b/python/py11_akantu.cc
@@ -0,0 +1 @@
+// This file is only for cmake < 3.12
diff --git a/python/py_aka_array.hh b/python/py_aka_array.hh
index 67689c65a..2efb37db2 100644
--- a/python/py_aka_array.hh
+++ b/python/py_aka_array.hh
@@ -1,238 +1,240 @@
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
/* -------------------------------------------------------------------------- */
#include <pybind11/numpy.h>
#include <pybind11/pybind11.h>
/* -------------------------------------------------------------------------- */
namespace py = pybind11;
namespace _aka = akantu;
namespace akantu {
+namespace detail {
+ template <class T> struct is_array_type : public std::false_type {};
+ template <class T> struct is_array_type<Vector<T>> : public std::true_type {};
+ template <class T> struct is_array_type<Matrix<T>> : public std::true_type {};
+ template <class T> struct is_array_type<Array<T>> : public std::true_type {};
-template <typename VecType> class Proxy : public VecType {
-protected:
- using T = typename VecType::value_type;
- // deallocate the memory
- void deallocate() override final {}
-
- // allocate the memory
- void allocate(__attribute__((unused)) UInt size,
- __attribute__((unused)) UInt nb_component) override final {}
-
- // allocate and initialize the memory
- void allocate(__attribute__((unused)) UInt size,
- __attribute__((unused)) UInt nb_component,
- __attribute__((unused)) const T & value) override final {}
-
-public:
- Proxy(T * data, UInt size, UInt nb_component) {
- this->values = data;
- this->size_ = size;
- this->nb_component = nb_component;
- }
-
- Proxy(const Array<T> & src) {
- this->values = src.storage();
- this->size_ = src.size();
- this->nb_component = src.getNbComponent();
- }
+ /* ------------------------------------------------------------------------ */
+ template <typename T> class ArrayProxy : public Array<T> {
+ protected:
+ // deallocate the memory
+ void deallocate() override final {}
- ~Proxy() { this->values = nullptr; }
+ // allocate the memory
+ void allocate(UInt /*size*/, UInt /*nb_component*/) override final {}
- void resize(UInt /*size*/, const T & /*val */) override final {
- AKANTU_EXCEPTION("cannot resize a temporary array");
- }
+ // allocate and initialize the memory
+ void allocate(UInt /*size*/, UInt /*nb_component*/,
+ const T & /*value*/) override final {}
- void resize(UInt /*new_size*/) override final {
- AKANTU_EXCEPTION("cannot resize a temporary array");
- }
+ public:
+ ArrayProxy(T * data, UInt size, UInt nb_component) {
+ this->values = data;
+ this->size_ = size;
+ this->nb_component = nb_component;
+ }
- void reserve(UInt /*size*/, UInt /*new_size*/) override final {
- AKANTU_EXCEPTION("cannot resize a temporary array");
- }
-};
+ ArrayProxy(const Array<T> & src) {
+ this->values = src.storage();
+ this->size_ = src.size();
+ this->nb_component = src.getNbComponent();
+ }
-template <typename T> using vec_proxy = Vector<T>;
-template <typename T> using mat_proxy = Matrix<T>;
-template <typename T> using array_proxy = Proxy<Array<T>>;
+ ~ArrayProxy() { this->values = nullptr; }
-template <typename array> struct ProxyType { using type = Proxy<array>; };
+ void resize(UInt /*size*/, const T & /*val */) override final {
+ AKANTU_EXCEPTION("cannot resize a temporary array");
+ }
-template <typename T> struct ProxyType<Vector<T>> { using type = Vector<T>; };
-template <typename T> struct ProxyType<Matrix<T>> { using type = Matrix<T>; };
+ void resize(UInt /*new_size*/) override final {
+ AKANTU_EXCEPTION("cannot resize a temporary array");
+ }
-template <typename array> using ProxyType_t = typename ProxyType<array>::type;
+ void reserve(UInt /*size*/, UInt /*new_size*/) override final {
+ AKANTU_EXCEPTION("cannot resize a temporary array");
+ }
+ };
+ /* ------------------------------------------------------------------------ */
+ template <typename T> struct ProxyType {};
+ template <typename T> struct ProxyType<Vector<T>> { using type = Vector<T>; };
+ template <typename T> struct ProxyType<Matrix<T>> { using type = Matrix<T>; };
+ template <typename T> struct ProxyType<Array<T>> {
+ using type = ArrayProxy<T>;
+ };
+ template <typename array> using ProxyType_t = typename ProxyType<array>::type;
+} // namespace detail
} // namespace akantu
namespace pybind11 {
namespace detail {
- template <typename U>
- using array_type = array_t<U, array::c_style | array::forcecast>;
+ template <typename T> struct AkaArrayType {
+ using type =
+ array_t<typename T::value_type, array::c_style | array::forcecast>;
+ };
+
+ template <typename T> struct AkaArrayType<_aka::Vector<T>> {
+ using type = array_t<T, array::f_style | array::forcecast>;
+ };
+ template <typename T> struct AkaArrayType<_aka::Matrix<T>> {
+ using type = array_t<T, array::f_style | array::forcecast>;
+ };
+
+ template <typename U> using array_type_t = typename AkaArrayType<U>::type;
+
+ /* ------------------------------------------------------------------------ */
+
template <typename T>
- void create_proxy(std::unique_ptr<_aka::vec_proxy<T>> & proxy,
- array_type<T> ref) {
- proxy =
- std::make_unique<_aka::vec_proxy<T>>(ref.mutable_data(), ref.shape(0));
+ decltype(auto) create_proxy(array_type_t<_aka::Vector<T>> & ref, const _aka::Vector<T> *) {
+ return std::make_unique<_aka::detail::ProxyType_t<_aka::Vector<T>>>(
+ ref.mutable_data(), ref.shape(0));
}
template <typename T>
- void create_proxy(std::unique_ptr<_aka::mat_proxy<T>> & proxy,
- array_type<T> ref) {
- proxy = std::make_unique<_aka::mat_proxy<T>>(ref.mutable_data(),
- ref.shape(0), ref.shape(1));
+ decltype(auto) create_proxy(array_type_t<_aka::Matrix<T>> & ref, const _aka::Matrix<T> *) {
+ return std::make_unique<_aka::detail::ProxyType_t<_aka::Matrix<T>>>(
+ ref.mutable_data(), ref.shape(0), ref.shape(1));
}
template <typename T>
- void create_proxy(std::unique_ptr<_aka::array_proxy<T>> & proxy,
- array_type<T> ref) {
- proxy = std::make_unique<_aka::array_proxy<T>>(ref.mutable_data(),
- ref.shape(0), ref.shape(1));
+ decltype(auto) create_proxy(array_type_t<_aka::Array<T>> & ref, const _aka::Array<T> *) {
+ return std::make_unique<_aka::detail::ProxyType_t<_aka::Array<T>>>(
+ ref.mutable_data(), ref.shape(0), ref.shape(1));
}
/* ------------------------------------------------------------------------ */
template <typename T>
py::handle aka_array_cast(const _aka::Array<T> & src,
py::handle base = handle(), bool writeable = true) {
array a;
- a = array_type<T>({src.size(), src.getNbComponent()}, src.storage(), base);
+ a = array_type_t<_aka::Array<T>>({src.size(), src.getNbComponent()},
+ src.storage(), base);
if (not writeable)
array_proxy(a.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
return a.release();
}
- template <typename U>
- using tensor_type = array_t<U, array::f_style | array::forcecast>;
-
template <typename T>
py::handle aka_array_cast(const _aka::Vector<T> & src,
py::handle base = handle(), bool writeable = true) {
array a;
- a = tensor_type<T>({src.size()}, src.storage(), base);
+ a = array_type_t<_aka::Vector<T>>({src.size()}, src.storage(), base);
if (not writeable)
array_proxy(a.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
return a.release();
}
template <typename T>
py::handle aka_array_cast(const _aka::Matrix<T> & src,
py::handle base = handle(), bool writeable = true) {
array a;
- a = tensor_type<T>({src.size(0), src.size(1)}, src.storage(), base);
+ a = array_type_t<_aka::Matrix<T>>({src.size(0), src.size(1)}, src.storage(),
+ base);
if (not writeable)
array_proxy(a.ptr())->flags &= ~detail::npy_api::NPY_ARRAY_WRITEABLE_;
return a.release();
}
/* ------------------------------------------------------------------------ */
- template <typename VecType>
- class [[gnu::visibility("default")]] my_type_caster {
+ template <typename AkaArrayType>
+ class [[gnu::visibility("default")]] type_caster<
+ AkaArrayType,
+ std::enable_if_t<_aka::detail::is_array_type<AkaArrayType>::value>> {
protected:
- using T = typename VecType::value_type;
- using type = VecType;
- using proxy_type = _aka::ProxyType_t<VecType>;
- type value;
+ using T = typename AkaArrayType::value_type;
+ using type = AkaArrayType;
+ using proxy_type = _aka::detail::ProxyType_t<AkaArrayType>;
+ using array_type = array_type_t<AkaArrayType>;
+
+ std::unique_ptr<proxy_type> array_proxy;
+ array_type_t<AkaArrayType> copy_or_ref;
public:
- static PYBIND11_DESCR name() { return type_descr(_("Toto")); };
+#if PYBIND11_VERSION_MAJOR >= 2 && PYBIND11_VERSION_MINOR >= 3
+ static constexpr auto name = _("AkaArray");
+ operator type &&() && { return std::move(*array_proxy); }
+ template <typename T_>
+ using cast_op_type = pybind11::detail::movable_cast_op_type<T_>;
+#else
+ static PYBIND11_DESCR name() { return type_descr(_("AkaArray")); };
+ template <typename _T>
+ using cast_op_type = pybind11::detail::cast_op_type<_T>;
+#endif
+ operator type *() { return array_proxy.get(); }
+ operator type &() { return *array_proxy; }
/**
* Conversion part 1 (Python->C++)
*/
bool load(handle src, bool convert) {
- bool need_copy = not isinstance<array_type<T>>(src);
+ bool need_copy = not isinstance<array_type>(src);
auto && fits = [&](auto && aref) {
auto && dims = aref.ndim();
if (dims < 1 || dims > 2)
return false;
return true;
};
if (not need_copy) {
// We don't need a converting copy, but we also need to check whether
// the strides are compatible with the Ref's stride requirements
- auto aref = py::cast<array_type<T>>(src);
+ auto aref = py::cast<array_type>(src);
if (not fits(aref)) {
return false;
}
copy_or_ref = std::move(aref);
} else {
if (not convert) {
return false;
}
- auto copy = array_type<T>::ensure(src);
+ auto copy = array_type::ensure(src);
if (not copy) {
return false;
}
if (not fits(copy)) {
return false;
}
- copy_or_ref = std::move(array_type<T>::ensure(src));
+ copy_or_ref = std::move(array_type::ensure(src));
loader_life_support::add_patient(copy_or_ref);
}
- create_proxy(array_proxy, copy_or_ref);
+ AkaArrayType* dispatch = nullptr; // cannot detect T from the expression
+ array_proxy = create_proxy(copy_or_ref, dispatch);
return true;
}
- operator type *() { return array_proxy.get(); }
- operator type &() { return *array_proxy; }
-
- template <typename _T>
- using cast_op_type = pybind11::detail::cast_op_type<_T>;
-
/**
* Conversion part 2 (C++ -> Python)
*/
static handle cast(const type & src, return_value_policy policy,
handle parent) {
switch (policy) {
case return_value_policy::copy:
return aka_array_cast<T>(src);
case return_value_policy::reference_internal:
return aka_array_cast<T>(src, parent);
case return_value_policy::reference:
case return_value_policy::automatic:
case return_value_policy::automatic_reference:
return aka_array_cast<T>(src, none());
default:
pybind11_fail("Invalid return_value_policy for ArrayProxy type");
}
}
-
- protected:
- std::unique_ptr<proxy_type> array_proxy;
- array_type<T> copy_or_ref;
};
-
- /* ------------------------------------------------------------------------ */
- // specializations
- /* ------------------------------------------------------------------------ */
-
- template <typename T>
- struct type_caster<_aka::Array<T>> : public my_type_caster<_aka::Array<T>> {};
-
- template <typename T>
- struct type_caster<_aka::Vector<T>> : public my_type_caster<_aka::Vector<T>> {
- };
-
- template <typename T>
- struct type_caster<_aka::Matrix<T>> : public my_type_caster<_aka::Matrix<T>> {
- };
-
} // namespace detail
} // namespace pybind11
diff --git a/python/py_group_manager.cc b/python/py_group_manager.cc
index bde0ed6b7..86f040107 100644
--- a/python/py_group_manager.cc
+++ b/python/py_group_manager.cc
@@ -1,74 +1,74 @@
/* -------------------------------------------------------------------------- */
#include "py_aka_array.hh"
/* -------------------------------------------------------------------------- */
#include <element_group.hh>
#include <node_group.hh>
/* -------------------------------------------------------------------------- */
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
/* -------------------------------------------------------------------------- */
namespace py = pybind11;
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void register_group_manager(py::module & mod) {
/* ------------------------------------------------------------------------ */
py::class_<NodeGroup>(mod, "NodeGroup")
.def("getNodes",
[](NodeGroup & self) -> decltype(auto) { return self.getNodes(); },
py::return_value_policy::reference);
/* ------------------------------------------------------------------------ */
py::class_<ElementGroup>(mod, "ElementGroup")
.def("getNodeGroup",
[](ElementGroup & self) -> decltype(auto) {
return self.getNodeGroup();
},
py::return_value_policy::reference);
/* ------------------------------------------------------------------------ */
py::class_<GroupManager>(mod, "GroupManager")
.def("getElementGroup",
[](GroupManager & self, const std::string & name) -> decltype(auto) {
return self.getElementGroup(name);
},
py::return_value_policy::reference)
.def("iterateElementGroups",
[](GroupManager & self) -> decltype(auto) {
std::vector<std::reference_wrapper<ElementGroup>> groups;
- for(auto & group: self.iterateElementGroups()) {
+ for (auto & group : self.iterateElementGroups()) {
groups.emplace_back(group);
}
return groups;
})
.def("iterateNodeGroups",
[](GroupManager & self) -> decltype(auto) {
std::vector<std::reference_wrapper<NodeGroup>> groups;
- for(auto & group: self.iterateNodeGroups()) {
+ for (auto & group : self.iterateNodeGroups()) {
groups.emplace_back(group);
}
return groups;
})
.def("createNodeGroup", &GroupManager::createNodeGroup,
py::return_value_policy::reference)
.def("createElementGroup",
py::overload_cast<const std::string &, UInt, bool>(
&GroupManager::createElementGroup),
py::return_value_policy::reference)
.def("createGroupsFromMeshDataUInt",
&GroupManager::createGroupsFromMeshData<UInt>)
.def("createElementGroupFromNodeGroup",
&GroupManager::createElementGroupFromNodeGroup, py::arg("name"),
py::arg("node_group"), py::arg("dimension") = _all_dimensions)
.def("getNodeGroup",
[](GroupManager & self, const std::string & name) -> decltype(auto) {
return self.getNodeGroup(name);
},
py::return_value_policy::reference)
.def("createBoundaryGroupFromGeometry",
&GroupManager::createBoundaryGroupFromGeometry);
}
} // namespace akantu
diff --git a/python/py_material.cc b/python/py_material.cc
index 926868425..56b5f4386 100644
--- a/python/py_material.cc
+++ b/python/py_material.cc
@@ -1,194 +1,194 @@
/* -------------------------------------------------------------------------- */
#include "py_aka_array.hh"
/* -------------------------------------------------------------------------- */
#include <material_selector.hh>
#include <solid_mechanics_model.hh>
/* -------------------------------------------------------------------------- */
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
/* -------------------------------------------------------------------------- */
namespace py = pybind11;
/* -------------------------------------------------------------------------- */
namespace akantu {
template <typename _Material> class PyMaterial : public _Material {
public:
/* Inherit the constructors */
using _Material::_Material;
virtual ~PyMaterial(){};
void initMaterial() override {
PYBIND11_OVERLOAD(void, _Material, initMaterial);
};
void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost) override {
PYBIND11_OVERLOAD_PURE(void, _Material, computeStress, el_type, ghost_type);
}
void computeTangentModuli(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost) override {
PYBIND11_OVERLOAD(void, _Material, computeTangentModuli, el_type,
tangent_matrix, ghost_type);
}
void computePotentialEnergy(ElementType el_type) override {
PYBIND11_OVERLOAD(void, _Material, computePotentialEnergy, el_type);
}
Real getPushWaveSpeed(const Element & element) const override {
PYBIND11_OVERLOAD(Real, _Material, getPushWaveSpeed, element);
}
Real getShearWaveSpeed(const Element & element) const override {
PYBIND11_OVERLOAD(Real, _Material, getShearWaveSpeed, element);
}
void registerInternal(const std::string & name, UInt nb_component) {
this->internals[name] = std::make_shared<InternalField<Real>>(name, *this);
AKANTU_DEBUG_INFO("alloc internal " << name << " "
<< &this->internals[name]);
this->internals[name]->initialize(nb_component);
}
auto & getInternals() { return this->internals; }
protected:
std::map<std::string, std::shared_ptr<InternalField<Real>>> internals;
};
/* -------------------------------------------------------------------------- */
template <typename T>
void register_element_type_map_array(py::module & mod,
const std::string & name) {
py::class_<ElementTypeMapArray<T>, std::shared_ptr<ElementTypeMapArray<T>>>(
mod, ("ElementTypeMapArray" + name).c_str())
.def("__call__",
[](ElementTypeMapArray<T> & self, ElementType & type,
const GhostType & ghost_type) -> decltype(auto) {
return self(type, ghost_type);
},
py::arg("type"), py::arg("ghost_type") = _not_ghost,
py::return_value_policy::reference)
.def("elementTypes",
[](ElementTypeMapArray<T> & self, UInt _dim, GhostType _ghost_type,
ElementKind _kind) -> decltype(auto) {
auto types = self.elementTypes(_dim, _ghost_type, _kind);
std::vector<ElementType> _types;
for (auto && t : types) {
_types.push_back(t);
}
return _types;
},
py::arg("dim") = _all_dimensions, py::arg("ghost_type") = _not_ghost,
py::arg("kind") = _ek_regular);
py::class_<InternalField<T>, ElementTypeMapArray<T>,
std::shared_ptr<InternalField<T>>>(
mod, ("InternalField" + name).c_str());
}
/* -------------------------------------------------------------------------- */
template <typename _Material>
void define_material(py::module & mod, const std::string & name) {
auto mat = py::class_<_Material, PyMaterial<_Material>, Parsable>(
mod, name.c_str(), py::multiple_inheritance());
mat.def(py::init<SolidMechanicsModel &, const ID &>())
.def("getGradU",
[](Material & self, ElementType el_type,
GhostType ghost_type = _not_ghost) -> decltype(auto) {
return self.getGradU(el_type, ghost_type);
},
py::arg("el_type"), py::arg("ghost_type") = _not_ghost,
py::return_value_policy::reference)
.def("getStress",
[](Material & self, ElementType el_type,
GhostType ghost_type = _not_ghost) -> decltype(auto) {
return self.getStress(el_type, ghost_type);
},
py::arg("el_type"), py::arg("ghost_type") = _not_ghost,
py::return_value_policy::reference)
.def("getPotentialEnergy",
[](Material & self, ElementType el_type) -> decltype(auto) {
return self.getPotentialEnergy(el_type);
},
py::return_value_policy::reference)
.def("initMaterial", &Material::initMaterial)
.def("getModel", &Material::getModel)
.def("registerInternal",
[](Material & self, const std::string & name, UInt nb_component) {
return dynamic_cast<PyMaterial<Material> &>(self).registerInternal(
name, nb_component);
})
.def_property_readonly(
"internals",
[](Material & self) {
return dynamic_cast<PyMaterial<Material> &>(self).getInternals();
})
.def_property_readonly("element_filter",
[](Material & self) -> decltype(auto) {
return self.getElementFilter();
},
py::return_value_policy::reference);
}
/* -------------------------------------------------------------------------- */
[[gnu::visibility("default")]] void register_material(py::module & mod) {
py::class_<MaterialFactory>(mod, "MaterialFactory")
.def_static("getInstance",
[]() -> MaterialFactory & { return Material::getFactory(); },
py::return_value_policy::reference)
.def("registerAllocator",
[](MaterialFactory & self, const std::string id, py::function func) {
self.registerAllocator(
id,
[func, id](UInt dim, const ID &, SolidMechanicsModel & model,
- const ID & id) -> std::unique_ptr<Material> {
- py::object obj = func(dim, id, model, id);
+ const ID & option) -> std::unique_ptr<Material> {
+ py::object obj = func(dim, id, model, option);
auto & ptr = py::cast<Material &>(obj);
obj.release();
return std::unique_ptr<Material>(&ptr);
});
});
register_element_type_map_array<Real>(mod, "Real");
register_element_type_map_array<UInt>(mod, "UInt");
define_material<Material>(mod, "Material");
}
/* -------------------------------------------------------------------------- */
template <typename T>
void register_data_material_selector(py::module & mod,
const std::string & name) {
py::class_<ElementDataMaterialSelector<T>, MaterialSelector,
std::shared_ptr<ElementDataMaterialSelector<T>>>(
mod, ("ElementDataMaterialSelector" + name).c_str());
py::class_<MeshDataMaterialSelector<T>, ElementDataMaterialSelector<T>,
std::shared_ptr<MeshDataMaterialSelector<T>>>(
mod, ("MeshDataMaterialSelector" + name).c_str())
.def(py::init<const std::string &, SolidMechanicsModel &, UInt>(),
py::arg("name"), py::arg("model"), py::arg("first_index") = 1);
}
/* -------------------------------------------------------------------------- */
void register_material_selector(py::module & mod) {
py::class_<MaterialSelector, std::shared_ptr<MaterialSelector>>(
mod, "MaterialSelector");
register_data_material_selector<std::string>(mod, "String");
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/python/py_model.cc b/python/py_model.cc
index 1279b8a2d..e0a1a063a 100644
--- a/python/py_model.cc
+++ b/python/py_model.cc
@@ -1,74 +1,77 @@
/* -------------------------------------------------------------------------- */
#include "py_aka_array.hh"
/* -------------------------------------------------------------------------- */
#include <model.hh>
#include <non_linear_solver.hh>
#include <sparse_matrix_aij.hh>
/* -------------------------------------------------------------------------- */
#include <pybind11/operators.h>
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
/* -------------------------------------------------------------------------- */
namespace py = pybind11;
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void register_model(py::module & mod) {
py::class_<SparseMatrix>(mod, "SparseMatrix")
.def("getMatrixType", &SparseMatrix::getMatrixType)
.def("size", &SparseMatrix::size);
py::class_<SparseMatrixAIJ, SparseMatrix>(mod, "SparseMatrixAIJ")
.def("getIRN", &SparseMatrixAIJ::getIRN)
.def("getJCN", &SparseMatrixAIJ::getJCN)
.def("getA", &SparseMatrixAIJ::getA);
py::class_<DOFManager>(mod, "DOFManager")
.def("getMatrix",
[](DOFManager & self, const std::string & name) {
return dynamic_cast<akantu::SparseMatrixAIJ &>(
self.getMatrix(name));
},
py::return_value_policy::reference);
py::class_<NonLinearSolver>(mod, "NonLinearSolver")
.def(
"set",
[](NonLinearSolver & self, const std::string & id, const Real & val) {
if (id == "max_iterations")
self.set(id, int(val));
else
self.set(id, val);
})
.def("set",
[](NonLinearSolver & self, const std::string & id,
const SolveConvergenceCriteria & val) { self.set(id, val); });
py::class_<ModelSolver, Parsable>(mod, "ModelSolver",
py::multiple_inheritance())
.def("getNonLinearSolver",
(NonLinearSolver & (ModelSolver::*)(const ID &)) &
ModelSolver::getNonLinearSolver,
py::arg("solver_id") = "", py::return_value_policy::reference)
- .def("solveStep", py::overload_cast<const ID &>(&ModelSolver::solveStep),
- py::arg("solver_id") = "");
+
+ .def("solveStep", [](ModelSolver & self) { self.solveStep(); })
+ .def("solveStep", [](ModelSolver & self, const ID & solver_id) {
+ self.solveStep(solver_id);
+ });
py::class_<Model, ModelSolver>(mod, "Model", py::multiple_inheritance())
.def("setBaseName", &Model::setBaseName)
.def("getFEEngine", &Model::getFEEngine, py::arg("name") = "",
py::return_value_policy::reference)
.def("addDumpFieldVector", &Model::addDumpFieldVector)
.def("addDumpField", &Model::addDumpField)
.def("setBaseNameToDumper", &Model::setBaseNameToDumper)
.def("addDumpFieldVectorToDumper", &Model::addDumpFieldVectorToDumper)
.def("addDumpFieldToDumper", &Model::addDumpFieldToDumper)
.def("dump", &Model::dump)
.def("initNewSolver", &Model::initNewSolver)
.def("getDOFManager", &Model::getDOFManager,
py::return_value_policy::reference);
}
} // namespace akantu
diff --git a/src/common/aka_array.hh b/src/common/aka_array.hh
index 55ebd007d..073cb5cb0 100644
--- a/src/common/aka_array.hh
+++ b/src/common/aka_array.hh
@@ -1,432 +1,436 @@
/**
* @file aka_array.hh
*
* @author Till Junge <till.junge@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Jan 16 2018
*
* @brief Array container for Akantu
* This container differs from the std::vector from the fact it as 2 dimensions
* a main dimension and the size stored per entries
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_VECTOR_HH__
#define __AKANTU_VECTOR_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#include <typeinfo>
#include <vector>
/* -------------------------------------------------------------------------- */
namespace akantu {
/// class that afford to store vectors in static memory
class ArrayBase {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
explicit ArrayBase(ID id = "") : id(std::move(id)) {}
ArrayBase(const ArrayBase & other, const ID & id = "") {
this->id = (id == "") ? other.id : id;
}
ArrayBase(ArrayBase && other) = default;
ArrayBase & operator=(const ArrayBase & other) = default;
// ArrayBase & operator=(ArrayBase && other) = default;
virtual ~ArrayBase() = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// get the amount of space allocated in bytes
virtual UInt getMemorySize() const = 0;
/// set the size to zero without freeing the allocated space
inline void empty();
/// function to print the containt of the class
virtual void printself(std::ostream & stream, int indent = 0) const = 0;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// Get the Size of the Array
UInt size() const { return size_; }
/// Get the number of components
AKANTU_GET_MACRO(NbComponent, nb_component, UInt);
/// Get the name of th array
AKANTU_GET_MACRO(ID, id, const ID &);
/// Set the name of th array
AKANTU_SET_MACRO(ID, id, const ID &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// id of the vector
ID id{""};
/// the size used
UInt size_{0};
/// number of components
UInt nb_component{1};
};
/* -------------------------------------------------------------------------- */
namespace {
template <std::size_t dim, typename T> struct IteratorHelper {};
template <typename T> struct IteratorHelper<0, T> { using type = T; };
template <typename T> struct IteratorHelper<1, T> { using type = Vector<T>; };
template <typename T> struct IteratorHelper<2, T> { using type = Matrix<T>; };
template <typename T> struct IteratorHelper<3, T> {
using type = Tensor3<T>;
};
template <std::size_t dim, typename T>
using IteratorHelper_t = typename IteratorHelper<dim, T>::type;
} // namespace
/* -------------------------------------------------------------------------- */
/* Memory handling layer */
/* -------------------------------------------------------------------------- */
enum class ArrayAllocationType {
_default,
_pod,
};
template <typename T>
struct ArrayAllocationTrait
: public std::conditional_t<
std::is_scalar<T>::value,
std::integral_constant<ArrayAllocationType,
ArrayAllocationType::_pod>,
std::integral_constant<ArrayAllocationType,
ArrayAllocationType::_default>> {};
/* -------------------------------------------------------------------------- */
template <typename T,
ArrayAllocationType allocation_trait = ArrayAllocationTrait<T>::value>
class ArrayDataLayer : public ArrayBase {
public:
using value_type = T;
using reference = value_type &;
using pointer_type = value_type *;
using const_reference = const value_type &;
public:
virtual ~ArrayDataLayer() = default;
/// Allocation of a new vector
explicit ArrayDataLayer(UInt size = 0, UInt nb_component = 1,
const ID & id = "");
/// Allocation of a new vector with a default value
ArrayDataLayer(UInt size, UInt nb_component, const_reference value,
const ID & id = "");
/// Copy constructor (deep copy)
ArrayDataLayer(const ArrayDataLayer & vect, const ID & id = "");
/// Copy constructor (deep copy)
explicit ArrayDataLayer(const std::vector<value_type> & vect);
// copy operator
ArrayDataLayer & operator=(const ArrayDataLayer & other);
// move constructor
ArrayDataLayer(ArrayDataLayer && other);
// move assign
ArrayDataLayer & operator=(ArrayDataLayer && other);
protected:
// deallocate the memory
virtual void deallocate() {}
// allocate the memory
virtual void allocate(UInt size, UInt nb_component);
// allocate and initialize the memory
virtual void allocate(UInt size, UInt nb_component, const T & value);
public:
/// append a tuple of size nb_component containing value
inline void push_back(const_reference value);
/// append a vector
// inline void push_back(const value_type new_elem[]);
/// append a Vector or a Matrix
template <template <typename> class C,
- typename = std::enable_if_t<aka::is_tensor<C<T>>::value>>
+ typename = std::enable_if_t<aka::is_tensor<C<T>>::value or
+ aka::is_tensor_proxy<C<T>>::value>>
inline void push_back(const C<T> & new_elem);
/// changes the allocated size but not the size, if new_size = 0, the size is
/// set to min(current_size and reserve size)
virtual void reserve(UInt size, UInt new_size = UInt(-1));
/// change the size of the Array
virtual void resize(UInt size);
/// change the size of the Array and initialize the values
virtual void resize(UInt size, const T & val);
/// get the amount of space allocated in bytes
inline UInt getMemorySize() const override;
/// Get the real size allocated in memory
inline UInt getAllocatedSize() const;
/// give the address of the memory allocated for this vector
T * storage() const { return values; };
protected:
/// allocation type agnostic data access
T * values{nullptr};
/// data storage
std::vector<T> data_storage;
};
/* -------------------------------------------------------------------------- */
/* Actual Array */
/* -------------------------------------------------------------------------- */
template <typename T, bool is_scal> class Array : public ArrayDataLayer<T> {
private:
using parent = ArrayDataLayer<T>;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
using value_type = typename parent::value_type;
using reference = typename parent::reference;
using pointer_type = typename parent::pointer_type;
using const_reference = typename parent::const_reference;
~Array() override;
- Array() : Array(0) {};
-
+ Array() : Array(0){};
+
/// Allocation of a new vector
explicit Array(UInt size, UInt nb_component = 1, const ID & id = "");
/// Allocation of a new vector with a default value
explicit Array(UInt size, UInt nb_component, const_reference value,
- const ID & id = "");
+ const ID & id = "");
/// Copy constructor (deep copy if deep=true)
Array(const Array & vect, const ID & id = "");
/// Copy constructor (deep copy)
explicit Array(const std::vector<T> & vect);
// copy operator
Array & operator=(const Array & other);
// move constructor
Array(Array && other) = default;
// move assign
Array & operator=(Array && other) = default;
/* ------------------------------------------------------------------------ */
/* Iterator */
/* ------------------------------------------------------------------------ */
/// \todo protected: does not compile with intel check why
public:
template <class R, class it, class IR = R,
bool is_tensor_ = aka::is_tensor<std::decay_t<R>>::value>
class iterator_internal;
public:
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
template <typename R = T> class const_iterator;
template <typename R = T> class iterator;
/* ------------------------------------------------------------------------ */
/// iterator for Array of nb_component = 1
using scalar_iterator = iterator<T>;
/// const_iterator for Array of nb_component = 1
using const_scalar_iterator = const_iterator<T>;
/// iterator returning Vectors of size n on entries of Array with
/// nb_component = n
using vector_iterator = iterator<Vector<T>>;
/// const_iterator returning Vectors of n size on entries of Array with
/// nb_component = n
using const_vector_iterator = const_iterator<Vector<T>>;
/// iterator returning Matrices of size (m, n) on entries of Array with
/// nb_component = m*n
using matrix_iterator = iterator<Matrix<T>>;
/// const iterator returning Matrices of size (m, n) on entries of Array with
/// nb_component = m*n
using const_matrix_iterator = const_iterator<Matrix<T>>;
/// iterator returning Tensor3 of size (m, n, k) on entries of Array with
/// nb_component = m*n*k
using tensor3_iterator = iterator<Tensor3<T>>;
/// const iterator returning Tensor3 of size (m, n, k) on entries of Array
/// with nb_component = m*n*k
using const_tensor3_iterator = const_iterator<Tensor3<T>>;
/* ------------------------------------------------------------------------ */
template <typename... Ns> inline decltype(auto) begin(Ns &&... n);
template <typename... Ns> inline decltype(auto) end(Ns &&... n);
template <typename... Ns> inline decltype(auto) begin(Ns &&... n) const;
template <typename... Ns> inline decltype(auto) end(Ns &&... n) const;
template <typename... Ns> inline decltype(auto) begin_reinterpret(Ns &&... n);
template <typename... Ns> inline decltype(auto) end_reinterpret(Ns &&... n);
template <typename... Ns>
inline decltype(auto) begin_reinterpret(Ns &&... n) const;
template <typename... Ns>
inline decltype(auto) end_reinterpret(Ns &&... n) const;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// search elem in the vector, return the position of the first occurrence or
/// -1 if not found
UInt find(const_reference elem) const;
/// @see Array::find(const_reference elem) const
UInt find(T elem[]) const;
inline void push_back(const_reference value) { parent::push_back(value); }
/// append a Vector or a Matrix
template <template <typename> class C,
- typename = std::enable_if_t<aka::is_tensor<C<T>>::value>>
+ typename = std::enable_if_t<aka::is_tensor<C<T>>::value or
+ aka::is_tensor_proxy<C<T>>::value>>
inline void push_back(const C<T> & new_elem) {
parent::push_back(new_elem);
}
template <typename Ret> inline void push_back(const iterator<Ret> & it) {
push_back(*it);
}
/// erase the value at position i
inline void erase(UInt i);
/// ask Nico, clarify
template <typename R> inline iterator<R> erase(const iterator<R> & it);
/// @see Array::find(const_reference elem) const
template <template <typename> class C,
- typename = std::enable_if_t<aka::is_tensor<C<T>>::value>>
+ typename = std::enable_if_t<aka::is_tensor<C<T>>::value or
+ aka::is_tensor_proxy<C<T>>::value>>
inline UInt find(const C<T> & elem);
/// set all entries of the array to the value t
/// @param t value to fill the array with
inline void set(T t) {
std::fill_n(this->values, this->size_ * this->nb_component, t);
}
/// set all entries of the array to 0
inline void clear() { set(T()); }
/// set all tuples of the array to a given vector or matrix
/// @param vm Matrix or Vector to fill the array with
template <template <typename> class C,
- typename = std::enable_if_t<aka::is_tensor<C<T>>::value>>
+ typename = std::enable_if_t<aka::is_tensor<C<T>>::value or
+ aka::is_tensor_proxy<C<T>>::value>>
inline void set(const C<T> & vm);
/// Append the content of the other array to the current one
void append(const Array<T> & other);
/// copy another Array in the current Array, the no_sanity_check allows you to
/// force the copy in cases where you know what you do with two non matching
/// Arrays in terms of n
void copy(const Array<T, is_scal> & other, bool no_sanity_check = false);
/// function to print the containt of the class
void printself(std::ostream & stream, int indent = 0) const override;
/* ------------------------------------------------------------------------ */
/* Operators */
/* ------------------------------------------------------------------------ */
public:
/// substraction entry-wise
Array<T, is_scal> & operator-=(const Array<T, is_scal> & other);
/// addition entry-wise
Array<T, is_scal> & operator+=(const Array<T, is_scal> & other);
/// multiply evry entry by alpha
Array<T, is_scal> & operator*=(const T & alpha);
/// check if the array are identical entry-wise
bool operator==(const Array<T, is_scal> & other) const;
/// @see Array::operator==(const Array<T, is_scal> & other) const
bool operator!=(const Array<T, is_scal> & other) const;
/// return a reference to the j-th entry of the i-th tuple
inline reference operator()(UInt i, UInt j = 0);
/// return a const reference to the j-th entry of the i-th tuple
inline const_reference operator()(UInt i, UInt j = 0) const;
/// return a reference to the ith component of the 1D array
inline reference operator[](UInt i);
/// return a const reference to the ith component of the 1D array
inline const_reference operator[](UInt i) const;
};
/* -------------------------------------------------------------------------- */
/* Inline Functions Array<T, is_scal> */
/* -------------------------------------------------------------------------- */
template <typename T, bool is_scal>
inline std::ostream & operator<<(std::ostream & stream,
const Array<T, is_scal> & _this) {
_this.printself(stream);
return stream;
}
/* -------------------------------------------------------------------------- */
/* Inline Functions ArrayBase */
/* -------------------------------------------------------------------------- */
inline std::ostream & operator<<(std::ostream & stream,
const ArrayBase & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "aka_array_tmpl.hh"
#include "aka_types.hh"
#endif /* __AKANTU_VECTOR_HH__ */
diff --git a/src/common/aka_array_printer.hh b/src/common/aka_array_printer.hh
new file mode 100644
index 000000000..e0949fb8b
--- /dev/null
+++ b/src/common/aka_array_printer.hh
@@ -0,0 +1,101 @@
+/**
+ * @file aka_array_printer.hh
+ *
+ * @author Nicolas Richart
+ *
+ * @date creation mer jun 19 2019
+ *
+ * @brief A Documented file.
+ *
+ * @section LICENSE
+ *
+ * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+ *
+ * Akantu is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Akantu. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+/* -------------------------------------------------------------------------- */
+#include "aka_array.hh"
+/* -------------------------------------------------------------------------- */
+
+#ifndef __AKANTU_AKA_ARRAY_PRINTER_HH__
+#define __AKANTU_AKA_ARRAY_PRINTER_HH__
+
+namespace akantu {
+
+/* -------------------------------------------------------------------------- */
+template <class container, bool no_explicit = true> class ArrayPrinter {
+public:
+ ArrayPrinter(const container & cont) : cont(cont) {}
+
+ void printself(std::ostream & stream, int indent = 0) const {
+ std::string space(indent, AKANTU_INDENT);
+
+ stream << space << "{";
+ for (UInt i = 0; i < this->cont.size(); ++i) {
+ stream << this->cont[i];
+ if (i != this->cont.size() - 1)
+ stream << ", ";
+ }
+ stream << "}" << std::endl;
+ }
+
+private:
+ const container & cont;
+};
+
+/* -------------------------------------------------------------------------- */
+template <class T> class ArrayPrinter<Array<T>> {
+public:
+ ArrayPrinter(const Array<T> & cont) : cont(cont) {}
+
+ void printself(std::ostream & stream, int indent = 0) const {
+ std::string space(indent, AKANTU_INDENT);
+
+ stream << space << "{";
+ for (UInt i = 0; i < this->cont.size(); ++i) {
+ stream << "{";
+ for (UInt j = 0; j < this->cont.getNbComponent(); ++j) {
+ stream << this->cont(i, j);
+ if (j != this->cont.getNbComponent() - 1)
+ stream << ", ";
+ }
+ stream << "}";
+ if (i != this->cont.size() - 1)
+ stream << ", ";
+ }
+ stream << "}" << std::endl;
+ }
+
+private:
+ const Array<T> & cont;
+};
+
+template <class container>
+decltype(auto) make_printer(const container & array) {
+ return ArrayPrinter<container>(array);
+}
+
+/* -------------------------------------------------------------------------- */
+template <class T>
+inline std::ostream & operator<<(std::ostream & stream,
+ const ArrayPrinter<T> & _this) {
+ _this.printself(stream);
+ return stream;
+}
+
+} // namespace akantu
+
+#endif /* __AKANTU_AKA_ARRAY_PRINTER_HH__ */
diff --git a/src/common/aka_array_tmpl.hh b/src/common/aka_array_tmpl.hh
index 302fc38fe..0ba694af5 100644
--- a/src/common/aka_array_tmpl.hh
+++ b/src/common/aka_array_tmpl.hh
@@ -1,1368 +1,1374 @@
/**
* @file aka_array_tmpl.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Jul 15 2010
* @date last modification: Tue Feb 20 2018
*
* @brief Inline functions of the classes Array<T> and ArrayBase
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* Inline Functions Array<T> */
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
/* -------------------------------------------------------------------------- */
#include <memory>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_ARRAY_TMPL_HH__
#define __AKANTU_AKA_ARRAY_TMPL_HH__
namespace akantu {
namespace debug {
struct ArrayException : public Exception {};
} // namespace debug
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait>::ArrayDataLayer(UInt size,
UInt nb_component,
const ID & id)
: ArrayBase(id) {
allocate(size, nb_component);
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait>::ArrayDataLayer(UInt size,
UInt nb_component,
const_reference value,
const ID & id)
: ArrayBase(id) {
allocate(size, nb_component, value);
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait>::ArrayDataLayer(const ArrayDataLayer & vect,
const ID & id)
: ArrayBase(vect, id) {
this->data_storage = vect.data_storage;
this->size_ = vect.size_;
this->nb_component = vect.nb_component;
this->values = this->data_storage.data();
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait>::ArrayDataLayer(
const std::vector<value_type> & vect) {
this->data_storage = vect;
this->size_ = vect.size();
this->nb_component = 1;
this->values = this->data_storage.data();
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait> & ArrayDataLayer<T, allocation_trait>::
operator=(const ArrayDataLayer & other) {
if (this != &other) {
this->data_storage = other.data_storage;
this->nb_component = other.nb_component;
this->size_ = other.size_;
this->values = this->data_storage.data();
}
return *this;
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait>::ArrayDataLayer(ArrayDataLayer && other) =
default;
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
ArrayDataLayer<T, allocation_trait> & ArrayDataLayer<T, allocation_trait>::
operator=(ArrayDataLayer && other) = default;
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
void ArrayDataLayer<T, allocation_trait>::allocate(UInt new_size,
UInt nb_component) {
this->nb_component = nb_component;
this->resize(new_size);
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
void ArrayDataLayer<T, allocation_trait>::allocate(UInt new_size,
UInt nb_component,
const T & val) {
this->nb_component = nb_component;
this->resize(new_size, val);
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
void ArrayDataLayer<T, allocation_trait>::resize(UInt new_size) {
this->data_storage.resize(new_size * this->nb_component);
this->values = this->data_storage.data();
this->size_ = new_size;
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
void ArrayDataLayer<T, allocation_trait>::resize(UInt new_size,
const T & value) {
this->data_storage.resize(new_size * this->nb_component, value);
this->values = this->data_storage.data();
this->size_ = new_size;
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
void ArrayDataLayer<T, allocation_trait>::reserve(UInt size, UInt new_size) {
- if(new_size != UInt(-1)) {
+ if (new_size != UInt(-1)) {
this->data_storage.resize(new_size * this->nb_component);
- }
-
+ }
+
this->data_storage.reserve(size * this->nb_component);
this->values = this->data_storage.data();
}
/* -------------------------------------------------------------------------- */
/**
* append a tuple to the array with the value value for all components
* @param value the new last tuple or the array will contain nb_component copies
* of value
*/
template <typename T, ArrayAllocationType allocation_trait>
inline void ArrayDataLayer<T, allocation_trait>::push_back(const T & value) {
this->data_storage.push_back(value);
this->values = this->data_storage.data();
this->size_ += 1;
}
/* -------------------------------------------------------------------------- */
/**
* append a matrix or a vector to the array
* @param new_elem a reference to a Matrix<T> or Vector<T> */
template <typename T, ArrayAllocationType allocation_trait>
template <template <typename> class C, typename>
inline void
ArrayDataLayer<T, allocation_trait>::push_back(const C<T> & new_elem) {
AKANTU_DEBUG_ASSERT(
nb_component == new_elem.size(),
"The vector("
<< new_elem.size()
<< ") as not a size compatible with the Array (nb_component="
<< nb_component << ").");
for (UInt i = 0; i < new_elem.size(); ++i) {
this->data_storage.push_back(new_elem[i]);
}
this->values = this->data_storage.data();
this->size_ += 1;
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
inline UInt ArrayDataLayer<T, allocation_trait>::getAllocatedSize() const {
return this->data_storage.capacity() / this->nb_component;
}
/* -------------------------------------------------------------------------- */
template <typename T, ArrayAllocationType allocation_trait>
inline UInt ArrayDataLayer<T, allocation_trait>::getMemorySize() const {
return this->data_storage.capacity() * sizeof(T);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <typename T>
class ArrayDataLayer<T, ArrayAllocationType::_pod> : public ArrayBase {
public:
using value_type = T;
using reference = value_type &;
using pointer_type = value_type *;
using const_reference = const value_type &;
public:
virtual ~ArrayDataLayer() { deallocate(); }
/// Allocation of a new vector
ArrayDataLayer(UInt size = 0, UInt nb_component = 1, const ID & id = "")
: ArrayBase(id) {
allocate(size, nb_component);
}
/// Allocation of a new vector with a default value
ArrayDataLayer(UInt size, UInt nb_component, const_reference value,
const ID & id = "")
: ArrayBase(id) {
allocate(size, nb_component, value);
}
/// Copy constructor (deep copy)
ArrayDataLayer(const ArrayDataLayer & vect, const ID & id = "")
: ArrayBase(vect, id) {
allocate(vect.size(), vect.getNbComponent());
std::copy_n(vect.storage(), this->size_ * this->nb_component, values);
}
/// Copy constructor (deep copy)
explicit ArrayDataLayer(const std::vector<value_type> & vect) {
allocate(vect.size(), 1);
std::copy_n(vect.data(), this->size_ * this->nb_component, values);
}
// copy operator
inline ArrayDataLayer & operator=(const ArrayDataLayer & other) {
if (this != &other) {
allocate(other.size(), other.getNbComponent());
std::copy_n(other.storage(), this->size_ * this->nb_component, values);
}
return *this;
}
// move constructor
inline ArrayDataLayer(ArrayDataLayer && other) = default;
// move assign
inline ArrayDataLayer & operator=(ArrayDataLayer && other) = default;
protected:
// deallocate the memory
virtual void deallocate() { free(this->values); }
// allocate the memory
virtual inline void allocate(UInt size, UInt nb_component) {
if (size != 0) { // malloc can return a non NULL pointer in case size is 0
this->values =
static_cast<T *>(std::malloc(nb_component * size * sizeof(T)));
}
if (this->values == nullptr and size != 0) {
throw std::bad_alloc();
}
this->nb_component = nb_component;
this->allocated_size = this->size_ = size;
}
// allocate and initialize the memory
virtual inline void allocate(UInt size, UInt nb_component, const T & value) {
allocate(size, nb_component);
std::fill_n(values, size * nb_component, value);
}
public:
/// append a tuple of size nb_component containing value
inline void push_back(const_reference value) {
resize(this->size_ + 1, value);
}
/// append a Vector or a Matrix
template <template <typename> class C,
- typename = std::enable_if_t<aka::is_tensor<C<T>>::value>>
+ typename = std::enable_if_t<aka::is_tensor<C<T>>::value or
+ aka::is_tensor_proxy<C<T>>::value>>
inline void push_back(const C<T> & new_elem) {
AKANTU_DEBUG_ASSERT(
nb_component == new_elem.size(),
"The vector("
<< new_elem.size()
<< ") as not a size compatible with the Array (nb_component="
<< nb_component << ").");
this->resize(this->size_ + 1);
std::copy_n(new_elem.storage(), new_elem.size(),
values + this->nb_component * (this->size_ - 1));
}
/// changes the allocated size but not the size
virtual void reserve(UInt size, UInt new_size = UInt(-1)) {
UInt tmp_size = this->size_;
- if (new_size != UInt(-1)) tmp_size = new_size;
+ if (new_size != UInt(-1))
+ tmp_size = new_size;
this->resize(size);
this->size_ = std::min(this->size_, tmp_size);
}
/// change the size of the Array
virtual void resize(UInt size) {
if (size * this->nb_component == 0) {
free(values);
values = nullptr;
this->allocated_size = 0;
} else {
if (this->values == nullptr) {
this->allocate(size, this->nb_component);
return;
}
Int diff = size - allocated_size;
UInt size_to_allocate = (std::abs(diff) > AKANTU_MIN_ALLOCATION)
? size
: (diff > 0)
? allocated_size + AKANTU_MIN_ALLOCATION
: allocated_size;
if(size_to_allocate != allocated_size) {
auto * tmp_ptr = reinterpret_cast<T *>(realloc(
this->values, size_to_allocate * this->nb_component * sizeof(T)));
if (tmp_ptr == nullptr) {
throw std::bad_alloc();
}
this->values = tmp_ptr;
this->allocated_size = size_to_allocate;
}
}
this->size_ = size;
}
/// change the size of the Array and initialize the values
virtual void resize(UInt size, const T & val) {
UInt tmp_size = this->size_;
this->resize(size);
if (size > tmp_size) {
std::fill_n(values + this->nb_component * tmp_size,
(size - tmp_size) * this->nb_component, val);
}
}
/// get the amount of space allocated in bytes
inline UInt getMemorySize() const override final {
return this->allocated_size * this->nb_component * sizeof(T);
}
/// Get the real size allocated in memory
inline UInt getAllocatedSize() const { return this->allocated_size; }
/// give the address of the memory allocated for this vector
T * storage() const { return values; };
protected:
/// allocation type agnostic data access
T * values{nullptr};
UInt allocated_size{0};
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* template <class T> class AllocatorMalloc : public Allocator<T> {
public:
T * allocate(UInt size, UInt nb_component) override final {
auto * ptr = reinterpret_cast<T *>(malloc(nb_component * size * sizeof(T)));
if (ptr == nullptr and size != 0) {
throw std::bad_alloc();
}
return ptr;
}
void deallocate(T * ptr, UInt size, UInt ,
UInt nb_component) override final {
if (ptr) {
if (not is_scalar<T>::value) {
for (UInt i = 0; i < size * nb_component; ++i) {
(ptr + i)->~T();
}
}
free(ptr);
}
}
std::tuple<T *, UInt> resize(UInt new_size, UInt size, UInt allocated_size,
UInt nb_component, T * ptr) override final {
UInt size_to_alloc = 0;
if (not is_scalar<T>::value and (new_size < size)) {
for (UInt i = new_size * nb_component; i < size * nb_component; ++i) {
(ptr + i)->~T();
}
}
// free some memory
if (new_size == 0) {
free(ptr);
return std::make_tuple(nullptr, 0);
}
if (new_size <= allocated_size) {
if (allocated_size - new_size > AKANTU_MIN_ALLOCATION) {
size_to_alloc = new_size;
} else {
return std::make_tuple(ptr, allocated_size);
}
} else {
// allocate more memory
size_to_alloc = (new_size - allocated_size < AKANTU_MIN_ALLOCATION)
? allocated_size + AKANTU_MIN_ALLOCATION
: new_size;
}
auto * tmp_ptr = reinterpret_cast<T *>(
realloc(ptr, size_to_alloc * nb_component * sizeof(T)));
if (tmp_ptr == nullptr) {
throw std::bad_alloc();
}
return std::make_tuple(tmp_ptr, size_to_alloc);
}
};
*/
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
inline auto Array<T, is_scal>::operator()(UInt i, UInt j) -> reference {
AKANTU_DEBUG_ASSERT(this->size_ > 0,
"The array \"" << this->id << "\" is empty");
AKANTU_DEBUG_ASSERT((i < this->size_) && (j < this->nb_component),
"The value at position ["
<< i << "," << j << "] is out of range in array \""
<< this->id << "\"");
return this->values[i * this->nb_component + j];
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
inline auto Array<T, is_scal>::operator()(UInt i, UInt j) const
-> const_reference {
AKANTU_DEBUG_ASSERT(this->size_ > 0,
"The array \"" << this->id << "\" is empty");
AKANTU_DEBUG_ASSERT((i < this->size_) && (j < this->nb_component),
"The value at position ["
<< i << "," << j << "] is out of range in array \""
<< this->id << "\"");
return this->values[i * this->nb_component + j];
}
template <class T, bool is_scal>
inline auto Array<T, is_scal>::operator[](UInt i) -> reference {
AKANTU_DEBUG_ASSERT(this->size_ > 0,
"The array \"" << this->id << "\" is empty");
AKANTU_DEBUG_ASSERT((i < this->size_ * this->nb_component),
"The value at position ["
<< i << "] is out of range in array \"" << this->id
<< "\"");
return this->values[i];
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
inline auto Array<T, is_scal>::operator[](UInt i) const -> const_reference {
AKANTU_DEBUG_ASSERT(this->size_ > 0,
"The array \"" << this->id << "\" is empty");
AKANTU_DEBUG_ASSERT((i < this->size_ * this->nb_component),
"The value at position ["
<< i << "] is out of range in array \"" << this->id
<< "\"");
return this->values[i];
}
/* -------------------------------------------------------------------------- */
/**
* erase an element. If the erased element is not the last of the array, the
* last element is moved into the hole in order to maintain contiguity. This
* may invalidate existing iterators (For instance an iterator obtained by
* Array::end() is no longer correct) and will change the order of the
* elements.
* @param i index of element to erase
*/
template <class T, bool is_scal> inline void Array<T, is_scal>::erase(UInt i) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT((this->size_ > 0), "The array is empty");
AKANTU_DEBUG_ASSERT((i < this->size_), "The element at position ["
<< i << "] is out of range (" << i
<< ">=" << this->size_ << ")");
if (i != (this->size_ - 1)) {
for (UInt j = 0; j < this->nb_component; ++j) {
this->values[i * this->nb_component + j] =
this->values[(this->size_ - 1) * this->nb_component + j];
}
}
this->resize(this->size_ - 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Subtract another array entry by entry from this array in place. Both arrays
* must
* have the same size and nb_component. If the arrays have different shapes,
* code compiled in debug mode will throw an expeption and optimised code
* will behave in an unpredicted manner
* @param other array to subtract from this
* @return reference to modified this
*/
template <class T, bool is_scal>
Array<T, is_scal> & Array<T, is_scal>::
operator-=(const Array<T, is_scal> & vect) {
AKANTU_DEBUG_ASSERT((this->size_ == vect.size_) &&
(this->nb_component == vect.nb_component),
"The too array don't have the same sizes");
T * a = this->values;
T * b = vect.storage();
for (UInt i = 0; i < this->size_ * this->nb_component; ++i) {
*a -= *b;
++a;
++b;
}
return *this;
}
/* -------------------------------------------------------------------------- */
/**
* Add another array entry by entry to this array in place. Both arrays must
* have the same size and nb_component. If the arrays have different shapes,
* code compiled in debug mode will throw an expeption and optimised code
* will behave in an unpredicted manner
* @param other array to add to this
* @return reference to modified this
*/
template <class T, bool is_scal>
Array<T, is_scal> & Array<T, is_scal>::
operator+=(const Array<T, is_scal> & vect) {
AKANTU_DEBUG_ASSERT((this->size_ == vect.size()) &&
(this->nb_component == vect.nb_component),
"The too array don't have the same sizes");
T * a = this->values;
T * b = vect.storage();
for (UInt i = 0; i < this->size_ * this->nb_component; ++i) {
*a++ += *b++;
}
return *this;
}
/* -------------------------------------------------------------------------- */
/**
* Multiply all entries of this array by a scalar in place
* @param alpha scalar multiplicant
* @return reference to modified this
*/
template <class T, bool is_scal>
Array<T, is_scal> & Array<T, is_scal>::operator*=(const T & alpha) {
T * a = this->values;
for (UInt i = 0; i < this->size_ * this->nb_component; ++i) {
*a++ *= alpha;
}
return *this;
}
/* -------------------------------------------------------------------------- */
/**
* Compare this array element by element to another.
* @param other array to compare to
* @return true it all element are equal and arrays have the same shape, else
* false
*/
template <class T, bool is_scal>
bool Array<T, is_scal>::operator==(const Array<T, is_scal> & array) const {
bool equal = this->nb_component == array.nb_component &&
this->size_ == array.size_ && this->id == array.id;
if (!equal)
return false;
if (this->values == array.storage())
return true;
else
return std::equal(this->values,
this->values + this->size_ * this->nb_component,
array.storage());
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
bool Array<T, is_scal>::operator!=(const Array<T, is_scal> & array) const {
return !operator==(array);
}
/* -------------------------------------------------------------------------- */
/**
* set all tuples of the array to a given vector or matrix
* @param vm Matrix or Vector to fill the array with
*/
template <class T, bool is_scal>
template <template <typename> class C, typename>
inline void Array<T, is_scal>::set(const C<T> & vm) {
AKANTU_DEBUG_ASSERT(
this->nb_component == vm.size(),
"The size of the object does not match the number of components");
for (T * it = this->values;
it < this->values + this->nb_component * this->size_;
it += this->nb_component) {
std::copy_n(vm.storage(), this->nb_component, it);
}
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
void Array<T, is_scal>::append(const Array<T> & other) {
AKANTU_DEBUG_ASSERT(
this->nb_component == other.nb_component,
"Cannot append an array with a different number of component");
UInt old_size = this->size_;
this->resize(this->size_ + other.size());
T * tmp = this->values + this->nb_component * old_size;
std::copy_n(other.storage(), other.size() * this->nb_component, tmp);
}
/* -------------------------------------------------------------------------- */
/* Functions Array<T, is_scal> */
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
Array<T, is_scal>::Array(UInt size, UInt nb_component, const ID & id)
: parent(size, nb_component, id) {}
template <>
inline Array<std::string, false>::Array(UInt size, UInt nb_component,
const ID & id)
: parent(size, nb_component, "", id) {}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
Array<T, is_scal>::Array(UInt size, UInt nb_component, const_reference value,
const ID & id)
: parent(size, nb_component, value, id) {}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
Array<T, is_scal>::Array(const Array & vect, const ID & id)
: parent(vect, id) {}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
Array<T, is_scal> & Array<T, is_scal>::
operator=(const Array<T, is_scal> & other) {
AKANTU_DEBUG_WARNING("You are copying the array "
<< this->id << " are you sure it is on purpose");
if (&other == this)
return *this;
parent::operator=(other);
return *this;
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
Array<T, is_scal>::Array(const std::vector<T> & vect) : parent(vect) {}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal> Array<T, is_scal>::~Array() = default;
/* -------------------------------------------------------------------------- */
/**
* search elem in the array, return the position of the first occurrence or
* -1 if not found
* @param elem the element to look for
* @return index of the first occurrence of elem or -1 if elem is not present
*/
template <class T, bool is_scal>
UInt Array<T, is_scal>::find(const_reference elem) const {
AKANTU_DEBUG_IN();
auto begin = this->begin();
auto end = this->end();
auto it = std::find(begin, end, elem);
AKANTU_DEBUG_OUT();
return (it != end) ? it - begin : UInt(-1);
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal> UInt Array<T, is_scal>::find(T elem[]) const {
AKANTU_DEBUG_IN();
T * it = this->values;
UInt i = 0;
for (; i < this->size_; ++i) {
if (*it == elem[0]) {
T * cit = it;
UInt c = 0;
for (; (c < this->nb_component) && (*cit == elem[c]); ++c, ++cit)
;
if (c == this->nb_component) {
AKANTU_DEBUG_OUT();
return i;
}
}
it += this->nb_component;
}
return UInt(-1);
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
template <template <typename> class C, typename>
inline UInt Array<T, is_scal>::find(const C<T> & elem) {
AKANTU_DEBUG_ASSERT(elem.size() == this->nb_component,
"Cannot find an element with a wrong size ("
<< elem.size() << ") != " << this->nb_component);
return this->find(elem.storage());
}
/* -------------------------------------------------------------------------- */
/**
* copy the content of another array. This overwrites the current content.
* @param other Array to copy into this array. It has to have the same
* nb_component as this. If compiled in debug mode, an incorrect other will
* result in an exception being thrown. Optimised code may result in
* unpredicted behaviour.
*/
template <class T, bool is_scal>
void Array<T, is_scal>::copy(const Array<T, is_scal> & vect,
bool no_sanity_check) {
AKANTU_DEBUG_IN();
if (!no_sanity_check)
if (vect.nb_component != this->nb_component)
AKANTU_ERROR("The two arrays do not have the same number of components");
this->resize((vect.size_ * vect.nb_component) / this->nb_component);
std::copy_n(vect.storage(), this->size_ * this->nb_component, this->values);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <bool is_scal> class ArrayPrintHelper {
public:
template <typename T>
static void print_content(const Array<T> & vect, std::ostream & stream,
int indent) {
- if (AKANTU_DEBUG_TEST(dblDump) || AKANTU_DEBUG_LEVEL_IS_TEST()) {
- std::string space(indent, AKANTU_INDENT);
-
- stream << space << " + values : {";
- for (UInt i = 0; i < vect.size(); ++i) {
- stream << "{";
- for (UInt j = 0; j < vect.getNbComponent(); ++j) {
- stream << vect(i, j);
- if (j != vect.getNbComponent() - 1)
- stream << ", ";
- }
- stream << "}";
- if (i != vect.size() - 1)
+ std::string space(indent, AKANTU_INDENT);
+
+ stream << space << " + values : {";
+ for (UInt i = 0; i < vect.size(); ++i) {
+ stream << "{";
+ for (UInt j = 0; j < vect.getNbComponent(); ++j) {
+ stream << vect(i, j);
+ if (j != vect.getNbComponent() - 1)
stream << ", ";
}
- stream << "}" << std::endl;
+ stream << "}";
+ if (i != vect.size() - 1)
+ stream << ", ";
}
+ stream << "}" << std::endl;
}
};
template <> class ArrayPrintHelper<false> {
public:
template <typename T>
static void print_content(__attribute__((unused)) const Array<T> & vect,
__attribute__((unused)) std::ostream & stream,
__attribute__((unused)) int indent) {}
};
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
void Array<T, is_scal>::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
std::streamsize prec = stream.precision();
std::ios_base::fmtflags ff = stream.flags();
stream.setf(std::ios_base::showbase);
stream.precision(2);
stream << space << "Array<" << debug::demangle(typeid(T).name()) << "> ["
<< std::endl;
stream << space << " + id : " << this->id << std::endl;
stream << space << " + size : " << this->size_ << std::endl;
stream << space << " + nb_component : " << this->nb_component << std::endl;
stream << space << " + allocated size : " << this->getAllocatedSize()
<< std::endl;
stream << space
<< " + memory size : " << printMemorySize<T>(this->getMemorySize())
<< std::endl;
if (!AKANTU_DEBUG_LEVEL_IS_TEST())
stream << space << " + address : " << std::hex << this->values
<< std::dec << std::endl;
stream.precision(prec);
stream.flags(ff);
- ArrayPrintHelper<is_scal or std::is_enum<T>::value>::print_content(*this, stream, indent);
+ if (AKANTU_DEBUG_TEST(dblDump) || AKANTU_DEBUG_LEVEL_IS_TEST()) {
+ ArrayPrintHelper<is_scal or std::is_enum<T>::value>::print_content(
+ *this, stream, indent);
+ }
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
/* Inline Functions ArrayBase */
/* -------------------------------------------------------------------------- */
inline void ArrayBase::empty() { this->size_ = 0; }
/* -------------------------------------------------------------------------- */
/* Iterators */
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
template <class R, class daughter, class IR, bool is_tensor>
class Array<T, is_scal>::iterator_internal {
public:
using value_type = R;
using pointer = R *;
using reference = R &;
using const_reference = const R &;
using internal_value_type = IR;
using internal_pointer = IR *;
using difference_type = std::ptrdiff_t;
using iterator_category = std::random_access_iterator_tag;
static_assert(not is_tensor, "Cannot handle tensors");
+
public:
iterator_internal(pointer data = nullptr) : ret(data), initial(data){};
iterator_internal(const iterator_internal & it) = default;
iterator_internal(iterator_internal && it) = default;
virtual ~iterator_internal() = default;
inline iterator_internal & operator=(const iterator_internal & it) = default;
UInt getCurrentIndex() { return (this->ret - this->initial); };
inline reference operator*() { return *ret; };
inline const_reference operator*() const { return *ret; };
inline pointer operator->() { return ret; };
inline daughter & operator++() {
++ret;
return static_cast<daughter &>(*this);
};
inline daughter & operator--() {
--ret;
return static_cast<daughter &>(*this);
};
inline daughter & operator+=(const UInt n) {
ret += n;
return static_cast<daughter &>(*this);
}
inline daughter & operator-=(const UInt n) {
ret -= n;
return static_cast<daughter &>(*this);
}
inline reference operator[](const UInt n) { return ret[n]; }
inline bool operator==(const iterator_internal & other) const {
return ret == other.ret;
}
inline bool operator!=(const iterator_internal & other) const {
return ret != other.ret;
}
inline bool operator<(const iterator_internal & other) const {
return ret < other.ret;
}
inline bool operator<=(const iterator_internal & other) const {
return ret <= other.ret;
}
inline bool operator>(const iterator_internal & other) const {
return ret > other.ret;
}
inline bool operator>=(const iterator_internal & other) const {
return ret >= other.ret;
}
inline daughter operator-(difference_type n) { return daughter(ret - n); }
inline daughter operator+(difference_type n) { return daughter(ret + n); }
inline difference_type operator-(const iterator_internal & b) {
return ret - b.ret;
}
inline pointer data() const { return ret; }
protected:
pointer ret{nullptr};
pointer initial{nullptr};
};
/* -------------------------------------------------------------------------- */
/**
* Specialization for scalar types
*/
template <class T, bool is_scal>
template <class R, class daughter, class IR>
class Array<T, is_scal>::iterator_internal<R, daughter, IR, true> {
public:
using value_type = R;
using pointer = R *;
using pointer_type = typename Array<T, is_scal>::pointer_type;
using reference = R &;
using proxy = typename R::proxy;
using const_proxy = const typename R::proxy;
using const_reference = const R &;
using internal_value_type = IR;
using internal_pointer = IR *;
using difference_type = std::ptrdiff_t;
using iterator_category = std::random_access_iterator_tag;
+ using pointer_type = typename Array<T, is_scal>::pointer_type;
public:
iterator_internal() = default;
iterator_internal(pointer_type data, UInt _offset)
: _offset(_offset), initial(data), ret(nullptr), ret_ptr(data) {
AKANTU_ERROR(
"The constructor should never be called it is just an ugly trick...");
}
iterator_internal(std::unique_ptr<internal_value_type> && wrapped)
: _offset(wrapped->size()), initial(wrapped->storage()),
ret(std::move(wrapped)), ret_ptr(ret->storage()) {}
iterator_internal(const iterator_internal & it) {
if (this != &it) {
this->_offset = it._offset;
this->initial = it.initial;
this->ret_ptr = it.ret_ptr;
this->ret = std::make_unique<internal_value_type>(*it.ret, false);
}
}
iterator_internal(iterator_internal && it) = default;
virtual ~iterator_internal() = default;
inline iterator_internal & operator=(const iterator_internal & it) {
if (this != &it) {
this->_offset = it._offset;
this->initial = it.initial;
this->ret_ptr = it.ret_ptr;
if (this->ret)
this->ret->shallowCopy(*it.ret);
else
this->ret = std::make_unique<internal_value_type>(*it.ret, false);
}
return *this;
}
UInt getCurrentIndex() {
return (this->ret_ptr - this->initial) / this->_offset;
};
inline reference operator*() {
ret->values = ret_ptr;
return *ret;
};
inline const_reference operator*() const {
ret->values = ret_ptr;
return *ret;
};
inline pointer operator->() {
ret->values = ret_ptr;
return ret.get();
};
inline daughter & operator++() {
ret_ptr += _offset;
return static_cast<daughter &>(*this);
};
inline daughter & operator--() {
ret_ptr -= _offset;
return static_cast<daughter &>(*this);
};
inline daughter & operator+=(const UInt n) {
ret_ptr += _offset * n;
return static_cast<daughter &>(*this);
}
inline daughter & operator-=(const UInt n) {
ret_ptr -= _offset * n;
return static_cast<daughter &>(*this);
}
inline proxy operator[](const UInt n) {
ret->values = ret_ptr + n * _offset;
return proxy(*ret);
}
inline const_proxy operator[](const UInt n) const {
ret->values = ret_ptr + n * _offset;
return const_proxy(*ret);
}
inline bool operator==(const iterator_internal & other) const {
return this->ret_ptr == other.ret_ptr;
}
inline bool operator!=(const iterator_internal & other) const {
return this->ret_ptr != other.ret_ptr;
}
inline bool operator<(const iterator_internal & other) const {
return this->ret_ptr < other.ret_ptr;
}
inline bool operator<=(const iterator_internal & other) const {
return this->ret_ptr <= other.ret_ptr;
}
inline bool operator>(const iterator_internal & other) const {
return this->ret_ptr > other.ret_ptr;
}
inline bool operator>=(const iterator_internal & other) const {
return this->ret_ptr >= other.ret_ptr;
}
inline daughter operator+(difference_type n) {
daughter tmp(static_cast<daughter &>(*this));
tmp += n;
return tmp;
}
inline daughter operator-(difference_type n) {
daughter tmp(static_cast<daughter &>(*this));
tmp -= n;
return tmp;
}
inline difference_type operator-(const iterator_internal & b) {
return (this->ret_ptr - b.ret_ptr) / _offset;
}
inline pointer_type data() const { return ret_ptr; }
inline difference_type offset() const { return _offset; }
protected:
UInt _offset{0};
pointer_type initial{nullptr};
std::unique_ptr<internal_value_type> ret{nullptr};
pointer_type ret_ptr{nullptr};
};
/* -------------------------------------------------------------------------- */
/* Iterators */
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
template <typename R>
class Array<T, is_scal>::const_iterator
: public iterator_internal<const R, Array<T, is_scal>::const_iterator<R>,
R> {
public:
using parent = iterator_internal<const R, const_iterator, R>;
using value_type = typename parent::value_type;
using pointer = typename parent::pointer;
using reference = typename parent::reference;
using difference_type = typename parent::difference_type;
using iterator_category = typename parent::iterator_category;
public:
const_iterator() : parent(){};
// const_iterator(pointer_type data, UInt offset) : parent(data, offset) {}
// const_iterator(pointer warped) : parent(warped) {}
// const_iterator(const parent & it) : parent(it) {}
const_iterator(const const_iterator & it) = default;
const_iterator(const_iterator && it) = default;
- template <typename P, typename = std::enable_if_t<not aka::is_tensor<P>::value>>
+ template <typename P,
+ typename = std::enable_if_t<not aka::is_tensor<P>::value>>
const_iterator(P * data) : parent(data) {}
- template <typename UP_P, typename = std::enable_if_t<
- aka::is_tensor<typename UP_P::element_type>::value>>
+ template <typename UP_P, typename = std::enable_if_t<aka::is_tensor<
+ typename UP_P::element_type>::value>>
const_iterator(UP_P && tensor) : parent(std::forward<UP_P>(tensor)) {}
const_iterator & operator=(const const_iterator & it) = default;
};
/* -------------------------------------------------------------------------- */
template <class T, class R, bool is_tensor_ = aka::is_tensor<R>::value>
struct ConstConverterIteratorHelper {
using const_iterator = typename Array<T>::template const_iterator<R>;
using iterator = typename Array<T>::template iterator<R>;
static inline const_iterator convert(const iterator & it) {
return const_iterator(std::unique_ptr<R>(new R(*it, false)));
}
};
template <class T, class R> struct ConstConverterIteratorHelper<T, R, false> {
using const_iterator = typename Array<T>::template const_iterator<R>;
using iterator = typename Array<T>::template iterator<R>;
static inline const_iterator convert(const iterator & it) {
return const_iterator(it.data());
}
};
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
template <typename R>
class Array<T, is_scal>::iterator
- : public iterator_internal<R, Array<T, is_scal>::iterator<R>> {
+ : public iterator_internal<R, Array<T, is_scal>::iterator<R>> {
public:
using parent = iterator_internal<R, iterator>;
using value_type = typename parent::value_type;
using pointer = typename parent::pointer;
using reference = typename parent::reference;
using difference_type = typename parent::difference_type;
using iterator_category = typename parent::iterator_category;
public:
iterator() : parent(){};
iterator(const iterator & it) = default;
iterator(iterator && it) = default;
- template <typename P, typename = std::enable_if_t<not aka::is_tensor<P>::value>>
+ template <typename P,
+ typename = std::enable_if_t<not aka::is_tensor<P>::value>>
iterator(P * data) : parent(data) {}
- template <typename UP_P, typename = std::enable_if_t<
- aka::is_tensor<typename UP_P::element_type>::value>>
+ template <typename UP_P, typename = std::enable_if_t<aka::is_tensor<
+ typename UP_P::element_type>::value>>
iterator(UP_P && tensor) : parent(std::forward<UP_P>(tensor)) {}
iterator & operator=(const iterator & it) = default;
operator const_iterator<R>() {
return ConstConverterIteratorHelper<T, R>::convert(*this);
}
};
-
/* -------------------------------------------------------------------------- */
/* Begin/End functions implementation */
/* -------------------------------------------------------------------------- */
namespace detail {
template <class Tuple, size_t... Is>
constexpr auto take_front_impl(Tuple && t, std::index_sequence<Is...>) {
return std::make_tuple(std::get<Is>(std::forward<Tuple>(t))...);
}
template <size_t N, class Tuple> constexpr auto take_front(Tuple && t) {
return take_front_impl(std::forward<Tuple>(t),
std::make_index_sequence<N>{});
}
template <typename... V> constexpr auto product_all(V &&... v) {
std::common_type_t<int, V...> result = 1;
(void)std::initializer_list<int>{(result *= v, 0)...};
return result;
}
template <typename... T> std::string to_string_all(T &&... t) {
if (sizeof...(T) == 0)
return "";
std::stringstream ss;
bool noComma = true;
ss << "(";
(void)std::initializer_list<bool>{
(ss << (noComma ? "" : ", ") << t, noComma = false)...};
ss << ")";
return ss.str();
}
template <std::size_t N> struct InstantiationHelper {
template <typename type, typename T, typename... Ns>
static auto instantiate(T && data, Ns... ns) {
return std::make_unique<type>(data, ns...);
}
};
template <> struct InstantiationHelper<0> {
template <typename type, typename T> static auto instantiate(T && data) {
return data;
}
};
template <typename Arr, typename T, typename... Ns>
decltype(auto) get_iterator(Arr && array, T * data, Ns &&... ns) {
using type = IteratorHelper_t<sizeof...(Ns) - 1, T>;
using array_type = std::decay_t<Arr>;
using iterator =
std::conditional_t<std::is_const<std::remove_reference_t<Arr>>::value,
typename array_type::template const_iterator<type>,
typename array_type::template iterator<type>>;
static_assert(sizeof...(Ns), "You should provide a least one size");
if (array.getNbComponent() * array.size() !=
product_all(std::forward<Ns>(ns)...)) {
AKANTU_CUSTOM_EXCEPTION_INFO(
debug::ArrayException(),
"The iterator on "
<< debug::demangle(typeid(Arr).name())
<< to_string_all(array.size(), array.getNbComponent())
<< "is not compatible with the type "
<< debug::demangle(typeid(type).name()) << to_string_all(ns...));
}
auto && wrapped = aka::apply(
[&](auto... n) {
return InstantiationHelper<sizeof...(n)>::template instantiate<type>(
data, n...);
},
take_front<sizeof...(Ns) - 1>(std::make_tuple(ns...)));
return iterator(std::move(wrapped));
}
} // namespace detail
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::begin(Ns &&... ns) {
return detail::get_iterator(*this, this->values, std::forward<Ns>(ns)...,
this->size_);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::end(Ns &&... ns) {
return detail::get_iterator(*this,
this->values + this->nb_component * this->size_,
std::forward<Ns>(ns)..., this->size_);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::begin(Ns &&... ns) const {
return detail::get_iterator(*this, this->values, std::forward<Ns>(ns)...,
this->size_);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::end(Ns &&... ns) const {
return detail::get_iterator(*this,
this->values + this->nb_component * this->size_,
std::forward<Ns>(ns)..., this->size_);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::begin_reinterpret(Ns &&... ns) {
return detail::get_iterator(*this, this->values, std::forward<Ns>(ns)...);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::end_reinterpret(Ns &&... ns) {
return detail::get_iterator(
*this, this->values + detail::product_all(std::forward<Ns>(ns)...),
std::forward<Ns>(ns)...);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::begin_reinterpret(Ns &&... ns) const {
return detail::get_iterator(*this, this->values, std::forward<Ns>(ns)...);
}
template <class T, bool is_scal>
template <typename... Ns>
inline decltype(auto) Array<T, is_scal>::end_reinterpret(Ns &&... ns) const {
return detail::get_iterator(
*this, this->values + detail::product_all(std::forward<Ns>(ns)...),
std::forward<Ns>(ns)...);
}
/* -------------------------------------------------------------------------- */
/* Views */
/* -------------------------------------------------------------------------- */
namespace detail {
template <typename Array, typename... Ns> class ArrayView {
using tuple = std::tuple<Ns...>;
public:
ArrayView(Array && array, Ns... ns)
: array(array), sizes(std::move(ns)...) {}
ArrayView(ArrayView && array_view) = default;
ArrayView & operator=(const ArrayView & array_view) = default;
ArrayView & operator=(ArrayView && array_view) = default;
decltype(auto) begin() {
return aka::apply(
[&](auto &&... ns) { return array.get().begin_reinterpret(ns...); },
sizes);
}
decltype(auto) begin() const {
return aka::apply(
[&](auto &&... ns) { return array.get().begin_reinterpret(ns...); },
sizes);
}
decltype(auto) end() {
return aka::apply(
[&](auto &&... ns) { return array.get().end_reinterpret(ns...); },
sizes);
}
decltype(auto) end() const {
return aka::apply(
[&](auto &&... ns) { return array.get().end_reinterpret(ns...); },
sizes);
}
decltype(auto) size() const {
return std::get<std::tuple_size<tuple>::value - 1>(sizes);
}
decltype(auto) dims() const { return std::tuple_size<tuple>::value - 1; }
private:
std::reference_wrapper<std::remove_reference_t<Array>> array;
tuple sizes;
};
} // namespace detail
/* -------------------------------------------------------------------------- */
template <typename Array, typename... Ns>
decltype(auto) make_view(Array && array, Ns... ns) {
static_assert(aka::conjunction<std::is_integral<std::decay_t<Ns>>...>::value,
"Ns should be integral types");
auto size = std::forward<decltype(array)>(array).size() *
std::forward<decltype(array)>(array).getNbComponent() /
detail::product_all(ns...);
return detail::ArrayView<Array, std::common_type_t<size_t, Ns>...,
std::common_type_t<size_t, decltype(size)>>(
std::forward<Array>(array), std::move(ns)..., size);
}
/* -------------------------------------------------------------------------- */
template <class T, bool is_scal>
template <typename R>
inline typename Array<T, is_scal>::template iterator<R>
Array<T, is_scal>::erase(const iterator<R> & it) {
T * curr = it.data();
UInt pos = (curr - this->values) / this->nb_component;
erase(pos);
iterator<R> rit = it;
return --rit;
}
} // namespace akantu
#endif /* __AKANTU_AKA_ARRAY_TMPL_HH__ */
diff --git a/src/common/aka_bbox.hh b/src/common/aka_bbox.hh
index 1df2cb61d..a202b295d 100644
--- a/src/common/aka_bbox.hh
+++ b/src/common/aka_bbox.hh
@@ -1,273 +1,273 @@
/**
* @file aka_bbox.hh
*
* @author Nicolas Richart
*
* @date creation Mon Feb 12 2018
*
* @brief A simple bounding box class
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_iterators.hh"
#include "aka_types.hh"
#include "communicator.hh"
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_BBOX_HH__
#define __AKANTU_AKA_BBOX_HH__
namespace akantu {
class BBox {
public:
BBox() = default;
BBox(UInt spatial_dimension)
: dim(spatial_dimension),
lower_bounds(spatial_dimension, std::numeric_limits<Real>::max()),
upper_bounds(spatial_dimension, std::numeric_limits<Real>::lowest()) {}
BBox(const BBox & other)
: dim(other.dim), empty{false}, lower_bounds(other.lower_bounds),
upper_bounds(other.upper_bounds) {}
BBox & operator=(const BBox & other) {
if (this != &other) {
this->dim = other.dim;
this->lower_bounds = other.lower_bounds;
this->upper_bounds = other.upper_bounds;
this->empty = other.empty;
}
return *this;
}
inline BBox & operator+=(const Vector<Real> & position) {
AKANTU_DEBUG_ASSERT(
this->dim == position.size(),
"You are adding a point of a wrong dimension to the bounding box");
this->empty = false;
for (auto s : arange(dim)) {
lower_bounds(s) = std::min(lower_bounds(s), position(s));
upper_bounds(s) = std::max(upper_bounds(s), position(s));
}
return *this;
}
/* ------------------------------------------------------------------------ */
inline bool intersects(const BBox & other,
const SpatialDirection & direction) const {
AKANTU_DEBUG_ASSERT(
this->dim == other.dim,
"You are intersecting bounding boxes of different dimensions");
return Math::intersects(lower_bounds(direction), upper_bounds(direction),
other.lower_bounds(direction),
other.upper_bounds(direction));
}
inline bool intersects(const BBox & other) const {
if (this->empty or other.empty)
return false;
bool intersects_ = true;
for (auto s : arange(this->dim)) {
intersects_ &= this->intersects(other, SpatialDirection(s));
}
return intersects_;
}
/* ------------------------------------------------------------------------ */
inline BBox intersection(const BBox & other) const {
AKANTU_DEBUG_ASSERT(
this->dim == other.dim,
"You are intersecting bounding boxes of different dimensions");
BBox intersection_(this->dim);
intersection_.empty = not this->intersects(other);
if (intersection_.empty)
return intersection_;
for (auto s : arange(this->dim)) {
// is lower point in range ?
bool point1 = Math::is_in_range(other.lower_bounds(s), lower_bounds(s),
upper_bounds(s));
// is upper point in range ?
bool point2 = Math::is_in_range(other.upper_bounds(s), lower_bounds(s),
upper_bounds(s));
if (point1 and not point2) {
// |-----------| this (i)
// |-----------| other(i)
// 1 2
intersection_.lower_bounds(s) = other.lower_bounds(s);
intersection_.upper_bounds(s) = upper_bounds(s);
} else if (point1 && point2) {
// |-----------------| this (i)
// |-----------| other(i)
// 1 2
intersection_.lower_bounds(s) = other.lower_bounds(s);
intersection_.upper_bounds(s) = other.upper_bounds(s);
} else if (!point1 && point2) {
// |-----------| this (i)
// |-----------| other(i)
// 1 2
intersection_.lower_bounds(s) = this->lower_bounds(s);
intersection_.upper_bounds(s) = other.upper_bounds(s);
} else {
// |-----------| this (i)
// |-----------------| other(i)
// 1 2
intersection_.lower_bounds(s) = this->lower_bounds(s);
intersection_.upper_bounds(s) = this->upper_bounds(s);
}
}
return intersection_;
}
/* ------------------------------------------------------------------------ */
inline bool contains(const Vector<Real> & point) const {
return (point >= lower_bounds) and (point <= upper_bounds);
}
/* ------------------------------------------------------------------------ */
inline void reset() {
lower_bounds.set(std::numeric_limits<Real>::max());
upper_bounds.set(std::numeric_limits<Real>::lowest());
}
/* -------------------------------------------------------------------------- */
inline void getCenter(Vector<Real> & center) {
center = upper_bounds;
center += lower_bounds;
center /= 2.;
}
/* ------------------------------------------------------------------------ */
const Vector<Real> & getLowerBounds() const { return lower_bounds; }
const Vector<Real> & getUpperBounds() const { return upper_bounds; }
Vector<Real> & getLowerBounds() { return lower_bounds; }
Vector<Real> & getUpperBounds() { return upper_bounds; }
/* ------------------------------------------------------------------------ */
inline Real size(const SpatialDirection & direction) const {
return upper_bounds(direction) - lower_bounds(direction);
}
Vector<Real> size() const {
Vector<Real> size_(dim);
for (auto s : arange(this->dim)) {
size_(s) = this->size(SpatialDirection(s));
}
return size_;
}
inline operator bool() const { return not empty; }
/* ------------------------------------------------------------------------ */
BBox allSum(const Communicator & communicator) const {
Matrix<Real> reduce_bounds(dim, 2);
Vector<Real>(reduce_bounds(0)) = lower_bounds;
Vector<Real>(reduce_bounds(1)) = Real(-1.) * upper_bounds;
communicator.allReduce(reduce_bounds, SynchronizerOperation::_min);
BBox global(dim);
global.lower_bounds = Vector<Real>(reduce_bounds(0));
global.upper_bounds = Real(-1.) * Vector<Real>(reduce_bounds(1));
global.empty = false;
return global;
}
std::vector<BBox> allGather(const Communicator & communicator) const {
auto prank = communicator.whoAmI();
auto nb_proc = communicator.getNbProc();
Array<Real> bboxes_data(nb_proc, dim * 2 + 1);
auto * base = bboxes_data.storage() + prank * (2 * dim + 1);
Vector<Real>(base + dim * 0, dim) = lower_bounds;
Vector<Real>(base + dim * 1, dim) = upper_bounds;
base[dim * 2] = empty ? 1. : 0.; // ugly trick
communicator.allGather(bboxes_data);
std::vector<BBox> bboxes;
bboxes.reserve(nb_proc);
for (auto p : arange(nb_proc)) {
bboxes.emplace_back(dim);
auto & bbox = bboxes.back();
auto * base = bboxes_data.storage() + p * (2 * dim + 1);
bbox.lower_bounds = Vector<Real>(base + dim * 0, dim);
bbox.upper_bounds = Vector<Real>(base + dim * 1, dim);
bbox.empty = base[dim * 2] == 1. ? true : false;
}
return bboxes;
}
std::map<UInt, BBox> intersection(const BBox & other,
const Communicator & communicator) {
// todo: change for a custom reduction algorithm
auto other_bboxes = other.allGather(communicator);
std::map<UInt, BBox> intersections;
for (const auto & bbox : enumerate(other_bboxes)) {
auto && tmp = this->intersection(std::get<1>(bbox));
if (tmp) {
intersections[std::get<0>(bbox)] = tmp;
}
}
return intersections;
}
void printself(std::ostream & stream) const {
stream << "BBox[";
if (not empty) {
stream << lower_bounds << " - " << upper_bounds;
}
stream << "]";
}
protected:
UInt dim{0};
bool empty{true};
Vector<Real> lower_bounds;
Vector<Real> upper_bounds;
};
inline std::ostream & operator<<(std::ostream & stream, const BBox & bbox) {
bbox.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_BBOX_HH__ */
diff --git a/src/common/aka_blas_lapack.hh b/src/common/aka_blas_lapack.hh
index 76a244310..aaf509a69 100644
--- a/src/common/aka_blas_lapack.hh
+++ b/src/common/aka_blas_lapack.hh
@@ -1,343 +1,343 @@
/**
* @file aka_blas_lapack.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Mar 06 2013
* @date last modification: Tue Feb 20 2018
*
* @brief Interface of the Fortran BLAS/LAPACK libraries
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_BLAS_LAPACK_HH__
#define __AKANTU_AKA_BLAS_LAPACK_HH__
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_BLAS
#include "aka_fortran_mangling.hh"
extern "C" {
/* ------------------------------------------------------------------------ */
/* Double precision */
/* ------------------------------------------------------------------------ */
// LEVEL 1
double AKA_FC_GLOBAL(ddot, DDOT)(int *, double *, int *, double *, int *);
void AKA_FC_GLOBAL(daxpy, DAXPY)(int *, double *, double *, int *, double *,
int *);
// LEVEL 2
void AKA_FC_GLOBAL(dgemv, DGEMV)(char *, int *, int *, double *, double *,
int *, double *, int *, double *, double *,
int *);
// LEVEL 3
void AKA_FC_GLOBAL(dgemm, DGEMM)(char *, char *, int *, int *, int *, double *,
double *, int *, double *, int *, double *,
double *, int *);
/* ------------------------------------------------------------------------ */
/* Simple precision */
/* ------------------------------------------------------------------------ */
// LEVEL 1
float AKA_FC_GLOBAL(sdot, SDOT)(int *, float *, int *, float *, int *);
void AKA_FC_GLOBAL(saxpy, SAXPY)(int *, float *, float *, int *, float *,
int *);
// LEVEL 2
void AKA_FC_GLOBAL(sgemv, SGEMV)(char *, int *, int *, float *, float *, int *,
float *, int *, float *, float *, int *);
// LEVEL 3
void AKA_FC_GLOBAL(sgemm, SGEMM)(char *, char *, int *, int *, int *, float *,
float *, int *, float *, int *, float *,
float *, int *);
}
#endif
namespace akantu {
#define AKANTU_WARNING_IGNORE_UNUSED_PARAMETER
#include "aka_warning.hh"
/// Wrapper around the S/DDOT BLAS function that returns the dot product of two
/// vectors
template <typename T>
inline T aka_dot(int * n, T * x, int * incx, T * y, int * incy) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"BLAS in the compilation options!");
}
/// Wrapper around the S/DAXPY BLAS function that computes \f$y := \alpha x +
/// y\f$
template <typename T>
inline void aka_axpy(int * n, T * alpha, T * x, int * incx, T * y, int * incy) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"BLAS in the compilation options!");
}
/// Wrapper around the S/DGEMV BLAS function that computes matrix-vector product
/// \f$y := \alpha A^{(T)}x + \beta y \f$
template <typename T>
inline void aka_gemv(char * trans, int * m, int * n, T * alpha, T * a,
int * lda, T * x, int * incx, T * beta, T * y,
int * incy) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"BLAS in the compilation options!");
}
/// Wrapper around the S/DGEMM BLAS function that computes the product of two
/// matrices \f$C := \alpha A^{(T)} B^{(T)} + \beta C \f$
template <typename T>
inline void aka_gemm(char * transa, char * transb, int * m, int * n, int * k,
T * alpha, T * a, int * lda, T * b, int * ldb, T * beta,
T * c, int * ldc) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"BLAS in the compilation options!");
}
#if defined(AKANTU_USE_BLAS)
template <>
inline double aka_dot<double>(int * n, double * x, int * incx, double * y,
int * incy) {
return AKA_FC_GLOBAL(ddot, DDOT)(n, x, incx, y, incy);
}
template <>
inline void aka_axpy(int * n, double * alpha, double * x, int * incx,
double * y, int * incy) {
return AKA_FC_GLOBAL(daxpy, DAXPY)(n, alpha, x, incx, y, incy);
}
template <>
inline void aka_gemv<double>(char * trans, int * m, int * n, double * alpha,
double * a, int * lda, double * x, int * incx,
double * beta, double * y, int * incy) {
return AKA_FC_GLOBAL(dgemv, DGEMV)(trans, m, n, alpha, a, lda, x, incx, beta,
y, incy);
}
template <>
inline void aka_gemm<double>(char * transa, char * transb, int * m, int * n,
int * k, double * alpha, double * a, int * lda,
double * b, int * ldb, double * beta, double * c,
int * ldc) {
AKA_FC_GLOBAL(dgemm, DGEMM)
(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <>
inline float aka_dot<float>(int * n, float * x, int * incx, float * y,
int * incy) {
return AKA_FC_GLOBAL(sdot, SDOT)(n, x, incx, y, incy);
}
template <>
inline void aka_axpy(int * n, float * alpha, float * x, int * incx, float * y,
int * incy) {
return AKA_FC_GLOBAL(daxpy, DAXPY)(n, alpha, x, incx, y, incy);
}
template <>
inline void aka_gemv<float>(char * trans, int * m, int * n, float * alpha,
float * a, int * lda, float * x, int * incx,
float * beta, float * y, int * incy) {
AKA_FC_GLOBAL(sgemv, SGEMV)
(trans, m, n, alpha, a, lda, x, incx, beta, y, incy);
}
template <>
inline void aka_gemm<float>(char * transa, char * transb, int * m, int * n,
int * k, float * alpha, float * a, int * lda,
float * b, int * ldb, float * beta, float * c,
int * ldc) {
AKA_FC_GLOBAL(sgemm, SGEMM)
(transa, transb, m, n, k, alpha, a, lda, b, ldb, beta, c, ldc);
}
#endif
-} // akantu
+} // namespace akantu
#ifdef AKANTU_USE_LAPACK
#include "aka_fortran_mangling.hh"
extern "C" {
/* ------------------------------------------------------------------------ */
/* Double general matrix */
/* ------------------------------------------------------------------------ */
/// compute the eigenvalues/vectors
void AKA_FC_GLOBAL(dgeev, DGEEV)(char * jobvl, char * jobvr, int * n,
double * a, int * lda, double * wr,
double * wi, double * vl, int * ldvl,
double * vr, int * ldvr, double * work,
int * lwork, int * info);
/// LU decomposition of a general matrix
void AKA_FC_GLOBAL(dgetrf, DGETRF)(int * m, int * n, double * a, int * lda,
int * ipiv, int * info);
/// generate inverse of a matrix given its LU decomposition
void AKA_FC_GLOBAL(dgetri, DGETRI)(int * n, double * a, int * lda, int * ipiv,
double * work, int * lwork, int * info);
/// solving A x = b using a LU factorization
void AKA_FC_GLOBAL(dgetrs, DGETRS)(char * trans, int * n, int * nrhs,
double * A, int * lda, int * ipiv,
double * b, int * ldb, int * info);
/* ------------------------------------------------------------------------ */
/* Simple general matrix */
/* ------------------------------------------------------------------------ */
/// compute the eigenvalues/vectors
void AKA_FC_GLOBAL(sgeev, SGEEV)(char * jobvl, char * jobvr, int * n, float * a,
int * lda, float * wr, float * wi, float * vl,
int * ldvl, float * vr, int * ldvr,
float * work, int * lwork, int * info);
/// LU decomposition of a general matrix
void AKA_FC_GLOBAL(sgetrf, SGETRF)(int * m, int * n, float * a, int * lda,
int * ipiv, int * info);
/// generate inverse of a matrix given its LU decomposition
void AKA_FC_GLOBAL(sgetri, SGETRI)(int * n, float * a, int * lda, int * ipiv,
float * work, int * lwork, int * info);
/// solving A x = b using a LU factorization
void AKA_FC_GLOBAL(sgetrs, SGETRS)(char * trans, int * n, int * nrhs, float * A,
int * lda, int * ipiv, float * b, int * ldb,
int * info);
}
#endif // AKANTU_USE_LAPACK
namespace akantu {
/// Wrapper around the S/DGEEV BLAS function that computes the eigenvalues and
/// eigenvectors of a matrix
template <typename T>
inline void aka_geev(char * jobvl, char * jobvr, int * n, T * a, int * lda,
T * wr, T * wi, T * vl, int * ldvl, T * vr, int * ldvr,
T * work, int * lwork, int * info) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"LAPACK in the compilation options!");
}
/// Wrapper around the S/DGETRF BLAS function that computes the LU decomposition
/// of a matrix
template <typename T>
inline void aka_getrf(int * m, int * n, T * a, int * lda, int * ipiv,
int * info) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"LAPACK in the compilation options!");
}
/// Wrapper around the S/DGETRI BLAS function that computes the inverse of a
/// matrix given its LU decomposition
template <typename T>
inline void aka_getri(int * n, T * a, int * lda, int * ipiv, T * work,
int * lwork, int * info) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"LAPACK in the compilation options!");
}
/// Wrapper around the S/DGETRS BLAS function that solves \f$A^{(T)}x = b\f$
/// using LU decomposition
template <typename T>
inline void aka_getrs(char * trans, int * n, int * nrhs, T * A, int * lda,
int * ipiv, T * b, int * ldb, int * info) {
AKANTU_ERROR(debug::demangle(typeid(T).name())
<< "is not a type recognized, or you didn't activated "
"LAPACK in the compilation options!");
}
#include "aka_warning_restore.hh"
#ifdef AKANTU_USE_LAPACK
template <>
inline void aka_geev<double>(char * jobvl, char * jobvr, int * n, double * a,
int * lda, double * wr, double * wi, double * vl,
int * ldvl, double * vr, int * ldvr, double * work,
int * lwork, int * info) {
AKA_FC_GLOBAL(dgeev, DGEEV)
(jobvl, jobvr, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
}
template <>
inline void aka_getrf<double>(int * m, int * n, double * a, int * lda,
int * ipiv, int * info) {
AKA_FC_GLOBAL(dgetrf, DGETRF)(m, n, a, lda, ipiv, info);
}
template <>
inline void aka_getri<double>(int * n, double * a, int * lda, int * ipiv,
double * work, int * lwork, int * info) {
AKA_FC_GLOBAL(dgetri, DGETRI)(n, a, lda, ipiv, work, lwork, info);
}
template <>
inline void aka_getrs<double>(char * trans, int * n, int * nrhs, double * A,
int * lda, int * ipiv, double * b, int * ldb,
int * info) {
AKA_FC_GLOBAL(dgetrs, DGETRS)(trans, n, nrhs, A, lda, ipiv, b, ldb, info);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <>
inline void aka_geev<float>(char * jobvl, char * jobvr, int * n, float * a,
int * lda, float * wr, float * wi, float * vl,
int * ldvl, float * vr, int * ldvr, float * work,
int * lwork, int * info) {
AKA_FC_GLOBAL(sgeev, SGEEV)
(jobvl, jobvr, n, a, lda, wr, wi, vl, ldvl, vr, ldvr, work, lwork, info);
}
template <>
inline void aka_getrf<float>(int * m, int * n, float * a, int * lda, int * ipiv,
int * info) {
AKA_FC_GLOBAL(sgetrf, SGETRF)(m, n, a, lda, ipiv, info);
}
template <>
inline void aka_getri<float>(int * n, float * a, int * lda, int * ipiv,
float * work, int * lwork, int * info) {
AKA_FC_GLOBAL(sgetri, SGETRI)(n, a, lda, ipiv, work, lwork, info);
}
template <>
inline void aka_getrs<float>(char * trans, int * n, int * nrhs, float * A,
int * lda, int * ipiv, float * b, int * ldb,
int * info) {
AKA_FC_GLOBAL(sgetrs, SGETRS)(trans, n, nrhs, A, lda, ipiv, b, ldb, info);
}
#endif
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_BLAS_LAPACK_HH__ */
diff --git a/src/common/aka_circular_array.hh b/src/common/aka_circular_array.hh
index 442967ff9..a62ebe41e 100644
--- a/src/common/aka_circular_array.hh
+++ b/src/common/aka_circular_array.hh
@@ -1,129 +1,129 @@
/**
* @file aka_circular_array.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Aug 13 2017
*
* @brief class of circular array
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_CIRCULAR_ARRAY_HH__
#define __AKANTU_AKA_CIRCULAR_ARRAY_HH__
/* -------------------------------------------------------------------------- */
#include <typeinfo>
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
template <class T> class CircularArray : protected Array<T> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
typedef typename Array<T>::value_type value_type;
typedef typename Array<T>::reference reference;
typedef typename Array<T>::pointer_type pointer_type;
typedef typename Array<T>::const_reference const_reference;
/// Allocation of a new array with a default value
CircularArray(UInt size, UInt nb_component = 1,
const_reference value = value_type(), const ID & id = "")
: Array<T>(size, nb_component, value, id), start_position(0),
end_position(size - 1) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
};
virtual ~CircularArray() {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/**
advance start and end position by one:
the first element is now at the end of the array
**/
inline void makeStep();
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
private:
/* ------------------------------------------------------------------------ */
/* Operators */
/* ------------------------------------------------------------------------ */
public:
inline reference operator()(UInt i, UInt j = 0);
inline const_reference operator()(UInt i, UInt j = 0) const;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
UInt size() const { return this->size_; };
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// indice of first element in this circular array
UInt start_position;
/// indice of last element in this circular array
UInt end_position;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_INCLUDE_INLINE_IMPL)
#include "aka_circular_array_inline_impl.cc"
#endif
/// standard output stream operator
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const CircularArray<T> & _this) {
_this.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_CIRCULAR_ARRAY_HH__ */
diff --git a/src/common/aka_common.cc b/src/common/aka_common.cc
index c7476c60e..866cc3447 100644
--- a/src/common/aka_common.cc
+++ b/src/common/aka_common.cc
@@ -1,167 +1,168 @@
/**
* @file aka_common.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jun 14 2010
* @date last modification: Mon Feb 05 2018
*
* @brief Initialization of global variables
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_random_generator.hh"
#include "aka_static_memory.hh"
#include "communicator.hh"
#include "cppargparse.hh"
#include "parser.hh"
#include "communication_tag.hh"
/* -------------------------------------------------------------------------- */
-#include <ctime>
#include <cmath>
+#include <ctime>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void initialize(int & argc, char **& argv) {
AKANTU_DEBUG_IN();
initialize("", argc, argv);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void initialize(const std::string & input_file, int & argc, char **& argv) {
AKANTU_DEBUG_IN();
StaticMemory::getStaticMemory();
Communicator & comm = Communicator::getStaticCommunicator(argc, argv);
Tag::setMaxTag(comm.getMaxTag());
debug::debugger.setParallelContext(comm.whoAmI(), comm.getNbProc());
debug::setDebugLevel(dblError);
static_argparser.setParallelContext(comm.whoAmI(), comm.getNbProc());
static_argparser.setExternalExitFunction(debug::exit);
static_argparser.addArgument("--aka_input_file", "Akantu's input file", 1,
cppargparse::_string, std::string());
static_argparser.addArgument(
"--aka_debug_level",
std::string("Akantu's overall debug level") +
std::string(" (0: error, 1: exceptions, 4: warnings, 5: info, ..., "
"100: dump") +
std::string(" more info on levels can be foind in aka_error.hh)"),
1, cppargparse::_integer, (long int)(dblWarning));
static_argparser.addArgument(
"--aka_print_backtrace",
"Should Akantu print a backtrace in case of error", 0,
cppargparse::_boolean, false, true);
static_argparser.addArgument("--aka_seed", "The seed to use on prank 0", 1,
cppargparse::_integer);
static_argparser.parse(argc, argv, cppargparse::_remove_parsed);
std::string infile = static_argparser["aka_input_file"];
if (infile == "")
infile = input_file;
debug::debugger.printBacktrace(static_argparser["aka_print_backtrace"]);
if ("" != infile) {
readInputFile(infile);
}
long int seed;
- if(static_argparser.has("aka_seed")) {
+ if (static_argparser.has("aka_seed")) {
seed = static_argparser["aka_seed"];
} else {
- seed = static_parser.getParameter("seed", time(nullptr), _ppsc_current_scope);
+ seed =
+ static_parser.getParameter("seed", time(nullptr), _ppsc_current_scope);
}
-
+
seed *= (comm.whoAmI() + 1);
RandomGenerator<UInt>::seed(seed);
long int dbl_level = static_argparser["aka_debug_level"];
debug::setDebugLevel(DebugLevel(dbl_level));
AKANTU_DEBUG_INFO("Random seed set to " << seed);
std::atexit(finalize);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void finalize() {
AKANTU_DEBUG_IN();
// if (StaticCommunicator::isInstantiated()) {
// StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
// delete &comm;
// }
if (StaticMemory::isInstantiated()) {
delete &(StaticMemory::getStaticMemory());
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void readInputFile(const std::string & input_file) {
static_parser.parse(input_file);
}
/* -------------------------------------------------------------------------- */
cppargparse::ArgumentParser & getStaticArgumentParser() {
return static_argparser;
}
/* -------------------------------------------------------------------------- */
Parser & getStaticParser() { return static_parser; }
/* -------------------------------------------------------------------------- */
const ParserSection & getUserParser() {
return *(static_parser.getSubSections(ParserType::_user).first);
}
std::unique_ptr<Communicator> Communicator::static_communicator;
std::ostream & operator<<(std::ostream & stream, NodeFlag flag) {
using under = std::underlying_type_t<NodeFlag>;
- int digits = std::log(std::numeric_limits<under>::max() + 1)/std::log(16);
+ int digits = std::log(std::numeric_limits<under>::max() + 1) / std::log(16);
std::ios_base::fmtflags ff;
ff = stream.flags();
auto value = static_cast<std::common_type_t<under, unsigned int>>(flag);
stream << "0x" << std::hex << std::setw(digits) << std::setfill('0') << value;
stream.flags(ff);
return stream;
}
} // namespace akantu
diff --git a/src/common/aka_common.hh b/src/common/aka_common.hh
index bb7edc6b1..e1cc6c6fb 100644
--- a/src/common/aka_common.hh
+++ b/src/common/aka_common.hh
@@ -1,637 +1,640 @@
/**
* @file aka_common.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jun 14 2010
* @date last modification: Mon Feb 12 2018
*
* @brief common type descriptions for akantu
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* All common things to be included in the projects files
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COMMON_HH__
#define __AKANTU_COMMON_HH__
#include "aka_compatibilty_with_cpp_standard.hh"
/* -------------------------------------------------------------------------- */
#define __BEGIN_AKANTU_DUMPER__ namespace dumper {
#define __END_AKANTU_DUMPER__ }
/* -------------------------------------------------------------------------- */
#if defined(WIN32)
#define __attribute__(x)
#endif
/* -------------------------------------------------------------------------- */
#include "aka_config.hh"
#include "aka_error.hh"
#include "aka_safe_enum.hh"
/* -------------------------------------------------------------------------- */
#include <boost/preprocessor.hpp>
#include <limits>
#include <list>
#include <memory>
#include <string>
#include <type_traits>
#include <unordered_map>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Constants */
/* -------------------------------------------------------------------------- */
namespace {
__attribute__((unused)) constexpr UInt _all_dimensions{
std::numeric_limits<UInt>::max()};
#ifdef AKANTU_NDEBUG
__attribute__((unused)) constexpr Real REAL_INIT_VALUE{0.};
#else
__attribute__((unused)) constexpr Real REAL_INIT_VALUE{
std::numeric_limits<Real>::quiet_NaN()};
#endif
} // namespace
/* -------------------------------------------------------------------------- */
/* Common types */
/* -------------------------------------------------------------------------- */
using ID = std::string;
using MemoryID = UInt;
} // namespace akantu
/* -------------------------------------------------------------------------- */
#include "aka_enum_macros.hh"
/* -------------------------------------------------------------------------- */
#include "aka_element_classes_info.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Mesh/FEM/Model types */
/* -------------------------------------------------------------------------- */
/// small help to use names for directions
enum SpatialDirection { _x = 0, _y = 1, _z = 2 };
/// enum MeshIOType type of mesh reader/writer
enum MeshIOType {
_miot_auto, ///< Auto guess of the reader to use based on the extension
_miot_gmsh, ///< Gmsh files
_miot_gmsh_struct, ///< Gsmh reader with reintpretation of elements has
/// structures elements
_miot_diana, ///< TNO Diana mesh format
_miot_abaqus ///< Abaqus mesh format
};
/// enum MeshEventHandlerPriority defines relative order of execution of
/// events
enum EventHandlerPriority {
_ehp_highest = 0,
_ehp_mesh = 5,
_ehp_fe_engine = 9,
_ehp_synchronizer = 10,
_ehp_dof_manager = 20,
_ehp_model = 94,
_ehp_non_local_manager = 100,
_ehp_lowest = 100
};
// clang-format off
#define AKANTU_MODEL_TYPES \
(model) \
(solid_mechanics_model) \
(solid_mechanics_model_cohesive) \
(heat_transfer_model) \
(structural_mechanics_model) \
(embedded_model) \
(contact_mechanics_model) \
(coupler_solid_contact)
// clang-format on
/// enum ModelType defines which type of physics is solved
AKANTU_CLASS_ENUM_DECLARE(ModelType, AKANTU_MODEL_TYPES)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(ModelType, AKANTU_MODEL_TYPES)
AKANTU_CLASS_ENUM_INPUT_STREAM(ModelType, AKANTU_MODEL_TYPES)
/// enum AnalysisMethod type of solving method used to solve the equation of
/// motion
enum AnalysisMethod {
_static = 0,
_implicit_dynamic = 1,
_explicit_lumped_mass = 2,
_explicit_lumped_capacity = 2,
_explicit_consistent_mass = 3,
_explicit_contact = 4,
_implicit_contact = 5,
_explicit_dynamic_contact = 6
};
/// enum DOFSupportType defines which kind of dof that can exists
enum DOFSupportType { _dst_nodal, _dst_generic };
#if !defined(DOXYGEN)
// clang-format off
#define AKANTU_NON_LINEAR_SOLVER_TYPES \
(linear) \
(newton_raphson) \
(newton_raphson_modified) \
(lumped) \
(gmres) \
(bfgs) \
(cg) \
(newton_raphson_contact) \
(auto)
// clang-format on
AKANTU_CLASS_ENUM_DECLARE(NonLinearSolverType, AKANTU_NON_LINEAR_SOLVER_TYPES)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(NonLinearSolverType,
AKANTU_NON_LINEAR_SOLVER_TYPES)
AKANTU_CLASS_ENUM_INPUT_STREAM(NonLinearSolverType,
AKANTU_NON_LINEAR_SOLVER_TYPES)
#else
/// Type of non linear resolution available in akantu
enum class NonLinearSolverType {
_linear, ///< No non linear convergence loop
_newton_raphson, ///< Regular Newton-Raphson
_newton_raphson_modified, ///< Newton-Raphson with initial tangent
_lumped, ///< Case of lumped mass or equivalent matrix
_gmres,
_bfgs,
_cg,
_newton_raphson_contact, ///< Regular Newton-Raphson modified
/// for contact problem
_auto, ///< This will take a default value that make sense in case of
/// model::getNewSolver
};
#endif
#if !defined(DOXYGEN)
// clang-format off
#define AKANTU_TIME_STEP_SOLVER_TYPE \
(static) \
(dynamic) \
(dynamic_lumped) \
(not_defined)
// clang-format on
AKANTU_CLASS_ENUM_DECLARE(TimeStepSolverType, AKANTU_TIME_STEP_SOLVER_TYPE)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(TimeStepSolverType,
AKANTU_TIME_STEP_SOLVER_TYPE)
AKANTU_CLASS_ENUM_INPUT_STREAM(TimeStepSolverType, AKANTU_TIME_STEP_SOLVER_TYPE)
#else
/// Type of time stepping solver
enum class TimeStepSolverType {
_static, ///< Static solution
_dynamic, ///< Dynamic solver
_dynamic_lumped, ///< Dynamic solver with lumped mass
_not_defined, ///< For not defined cases
};
#endif
#if !defined(DOXYGEN)
// clang-format off
#define AKANTU_INTEGRATION_SCHEME_TYPE \
(pseudo_time) \
(forward_euler) \
(trapezoidal_rule_1) \
(backward_euler) \
(central_difference) \
(fox_goodwin) \
(trapezoidal_rule_2) \
(linear_acceleration) \
(newmark_beta) \
(generalized_trapezoidal)
// clang-format on
AKANTU_CLASS_ENUM_DECLARE(IntegrationSchemeType, AKANTU_INTEGRATION_SCHEME_TYPE)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(IntegrationSchemeType,
AKANTU_INTEGRATION_SCHEME_TYPE)
AKANTU_CLASS_ENUM_INPUT_STREAM(IntegrationSchemeType,
AKANTU_INTEGRATION_SCHEME_TYPE)
#else
/// Type of integration scheme
enum class IntegrationSchemeType {
_pseudo_time, ///< Pseudo Time
_forward_euler, ///< GeneralizedTrapezoidal(0)
_trapezoidal_rule_1, ///< GeneralizedTrapezoidal(1/2)
_backward_euler, ///< GeneralizedTrapezoidal(1)
_central_difference, ///< NewmarkBeta(0, 1/2)
_fox_goodwin, ///< NewmarkBeta(1/6, 1/2)
_trapezoidal_rule_2, ///< NewmarkBeta(1/2, 1/2)
_linear_acceleration, ///< NewmarkBeta(1/3, 1/2)
_newmark_beta, ///< generic NewmarkBeta with user defined
/// alpha and beta
_generalized_trapezoidal ///< generic GeneralizedTrapezoidal with user
/// defined alpha
};
#endif
#if !defined(DOXYGEN)
// clang-format off
#define AKANTU_SOLVE_CONVERGENCE_CRITERIA \
(residual) \
(solution) \
(residual_mass_wgh)
// clang-format on
AKANTU_CLASS_ENUM_DECLARE(SolveConvergenceCriteria,
AKANTU_SOLVE_CONVERGENCE_CRITERIA)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(SolveConvergenceCriteria,
AKANTU_SOLVE_CONVERGENCE_CRITERIA)
AKANTU_CLASS_ENUM_INPUT_STREAM(SolveConvergenceCriteria,
AKANTU_SOLVE_CONVERGENCE_CRITERIA)
#else
/// enum SolveConvergenceCriteria different convergence criteria
enum class SolveConvergenceCriteria {
_residual, ///< Use residual to test the convergence
_solution, ///< Use solution to test the convergence
_residual_mass_wgh ///< Use residual weighted by inv. nodal mass to
///< testb
};
#endif
/// enum CohesiveMethod type of insertion of cohesive elements
enum CohesiveMethod { _intrinsic, _extrinsic };
/// @enum SparseMatrixType type of sparse matrix used
enum MatrixType { _unsymmetric, _symmetric, _mt_not_defined };
/// @enum Type of contact detection
enum DetectionType { _explicit, _implicit};
/* -------------------------------------------------------------------------- */
/* Ghosts handling */
/* -------------------------------------------------------------------------- */
/// @enum CommunicatorType type of communication method to use
enum CommunicatorType { _communicator_mpi, _communicator_dummy };
#if !defined(DOXYGEN)
// clang-format off
#define AKANTU_SYNCHRONIZATION_TAG \
(whatever) \
(update) \
(ask_nodes) \
(size) \
(smm_mass) \
(smm_for_gradu) \
(smm_boundary) \
(smm_uv) \
(smm_res) \
(smm_init_mat) \
(smm_stress) \
(smmc_facets) \
(smmc_facets_conn) \
(smmc_facets_stress) \
(smmc_damage) \
(giu_global_conn) \
(ce_groups) \
(gm_clusters) \
(htm_temperature) \
(htm_gradient_temperature) \
(htm_phi) \
(htm_gradient_phi) \
(mnl_for_average) \
(mnl_weight) \
(nh_criterion) \
(test) \
(user_1) \
(user_2) \
(material_id) \
(for_dump) \
(cf_nodal) \
(cf_incr) \
(solver_solution)
// clang-format on
AKANTU_CLASS_ENUM_DECLARE(SynchronizationTag, AKANTU_SYNCHRONIZATION_TAG)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(SynchronizationTag, AKANTU_SYNCHRONIZATION_TAG)
#else
/// @enum SynchronizationTag type of synchronizations
enum class SynchronizationTag {
//--- Generic tags ---
_whatever,
_update,
_ask_nodes,
_size,
//--- SolidMechanicsModel tags ---
_smm_mass, ///< synchronization of the SolidMechanicsModel.mass
_smm_for_gradu, ///< synchronization of the
/// SolidMechanicsModel.displacement
_smm_boundary, ///< synchronization of the boundary, forces, velocities
/// and displacement
_smm_uv, ///< synchronization of the nodal velocities and displacement
_smm_res, ///< synchronization of the nodal residual
_smm_init_mat, ///< synchronization of the data to initialize materials
_smm_stress, ///< synchronization of the stresses to compute the
///< internal
/// forces
_smmc_facets, ///< synchronization of facet data to setup facet synch
_smmc_facets_conn, ///< synchronization of facet global connectivity
_smmc_facets_stress, ///< synchronization of facets' stress to setup
///< facet
/// synch
_smmc_damage, ///< synchronization of damage
// --- GlobalIdsUpdater tags ---
_giu_global_conn, ///< synchronization of global connectivities
// --- CohesiveElementInserter tags ---
_ce_groups, ///< synchronization of cohesive element insertion depending
/// on facet groups
// --- GroupManager tags ---
_gm_clusters, ///< synchronization of clusters
// --- HeatTransfer tags ---
_htm_temperature, ///< synchronization of the nodal temperature
_htm_gradient_temperature, ///< synchronization of the element gradient
/// temperature
// --- LevelSet tags ---
_htm_phi, ///< synchronization of the nodal level set value phi
_htm_gradient_phi, ///< synchronization of the element gradient phi
_pfm_damage,
_pfm_gradient_damage,
//--- Material non local ---
_mnl_for_average, ///< synchronization of data to average in non local
/// material
_mnl_weight, ///< synchronization of data for the weight computations
// --- NeighborhoodSynchronization tags ---
_nh_criterion,
// --- General tags ---
_test, ///< Test tag
_user_1, ///< tag for user simulations
_user_2, ///< tag for user simulations
_material_id, ///< synchronization of the material ids
_for_dump, ///< everything that needs to be synch before dump
// --- Contact & Friction ---
_cf_nodal, ///< synchronization of disp, velo, and current position
_cf_incr, ///< synchronization of increment
// --- Solver tags ---
_solver_solution ///< synchronization of the solution obained with the
/// PETSc solver
};
#endif
/// @enum GhostType type of ghost
enum GhostType {
_not_ghost = 0,
_ghost = 1,
_casper // not used but a real cute ghost
};
/// Define the flag that can be set to a node
enum class NodeFlag : std::uint8_t {
_normal = 0x00,
_distributed = 0x01,
_master = 0x03,
_slave = 0x05,
_pure_ghost = 0x09,
_shared_mask = 0x0F,
_periodic = 0x10,
_periodic_master = 0x30,
_periodic_slave = 0x50,
_periodic_mask = 0xF0,
_local_master_mask = 0xCC, // ~(_master & _periodic_mask)
};
inline NodeFlag operator&(const NodeFlag & a, const NodeFlag & b) {
using under = std::underlying_type_t<NodeFlag>;
return NodeFlag(under(a) & under(b));
}
inline NodeFlag operator|(const NodeFlag & a, const NodeFlag & b) {
using under = std::underlying_type_t<NodeFlag>;
return NodeFlag(under(a) | under(b));
}
inline NodeFlag & operator|=(NodeFlag & a, const NodeFlag & b) {
a = a | b;
return a;
}
inline NodeFlag & operator&=(NodeFlag & a, const NodeFlag & b) {
a = a & b;
return a;
}
inline NodeFlag operator~(const NodeFlag & a) {
using under = std::underlying_type_t<NodeFlag>;
return NodeFlag(~under(a));
}
std::ostream & operator<<(std::ostream & stream, NodeFlag flag);
} // namespace akantu
AKANTU_ENUM_HASH(GhostType)
namespace akantu {
/* -------------------------------------------------------------------------- */
struct GhostType_def {
using type = GhostType;
static const type _begin_ = _not_ghost;
static const type _end_ = _casper;
};
using ghost_type_t = safe_enum<GhostType_def>;
extern ghost_type_t ghost_types;
/// standard output stream operator for GhostType
inline std::ostream & operator<<(std::ostream & stream, GhostType type);
/* -------------------------------------------------------------------------- */
/* Global defines */
/* -------------------------------------------------------------------------- */
#define AKANTU_MIN_ALLOCATION 2000
#define AKANTU_INDENT ' '
#define AKANTU_INCLUDE_INLINE_IMPL
/* -------------------------------------------------------------------------- */
#define AKANTU_SET_MACRO(name, variable, type) \
inline void set##name(type variable) { this->variable = variable; }
#define AKANTU_GET_MACRO(name, variable, type) \
inline type get##name() const { return variable; }
#define AKANTU_GET_MACRO_NOT_CONST(name, variable, type) \
inline type get##name() { return variable; }
#define AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, support, con) \
inline con Array<type> & get##name( \
const support & el_type, const GhostType & ghost_type = _not_ghost) \
con { \
return variable(el_type, ghost_type); \
}
#define AKANTU_GET_MACRO_BY_ELEMENT_TYPE(name, variable, type) \
AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, ElementType, )
#define AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(name, variable, type) \
AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, ElementType, const)
#define AKANTU_GET_MACRO_BY_GEOMETRIE_TYPE(name, variable, type) \
AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, GeometricalType, )
#define AKANTU_GET_MACRO_BY_GEOMETRIE_TYPE_CONST(name, variable, type) \
AKANTU_GET_MACRO_BY_SUPPORT_TYPE(name, variable, type, GeometricalType, const)
/* -------------------------------------------------------------------------- */
/// initialize the static part of akantu
void initialize(int & argc, char **& argv);
/// initialize the static part of akantu and read the global input_file
void initialize(const std::string & input_file, int & argc, char **& argv);
/* -------------------------------------------------------------------------- */
/// finilize correctly akantu and clean the memory
void finalize();
/* -------------------------------------------------------------------------- */
/// Read an new input file
void readInputFile(const std::string & input_file);
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* string manipulation */
/* -------------------------------------------------------------------------- */
inline std::string to_lower(const std::string & str);
/* -------------------------------------------------------------------------- */
inline std::string trim(const std::string & to_trim);
inline std::string trim(const std::string & to_trim, char c);
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/// give a string representation of the a human readable size in bit
template <typename T> std::string printMemorySize(UInt size);
/* -------------------------------------------------------------------------- */
struct TensorTrait {};
+struct TensorProxyTrait {};
+
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* Type traits */
/* -------------------------------------------------------------------------- */
namespace aka {
/* ------------------------------------------------------------------------ */
template <typename T> using is_tensor = std::is_base_of<akantu::TensorTrait, T>;
+template <typename T> using is_tensor_proxy = std::is_base_of<akantu::TensorProxyTrait, T>;
/* ------------------------------------------------------------------------ */
template <typename T> using is_scalar = std::is_arithmetic<T>;
/* ------------------------------------------------------------------------ */
template <typename R, typename T,
std::enable_if_t<std::is_reference<T>::value> * = nullptr>
bool is_of_type(T && t) {
return (
dynamic_cast<std::add_pointer_t<
std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
std::add_const_t<R>, R>>>(&t) != nullptr);
}
/* -------------------------------------------------------------------------- */
template <typename R, typename T> bool is_of_type(std::unique_ptr<T> & t) {
return (
dynamic_cast<std::add_pointer_t<
std::conditional_t<std::is_const<T>::value, std::add_const_t<R>, R>>>(
t.get()) != nullptr);
}
/* ------------------------------------------------------------------------ */
template <typename R, typename T,
std::enable_if_t<std::is_reference<T>::value> * = nullptr>
decltype(auto) as_type(T && t) {
static_assert(
disjunction<
std::is_base_of<std::decay_t<T>, std::decay_t<R>>, // down-cast
std::is_base_of<std::decay_t<R>, std::decay_t<T>> // up-cast
>::value,
"Type T and R are not valid for a as_type conversion");
return dynamic_cast<std::add_lvalue_reference_t<
std::conditional_t<std::is_const<std::remove_reference_t<T>>::value,
std::add_const_t<R>, R>>>(t);
}
/* -------------------------------------------------------------------------- */
template <typename R, typename T,
std::enable_if_t<std::is_pointer<T>::value> * = nullptr>
decltype(auto) as_type(T && t) {
return &as_type<R>(*t);
}
/* -------------------------------------------------------------------------- */
template <typename R, typename T>
decltype(auto) as_type(const std::shared_ptr<T> & t) {
return std::dynamic_pointer_cast<R>(t);
}
} // namespace aka
#include "aka_fwd.hh"
namespace akantu {
/// get access to the internal argument parser
cppargparse::ArgumentParser & getStaticArgumentParser();
/// get access to the internal input file parser
Parser & getStaticParser();
/// get access to the user part of the internal input file parser
const ParserSection & getUserParser();
} // namespace akantu
#include "aka_common_inline_impl.cc"
/* -------------------------------------------------------------------------- */
#if AKANTU_INTEGER_SIZE == 4
#define AKANTU_HASH_COMBINE_MAGIC_NUMBER 0x9e3779b9
#elif AKANTU_INTEGER_SIZE == 8
#define AKANTU_HASH_COMBINE_MAGIC_NUMBER 0x9e3779b97f4a7c13LL
#endif
namespace std {
/**
* Hashing function for pairs based on hash_combine from boost The magic
* number is coming from the golden number @f[\phi = \frac{1 + \sqrt5}{2}@f]
* @f[\frac{2^32}{\phi} = 0x9e3779b9@f]
* http://stackoverflow.com/questions/4948780/magic-number-in-boosthash-combine
* http://burtleburtle.net/bob/hash/doobs.html
*/
template <typename a, typename b> struct hash<std::pair<a, b>> {
hash() = default;
size_t operator()(const std::pair<a, b> & p) const {
size_t seed = ah(p.first);
return bh(p.second) + AKANTU_HASH_COMBINE_MAGIC_NUMBER + (seed << 6) +
(seed >> 2);
}
private:
const hash<a> ah{};
const hash<b> bh{};
};
} // namespace std
#endif /* __AKANTU_COMMON_HH__ */
diff --git a/src/common/aka_common_inline_impl.cc b/src/common/aka_common_inline_impl.cc
index 34d141d77..4fe579bd6 100644
--- a/src/common/aka_common_inline_impl.cc
+++ b/src/common/aka_common_inline_impl.cc
@@ -1,165 +1,164 @@
/**
* @file aka_common_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief inline implementations of common akantu type descriptions
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* All common things to be included in the projects files
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include <algorithm>
#include <cctype>
#include <iomanip>
#include <iostream>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_COMMON_INLINE_IMPL_CC__
#define __AKANTU_AKA_COMMON_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
/// standard output stream operator for GhostType
inline std::ostream & operator<<(std::ostream & stream, GhostType type) {
switch (type) {
case _not_ghost:
stream << "not_ghost";
break;
case _ghost:
stream << "ghost";
break;
case _casper:
stream << "Casper the friendly ghost";
break;
}
return stream;
}
/* -------------------------------------------------------------------------- */
inline std::string to_lower(const std::string & str) {
std::string lstr = str;
std::transform(lstr.begin(), lstr.end(), lstr.begin(), (int (*)(int))tolower);
return lstr;
}
namespace {
template <typename pred>
inline std::string trim_p(const std::string & to_trim, pred && p) {
std::string trimed = to_trim;
auto && not_ = [&](auto && a) { return not p(a); };
// left trim
trimed.erase(trimed.begin(),
std::find_if(trimed.begin(), trimed.end(), not_));
// right trim
- trimed.erase(
- std::find_if(trimed.rbegin(), trimed.rend(), not_).base(),
- trimed.end());
+ trimed.erase(std::find_if(trimed.rbegin(), trimed.rend(), not_).base(),
+ trimed.end());
return trimed;
}
} // namespace
/* -------------------------------------------------------------------------- */
inline std::string trim(const std::string & to_trim) {
return trim_p(to_trim, [&](auto && a) { return std::isspace(a); });
}
inline std::string trim(const std::string & to_trim, char c) {
return trim_p(to_trim, [&c](auto && a) { return (a == c); });
}
} // namespace akantu
#include <cmath>
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T> std::string printMemorySize(UInt size) {
Real real_size = size * sizeof(T);
UInt mult = 0;
if (real_size != 0)
mult = (std::log(real_size) / std::log(2)) / 10;
std::stringstream sstr;
real_size /= Real(1 << (10 * mult));
sstr << std::setprecision(2) << std::fixed << real_size;
std::string size_prefix;
switch (mult) {
case 0:
sstr << "";
break;
case 1:
sstr << "Ki";
break;
case 2:
sstr << "Mi";
break;
case 3:
sstr << "Gi";
break; // I started on this type of machines
// (32bit computers) (Nicolas)
case 4:
sstr << "Ti";
break;
case 5:
sstr << "Pi";
break;
case 6:
sstr << "Ei";
break; // theoritical limit of RAM of the current
// computers in 2014 (64bit computers) (Nicolas)
case 7:
sstr << "Zi";
break;
case 8:
sstr << "Yi";
break;
default:
AKANTU_ERROR(
"The programmer in 2014 didn't thought so far (even wikipedia does not "
"go further)."
<< " You have at least 1024 times more than a yobibit of RAM!!!"
<< " Just add the prefix corresponding in this switch case.");
}
sstr << "Byte";
return sstr.str();
}
} // namespace akantu
#endif /* __AKANTU_AKA_COMMON_INLINE_IMPL_CC__ */
diff --git a/src/common/aka_csr.hh b/src/common/aka_csr.hh
index aa9dcb291..d79ea10ad 100644
--- a/src/common/aka_csr.hh
+++ b/src/common/aka_csr.hh
@@ -1,281 +1,283 @@
/**
* @file aka_csr.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Apr 20 2011
* @date last modification: Sun Dec 03 2017
*
* @brief A compresed sparse row structure based on akantu Arrays
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_CSR_HH__
#define __AKANTU_AKA_CSR_HH__
namespace akantu {
/**
* This class can be used to store the structure of a sparse matrix or for
* vectors with variable number of component per element
*
* @param nb_rows number of rows of a matrix or size of a vector.
*/
template <typename T> class CSR {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
explicit CSR(UInt nb_rows = 0)
: nb_rows(nb_rows), rows_offsets(nb_rows + 1, 1, "rows_offsets"),
rows(0, 1, "rows") {
rows_offsets.clear();
};
virtual ~CSR() = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// does nothing
inline void beginInsertions(){};
/// insert a new entry val in row row
inline UInt insertInRow(UInt row, const T & val) {
UInt pos = rows_offsets(row)++;
rows(pos) = val;
return pos;
}
/// access an element of the matrix
inline const T & operator()(UInt row, UInt col) const {
AKANTU_DEBUG_ASSERT(rows_offsets(row + 1) - rows_offsets(row) > col,
"This element is not present in this CSR");
return rows(rows_offsets(row) + col);
}
/// access an element of the matrix
inline T & operator()(UInt row, UInt col) {
AKANTU_DEBUG_ASSERT(rows_offsets(row + 1) - rows_offsets(row) > col,
"This element is not present in this CSR");
return rows(rows_offsets(row) + col);
}
inline void endInsertions() {
for (UInt i = nb_rows; i > 0; --i)
rows_offsets(i) = rows_offsets(i - 1);
rows_offsets(0) = 0;
}
inline void countToCSR() {
for (UInt i = 1; i < nb_rows; ++i)
rows_offsets(i) += rows_offsets(i - 1);
for (UInt i = nb_rows; i >= 1; --i)
rows_offsets(i) = rows_offsets(i - 1);
rows_offsets(0) = 0;
}
inline void clearRows() {
rows_offsets.clear();
rows.resize(0);
};
inline void resizeRows(UInt nb_rows) {
this->nb_rows = nb_rows;
rows_offsets.resize(nb_rows + 1);
rows_offsets.clear();
}
inline void resizeCols() { rows.resize(rows_offsets(nb_rows)); }
inline void copy(Array<UInt> & offsets, Array<T> & values) {
offsets.copy(rows_offsets);
values.copy(rows);
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// returns the number of rows
inline UInt getNbRows() const { return rows_offsets.size() - 1; };
/// returns the number of non-empty columns in a given row
inline UInt getNbCols(UInt row) const {
return rows_offsets(row + 1) - rows_offsets(row);
};
/// returns the offset (start of columns) for a given row
inline UInt & rowOffset(UInt row) { return rows_offsets(row); };
// /// iterator on a row
// template <class array_iterator>
// class iterator_internal
// : public std::iterator<std::bidirectional_iterator_tag, typename
// array_iterator::value_type> {
// public:
// using _parent = std::iterator<std::bidirectional_iterator_tag, R>;
// using pointer = typename _parent::pointer;
// using reference = typename _parent::reference;
// explicit iterator_internal(array_iterator ait) : pos(std::move(ait)){};
// iterator_internal(const iterator_internal & it) : pos(it.pos){};
// iterator_internal & operator++() {
// ++pos;
// return *this;
// };
// iterator_internal operator++(int) {
// iterator tmp(*this);
// operator++();
// return tmp;
// };
// iterator_internal & operator--() {
// --pos;
// return *this;
// };
// iterator_internal operator--(int) {
// iterator_internal tmp(*this);
// operator--();
// return tmp;
// };
// bool operator==(const iterator_internal & rhs) { return pos == rhs.pos;
// }; bool operator!=(const iterator_internal & rhs) { return pos !=
// rhs.pos; }; reference operator*() { return *pos; }; pointer operator->()
// const { return pos; };
// private:
// array_iterator pos;
// };
using iterator = typename Array<T>::scalar_iterator;
using const_iterator = typename Array<T>::const_scalar_iterator;
template <typename iterator_internal> class CSRRow {
public:
CSRRow(iterator_internal begin, iterator_internal end)
: begin_(std::move(begin)), end_(std::move(end)) {}
inline auto begin() const { return begin_; }
inline auto end() const { return end_; }
private:
iterator_internal begin_, end_;
};
inline iterator begin(UInt row) { return rows.begin() + rows_offsets(row); };
inline iterator end(UInt row) {
return rows.begin() + rows_offsets(row + 1);
};
inline const_iterator begin(UInt row) const {
return rows.begin() + rows_offsets(row);
};
inline const_iterator end(UInt row) const {
return rows.begin() + rows_offsets(row + 1);
};
private:
template <typename iterator_internal>
decltype(auto) make_row(iterator_internal begin, iterator_internal end) {
return CSRRow<iterator_internal>(std::move(begin), std::move(end));
}
public:
- inline decltype(auto) getRow(UInt row) { return make_row(begin(row), end(row)); }
+ inline decltype(auto) getRow(UInt row) {
+ return make_row(begin(row), end(row));
+ }
inline decltype(auto) getRow(UInt row) const {
return make_row(begin(row), end(row));
}
inline iterator rbegin(UInt row) {
return rows.begin() + rows_offsets(row + 1) - 1;
};
inline iterator rend(UInt row) {
return rows.begin() + rows_offsets(row) - 1;
};
inline const Array<UInt> & getRowsOffset() const { return rows_offsets; };
inline const Array<T> & getRows() const { return rows; };
inline Array<T> & getRows() { return rows; };
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
UInt nb_rows;
/// array of size nb_rows containing the offset where the values are stored in
Array<UInt> rows_offsets;
/// compressed row values, values of row[i] are stored between rows_offsets[i]
/// and rows_offsets[i+1]
Array<T> rows;
};
/* -------------------------------------------------------------------------- */
/* Data CSR */
/* -------------------------------------------------------------------------- */
/**
* Inherits from CSR<UInt> and can contain information such as matrix values
* where the mother class would be a CSR structure for row and cols
*
* @return nb_rows
*/
template <class T> class DataCSR : public CSR<UInt> {
public:
DataCSR(UInt nb_rows = 0) : CSR<UInt>(nb_rows), data(0, 1){};
inline void resizeCols() {
CSR<UInt>::resizeCols();
data.resize(rows_offsets(nb_rows));
}
inline const Array<T> & getData() const { return data; };
private:
Array<T> data;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "aka_csr_inline_impl.cc"
/// standard output stream operator
// inline std::ostream & operator <<(std::ostream & stream, const CSR & _this)
// {
// _this.printself(stream);
// return stream;
// }
} // namespace akantu
#endif /* __AKANTU_AKA_CSR_HH__ */
diff --git a/src/common/aka_element_classes_info_inline_impl.cc b/src/common/aka_element_classes_info_inline_impl.cc
index bcf9cb8ea..cba7f9bbe 100644
--- a/src/common/aka_element_classes_info_inline_impl.cc
+++ b/src/common/aka_element_classes_info_inline_impl.cc
@@ -1,53 +1,54 @@
/**
* @file aka_element_classes_info_inline_impl.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Jun 18 2015
* @date last modification: Wed Jan 10 2018
*
* @brief Implementation of the streaming fonction for the element classes
* enums
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <unordered_map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_ELEMENT_CLASSES_INFO_INLINE_IMPL_CC__
#define __AKANTU_AKA_ELEMENT_CLASSES_INFO_INLINE_IMPL_CC__
namespace akantu {
-AKANTU_ENUM_OUTPUT_STREAM(ElementType, AKANTU_ALL_ELEMENT_TYPE(_not_defined)(_max_element_type))
+AKANTU_ENUM_OUTPUT_STREAM(
+ ElementType, AKANTU_ALL_ELEMENT_TYPE(_not_defined)(_max_element_type))
AKANTU_ENUM_INPUT_STREAM(ElementType, AKANTU_ALL_ELEMENT_TYPE)
AKANTU_ENUM_OUTPUT_STREAM(InterpolationType, AKANTU_INTERPOLATION_TYPES)
AKANTU_ENUM_INPUT_STREAM(InterpolationType, AKANTU_INTERPOLATION_TYPES)
AKANTU_ENUM_OUTPUT_STREAM(ElementKind, AKANTU_ELEMENT_KIND)
AKANTU_ENUM_INPUT_STREAM(ElementKind, AKANTU_ELEMENT_KIND)
} // namespace akantu
#endif /* __AKANTU_AKA_ELEMENT_CLASSES_INFO_INLINE_IMPL_CC__ */
diff --git a/src/common/aka_error.cc b/src/common/aka_error.cc
index 9747c9086..e7c640ee5 100644
--- a/src/common/aka_error.cc
+++ b/src/common/aka_error.cc
@@ -1,361 +1,350 @@
/**
* @file aka_error.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Sep 06 2010
* @date last modification: Sun Dec 03 2017
*
* @brief handling of errors
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_error.hh"
#include "aka_common.hh"
#include "aka_config.hh"
/* -------------------------------------------------------------------------- */
#include <csignal>
#include <iostream>
#if (defined(READLINK_COMMAND) || defined(ADDR2LINE_COMMAND)) && \
(not defined(_WIN32))
#include <execinfo.h>
#include <sys/wait.h>
#endif
+#include <chrono>
#include <cmath>
#include <cstring>
#include <cxxabi.h>
#include <fstream>
#include <iomanip>
#include <map>
#include <sys/types.h>
#include <unistd.h>
-#if defined(AKANTU_CORE_CXX11)
-#include <chrono>
-#elif defined(AKANTU_USE_OBSOLETE_GETTIMEOFDAY)
-#include <sys/time.h>
-#else
-#include <time.h>
-#endif
-
#ifdef AKANTU_USE_MPI
#include <mpi.h>
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
namespace debug {
static void printBacktraceAndExit(int) { std::terminate(); }
/* ------------------------------------------------------------------------ */
void initSignalHandler() { std::signal(SIGSEGV, &printBacktraceAndExit); }
/* ------------------------------------------------------------------------ */
std::string demangle(const char * symbol) {
int status;
std::string result;
char * demangled_name;
if ((demangled_name = abi::__cxa_demangle(symbol, nullptr, nullptr,
&status)) != nullptr) {
result = demangled_name;
free(demangled_name);
} else {
result = symbol;
}
return result;
}
/* ------------------------------------------------------------------------ */
#if (defined(READLINK_COMMAND) || defined(ADDR2LINK_COMMAND)) && \
(not defined(_WIN32))
std::string exec(const std::string & cmd) {
FILE * pipe = popen(cmd.c_str(), "r");
if (!pipe)
return "";
char buffer[1024];
std::string result = "";
while (!feof(pipe)) {
if (fgets(buffer, 128, pipe) != nullptr)
result += buffer;
}
result = result.substr(0, result.size() - 1);
pclose(pipe);
return result;
}
#endif
/* ------------------------------------------------------------------------ */
void printBacktrace(__attribute__((unused)) int sig) {
AKANTU_DEBUG_INFO("Caught signal " << sig << "!");
#if not defined(_WIN32)
#if defined(READLINK_COMMAND) && defined(ADDR2LINE_COMMAND)
std::string me = "";
char buf[1024];
/* The manpage says it won't null terminate. Let's zero the buffer. */
memset(buf, 0, sizeof(buf));
/* Note we use sizeof(buf)-1 since we may need an extra char for NUL. */
if (readlink("/proc/self/exe", buf, sizeof(buf) - 1))
me = std::string(buf);
std::ifstream inmaps;
inmaps.open("/proc/self/maps");
std::map<std::string, size_t> addr_map;
std::string line;
while (inmaps.good()) {
std::getline(inmaps, line);
std::stringstream sstr(line);
size_t first = line.find('-');
std::stringstream sstra(line.substr(0, first));
size_t addr;
sstra >> std::hex >> addr;
std::string lib;
sstr >> lib;
sstr >> lib;
sstr >> lib;
sstr >> lib;
sstr >> lib;
sstr >> lib;
if (lib != "" && addr_map.find(lib) == addr_map.end()) {
addr_map[lib] = addr;
}
}
if (me != "")
addr_map[me] = 0;
#endif
/// \todo for windows this part could be coded using CaptureStackBackTrace
/// and SymFromAddr
const size_t max_depth = 100;
size_t stack_depth;
void * stack_addrs[max_depth];
char ** stack_strings;
size_t i;
stack_depth = backtrace(stack_addrs, max_depth);
stack_strings = backtrace_symbols(stack_addrs, stack_depth);
std::cerr << "BACKTRACE : " << stack_depth << " stack frames."
<< std::endl;
auto w = size_t(std::floor(log(double(stack_depth)) / std::log(10.)) + 1);
/// -1 to remove the call to the printBacktrace function
for (i = 1; i < stack_depth; i++) {
std::cerr << std::dec << " [" << std::setw(w) << i << "] ";
std::string bt_line(stack_strings[i]);
size_t first, second;
if ((first = bt_line.find('(')) != std::string::npos &&
(second = bt_line.find('+')) != std::string::npos) {
std::string location = bt_line.substr(0, first);
#if defined(READLINK_COMMAND)
std::string location_cmd =
std::string(BOOST_PP_STRINGIZE(READLINK_COMMAND)) +
std::string(" -f ") + location;
location = exec(location_cmd);
#endif
std::string call =
demangle(bt_line.substr(first + 1, second - first - 1).c_str());
size_t f = bt_line.find('[');
size_t s = bt_line.find(']');
std::string address = bt_line.substr(f + 1, s - f - 1);
std::stringstream sstra(address);
size_t addr;
sstra >> std::hex >> addr;
std::cerr << location << " [" << call << "]";
#if defined(READLINK_COMMAND) && defined(ADDR2LINE_COMMAND)
auto it = addr_map.find(location);
if (it != addr_map.end()) {
std::stringstream syscom;
syscom << BOOST_PP_STRINGIZE(ADDR2LINE_COMMAND) << " 0x" << std::hex
<< (addr - it->second) << " -i -e " << location;
std::string line = exec(syscom.str());
std::cerr << " (" << line << ")" << std::endl;
} else {
#endif
std::cerr << " (0x" << std::hex << addr << ")" << std::endl;
#if defined(READLINK_COMMAND) && defined(ADDR2LINE_COMMAND)
}
#endif
} else {
std::cerr << bt_line << std::endl;
}
}
free(stack_strings);
std::cerr << "END BACKTRACE" << std::endl;
#endif
}
/* ------------------------------------------------------------------------ */
namespace {
void terminate_handler() {
auto eptr = std::current_exception();
auto t = abi::__cxa_current_exception_type();
auto name = t ? demangle(t->name()) : std::string("unknown");
try {
if (eptr)
std::rethrow_exception(eptr);
else
- std::cerr << AKANTU_LOCATION << "!! Execution terminated for unknown reasons !!"
+ std::cerr << AKANTU_LOCATION
+ << "!! Execution terminated for unknown reasons !!"
<< std::endl;
} catch (std::exception & e) {
std::cerr << AKANTU_LOCATION << "!! Uncaught exception of type " << name
<< " !!\nwhat(): \"" << e.what() << "\"" << std::endl;
} catch (...) {
- std::cerr << AKANTU_LOCATION << "!! Something strange of type \"" << name
- << "\" was thrown.... !!" << std::endl;
+ std::cerr << AKANTU_LOCATION << "!! Something strange of type \""
+ << name << "\" was thrown.... !!" << std::endl;
}
if (debugger.printBacktrace())
printBacktrace(15);
}
} // namespace
+
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
Debugger::Debugger() {
cout = &std::cerr;
level = dblWarning;
parallel_context = "";
file_open = false;
print_backtrace = false;
initSignalHandler();
std::set_terminate(terminate_handler);
}
/* ------------------------------------------------------------------------ */
Debugger::~Debugger() {
if (file_open) {
dynamic_cast<std::ofstream *>(cout)->close();
delete cout;
}
}
/* ------------------------------------------------------------------------ */
void Debugger::exit(int status) {
if (status != 0)
std::terminate();
std::exit(0);
}
/*------------------------------------------------------------------------- */
void Debugger::throwException(const std::string & info,
const std::string & file, unsigned int line,
__attribute__((unused)) bool silent,
__attribute__((unused))
- const std::string & location) const
+ const std::string & location,
+ const std::string & module) const
noexcept(false) {
#if !defined(AKANTU_NDEBUG)
- if (!silent) {
- printMessage("###", dblWarning, info + " " + location);
+ if (not silent) {
+ printMessage("###", dblWarning, info + " " + location, module);
}
#endif
debug::Exception ex(info, file, line);
+ ex.setModule(module);
throw ex;
}
/* ------------------------------------------------------------------------ */
void Debugger::printMessage(const std::string & prefix,
const DebugLevel & level,
- const std::string & info) const {
- if (this->level >= level) {
-#if defined(AKANTU_CORE_CXX11)
+ const std::string & info,
+ const std::string & module) const {
+ if (testLevel(level, module)) {
double timestamp =
std::chrono::duration_cast<std::chrono::duration<double, std::micro>>(
std::chrono::system_clock::now().time_since_epoch())
.count();
-#elif defined(AKANTU_USE_OBSOLETE_GETTIMEOFDAY)
- struct timeval time;
- gettimeofday(&time, NULL);
- double timestamp = time.tv_sec * 1e6 + time.tv_usec; /*in us*/
-#else
- struct timespec time;
- clock_gettime(CLOCK_REALTIME_COARSE, &time);
- double timestamp = time.tv_sec * 1e6 + time.tv_nsec * 1e-3; /*in us*/
-#endif
+
*(cout) << parallel_context << "{" << (size_t)timestamp << "} " << prefix
<< " " << info << std::endl;
}
}
/* ------------------------------------------------------------------------ */
void Debugger::setDebugLevel(const DebugLevel & level) {
this->level = level;
}
/* ------------------------------------------------------------------------ */
const DebugLevel & Debugger::getDebugLevel() const { return this->level; }
/* ------------------------------------------------------------------------ */
void Debugger::setLogFile(const std::string & filename) {
if (file_open) {
dynamic_cast<std::ofstream *>(cout)->close();
delete cout;
}
auto * fileout = new std::ofstream(filename.c_str());
file_open = true;
cout = fileout;
}
std::ostream & Debugger::getOutputStream() { return *cout; }
/* ------------------------------------------------------------------------ */
void Debugger::setParallelContext(int rank, int size) {
std::stringstream sstr;
UInt pad = std::ceil(std::log10(size));
sstr << "<" << getpid() << ">[R" << std::setfill(' ') << std::right
<< std::setw(pad) << rank << "|S" << size << "] ";
parallel_context = sstr.str();
}
void setDebugLevel(const DebugLevel & level) {
debugger.setDebugLevel(level);
}
const DebugLevel & getDebugLevel() { return debugger.getDebugLevel(); }
/* --------------------------------------------------------------------------
*/
void exit(int status) { debugger.exit(status); }
} // namespace debug
} // namespace akantu
diff --git a/src/common/aka_error.hh b/src/common/aka_error.hh
index 0519e100b..9dc9e316f 100644
--- a/src/common/aka_error.hh
+++ b/src/common/aka_error.hh
@@ -1,356 +1,384 @@
/**
* @file aka_error.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jun 14 2010
* @date last modification: Tue Feb 20 2018
*
* @brief error management and internal exceptions
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
+#include <set>
#include <sstream>
#include <typeinfo>
#include <utility>
-#include <set>
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ERROR_HH__
#define __AKANTU_ERROR_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
enum DebugLevel {
dbl0 = 0,
dblError = 0,
dblAssert = 0,
dbl1 = 1,
dblException = 1,
dblCritical = 1,
dbl2 = 2,
dblMajor = 2,
dbl3 = 3,
dblCall = 3,
dblSecondary = 3,
dblHead = 3,
dbl4 = 4,
dblWarning = 4,
dbl5 = 5,
dblInfo = 5,
dbl6 = 6,
dblIn = 6,
dblOut = 6,
dbl7 = 7,
dbl8 = 8,
dblTrace = 8,
dbl9 = 9,
dblAccessory = 9,
dbl10 = 10,
dblDebug = 42,
dbl100 = 100,
dblDump = 100,
dblTest = 1337
};
/* -------------------------------------------------------------------------- */
#define AKANTU_LOCATION \
"(" << __func__ << "(): " << __FILE__ << ":" << __LINE__ << ")"
/* -------------------------------------------------------------------------- */
namespace debug {
void setDebugLevel(const DebugLevel & level);
const DebugLevel & getDebugLevel();
void initSignalHandler();
std::string demangle(const char * symbol);
+ template <class T> std::string demangle() {
+ return demangle(typeid(T).name());
+ }
std::string exec(const std::string & cmd);
void printBacktrace(int sig);
void exit(int status) __attribute__((noreturn));
/* ------------------------------------------------------------------------ */
/// exception class that can be thrown by akantu
class Exception : public std::exception {
/* ---------------------------------------------------------------------- */
/* Constructors/Destructors */
/* ---------------------------------------------------------------------- */
protected:
explicit Exception(std::string info = "")
: _info(std::move(info)), _file("") {}
public:
//! full constructor
Exception(std::string info, std::string file, unsigned int line)
: _info(std::move(info)), _file(std::move(file)), _line(line) {}
//! destructor
~Exception() noexcept override = default;
/* ---------------------------------------------------------------------- */
/* Methods */
/* ---------------------------------------------------------------------- */
public:
const char * what() const noexcept override { return _info.c_str(); }
virtual const std::string info() const noexcept {
std::stringstream stream;
stream << debug::demangle(typeid(*this).name()) << " : " << _info << " ["
<< _file << ":" << _line << "]";
return stream.str();
}
public:
void setInfo(const std::string & info) { _info = info; }
void setFile(const std::string & file) { _file = file; }
void setLine(unsigned int line) { _line = line; }
+ void setModule(const std::string & module) { _module = module; }
/* ---------------------------------------------------------------------- */
/* Class Members */
/* ---------------------------------------------------------------------- */
protected:
/// exception description and additionals
std::string _info;
private:
/// file it is thrown from
std::string _file;
- /// ligne it is thrown from
+ /// line it is thrown from
unsigned int _line{0};
+
+ /// module in which exception was raised
+ std::string _module{"core"};
};
class CriticalError : public Exception {};
class AssertException : public Exception {};
class NotImplementedException : public Exception {};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const Exception & _this) {
stream << _this.what();
return stream;
}
/* --------------------------------------------------------------------------
*/
class Debugger {
public:
Debugger();
virtual ~Debugger();
Debugger(const Debugger &) = default;
Debugger & operator=(const Debugger &) = default;
void exit(int status) __attribute__((noreturn));
void throwException(const std::string & info, const std::string & file,
- unsigned int line, bool, const std::string &) const
- noexcept(false) __attribute__((noreturn));
+ unsigned int line, bool, const std::string &,
+ const std::string & module) const noexcept(false)
+ __attribute__((noreturn));
/*----------------------------------------------------------------------- */
template <class Except>
void throwCustomException(const Except & ex, const std::string & info,
- const std::string & file, unsigned int line) const
- noexcept(false) __attribute__((noreturn));
+ const std::string & file, unsigned int line,
+ const std::string & module) const noexcept(false)
+ __attribute__((noreturn));
/*----------------------------------------------------------------------- */
template <class Except>
void throwCustomException(const Except & ex, const std::string & file,
- unsigned int line) const noexcept(false)
+ unsigned int line,
+ const std::string & module) const noexcept(false)
__attribute__((noreturn));
void printMessage(const std::string & prefix, const DebugLevel & level,
- const std::string & info) const;
+ const std::string & info,
+ const std::string & module) const;
void setOutStream(std::ostream & out) { cout = &out; }
std::ostream & getOutStream() { return *cout; }
public:
void setParallelContext(int rank, int size);
void setDebugLevel(const DebugLevel & level);
const DebugLevel & getDebugLevel() const;
void setLogFile(const std::string & filename);
std::ostream & getOutputStream();
inline bool testLevel(const DebugLevel & level,
const std::string & module = "core") const {
auto level_reached = (this->level >= (level));
auto correct_module =
(level <= dblCritical) or (modules_to_debug.size() == 0) or
(modules_to_debug.find(module) != modules_to_debug.end());
return level_reached and correct_module;
}
void printBacktrace(bool on_off) { this->print_backtrace = on_off; }
bool printBacktrace() { return this->print_backtrace; }
void addModuleToDebug(const std::string & id) {
modules_to_debug.insert(id);
}
void removeModuleToDebug(const std::string & id) {
auto it = modules_to_debug.find(id);
- if(it != modules_to_debug.end())
+ if (it != modules_to_debug.end())
modules_to_debug.erase(it);
}
+
+ void listModules() {
+ for (auto & module_ : modules_to_debug) {
+ (*cout) << module_ << std::endl;
+ }
+ }
+
private:
std::string parallel_context;
std::ostream * cout;
bool file_open;
DebugLevel level;
bool print_backtrace;
std::set<std::string> modules_to_debug;
};
extern Debugger debugger;
} // namespace debug
/* -------------------------------------------------------------------------- */
#define AKANTU_STRINGIZE_(str) #str
#define AKANTU_STRINGIZE(str) AKANTU_STRINGIZE_(str)
/* -------------------------------------------------------------------------- */
+#define AKANTU_DEBUG_MODULE AKANTU_STRINGIZE(AKANTU_MODULE)
+/* -------------------------------------------------------------------------- */
#define AKANTU_STRINGSTREAM_IN(_str, _sstr) \
; \
do { \
std::stringstream _dbg_s_info; \
_dbg_s_info << _sstr; \
_str = _dbg_s_info.str(); \
} while (false)
/* -------------------------------------------------------------------------- */
#define AKANTU_EXCEPTION(info) AKANTU_EXCEPTION_(info, false)
#define AKANTU_SILENT_EXCEPTION(info) AKANTU_EXCEPTION_(info, true)
#define AKANTU_EXCEPTION_(info, silent) \
do { \
std::stringstream _dbg_str; \
_dbg_str << info; \
std::stringstream _dbg_loc; \
_dbg_loc << AKANTU_LOCATION; \
- ::akantu::debug::debugger.throwException( \
- _dbg_str.str(), __FILE__, __LINE__, silent, _dbg_loc.str()); \
+ ::akantu::debug::debugger.throwException(_dbg_str.str(), __FILE__, \
+ __LINE__, silent, _dbg_loc.str(), \
+ AKANTU_DEBUG_MODULE); \
} while (false)
#define AKANTU_CUSTOM_EXCEPTION_INFO(ex, info) \
do { \
std::stringstream _dbg_str; \
_dbg_str << info; \
- ::akantu::debug::debugger.throwCustomException(ex, _dbg_str.str(), \
- __FILE__, __LINE__); \
+ ::akantu::debug::debugger.throwCustomException( \
+ ex, _dbg_str.str(), __FILE__, __LINE__, AKANTU_DEBUG_MODULE); \
} while (false)
#define AKANTU_CUSTOM_EXCEPTION(ex) \
do { \
- ::akantu::debug::debugger.throwCustomException(ex, __FILE__, __LINE__); \
+ ::akantu::debug::debugger.throwCustomException(ex, __FILE__, __LINE__, \
+ AKANTU_DEBUG_MODULE); \
} while (false)
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_NDEBUG
#define AKANTU_DEBUG_TEST(level) (false)
#define AKANTU_DEBUG_LEVEL_IS_TEST() \
- (::akantu::debug::debugger.testLevel(dblTest, AKANTU_STRINGIZE(AKANTU_MODULE)))
+ (::akantu::debug::debugger.testLevel(dblTest, AKANTU_DEBUG_MODULE))
#define AKANTU_DEBUG(level, info)
#define AKANTU_DEBUG_(pref, level, info)
#define AKANTU_DEBUG_IN()
#define AKANTU_DEBUG_OUT()
#define AKANTU_DEBUG_INFO(info)
#define AKANTU_DEBUG_WARNING(info)
#define AKANTU_DEBUG_TRACE(info)
#define AKANTU_DEBUG_ASSERT(test, info)
#define AKANTU_ERROR(info) \
AKANTU_CUSTOM_EXCEPTION_INFO(::akantu::debug::CriticalError(), info)
/* -------------------------------------------------------------------------- */
#else
#define AKANTU_DEBUG(level, info) AKANTU_DEBUG_(" ", level, info)
#define AKANTU_DEBUG_(pref, level, info) \
do { \
std::string _dbg_str; \
AKANTU_STRINGSTREAM_IN(_dbg_str, info << " " << AKANTU_LOCATION); \
- ::akantu::debug::debugger.printMessage(pref, level, _dbg_str); \
+ ::akantu::debug::debugger.printMessage(pref, level, _dbg_str, \
+ AKANTU_DEBUG_MODULE); \
} while (false)
#define AKANTU_DEBUG_TEST(level) \
- (::akantu::debug::debugger.testLevel(level, AKANTU_STRINGIZE(AKANTU_MODULE)))
+ (::akantu::debug::debugger.testLevel(level, AKANTU_DEBUG_MODULE))
#define AKANTU_DEBUG_LEVEL_IS_TEST() \
(::akantu::debug::debugger.testLevel(dblTest))
#define AKANTU_DEBUG_IN() \
AKANTU_DEBUG_("==>", ::akantu::dblIn, __func__ << "()")
#define AKANTU_DEBUG_OUT() \
AKANTU_DEBUG_("<==", ::akantu::dblOut, __func__ << "()")
#define AKANTU_DEBUG_INFO(info) AKANTU_DEBUG_("---", ::akantu::dblInfo, info)
#define AKANTU_DEBUG_WARNING(info) \
AKANTU_DEBUG_("/!\\", ::akantu::dblWarning, info)
#define AKANTU_DEBUG_TRACE(info) AKANTU_DEBUG_(">>>", ::akantu::dblTrace, info)
#define AKANTU_DEBUG_ASSERT(test, info) \
do { \
if (not(test)) \
AKANTU_CUSTOM_EXCEPTION_INFO(::akantu::debug::AssertException(), \
"assert [" << #test << "] " << info); \
} while (false)
#define AKANTU_ERROR(info) \
do { \
AKANTU_DEBUG_("!!! ", ::akantu::dblError, info); \
AKANTU_CUSTOM_EXCEPTION_INFO(::akantu::debug::CriticalError(), info); \
} while (false)
#endif // AKANTU_NDEBUG
#define AKANTU_TO_IMPLEMENT() \
AKANTU_CUSTOM_EXCEPTION_INFO(::akantu::debug::NotImplementedException(), \
__func__ << " : not implemented yet !")
/* -------------------------------------------------------------------------- */
namespace debug {
/* ------------------------------------------------------------------------ */
template <class Except>
- void Debugger::throwCustomException(const Except & ex,
- const std::string & info,
- const std::string & file,
- unsigned int line) const noexcept(false) {
+ void
+ Debugger::throwCustomException(const Except & ex, const std::string & info,
+ const std::string & file, unsigned int line,
+ const std::string & module) const
+ noexcept(false) {
auto & nc_ex = const_cast<Except &>(ex);
nc_ex.setInfo(info);
nc_ex.setFile(file);
nc_ex.setLine(line);
+ nc_ex.setModule(module);
throw ex;
}
/* ------------------------------------------------------------------------ */
template <class Except>
void Debugger::throwCustomException(const Except & ex,
const std::string & file,
- unsigned int line) const noexcept(false) {
+ unsigned int line,
+ const std::string & module) const
+ noexcept(false) {
auto & nc_ex = const_cast<Except &>(ex);
nc_ex.setFile(file);
nc_ex.setLine(line);
+ nc_ex.setModule(module);
throw ex;
}
} // namespace debug
} // namespace akantu
#endif /* __AKANTU_ERROR_HH__ */
diff --git a/src/common/aka_grid_dynamic.hh b/src/common/aka_grid_dynamic.hh
index 045a452cc..899400a72 100644
--- a/src/common/aka_grid_dynamic.hh
+++ b/src/common/aka_grid_dynamic.hh
@@ -1,517 +1,516 @@
/**
* @file aka_grid_dynamic.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Feb 21 2013
* @date last modification: Wed Nov 08 2017
*
* @brief Grid that is auto balanced
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
#include "aka_types.hh"
#include <iostream>
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_GRID_DYNAMIC_HH__
#define __AKANTU_AKA_GRID_DYNAMIC_HH__
namespace akantu {
class Mesh;
template <typename T> class SpatialGrid {
public:
explicit SpatialGrid(UInt dimension)
: dimension(dimension), spacing(dimension), center(dimension),
lower(dimension), upper(dimension), empty_cell() {}
SpatialGrid(UInt dimension, const Vector<Real> & spacing,
const Vector<Real> & center)
: dimension(dimension), spacing(spacing), center(center),
lower(dimension), upper(dimension), empty_cell() {
for (UInt i = 0; i < dimension; ++i) {
lower(i) = std::numeric_limits<Real>::max();
upper(i) = -std::numeric_limits<Real>::max();
}
}
virtual ~SpatialGrid() = default;
class neighbor_cells_iterator;
class cells_iterator;
class CellID {
public:
CellID() : ids() {}
explicit CellID(UInt dimention) : ids(dimention) {}
void setID(UInt dir, Int id) { ids(dir) = id; }
Int getID(UInt dir) const { return ids(dir); }
bool operator<(const CellID & id) const {
return std::lexicographical_compare(
ids.storage(), ids.storage() + ids.size(), id.ids.storage(),
id.ids.storage() + id.ids.size());
}
bool operator==(const CellID & id) const {
return std::equal(ids.storage(), ids.storage() + ids.size(),
id.ids.storage());
}
bool operator!=(const CellID & id) const { return !(operator==(id)); }
class neighbor_cells_iterator
: private std::iterator<std::forward_iterator_tag, UInt> {
public:
neighbor_cells_iterator(const CellID & cell_id, bool end)
: cell_id(cell_id), position(cell_id.ids.size(), end ? 1 : -1) {
this->updateIt();
if (end)
this->it++;
}
neighbor_cells_iterator & operator++() {
UInt i = 0;
for (; i < position.size() && position(i) == 1; ++i)
;
if (i == position.size()) {
++it;
return *this;
}
for (UInt j = 0; j < i; ++j)
position(j) = -1;
position(i)++;
updateIt();
return *this;
}
neighbor_cells_iterator operator++(int) {
neighbor_cells_iterator tmp(*this);
operator++();
return tmp;
};
bool operator==(const neighbor_cells_iterator & rhs) const {
return cell_id == rhs.cell_id && it == rhs.it;
};
bool operator!=(const neighbor_cells_iterator & rhs) const {
return !operator==(rhs);
};
CellID operator*() const {
CellID cur_cell_id(cell_id);
cur_cell_id.ids += position;
return cur_cell_id;
};
private:
void updateIt() {
it = 0;
for (UInt i = 0; i < position.size(); ++i)
it = it * 3 + (position(i) + 1);
}
private:
/// central cell id
const CellID & cell_id;
// number representing the current neighbor in base 3;
UInt it;
// current cell shift
Vector<Int> position;
};
class Neighbors {
public:
explicit Neighbors(const CellID & cell_id) : cell_id(cell_id) {}
decltype(auto) begin() { return neighbor_cells_iterator(cell_id, false); }
decltype(auto) end() { return neighbor_cells_iterator(cell_id, true); }
private:
const CellID & cell_id;
};
decltype(auto) neighbors() { return Neighbors(*this); }
private:
friend class cells_iterator;
Vector<Int> ids;
};
/* ------------------------------------------------------------------------ */
class Cell {
public:
using iterator = typename std::vector<T>::iterator;
using const_iterator = typename std::vector<T>::const_iterator;
Cell() : id(), data() {}
explicit Cell(const CellID & cell_id) : id(cell_id), data() {}
bool operator==(const Cell & cell) const { return id == cell.id; }
bool operator!=(const Cell & cell) const { return id != cell.id; }
Cell & add(const T & d) {
data.push_back(d);
return *this;
}
iterator begin() { return data.begin(); }
const_iterator begin() const { return data.begin(); }
iterator end() { return data.end(); }
const_iterator end() const { return data.end(); }
private:
CellID id;
std::vector<T> data;
};
private:
using cells_container = std::map<CellID, Cell>;
public:
const Cell & getCell(const CellID & cell_id) const {
auto it = cells.find(cell_id);
if (it != cells.end())
return it->second;
return empty_cell;
}
decltype(auto) beginCell(const CellID & cell_id) {
auto it = cells.find(cell_id);
if (it != cells.end())
return it->second.begin();
return empty_cell.begin();
}
decltype(auto) endCell(const CellID & cell_id) {
auto it = cells.find(cell_id);
if (it != cells.end())
return it->second.end();
return empty_cell.end();
}
decltype(auto) beginCell(const CellID & cell_id) const {
auto it = cells.find(cell_id);
if (it != cells.end())
return it->second.begin();
return empty_cell.begin();
}
decltype(auto) endCell(const CellID & cell_id) const {
auto it = cells.find(cell_id);
if (it != cells.end())
return it->second.end();
return empty_cell.end();
}
/* ------------------------------------------------------------------------ */
class cells_iterator
: private std::iterator<std::forward_iterator_tag, CellID> {
public:
explicit cells_iterator(typename std::map<CellID, Cell>::const_iterator it)
: it(it) {}
cells_iterator & operator++() {
this->it++;
return *this;
}
cells_iterator operator++(int) {
cells_iterator tmp(*this);
operator++();
return tmp;
};
bool operator==(const cells_iterator & rhs) const { return it == rhs.it; };
bool operator!=(const cells_iterator & rhs) const {
return !operator==(rhs);
};
CellID operator*() const {
CellID cur_cell_id(this->it->first);
return cur_cell_id;
};
private:
/// map iterator
typename std::map<CellID, Cell>::const_iterator it;
};
public:
template <class vector_type>
Cell & insert(const T & d, const vector_type & position) {
auto && cell_id = getCellID(position);
auto && it = cells.find(cell_id);
if (it == cells.end()) {
Cell cell(cell_id);
auto & tmp = (cells[cell_id] = cell).add(d);
for (UInt i = 0; i < dimension; ++i) {
Real posl = center(i) + cell_id.getID(i) * spacing(i);
Real posu = posl + spacing(i);
if (posl <= lower(i))
lower(i) = posl;
if (posu > upper(i))
upper(i) = posu;
}
return tmp;
} else {
return it->second.add(d);
}
}
/* ------------------------------------------------------------------------ */
inline decltype(auto) begin() const {
auto begin = this->cells.begin();
return cells_iterator(begin);
}
inline decltype(auto) end() const {
auto end = this->cells.end();
return cells_iterator(end);
}
template <class vector_type>
CellID getCellID(const vector_type & position) const {
CellID cell_id(dimension);
for (UInt i = 0; i < dimension; ++i) {
cell_id.setID(i, getCellID(position(i), i));
}
return cell_id;
}
void printself(std::ostream & stream, int indent = 0) const {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
std::streamsize prec = stream.precision();
std::ios_base::fmtflags ff = stream.flags();
stream.setf(std::ios_base::showbase);
stream.precision(5);
stream << space << "SpatialGrid<" << debug::demangle(typeid(T).name())
<< "> [" << std::endl;
stream << space << " + dimension : " << this->dimension << std::endl;
stream << space << " + lower bounds : {";
for (UInt i = 0; i < lower.size(); ++i) {
if (i != 0)
stream << ", ";
stream << lower(i);
};
stream << "}" << std::endl;
stream << space << " + upper bounds : {";
for (UInt i = 0; i < upper.size(); ++i) {
if (i != 0)
stream << ", ";
stream << upper(i);
};
stream << "}" << std::endl;
stream << space << " + spacing : {";
for (UInt i = 0; i < spacing.size(); ++i) {
if (i != 0)
stream << ", ";
stream << spacing(i);
};
stream << "}" << std::endl;
stream << space << " + center : {";
for (UInt i = 0; i < center.size(); ++i) {
if (i != 0)
stream << ", ";
stream << center(i);
};
stream << "}" << std::endl;
stream << space << " + nb_cells : " << this->cells.size() << "/";
Vector<Real> dist(this->dimension);
dist = upper;
dist -= lower;
for (UInt i = 0; i < this->dimension; ++i) {
dist(i) /= spacing(i);
}
UInt nb_cells = std::ceil(dist(0));
for (UInt i = 1; i < this->dimension; ++i) {
nb_cells *= std::ceil(dist(i));
}
stream << nb_cells << std::endl;
stream << space << "]" << std::endl;
stream.precision(prec);
stream.flags(ff);
}
void saveAsMesh(Mesh & mesh) const;
private:
/* --------------------------------------------------------------------------
*/
inline UInt getCellID(Real position, UInt direction) const {
- AKANTU_DEBUG_ASSERT(direction < center.size(),
- "The direction asked (" << direction
- << ") is out of range "
- << center.size());
+ AKANTU_DEBUG_ASSERT(direction < center.size(), "The direction asked ("
+ << direction
+ << ") is out of range "
+ << center.size());
Real dist_center = position - center(direction);
Int id = std::floor(dist_center / spacing(direction));
// if(dist_center < 0) id--;
return id;
}
friend class GridSynchronizer;
public:
AKANTU_GET_MACRO(LowerBounds, lower, const Vector<Real> &);
AKANTU_GET_MACRO(UpperBounds, upper, const Vector<Real> &);
AKANTU_GET_MACRO(Spacing, spacing, const Vector<Real> &);
AKANTU_SET_MACRO(Spacing, spacing, Vector<Real> &);
AKANTU_GET_MACRO(Center, center, const Vector<Real> &);
AKANTU_SET_MACRO(Center, center, Vector<Real> &);
protected:
UInt dimension;
cells_container cells;
Vector<Real> spacing;
Vector<Real> center;
Vector<Real> lower;
Vector<Real> upper;
Cell empty_cell;
};
/// standard output stream operator
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const SpatialGrid<T> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "mesh.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T> void SpatialGrid<T>::saveAsMesh(Mesh & mesh) const {
auto & nodes = const_cast<Array<Real> &>(mesh.getNodes());
ElementType type = _not_defined;
switch (dimension) {
case 1:
type = _segment_2;
break;
case 2:
type = _quadrangle_4;
break;
case 3:
type = _hexahedron_8;
break;
-
}
mesh.addConnectivityType(type);
auto & connectivity = const_cast<Array<UInt> &>(mesh.getConnectivity(type));
auto & uint_data = mesh.getDataPointer<UInt>("tag_1", type);
Vector<Real> pos(dimension);
UInt global_id = 0;
for (auto & cell_pair : cells) {
UInt cur_node = nodes.size();
UInt cur_elem = connectivity.size();
const CellID & cell_id = cell_pair.first;
for (UInt i = 0; i < dimension; ++i)
pos(i) = center(i) + cell_id.getID(i) * spacing(i);
nodes.push_back(pos);
for (UInt i = 0; i < dimension; ++i)
pos(i) += spacing(i);
nodes.push_back(pos);
connectivity.push_back(cur_node);
switch (dimension) {
case 1:
connectivity(cur_elem, 1) = cur_node + 1;
break;
case 2:
pos(0) -= spacing(0);
nodes.push_back(pos);
pos(0) += spacing(0);
pos(1) -= spacing(1);
nodes.push_back(pos);
connectivity(cur_elem, 1) = cur_node + 3;
connectivity(cur_elem, 2) = cur_node + 1;
connectivity(cur_elem, 3) = cur_node + 2;
break;
case 3:
pos(1) -= spacing(1);
pos(2) -= spacing(2);
nodes.push_back(pos);
pos(1) += spacing(1);
nodes.push_back(pos);
pos(0) -= spacing(0);
nodes.push_back(pos);
pos(1) -= spacing(1);
pos(2) += spacing(2);
nodes.push_back(pos);
pos(0) += spacing(0);
nodes.push_back(pos);
pos(0) -= spacing(0);
pos(1) += spacing(1);
nodes.push_back(pos);
connectivity(cur_elem, 1) = cur_node + 2;
connectivity(cur_elem, 2) = cur_node + 3;
connectivity(cur_elem, 3) = cur_node + 4;
connectivity(cur_elem, 4) = cur_node + 5;
connectivity(cur_elem, 5) = cur_node + 6;
connectivity(cur_elem, 6) = cur_node + 1;
connectivity(cur_elem, 7) = cur_node + 7;
break;
}
uint_data.push_back(global_id);
++global_id;
}
}
} // namespace akantu
#endif /* __AKANTU_AKA_GRID_DYNAMIC_HH__ */
diff --git a/src/common/aka_iterators.hh b/src/common/aka_iterators.hh
index 88843dd2c..fc4240364 100644
--- a/src/common/aka_iterators.hh
+++ b/src/common/aka_iterators.hh
@@ -1,721 +1,712 @@
/**
* @file aka_iterators.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Aug 11 2017
* @date last modification: Mon Jan 29 2018
*
* @brief iterator interfaces
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_compatibilty_with_cpp_standard.hh"
/* -------------------------------------------------------------------------- */
+#include <iterator>
#include <tuple>
#include <utility>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_ITERATORS_HH__
#define __AKANTU_AKA_ITERATORS_HH__
namespace akantu {
namespace tuple {
/* ------------------------------------------------------------------------ */
namespace details {
template <size_t N> struct Foreach {
template <class Tuple>
static inline bool not_equal(Tuple && a, Tuple && b) {
if (std::get<N - 1>(std::forward<Tuple>(a)) ==
std::get<N - 1>(std::forward<Tuple>(b)))
return false;
return Foreach<N - 1>::not_equal(std::forward<Tuple>(a),
std::forward<Tuple>(b));
}
};
/* ---------------------------------------------------------------------- */
template <> struct Foreach<0> {
template <class Tuple>
static inline bool not_equal(Tuple && a, Tuple && b) {
return std::get<0>(std::forward<Tuple>(a)) !=
std::get<0>(std::forward<Tuple>(b));
}
};
template <typename... Ts>
decltype(auto) make_tuple_no_decay(Ts &&... args) {
return std::tuple<Ts...>(std::forward<Ts>(args)...);
}
template <class F, class Tuple, size_t... Is>
void foreach_impl(F && func, Tuple && tuple,
std::index_sequence<Is...> &&) {
(void)std::initializer_list<int>{
(std::forward<F>(func)(std::get<Is>(std::forward<Tuple>(tuple))),
0)...};
}
template <class F, class Tuple, size_t... Is>
decltype(auto) transform_impl(F && func, Tuple && tuple,
std::index_sequence<Is...> &&) {
return make_tuple_no_decay(
std::forward<F>(func)(std::get<Is>(std::forward<Tuple>(tuple)))...);
}
} // namespace details
/* ------------------------------------------------------------------------ */
template <class Tuple> bool are_not_equal(Tuple && a, Tuple && b) {
return details::Foreach<std::tuple_size<std::decay_t<Tuple>>::value>::
not_equal(std::forward<Tuple>(a), std::forward<Tuple>(b));
}
template <class F, class Tuple> void foreach (F && func, Tuple && tuple) {
return details::foreach_impl(
std::forward<F>(func), std::forward<Tuple>(tuple),
std::make_index_sequence<
std::tuple_size<std::decay_t<Tuple>>::value>{});
}
template <class F, class Tuple>
decltype(auto) transform(F && func, Tuple && tuple) {
return details::transform_impl(
std::forward<F>(func), std::forward<Tuple>(tuple),
std::make_index_sequence<
std::tuple_size<std::decay_t<Tuple>>::value>{});
}
namespace details {
template <class Tuple, std::size_t... Is>
decltype(auto) flatten(Tuple && tuples, std::index_sequence<Is...>) {
return std::tuple_cat(std::get<Is>(tuples)...);
}
} // namespace details
template <class Tuple> decltype(auto) flatten(Tuple && tuples) {
return details::flatten(std::forward<Tuple>(tuples),
std::make_index_sequence<
std::tuple_size<std::decay_t<Tuple>>::value>());
}
} // namespace tuple
/* -------------------------------------------------------------------------- */
namespace iterators {
namespace details {
template <typename cat1, typename cat2>
using is_iterator_category_at_least =
std::is_same<std::common_type_t<cat1, cat2>, cat2>;
}
template <class... Iterators> class ZipIterator {
public:
using value_type =
std::tuple<typename std::iterator_traits<Iterators>::value_type...>;
using difference_type = std::common_type_t<
typename std::iterator_traits<Iterators>::difference_type...>;
using pointer =
std::tuple<typename std::iterator_traits<Iterators>::pointer...>;
using reference =
std::tuple<typename std::iterator_traits<Iterators>::reference...>;
using iterator_category = // std::input_iterator_tag;
std::common_type_t<
typename std::iterator_traits<Iterators>::iterator_category...>;
private:
using tuple_t = std::tuple<Iterators...>;
public:
explicit ZipIterator(tuple_t iterators) : iterators(std::move(iterators)) {}
template <class iterator_category_ = iterator_category,
std::enable_if_t<details::is_iterator_category_at_least<
iterator_category_,
std::bidirectional_iterator_tag>::value> * = nullptr>
ZipIterator & operator--() {
tuple::foreach ([](auto && it) { --it; }, iterators);
return *this;
}
template <class iterator_category_ = iterator_category,
std::enable_if_t<details::is_iterator_category_at_least<
iterator_category_,
std::bidirectional_iterator_tag>::value> * = nullptr>
ZipIterator operator--(int a) {
auto cpy = *this;
this->operator--(a);
return cpy;
}
// input iterator ++it
ZipIterator & operator++() {
tuple::foreach ([](auto && it) { ++it; }, iterators);
return *this;
}
// input iterator it++
ZipIterator operator++(int) {
auto cpy = *this;
this->operator++();
return cpy;
}
// input iterator it != other_it
bool operator!=(const ZipIterator & other) const {
return tuple::are_not_equal(iterators, other.iterators);
}
// input iterator dereference *it
decltype(auto) operator*() {
return tuple::transform([](auto && it) -> decltype(auto) { return *it; },
iterators);
}
template <class iterator_category_ = iterator_category,
std::enable_if_t<details::is_iterator_category_at_least<
iterator_category_,
std::random_access_iterator_tag>::value> * = nullptr>
difference_type operator-(const ZipIterator & other) {
return other - *this;
}
// random iterator it[idx]
template <class iterator_category_ = iterator_category,
std::enable_if_t<details::is_iterator_category_at_least<
iterator_category_,
std::random_access_iterator_tag>::value> * = nullptr>
decltype(auto) operator[](std::size_t idx) {
return tuple::transform(
[idx](auto && it) -> decltype(auto) { return it[idx]; }, iterators);
}
template <
class iterator_category_ = iterator_category,
std::enable_if_t<details::is_iterator_category_at_least<
iterator_category_, std::forward_iterator_tag>::value> * = nullptr>
bool operator==(const ZipIterator & other) const {
return not tuple::are_not_equal(iterators, other.iterators);
}
private:
tuple_t iterators;
};
} // namespace iterators
/* -------------------------------------------------------------------------- */
template <class... Iterators>
decltype(auto) zip_iterator(std::tuple<Iterators...> && iterators_tuple) {
auto zip = iterators::ZipIterator<Iterators...>(
std::forward<decltype(iterators_tuple)>(iterators_tuple));
return zip;
}
/* -------------------------------------------------------------------------- */
namespace containers {
template <class... Containers> class ZipContainer {
using containers_t = std::tuple<Containers...>;
public:
explicit ZipContainer(Containers &&... containers)
: containers(std::forward<Containers>(containers)...) {}
decltype(auto) begin() const {
return zip_iterator(
tuple::transform([](auto && c) { return c.begin(); },
std::forward<containers_t>(containers)));
}
decltype(auto) end() const {
return zip_iterator(
tuple::transform([](auto && c) { return c.end(); },
std::forward<containers_t>(containers)));
}
decltype(auto) begin() {
return zip_iterator(
tuple::transform([](auto && c) { return c.begin(); },
std::forward<containers_t>(containers)));
}
decltype(auto) end() {
return zip_iterator(
tuple::transform([](auto && c) { return c.end(); },
std::forward<containers_t>(containers)));
}
// template <class Container = std::tuple_element<0, containers_t>,
// std::enable_if_t<std::is_integral<decltype(
// std::declval<Container>().size())>::value> * = nullptr>
// decltype(auto) size() {
// return std::forward<Container>(std::get<0>(containers)).size();
// }
private:
containers_t containers;
};
template <class Iterator> class Range {
public:
using iterator = Iterator;
// ugly trick
using const_iterator = Iterator;
explicit Range(Iterator && it1, Iterator && it2)
: iterators(std::forward<Iterator>(it1), std::forward<Iterator>(it2)) {}
decltype(auto) begin() const { return std::get<0>(iterators); }
decltype(auto) begin() { return std::get<0>(iterators); }
decltype(auto) end() const { return std::get<1>(iterators); }
decltype(auto) end() { return std::get<1>(iterators); }
private:
std::tuple<Iterator, Iterator> iterators;
};
} // namespace containers
/* -------------------------------------------------------------------------- */
template <class... Containers> decltype(auto) zip(Containers &&... conts) {
return containers::ZipContainer<Containers...>(
std::forward<Containers>(conts)...);
}
template <class Iterator>
decltype(auto) range(Iterator && it1, Iterator && it2) {
return containers::Range<Iterator>(std::forward<Iterator>(it1),
std::forward<Iterator>(it2));
}
/* -------------------------------------------------------------------------- */
/* Arange */
/* -------------------------------------------------------------------------- */
namespace iterators {
template <class T> class ArangeIterator {
public:
using value_type = T;
using pointer = T *;
using reference = T &;
using difference_type = size_t;
using iterator_category = std::forward_iterator_tag;
constexpr ArangeIterator(T value, T step) : value(value), step(step) {}
constexpr ArangeIterator(const ArangeIterator &) = default;
constexpr ArangeIterator & operator++() {
value += step;
return *this;
}
constexpr T operator*() const { return value; }
constexpr bool operator==(const ArangeIterator & other) const {
return (value == other.value) and (step == other.step);
}
constexpr bool operator!=(const ArangeIterator & other) const {
return not operator==(other);
}
private:
T value{0};
const T step{1};
};
} // namespace iterators
namespace containers {
template <class T> class ArangeContainer {
public:
using iterator = iterators::ArangeIterator<T>;
using const_iterator = iterators::ArangeIterator<T>;
constexpr ArangeContainer(T start, T stop, T step = 1)
: start(start), stop((stop - start) % step == 0
? stop
: start + (1 + (stop - start) / step) * step),
step(step) {}
explicit constexpr ArangeContainer(T stop) : ArangeContainer(0, stop, 1) {}
constexpr T operator[](size_t i) {
T val = start + i * step;
assert(val < stop && "i is out of range");
return val;
}
constexpr T size() { return (stop - start) / step; }
constexpr iterator begin() { return iterator(start, step); }
constexpr iterator end() { return iterator(stop, step); }
private:
const T start{0}, stop{0}, step{1};
};
} // namespace containers
template <class T,
typename = std::enable_if_t<std::is_integral<std::decay_t<T>>::value>>
inline decltype(auto) arange(const T & stop) {
return containers::ArangeContainer<T>(stop);
}
template <class T1, class T2,
typename = std::enable_if_t<
std::is_integral<std::common_type_t<T1, T2>>::value>>
inline constexpr decltype(auto) arange(const T1 & start, const T2 & stop) {
return containers::ArangeContainer<std::common_type_t<T1, T2>>(start, stop);
}
template <class T1, class T2, class T3,
typename = std::enable_if_t<
std::is_integral<std::common_type_t<T1, T2, T3>>::value>>
inline constexpr decltype(auto) arange(const T1 & start, const T2 & stop,
const T3 & step) {
return containers::ArangeContainer<std::common_type_t<T1, T2, T3>>(
start, stop, step);
}
/* -------------------------------------------------------------------------- */
namespace iterators {
template <class Iterator> class EnumerateIterator {
public:
using value_type =
- std::tuple<size_t,
- typename std::iterator_traits<Iterator>::value_type>;
+ std::tuple<size_t, typename std::iterator_traits<Iterator>::value_type>;
using difference_type = size_t;
using pointer =
std::tuple<size_t, typename std::iterator_traits<Iterator>::pointer>;
using reference =
- std::tuple<size_t,
- typename std::iterator_traits<Iterator>::reference>;
+ std::tuple<size_t, typename std::iterator_traits<Iterator>::reference>;
using iterator_category = std::input_iterator_tag;
public:
- explicit EnumerateIterator(Iterator && iterator)
- : iterator(iterator) {}
+ explicit EnumerateIterator(Iterator && iterator) : iterator(iterator) {}
// input iterator ++it
EnumerateIterator & operator++() {
++iterator;
++index;
return *this;
}
// input iterator it++
EnumerateIterator operator++(int) {
auto cpy = *this;
this->operator++();
return cpy;
}
// input iterator it != other_it
bool operator!=(const EnumerateIterator & other) const {
return iterator != other.iterator;
}
// input iterator dereference *it
decltype(auto) operator*() {
return std::tuple_cat(std::make_tuple(index), *iterator);
}
bool operator==(const EnumerateIterator & other) const {
return not this->operator!=(other);
}
private:
Iterator iterator;
size_t index{0};
};
template <class Iterator>
inline constexpr decltype(auto) enumerate(Iterator && iterator) {
return EnumerateIterator<Iterator>(std::forward<Iterator>(iterator));
}
} // namespace iterators
namespace containers {
template <class... Containers> class EnumerateContainer {
public:
explicit EnumerateContainer(Containers &&... containers)
: zip_container(std::forward<Containers>(containers)...) {}
decltype(auto) begin() {
return iterators::enumerate(zip_container.begin());
}
decltype(auto) begin() const {
return iterators::enumerate(zip_container.begin());
}
- decltype(auto) end() {
- return iterators::enumerate(zip_container.end());
- }
+ decltype(auto) end() { return iterators::enumerate(zip_container.end()); }
decltype(auto) end() const {
return iterators::enumerate(zip_container.end());
}
private:
ZipContainer<Containers...> zip_container;
};
} // namespace containers
template <class... Container>
inline constexpr decltype(auto) enumerate(Container &&... container) {
return containers::EnumerateContainer<Container...>(
std::forward<Container>(container)...);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
namespace iterators {
template <class iterator_t, class operator_t>
class transform_adaptor_iterator {
public:
using value_type = decltype(std::declval<operator_t>()(
std::declval<typename iterator_t::value_type>()));
using difference_type = typename iterator_t::difference_type;
using pointer = std::decay_t<value_type> *;
using reference = value_type &;
using iterator_category = typename iterator_t::iterator_category;
transform_adaptor_iterator(iterator_t it, operator_t op)
: it(std::move(it)), op(op) {}
transform_adaptor_iterator(const transform_adaptor_iterator &) = default;
transform_adaptor_iterator & operator++() {
++it;
return *this;
}
- decltype(auto) operator*() {
- return op(std::forward<decltype(*it)>(*it));
- }
+ decltype(auto) operator*() { return op(std::forward<decltype(*it)>(*it)); }
bool operator==(const transform_adaptor_iterator & other) const {
return (it == other.it);
}
bool operator!=(const transform_adaptor_iterator & other) const {
return not operator==(other);
}
template <class iterator_category_ = iterator_category,
std::enable_if_t<details::is_iterator_category_at_least<
iterator_category_,
std::random_access_iterator_tag>::value> * = nullptr>
difference_type operator-(const transform_adaptor_iterator & other) {
return other - *this;
}
private:
iterator_t it;
operator_t op;
};
template <class iterator_t, class operator_t>
- decltype(auto) make_transform_adaptor_iterator(iterator_t it,
- operator_t op) {
+ decltype(auto) make_transform_adaptor_iterator(iterator_t it, operator_t op) {
return transform_adaptor_iterator<iterator_t, operator_t>(
it, std::forward<operator_t>(op));
}
} // namespace iterators
namespace containers {
template <class container_t, class operator_t>
class TransformIteratorAdaptor {
public:
// using const_iterator = typename
// std::decay_t<container_t>::const_iterator; using iterator = typename
// std::decay_t<container_t>::iterator;
TransformIteratorAdaptor(container_t && cont, operator_t op)
: cont(std::forward<container_t>(cont)),
op(std::forward<operator_t>(op)) {}
decltype(auto) begin() const {
return iterators::make_transform_adaptor_iterator(cont.begin(), op);
}
decltype(auto) begin() {
return iterators::make_transform_adaptor_iterator(cont.begin(), op);
}
decltype(auto) end() const {
return iterators::make_transform_adaptor_iterator(cont.end(), op);
}
decltype(auto) end() {
return iterators::make_transform_adaptor_iterator(cont.end(), op);
}
private:
container_t cont;
operator_t op;
};
} // namespace containers
template <class container_t, class operator_t>
decltype(auto) make_transform_adaptor(container_t && cont, operator_t && op) {
return containers::TransformIteratorAdaptor<container_t, operator_t>(
std::forward<container_t>(cont), std::forward<operator_t>(op));
}
template <class container_t>
decltype(auto) make_keys_adaptor(container_t && cont) {
- return make_transform_adaptor(
- std::forward<container_t>(cont),
- [](auto && pair) -> const auto & { return pair.first; });
+ return make_transform_adaptor(std::forward<container_t>(cont), [
+ ](auto && pair) -> const auto & { return pair.first; });
}
template <class container_t>
decltype(auto) make_values_adaptor(container_t && cont) {
- return make_transform_adaptor(
- std::forward<container_t>(cont),
- [](auto && pair) -> auto & { return pair.second; });
+ return make_transform_adaptor(std::forward<container_t>(cont), [
+ ](auto && pair) -> auto & { return pair.second; });
}
template <class container_t>
decltype(auto) make_dereference_adaptor(container_t && cont) {
return make_transform_adaptor(
std::forward<container_t>(cont),
[](auto && value) -> decltype(*value) { return *value; });
}
template <class... zip_container_t>
decltype(auto) make_zip_cat(zip_container_t &&... cont) {
return make_transform_adaptor(
zip(std::forward<zip_container_t>(cont)...),
[](auto && value) { return tuple::flatten(value); });
}
/* -------------------------------------------------------------------------- */
namespace iterators {
template <class filter_iterator_t, class container_iterator_t>
class RandomAccessFilterIterator {
public:
using value_type =
decltype(std::declval<container_iterator_t>().operator[](0));
using difference_type = typename filter_iterator_t::difference_type;
using pointer = std::decay_t<value_type> *;
using reference = value_type &;
using iterator_category = typename filter_iterator_t::iterator_category;
RandomAccessFilterIterator(filter_iterator_t && filter_it,
container_iterator_t && container_begin)
: filter_it(std::forward<filter_iterator_t>(filter_it)),
container_begin(std::forward<container_iterator_t>(container_begin)) {
}
RandomAccessFilterIterator(const RandomAccessFilterIterator &) = default;
RandomAccessFilterIterator & operator++() {
++filter_it;
return *this;
}
decltype(auto) operator*() { return container_begin[*filter_it]; }
decltype(auto) operator*() const { return container_begin[*filter_it]; }
bool operator==(const RandomAccessFilterIterator & other) const {
return (filter_it == other.filter_it) and
(container_begin == other.container_begin);
}
bool operator!=(const RandomAccessFilterIterator & other) const {
return not operator==(other);
}
private:
filter_iterator_t filter_it;
container_iterator_t container_begin;
};
template <class filter_iterator_t, class container_iterator_t>
decltype(auto)
make_random_access_filter_iterator(filter_iterator_t && filter_it,
container_iterator_t && container_begin) {
return RandomAccessFilterIterator<filter_iterator_t, container_iterator_t>(
std::forward<filter_iterator_t>(filter_it),
std::forward<container_iterator_t>(container_begin));
}
} // namespace iterators
namespace containers {
template <class filter_t, class container_t> class RandomAccessFilterAdaptor {
public:
RandomAccessFilterAdaptor(filter_t && filter, container_t && container)
: filter(std::forward<filter_t>(filter)),
container(std::forward<container_t>(container)) {}
decltype(auto) begin() const {
return iterators::make_random_access_filter_iterator(filter.begin(),
container.begin());
}
decltype(auto) begin() {
return iterators::make_random_access_filter_iterator(filter.begin(),
container.begin());
}
decltype(auto) end() const {
return iterators::make_random_access_filter_iterator(filter.end(),
container.begin());
}
decltype(auto) end() {
return iterators::make_random_access_filter_iterator(filter.end(),
container.begin());
}
private:
filter_t filter;
container_t container;
};
} // namespace containers
template <
class filter_t, class container_t,
std::enable_if_t<std::is_same<
std::random_access_iterator_tag,
typename std::decay_t<decltype(std::declval<container_t>().begin())>::
iterator_category>::value> * = nullptr>
decltype(auto) make_filtered_adaptor(filter_t && filter,
container_t && container) {
return containers::RandomAccessFilterAdaptor<filter_t, container_t>(
std::forward<filter_t>(filter), std::forward<container_t>(container));
}
} // namespace akantu
namespace std {
template <typename... Its>
struct iterator_traits<::akantu::iterators::ZipIterator<Its...>> {
using iterator_category = forward_iterator_tag;
using value_type =
typename ::akantu::iterators::ZipIterator<Its...>::value_type;
using difference_type =
typename ::akantu::iterators::ZipIterator<Its...>::difference_type;
using pointer = typename ::akantu::iterators::ZipIterator<Its...>::pointer;
using reference =
typename ::akantu::iterators::ZipIterator<Its...>::reference;
};
} // namespace std
#endif /* __AKANTU_AKA_ITERATORS_HH__ */
diff --git a/src/common/aka_math.cc b/src/common/aka_math.cc
index bb9b74e7f..530641632 100644
--- a/src/common/aka_math.cc
+++ b/src/common/aka_math.cc
@@ -1,252 +1,253 @@
/**
* @file aka_math.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Leonardo Snozzi <leonardo.snozzi@epfl.ch>
* @author Peter Spijker <peter.spijker@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Sun Aug 13 2017
*
* @brief Implementation of the math toolbox
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_math.hh"
#include "aka_array.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void Math::matrix_vector(UInt m, UInt n, const Array<Real> & A,
const Array<Real> & x, Array<Real> & y, Real alpha) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(A.size() == x.size(),
"The vector A(" << A.getID() << ") and the vector x("
<< x.getID()
<< ") must have the same size");
AKANTU_DEBUG_ASSERT(A.getNbComponent() == m * n,
"The vector A(" << A.getID()
<< ") has the good number of component.");
AKANTU_DEBUG_ASSERT(
x.getNbComponent() == n,
"The vector x(" << x.getID() << ") do not the good number of component.");
AKANTU_DEBUG_ASSERT(
y.getNbComponent() == n,
"The vector y(" << y.getID() << ") do not the good number of component.");
UInt nb_element = A.size();
UInt offset_A = A.getNbComponent();
UInt offset_x = x.getNbComponent();
y.resize(nb_element);
Real * A_val = A.storage();
Real * x_val = x.storage();
Real * y_val = y.storage();
for (UInt el = 0; el < nb_element; ++el) {
matrix_vector(m, n, A_val, x_val, y_val, alpha);
A_val += offset_A;
x_val += offset_x;
y_val += offset_x;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Math::matrix_matrix(UInt m, UInt n, UInt k, const Array<Real> & A,
const Array<Real> & B, Array<Real> & C, Real alpha) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(A.size() == B.size(),
"The vector A(" << A.getID() << ") and the vector B("
<< B.getID()
<< ") must have the same size");
AKANTU_DEBUG_ASSERT(A.getNbComponent() == m * k,
"The vector A(" << A.getID()
<< ") has the good number of component.");
AKANTU_DEBUG_ASSERT(
B.getNbComponent() == k * n,
"The vector B(" << B.getID() << ") do not the good number of component.");
AKANTU_DEBUG_ASSERT(
C.getNbComponent() == m * n,
"The vector C(" << C.getID() << ") do not the good number of component.");
UInt nb_element = A.size();
UInt offset_A = A.getNbComponent();
UInt offset_B = B.getNbComponent();
UInt offset_C = C.getNbComponent();
C.resize(nb_element);
Real * A_val = A.storage();
Real * B_val = B.storage();
Real * C_val = C.storage();
for (UInt el = 0; el < nb_element; ++el) {
matrix_matrix(m, n, k, A_val, B_val, C_val, alpha);
A_val += offset_A;
B_val += offset_B;
C_val += offset_C;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Math::matrix_matrixt(UInt m, UInt n, UInt k, const Array<Real> & A,
const Array<Real> & B, Array<Real> & C, Real alpha) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(A.size() == B.size(),
"The vector A(" << A.getID() << ") and the vector B("
<< B.getID()
<< ") must have the same size");
AKANTU_DEBUG_ASSERT(A.getNbComponent() == m * k,
"The vector A(" << A.getID()
<< ") has the good number of component.");
AKANTU_DEBUG_ASSERT(
B.getNbComponent() == k * n,
"The vector B(" << B.getID() << ") do not the good number of component.");
AKANTU_DEBUG_ASSERT(
C.getNbComponent() == m * n,
"The vector C(" << C.getID() << ") do not the good number of component.");
UInt nb_element = A.size();
UInt offset_A = A.getNbComponent();
UInt offset_B = B.getNbComponent();
UInt offset_C = C.getNbComponent();
C.resize(nb_element);
Real * A_val = A.storage();
Real * B_val = B.storage();
Real * C_val = C.storage();
for (UInt el = 0; el < nb_element; ++el) {
matrix_matrixt(m, n, k, A_val, B_val, C_val, alpha);
A_val += offset_A;
B_val += offset_B;
C_val += offset_C;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Math::compute_tangents(const Array<Real> & normals,
Array<Real> & tangents) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = normals.getNbComponent();
UInt tangent_components = spatial_dimension * (spatial_dimension - 1);
- if (tangent_components == 0) return;
+ if (tangent_components == 0)
+ return;
AKANTU_DEBUG_ASSERT(
tangent_components == tangents.getNbComponent(),
"Cannot compute the tangents, the storage array for tangents"
<< " does not have the good amount of components.");
UInt nb_normals = normals.size();
tangents.resize(nb_normals, 0.);
Real * normal_it = normals.storage();
Real * tangent_it = tangents.storage();
/// compute first tangent
for (UInt q = 0; q < nb_normals; ++q) {
/// if normal is orthogonal to xy plane, arbitrarly define tangent
if (Math::are_float_equal(Math::norm2(normal_it), 0))
tangent_it[0] = 1;
else
Math::normal2(normal_it, tangent_it);
normal_it += spatial_dimension;
tangent_it += tangent_components;
}
/// compute second tangent (3D case)
if (spatial_dimension == 3) {
normal_it = normals.storage();
tangent_it = tangents.storage();
for (UInt q = 0; q < nb_normals; ++q) {
Math::normal3(normal_it, tangent_it, tangent_it + spatial_dimension);
normal_it += spatial_dimension;
tangent_it += tangent_components;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real Math::reduce(Array<Real> & array) {
UInt nb_values = array.size();
if (nb_values == 0)
return 0.;
UInt nb_values_to_sum = nb_values >> 1;
std::sort(array.begin(), array.end());
// as long as the half is not empty
while (nb_values_to_sum) {
UInt remaining = (nb_values - 2 * nb_values_to_sum);
if (remaining)
array(nb_values - 2) += array(nb_values - 1);
// sum to consecutive values and store the sum in the first half
for (UInt i = 0; i < nb_values_to_sum; ++i) {
array(i) = array(2 * i) + array(2 * i + 1);
}
nb_values = nb_values_to_sum;
nb_values_to_sum >>= 1;
}
return array(0);
}
-} // akantu
+} // namespace akantu
diff --git a/src/common/aka_math.hh b/src/common/aka_math.hh
index 6b0966ffb..1f9118dc2 100644
--- a/src/common/aka_math.hh
+++ b/src/common/aka_math.hh
@@ -1,296 +1,296 @@
/**
* @file aka_math.hh
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Leonardo Snozzi <leonardo.snozzi@epfl.ch>
* @author Peter Spijker <peter.spijker@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Mon Sep 11 2017
*
* @brief mathematical operations
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_MATH_H__
#define __AKANTU_AKA_MATH_H__
/* -------------------------------------------------------------------------- */
#include <utility>
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T, bool is_scal> class Array;
class Math {
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Matrix algebra */
/* ------------------------------------------------------------------------ */
/// @f$ y = A*x @f$
static void matrix_vector(UInt m, UInt n, const Array<Real, true> & A,
const Array<Real, true> & x, Array<Real, true> & y,
Real alpha = 1.);
/// @f$ y = A*x @f$
static inline void matrix_vector(UInt m, UInt n, Real * A, Real * x, Real * y,
Real alpha = 1.);
/// @f$ y = A^t*x @f$
static inline void matrixt_vector(UInt m, UInt n, Real * A, Real * x,
Real * y, Real alpha = 1.);
/// @f$ C = A*B @f$
static void matrix_matrix(UInt m, UInt n, UInt k, const Array<Real, true> & A,
const Array<Real, true> & B, Array<Real, true> & C,
Real alpha = 1.);
/// @f$ C = A*B^t @f$
static void matrix_matrixt(UInt m, UInt n, UInt k,
const Array<Real, true> & A,
const Array<Real, true> & B, Array<Real, true> & C,
Real alpha = 1.);
/// @f$ C = A*B @f$
static inline void matrix_matrix(UInt m, UInt n, UInt k, Real * A, Real * B,
Real * C, Real alpha = 1.);
/// @f$ C = A^t*B @f$
static inline void matrixt_matrix(UInt m, UInt n, UInt k, Real * A, Real * B,
Real * C, Real alpha = 1.);
/// @f$ C = A*B^t @f$
static inline void matrix_matrixt(UInt m, UInt n, UInt k, Real * A, Real * B,
Real * C, Real alpha = 1.);
/// @f$ C = A^t*B^t @f$
static inline void matrixt_matrixt(UInt m, UInt n, UInt k, Real * A, Real * B,
Real * C, Real alpha = 1.);
template <bool tr_A, bool tr_B>
static inline void matMul(UInt m, UInt n, UInt k, Real alpha, Real * A,
Real * B, Real beta, Real * C);
template <bool tr_A>
static inline void matVectMul(UInt m, UInt n, Real alpha, Real * A, Real * x,
Real beta, Real * y);
static inline void aXplusY(UInt n, Real alpha, Real * x, Real * y);
static inline void matrix33_eigenvalues(Real * A, Real * Adiag);
static inline void matrix22_eigenvalues(Real * A, Real * Adiag);
template <UInt dim> static inline void eigenvalues(Real * A, Real * d);
/// solve @f$ A x = \Lambda x @f$ and return d and V such as @f$ A V[i:] =
/// d[i] V[i:]@f$
template <typename T>
static void matrixEig(UInt n, T * A, T * d, T * V = nullptr);
/// determinent of a 2x2 matrix
static inline Real det2(const Real * mat);
/// determinent of a 3x3 matrix
static inline Real det3(const Real * mat);
/// determinent of a nxn matrix
template <UInt n> static inline Real det(const Real * mat);
/// determinent of a nxn matrix
template <typename T> static inline T det(UInt n, const T * mat);
/// inverse a nxn matrix
template <UInt n> static inline void inv(const Real * mat, Real * inv);
/// inverse a nxn matrix
template <typename T> static inline void inv(UInt n, const T * mat, T * inv);
/// inverse a 3x3 matrix
static inline void inv3(const Real * mat, Real * inv);
/// inverse a 2x2 matrix
static inline void inv2(const Real * mat, Real * inv);
/// solve A x = b using a LU factorization
template <typename T>
static inline void solve(UInt n, const T * A, T * x, const T * b);
/// return the double dot product between 2 tensors in 2d
static inline Real matrixDoubleDot22(Real * A, Real * B);
/// return the double dot product between 2 tensors in 3d
static inline Real matrixDoubleDot33(Real * A, Real * B);
/// extension of the double dot product to two 2nd order tensor in dimension n
static inline Real matrixDoubleDot(UInt n, Real * A, Real * B);
/* ------------------------------------------------------------------------ */
/* Array algebra */
/* ------------------------------------------------------------------------ */
/// vector cross product
static inline void vectorProduct3(const Real * v1, const Real * v2,
Real * res);
/// normalize a vector
static inline void normalize2(Real * v);
/// normalize a vector
static inline void normalize3(Real * v);
/// return norm of a 2-vector
static inline Real norm2(const Real * v);
/// return norm of a 3-vector
static inline Real norm3(const Real * v);
/// return norm of a vector
static inline Real norm(UInt n, const Real * v);
/// return the dot product between 2 vectors in 2d
static inline Real vectorDot2(const Real * v1, const Real * v2);
/// return the dot product between 2 vectors in 3d
static inline Real vectorDot3(const Real * v1, const Real * v2);
/// return the dot product between 2 vectors
static inline Real vectorDot(Real * v1, Real * v2, UInt n);
/* ------------------------------------------------------------------------ */
/* Geometry */
/* ------------------------------------------------------------------------ */
/// compute normal a normal to a vector
static inline void normal2(const Real * v1, Real * res);
/// compute normal a normal to a vector
static inline void normal3(const Real * v1, const Real * v2, Real * res);
/// compute the tangents to an array of normal vectors
static void compute_tangents(const Array<Real> & normals,
Array<Real> & tangents);
/// distance in 2D between x and y
static inline Real distance_2d(const Real * x, const Real * y);
/// distance in 3D between x and y
static inline Real distance_3d(const Real * x, const Real * y);
/// radius of the in-circle of a triangle in 2d space
static inline Real triangle_inradius_2d(const Real * coord1, const Real * coord2,
const Real * coord3);
/// radius of the in-circle of a triangle in 3d space
static inline Real triangle_inradius_3d(const Real * coord1, const Real * coord2,
const Real * coord3);
/// radius of the in-circle of a tetrahedron
static inline Real tetrahedron_inradius(const Real * coord1,
const Real * coord2,
const Real * coord3,
const Real * coord4);
/// volume of a tetrahedron
static inline Real tetrahedron_volume(const Real * coord1,
const Real * coord2,
const Real * coord3,
const Real * coord4);
/// compute the barycenter of n points
static inline void barycenter(const Real * coord, UInt nb_points,
UInt spatial_dimension, Real * barycenter);
/// vector between x and y
static inline void vector_2d(const Real * x, const Real * y, Real * vec);
/// vector pointing from x to y in 3 spatial dimension
static inline void vector_3d(const Real * x, const Real * y, Real * vec);
/// test if two scalar are equal within a given tolerance
static inline bool are_float_equal(Real x, Real y);
/// test if two vectors are equal within a given tolerance
static inline bool are_vector_equal(UInt n, Real * x, Real * y);
#ifdef isnan
#error \
"You probably included <math.h> which is incompatible with aka_math please use\
<cmath> or add a \"#undef isnan\" before akantu includes"
#endif
/// test if a real is a NaN
static inline bool isnan(Real x);
/// test if the line x and y intersects each other
static inline bool intersects(Real x_min, Real x_max, Real y_min, Real y_max);
/// test if a is in the range [x_min, x_max]
static inline bool is_in_range(Real a, Real x_min, Real x_max);
static inline Real getTolerance() { return tolerance; };
static inline void setTolerance(Real tol) { tolerance = tol; };
template <UInt p, typename T> static inline T pow(T x);
/// reduce all the values of an array, the summation is done in place and the
/// array is modified
static Real reduce(Array<Real> & array);
class NewtonRaphson {
public:
NewtonRaphson(Real tolerance, Real max_iteration)
: tolerance(tolerance), max_iteration(max_iteration) {}
template <class Functor> Real solve(const Functor & funct, Real x_0);
private:
Real tolerance;
Real max_iteration;
};
struct NewtonRaphsonFunctor {
explicit NewtonRaphsonFunctor(std::string name) : name(std::move(name)) {}
virtual ~NewtonRaphsonFunctor() = default;
virtual Real f(Real x) const = 0;
virtual Real f_prime(Real x) const = 0;
std::string name;
};
private:
/// tolerance for functions that need one
static Real tolerance;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "aka_math_tmpl.hh"
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_MATH_H__ */
diff --git a/src/common/aka_math_tmpl.hh b/src/common/aka_math_tmpl.hh
index 474a64d99..bafd22dab 100644
--- a/src/common/aka_math_tmpl.hh
+++ b/src/common/aka_math_tmpl.hh
@@ -1,809 +1,809 @@
/**
* @file aka_math_tmpl.hh
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Alejandro M. Aragón <alejandro.aragon@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Mathilde Radiguet <mathilde.radiguet@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Leonardo Snozzi <leonardo.snozzi@epfl.ch>
* @author Peter Spijker <peter.spijker@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Tue Feb 20 2018
*
* @brief Implementation of the inline functions of the math toolkit
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
} // akantu
#include <cmath>
#include <cstring>
#include <typeinfo>
#include "aka_blas_lapack.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
inline void Math::matrix_vector(UInt im, UInt in, Real * A, Real * x, Real * y,
Real alpha) {
#ifdef AKANTU_USE_BLAS
/// y = alpha*op(A)*x + beta*y
char tran_A = 'N';
int incx = 1;
int incy = 1;
double beta = 0.;
int m = im;
int n = in;
aka_gemv(&tran_A, &m, &n, &alpha, A, &m, x, &incx, &beta, y, &incy);
#else
memset(y, 0, im * sizeof(Real));
for (UInt i = 0; i < im; ++i) {
for (UInt j = 0; j < in; ++j) {
y[i] += A[i + j * im] * x[j];
}
y[i] *= alpha;
}
#endif
}
/* -------------------------------------------------------------------------- */
inline void Math::matrixt_vector(UInt im, UInt in, Real * A, Real * x, Real * y,
Real alpha) {
#ifdef AKANTU_USE_BLAS
/// y = alpha*op(A)*x + beta*y
char tran_A = 'T';
int incx = 1;
int incy = 1;
double beta = 0.;
int m = im;
int n = in;
aka_gemv(&tran_A, &m, &n, &alpha, A, &m, x, &incx, &beta, y, &incy);
#else
memset(y, 0, in * sizeof(Real));
for (UInt i = 0; i < im; ++i) {
for (UInt j = 0; j < in; ++j) {
y[j] += A[j * im + i] * x[i];
}
y[i] *= alpha;
}
#endif
}
/* -------------------------------------------------------------------------- */
inline void Math::matrix_matrix(UInt im, UInt in, UInt ik, Real * A, Real * B,
Real * C, Real alpha) {
#ifdef AKANTU_USE_BLAS
/// C := alpha*op(A)*op(B) + beta*C
char trans_a = 'N';
char trans_b = 'N';
double beta = 0.;
int m = im, n = in, k = ik;
aka_gemm(&trans_a, &trans_b, &m, &n, &k, &alpha, A, &m, B, &k, &beta, C, &m);
#else
memset(C, 0, im * in * sizeof(Real));
for (UInt j = 0; j < in; ++j) {
UInt _jb = j * ik;
UInt _jc = j * im;
for (UInt i = 0; i < im; ++i) {
for (UInt l = 0; l < ik; ++l) {
UInt _la = l * im;
C[i + _jc] += A[i + _la] * B[l + _jb];
}
C[i + _jc] *= alpha;
}
}
#endif
}
/* -------------------------------------------------------------------------- */
inline void Math::matrixt_matrix(UInt im, UInt in, UInt ik, Real * A, Real * B,
Real * C, Real alpha) {
#ifdef AKANTU_USE_BLAS
/// C := alpha*op(A)*op(B) + beta*C
char trans_a = 'T';
char trans_b = 'N';
double beta = 0.;
int m = im, n = in, k = ik;
aka_gemm(&trans_a, &trans_b, &m, &n, &k, &alpha, A, &k, B, &k, &beta, C, &m);
#else
memset(C, 0, im * in * sizeof(Real));
for (UInt j = 0; j < in; ++j) {
UInt _jc = j * im;
UInt _jb = j * ik;
for (UInt i = 0; i < im; ++i) {
UInt _ia = i * ik;
for (UInt l = 0; l < ik; ++l) {
C[i + _jc] += A[l + _ia] * B[l + _jb];
}
C[i + _jc] *= alpha;
}
}
#endif
}
/* -------------------------------------------------------------------------- */
inline void Math::matrix_matrixt(UInt im, UInt in, UInt ik, Real * A, Real * B,
Real * C, Real alpha) {
#ifdef AKANTU_USE_BLAS
/// C := alpha*op(A)*op(B) + beta*C
char trans_a = 'N';
char trans_b = 'T';
double beta = 0.;
int m = im, n = in, k = ik;
aka_gemm(&trans_a, &trans_b, &m, &n, &k, &alpha, A, &m, B, &n, &beta, C, &m);
#else
memset(C, 0, im * in * sizeof(Real));
for (UInt j = 0; j < in; ++j) {
UInt _jc = j * im;
for (UInt i = 0; i < im; ++i) {
for (UInt l = 0; l < ik; ++l) {
UInt _la = l * im;
UInt _lb = l * in;
C[i + _jc] += A[i + _la] * B[j + _lb];
}
C[i + _jc] *= alpha;
}
}
#endif
}
/* -------------------------------------------------------------------------- */
inline void Math::matrixt_matrixt(UInt im, UInt in, UInt ik, Real * A, Real * B,
Real * C, Real alpha) {
#ifdef AKANTU_USE_BLAS
/// C := alpha*op(A)*op(B) + beta*C
char trans_a = 'T';
char trans_b = 'T';
double beta = 0.;
int m = im, n = in, k = ik;
aka_gemm(&trans_a, &trans_b, &m, &n, &k, &alpha, A, &k, B, &n, &beta, C, &m);
#else
memset(C, 0, im * in * sizeof(Real));
for (UInt j = 0; j < in; ++j) {
UInt _jc = j * im;
for (UInt i = 0; i < im; ++i) {
UInt _ia = i * ik;
for (UInt l = 0; l < ik; ++l) {
UInt _lb = l * in;
C[i + _jc] += A[l + _ia] * B[j + _lb];
}
C[i + _jc] *= alpha;
}
}
#endif
}
/* -------------------------------------------------------------------------- */
inline void Math::aXplusY(UInt n, Real alpha, Real * x, Real * y) {
#ifdef AKANTU_USE_BLAS
/// y := alpha x + y
int incx = 1, incy = 1;
aka_axpy(&n, &alpha, x, &incx, y, &incy);
#else
for (UInt i = 0; i < n; ++i)
*(y++) += alpha * *(x++);
#endif
}
/* -------------------------------------------------------------------------- */
inline Real Math::vectorDot(Real * v1, Real * v2, UInt in) {
#ifdef AKANTU_USE_BLAS
/// d := v1 . v2
int incx = 1, incy = 1, n = in;
Real d = aka_dot(&n, v1, &incx, v2, &incy);
#else
Real d = 0;
for (UInt i = 0; i < in; ++i) {
d += v1[i] * v2[i];
}
#endif
return d;
}
/* -------------------------------------------------------------------------- */
template <bool tr_A, bool tr_B>
inline void Math::matMul(UInt m, UInt n, UInt k, Real alpha, Real * A, Real * B,
__attribute__((unused)) Real beta, Real * C) {
if (tr_A) {
if (tr_B)
matrixt_matrixt(m, n, k, A, B, C, alpha);
else
matrixt_matrix(m, n, k, A, B, C, alpha);
} else {
if (tr_B)
matrix_matrixt(m, n, k, A, B, C, alpha);
else
matrix_matrix(m, n, k, A, B, C, alpha);
}
}
/* -------------------------------------------------------------------------- */
template <bool tr_A>
inline void Math::matVectMul(UInt m, UInt n, Real alpha, Real * A, Real * x,
__attribute__((unused)) Real beta, Real * y) {
if (tr_A) {
matrixt_vector(m, n, A, x, y, alpha);
} else {
matrix_vector(m, n, A, x, y, alpha);
}
}
/* -------------------------------------------------------------------------- */
template <typename T> inline void Math::matrixEig(UInt n, T * A, T * d, T * V) {
// Matrix A is row major, so the lapack function in fortran will process
// A^t. Asking for the left eigenvectors of A^t will give the transposed right
// eigenvectors of A so in the C++ code the right eigenvectors.
char jobvr, jobvl;
if (V != nullptr)
jobvr = 'V'; // compute left eigenvectors
else
jobvr = 'N'; // compute left eigenvectors
jobvl = 'N'; // compute right eigenvectors
auto * di = new T[n]; // imaginary part of the eigenvalues
int info;
int N = n;
T wkopt;
int lwork = -1;
// query and allocate the optimal workspace
aka_geev<T>(&jobvl, &jobvr, &N, A, &N, d, di, nullptr, &N, V, &N, &wkopt,
&lwork, &info);
lwork = int(wkopt);
auto * work = new T[lwork];
// solve the eigenproblem
aka_geev<T>(&jobvl, &jobvr, &N, A, &N, d, di, nullptr, &N, V, &N, work,
&lwork, &info);
AKANTU_DEBUG_ASSERT(
info == 0,
"Problem computing eigenvalues/vectors. DGEEV exited with the value "
<< info);
delete[] work;
delete[] di; // I hope for you that there was no complex eigenvalues !!!
}
/* -------------------------------------------------------------------------- */
inline void Math::matrix22_eigenvalues(Real * A, Real * Adiag) {
/// d = determinant of Matrix A
Real d = det2(A);
/// b = trace of Matrix A
Real b = A[0] + A[3];
Real c = sqrt(b * b - 4 * d);
Adiag[0] = .5 * (b + c);
Adiag[1] = .5 * (b - c);
}
/* -------------------------------------------------------------------------- */
inline void Math::matrix33_eigenvalues(Real * A, Real * Adiag) {
matrixEig(3, A, Adiag);
}
/* -------------------------------------------------------------------------- */
template <UInt dim> inline void Math::eigenvalues(Real * A, Real * d) {
if (dim == 1) {
d[0] = A[0];
} else if (dim == 2) {
matrix22_eigenvalues(A, d);
}
// else if(dim == 3) { matrix33_eigenvalues(A, d); }
else
matrixEig(dim, A, d);
}
/* -------------------------------------------------------------------------- */
inline Real Math::det2(const Real * mat) {
return mat[0] * mat[3] - mat[1] * mat[2];
}
/* -------------------------------------------------------------------------- */
inline Real Math::det3(const Real * mat) {
return mat[0] * (mat[4] * mat[8] - mat[7] * mat[5]) -
mat[3] * (mat[1] * mat[8] - mat[7] * mat[2]) +
mat[6] * (mat[1] * mat[5] - mat[4] * mat[2]);
}
/* -------------------------------------------------------------------------- */
template <UInt n> inline Real Math::det(const Real * mat) {
if (n == 1)
return *mat;
else if (n == 2)
return det2(mat);
else if (n == 3)
return det3(mat);
else
return det(n, mat);
}
/* -------------------------------------------------------------------------- */
template <typename T> inline T Math::det(UInt n, const T * A) {
int N = n;
int info;
auto * ipiv = new int[N + 1];
auto * LU = new T[N * N];
std::copy(A, A + N * N, LU);
// LU factorization of A
aka_getrf(&N, &N, LU, &N, ipiv, &info);
if (info > 0) {
AKANTU_ERROR("Singular matrix - cannot factorize it (info: " << info
<< " )");
}
// det(A) = det(L) * det(U) = 1 * det(U) = product_i U_{ii}
T det = 1.;
for (int i = 0; i < N; ++i)
det *= (2 * (ipiv[i] == i) - 1) * LU[i * n + i];
delete[] ipiv;
delete[] LU;
return det;
}
/* -------------------------------------------------------------------------- */
inline void Math::normal2(const Real * vec, Real * normal) {
normal[0] = vec[1];
normal[1] = -vec[0];
Math::normalize2(normal);
}
/* -------------------------------------------------------------------------- */
inline void Math::normal3(const Real * vec1, const Real * vec2, Real * normal) {
Math::vectorProduct3(vec1, vec2, normal);
Math::normalize3(normal);
}
/* -------------------------------------------------------------------------- */
inline void Math::normalize2(Real * vec) {
Real norm = Math::norm2(vec);
vec[0] /= norm;
vec[1] /= norm;
}
/* -------------------------------------------------------------------------- */
inline void Math::normalize3(Real * vec) {
Real norm = Math::norm3(vec);
vec[0] /= norm;
vec[1] /= norm;
vec[2] /= norm;
}
/* -------------------------------------------------------------------------- */
inline Real Math::norm2(const Real * vec) {
return sqrt(vec[0] * vec[0] + vec[1] * vec[1]);
}
/* -------------------------------------------------------------------------- */
inline Real Math::norm3(const Real * vec) {
return sqrt(vec[0] * vec[0] + vec[1] * vec[1] + vec[2] * vec[2]);
}
/* -------------------------------------------------------------------------- */
inline Real Math::norm(UInt n, const Real * vec) {
Real norm = 0.;
for (UInt i = 0; i < n; ++i) {
norm += vec[i] * vec[i];
}
return sqrt(norm);
}
/* -------------------------------------------------------------------------- */
inline void Math::inv2(const Real * mat, Real * inv) {
Real det_mat = det2(mat);
inv[0] = mat[3] / det_mat;
inv[1] = -mat[1] / det_mat;
inv[2] = -mat[2] / det_mat;
inv[3] = mat[0] / det_mat;
}
/* -------------------------------------------------------------------------- */
inline void Math::inv3(const Real * mat, Real * inv) {
Real det_mat = det3(mat);
inv[0] = (mat[4] * mat[8] - mat[7] * mat[5]) / det_mat;
inv[1] = (mat[2] * mat[7] - mat[8] * mat[1]) / det_mat;
inv[2] = (mat[1] * mat[5] - mat[4] * mat[2]) / det_mat;
inv[3] = (mat[5] * mat[6] - mat[8] * mat[3]) / det_mat;
inv[4] = (mat[0] * mat[8] - mat[6] * mat[2]) / det_mat;
inv[5] = (mat[2] * mat[3] - mat[5] * mat[0]) / det_mat;
inv[6] = (mat[3] * mat[7] - mat[6] * mat[4]) / det_mat;
inv[7] = (mat[1] * mat[6] - mat[7] * mat[0]) / det_mat;
inv[8] = (mat[0] * mat[4] - mat[3] * mat[1]) / det_mat;
}
/* -------------------------------------------------------------------------- */
template <UInt n> inline void Math::inv(const Real * A, Real * Ainv) {
if (n == 1)
*Ainv = 1. / *A;
else if (n == 2)
inv2(A, Ainv);
else if (n == 3)
inv3(A, Ainv);
else
inv(n, A, Ainv);
}
/* -------------------------------------------------------------------------- */
template <typename T> inline void Math::inv(UInt n, const T * A, T * invA) {
int N = n;
int info;
auto * ipiv = new int[N + 1];
int lwork = N * N;
auto * work = new T[lwork];
std::copy(A, A + n * n, invA);
aka_getrf(&N, &N, invA, &N, ipiv, &info);
if (info > 0) {
AKANTU_ERROR("Singular matrix - cannot factorize it (info: " << info
<< " )");
}
aka_getri(&N, invA, &N, ipiv, work, &lwork, &info);
if (info != 0) {
AKANTU_ERROR("Cannot invert the matrix (info: " << info << " )");
}
delete[] ipiv;
delete[] work;
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Math::solve(UInt n, const T * A, T * x, const T * b) {
int N = n;
int info;
auto * ipiv = new int[N];
auto * lu_A = new T[N * N];
std::copy(A, A + N * N, lu_A);
aka_getrf(&N, &N, lu_A, &N, ipiv, &info);
if (info > 0) {
AKANTU_ERROR("Singular matrix - cannot factorize it (info: " << info
<< " )");
}
char trans = 'N';
int nrhs = 1;
std::copy(b, b + N, x);
aka_getrs(&trans, &N, &nrhs, lu_A, &N, ipiv, x, &N, &info);
if (info != 0) {
AKANTU_ERROR("Cannot solve the system (info: " << info << " )");
}
delete[] ipiv;
delete[] lu_A;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
inline Real Math::matrixDoubleDot22(Real * A, Real * B) {
Real d;
d = A[0] * B[0] + A[1] * B[1] + A[2] * B[2] + A[3] * B[3];
return d;
}
/* -------------------------------------------------------------------------- */
inline Real Math::matrixDoubleDot33(Real * A, Real * B) {
Real d;
d = A[0] * B[0] + A[1] * B[1] + A[2] * B[2] + A[3] * B[3] + A[4] * B[4] +
A[5] * B[5] + A[6] * B[6] + A[7] * B[7] + A[8] * B[8];
return d;
}
/* -------------------------------------------------------------------------- */
inline Real Math::matrixDoubleDot(UInt n, Real * A, Real * B) {
Real d = 0.;
for (UInt i = 0; i < n; ++i) {
for (UInt j = 0; j < n; ++j) {
d += A[i * n + j] * B[i * n + j];
}
}
return d;
}
/* -------------------------------------------------------------------------- */
inline void Math::vectorProduct3(const Real * v1, const Real * v2, Real * res) {
res[0] = v1[1] * v2[2] - v1[2] * v2[1];
res[1] = v1[2] * v2[0] - v1[0] * v2[2];
res[2] = v1[0] * v2[1] - v1[1] * v2[0];
}
/* -------------------------------------------------------------------------- */
inline Real Math::vectorDot2(const Real * v1, const Real * v2) {
return (v1[0] * v2[0] + v1[1] * v2[1]);
}
/* -------------------------------------------------------------------------- */
inline Real Math::vectorDot3(const Real * v1, const Real * v2) {
return (v1[0] * v2[0] + v1[1] * v2[1] + v1[2] * v2[2]);
}
/* -------------------------------------------------------------------------- */
inline Real Math::distance_2d(const Real * x, const Real * y) {
return sqrt((y[0] - x[0]) * (y[0] - x[0]) + (y[1] - x[1]) * (y[1] - x[1]));
}
/* -------------------------------------------------------------------------- */
inline Real Math::triangle_inradius_2d(const Real * coord1, const Real * coord2,
const Real * coord3) {
/**
* @f{eqnarray*}{
* r &=& A / s \\
* A &=& 1/4 * \sqrt{(a + b + c) * (a - b + c) * (a + b - c) (-a + b + c)} \\
* s &=& \frac{a + b + c}{2}
* @f}
*/
Real a, b, c;
a = distance_2d(coord1, coord2);
b = distance_2d(coord2, coord3);
c = distance_2d(coord1, coord3);
Real s;
s = (a + b + c) * 0.5;
return sqrt((s - a) * (s - b) * (s - c) / s);
}
/* -------------------------------------------------------------------------- */
inline Real Math::triangle_inradius_3d(const Real * coord1, const Real * coord2,
const Real * coord3) {
/**
* @f{eqnarray*}{
* r &=& A / s \\
* A &=& 1/4 * \sqrt{(a + b + c) * (a - b + c) * (a + b - c) (-a + b + c)} \\
* s &=& \frac{a + b + c}{2}
* @f}
*/
Real a, b, c;
a = distance_3d(coord1, coord2);
b = distance_3d(coord2, coord3);
c = distance_3d(coord1, coord3);
Real s;
s = (a + b + c) * 0.5;
return sqrt((s - a) * (s - b) * (s - c) / s);
}
/* -------------------------------------------------------------------------- */
inline Real Math::distance_3d(const Real * x, const Real * y) {
return sqrt((y[0] - x[0]) * (y[0] - x[0]) + (y[1] - x[1]) * (y[1] - x[1]) +
(y[2] - x[2]) * (y[2] - x[2]));
}
/* -------------------------------------------------------------------------- */
inline Real Math::tetrahedron_volume(const Real * coord1, const Real * coord2,
const Real * coord3, const Real * coord4) {
Real xx[9], vol;
xx[0] = coord2[0];
xx[1] = coord2[1];
xx[2] = coord2[2];
xx[3] = coord3[0];
xx[4] = coord3[1];
xx[5] = coord3[2];
xx[6] = coord4[0];
xx[7] = coord4[1];
xx[8] = coord4[2];
vol = det3(xx);
xx[0] = coord1[0];
xx[1] = coord1[1];
xx[2] = coord1[2];
xx[3] = coord3[0];
xx[4] = coord3[1];
xx[5] = coord3[2];
xx[6] = coord4[0];
xx[7] = coord4[1];
xx[8] = coord4[2];
vol -= det3(xx);
xx[0] = coord1[0];
xx[1] = coord1[1];
xx[2] = coord1[2];
xx[3] = coord2[0];
xx[4] = coord2[1];
xx[5] = coord2[2];
xx[6] = coord4[0];
xx[7] = coord4[1];
xx[8] = coord4[2];
vol += det3(xx);
xx[0] = coord1[0];
xx[1] = coord1[1];
xx[2] = coord1[2];
xx[3] = coord2[0];
xx[4] = coord2[1];
xx[5] = coord2[2];
xx[6] = coord3[0];
xx[7] = coord3[1];
xx[8] = coord3[2];
vol -= det3(xx);
vol /= 6;
return vol;
}
/* -------------------------------------------------------------------------- */
inline Real Math::tetrahedron_inradius(const Real * coord1, const Real * coord2,
const Real * coord3,
const Real * coord4) {
Real l12, l13, l14, l23, l24, l34;
l12 = distance_3d(coord1, coord2);
l13 = distance_3d(coord1, coord3);
l14 = distance_3d(coord1, coord4);
l23 = distance_3d(coord2, coord3);
l24 = distance_3d(coord2, coord4);
l34 = distance_3d(coord3, coord4);
Real s1, s2, s3, s4;
s1 = (l12 + l23 + l13) * 0.5;
s1 = sqrt(s1 * (s1 - l12) * (s1 - l23) * (s1 - l13));
s2 = (l12 + l24 + l14) * 0.5;
s2 = sqrt(s2 * (s2 - l12) * (s2 - l24) * (s2 - l14));
s3 = (l23 + l34 + l24) * 0.5;
s3 = sqrt(s3 * (s3 - l23) * (s3 - l34) * (s3 - l24));
s4 = (l13 + l34 + l14) * 0.5;
s4 = sqrt(s4 * (s4 - l13) * (s4 - l34) * (s4 - l14));
Real volume = Math::tetrahedron_volume(coord1, coord2, coord3, coord4);
return 3 * volume / (s1 + s2 + s3 + s4);
}
/* -------------------------------------------------------------------------- */
inline void Math::barycenter(const Real * coord, UInt nb_points,
UInt spatial_dimension, Real * barycenter) {
memset(barycenter, 0, spatial_dimension * sizeof(Real));
for (UInt n = 0; n < nb_points; ++n) {
UInt offset = n * spatial_dimension;
for (UInt i = 0; i < spatial_dimension; ++i) {
barycenter[i] += coord[offset + i] / (Real)nb_points;
}
}
}
/* -------------------------------------------------------------------------- */
inline void Math::vector_2d(const Real * x, const Real * y, Real * res) {
res[0] = y[0] - x[0];
res[1] = y[1] - x[1];
}
/* -------------------------------------------------------------------------- */
inline void Math::vector_3d(const Real * x, const Real * y, Real * res) {
res[0] = y[0] - x[0];
res[1] = y[1] - x[1];
res[2] = y[2] - x[2];
}
/* -------------------------------------------------------------------------- */
/// Combined absolute and relative tolerance test proposed in
/// Real-time collision detection by C. Ericson (2004)
inline bool Math::are_float_equal(const Real x, const Real y) {
Real abs_max = std::max(std::abs(x), std::abs(y));
abs_max = std::max(abs_max, Real(1.));
return std::abs(x - y) <= (tolerance * abs_max);
}
/* -------------------------------------------------------------------------- */
inline bool Math::isnan(Real x) {
#if defined(__INTEL_COMPILER)
#pragma warning(push)
#pragma warning(disable : 1572)
#endif // defined(__INTEL_COMPILER)
// x = x return false means x = quiet_NaN
return !(x == x);
#if defined(__INTEL_COMPILER)
#pragma warning(pop)
#endif // defined(__INTEL_COMPILER)
}
/* -------------------------------------------------------------------------- */
inline bool Math::are_vector_equal(UInt n, Real * x, Real * y) {
bool test = true;
for (UInt i = 0; i < n; ++i) {
test &= are_float_equal(x[i], y[i]);
}
return test;
}
/* -------------------------------------------------------------------------- */
inline bool Math::intersects(Real x_min, Real x_max, Real y_min, Real y_max) {
- return not ((x_max < y_min) or (x_min > y_max));
+ return not((x_max < y_min) or (x_min > y_max));
}
/* -------------------------------------------------------------------------- */
inline bool Math::is_in_range(Real a, Real x_min, Real x_max) {
return ((a >= x_min) and (a <= x_max));
}
/* -------------------------------------------------------------------------- */
template <UInt p, typename T> inline T Math::pow(T x) {
return (pow<p - 1, T>(x) * x);
}
template <> inline UInt Math::pow<0, UInt>(__attribute__((unused)) UInt x) {
return (1);
}
template <> inline Real Math::pow<0, Real>(__attribute__((unused)) Real x) {
return (1.);
}
/* -------------------------------------------------------------------------- */
template <class Functor>
Real Math::NewtonRaphson::solve(const Functor & funct, Real x_0) {
Real x = x_0;
Real f_x = funct.f(x);
UInt iter = 0;
while (std::abs(f_x) > this->tolerance && iter < this->max_iteration) {
x -= f_x / funct.f_prime(x);
f_x = funct.f(x);
iter++;
}
AKANTU_DEBUG_ASSERT(iter < this->max_iteration,
"Newton Raphson ("
<< funct.name << ") solve did not converge in "
<< this->max_iteration << " iterations (tolerance: "
<< this->tolerance << ")");
return x;
}
diff --git a/src/common/aka_memory.cc b/src/common/aka_memory.cc
index ed6c70903..d50dd1c72 100644
--- a/src/common/aka_memory.cc
+++ b/src/common/aka_memory.cc
@@ -1,63 +1,63 @@
/**
* @file aka_memory.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief static memory wrapper
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <utility>
#include "aka_memory.hh"
#include "aka_static_memory.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Memory::Memory(ID id, MemoryID memory_id)
: static_memory(StaticMemory::getStaticMemory()), id(std::move(id)),
memory_id(memory_id) {}
/* -------------------------------------------------------------------------- */
Memory::~Memory() {
if (StaticMemory::isInstantiated()) {
std::list<ID>::iterator it;
for (it = handeld_vectors_id.begin(); it != handeld_vectors_id.end();
++it) {
AKANTU_DEBUG(dblAccessory, "Deleting the vector " << *it);
static_memory.sfree(memory_id, *it);
}
static_memory.destroy();
}
handeld_vectors_id.clear();
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/common/aka_memory.hh b/src/common/aka_memory.hh
index d2e030a1e..5bf913cc9 100644
--- a/src/common/aka_memory.hh
+++ b/src/common/aka_memory.hh
@@ -1,114 +1,114 @@
/**
* @file aka_memory.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief wrapper for the static_memory, all object which wants
* to access the static_memory as to inherit from the class memory
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MEMORY_HH__
#define __AKANTU_MEMORY_HH__
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
#include "aka_static_memory.hh"
/* -------------------------------------------------------------------------- */
#include <list>
/* -------------------------------------------------------------------------- */
namespace akantu {
class Memory {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
protected:
Memory(ID id, MemoryID memory_id = 0);
virtual ~Memory();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
protected:
/// malloc
template <class T>
inline Array<T> & alloc(const ID & name, UInt size, UInt nb_component);
/// malloc
template <class T>
inline Array<T> & alloc(const ID & name, UInt size, UInt nb_component,
const T & init_value);
/* ------------------------------------------------------------------------ */
/// free an array
inline void dealloc(const ID & name);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
protected:
template <typename T> inline Array<T> & getArray(const ID & name);
template <typename T> inline const Array<T> & getArray(const ID & name) const;
public:
AKANTU_GET_MACRO(MemoryID, memory_id, const MemoryID &);
AKANTU_GET_MACRO(ID, id, const ID &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// the static memory instance
StaticMemory & static_memory;
/// list of allocated vectors id
std::list<ID> handeld_vectors_id;
protected:
ID id;
/// the id registred in the static memory
MemoryID memory_id;
};
/* -------------------------------------------------------------------------- */
/* Inline functions */
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_INCLUDE_INLINE_IMPL)
#include "aka_memory_inline_impl.cc"
#endif
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MEMORY_HH__ */
diff --git a/src/common/aka_random_generator.hh b/src/common/aka_random_generator.hh
index 24b5f83b6..3d22a4777 100644
--- a/src/common/aka_random_generator.hh
+++ b/src/common/aka_random_generator.hh
@@ -1,271 +1,271 @@
/**
* @file aka_random_generator.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Feb 21 2013
* @date last modification: Wed Nov 08 2017
*
* @brief generic random generator
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
/* -------------------------------------------------------------------------- */
#include <random>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_RANDOM_GENERATOR_HH__
#define __AKANTU_AKA_RANDOM_GENERATOR_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* List of available distributions */
/* -------------------------------------------------------------------------- */
// clang-format off
#define AKANTU_RANDOM_DISTRIBUTION_TYPES \
((uniform , std::uniform_real_distribution )) \
((exponential , std::exponential_distribution )) \
((gamma , std::gamma_distribution )) \
((weibull , std::weibull_distribution )) \
((extreme_value, std::extreme_value_distribution)) \
((normal , std::normal_distribution )) \
((lognormal , std::lognormal_distribution )) \
((chi_squared , std::chi_squared_distribution )) \
((cauchy , std::cauchy_distribution )) \
((fisher_f , std::fisher_f_distribution )) \
((student_t , std::student_t_distribution ))
// clang-format on
#define AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX(elem) BOOST_PP_CAT(_rdt_, elem)
#define AKANTU_RANDOM_DISTRIBUTION_PREFIX(s, data, elem) \
AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX(BOOST_PP_TUPLE_ELEM(2, 0, elem))
enum RandomDistributionType {
BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM(AKANTU_RANDOM_DISTRIBUTION_PREFIX, _,
AKANTU_RANDOM_DISTRIBUTION_TYPES)),
_rdt_not_defined
};
/* -------------------------------------------------------------------------- */
/* Generator */
/* -------------------------------------------------------------------------- */
template <typename T> class RandomGenerator {
/* ------------------------------------------------------------------------ */
public:
inline T operator()() { return generator(); }
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int) const {
stream << "RandGenerator [seed=" << _seed << "]";
}
/* ------------------------------------------------------------------------ */
public:
static void seed(long int s) {
_seed = s;
generator.seed(_seed);
}
static long int seed() { return _seed; }
static constexpr T min() { return generator.min(); }
static constexpr T max() { return generator.max(); }
/* ------------------------------------------------------------------------ */
private:
static long int _seed;
static std::default_random_engine generator;
};
// template <typename T>
// long int RandomGenerator<T>::_seed = 0;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#undef AKANTU_RANDOM_DISTRIBUTION_PREFIX
#define AKANTU_RANDOM_DISTRIBUTION_TYPE_PRINT_CASE(r, data, elem) \
case AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX( \
BOOST_PP_TUPLE_ELEM(2, 0, elem)): { \
stream << BOOST_PP_STRINGIZE(AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX( \
BOOST_PP_TUPLE_ELEM(2, 0, elem))); \
break; \
}
inline std::ostream & operator<<(std::ostream & stream,
RandomDistributionType type) {
switch (type) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_RANDOM_DISTRIBUTION_TYPE_PRINT_CASE, _,
AKANTU_RANDOM_DISTRIBUTION_TYPES)
default:
stream << UInt(type) << " not a RandomDistributionType";
break;
}
return stream;
}
#undef AKANTU_RANDOM_DISTRIBUTION_TYPE_PRINT_CASE
/* -------------------------------------------------------------------------- */
/* Some Helper */
/* -------------------------------------------------------------------------- */
template <typename T, class Distribution> class RandomDistributionTypeHelper {
enum { value = _rdt_not_defined };
};
/* -------------------------------------------------------------------------- */
#define AKANTU_RANDOM_DISTRIBUTION_TYPE_GET_TYPE(r, data, elem) \
template <typename T> \
- struct RandomDistributionTypeHelper< \
- T, BOOST_PP_TUPLE_ELEM(2, 1, elem) < T>> { \
+ struct RandomDistributionTypeHelper<T, BOOST_PP_TUPLE_ELEM(2, 1, elem) < \
+ T>> { \
enum { \
value = AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX( \
BOOST_PP_TUPLE_ELEM(2, 0, elem)) \
}; \
\
static void printself(std::ostream & stream) { \
stream << BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 0, elem)); \
} \
};
BOOST_PP_SEQ_FOR_EACH(AKANTU_RANDOM_DISTRIBUTION_TYPE_GET_TYPE, _,
AKANTU_RANDOM_DISTRIBUTION_TYPES)
#undef AKANTU_RANDOM_DISTRIBUTION_TYPE_GET_TYPE
/* -------------------------------------------------------------------------- */
template <class T> class RandomDistribution {
public:
virtual ~RandomDistribution() = default;
virtual T operator()(RandomGenerator<UInt> & gen) = 0;
virtual std::unique_ptr<RandomDistribution<T>> make_unique() const = 0;
virtual void printself(std::ostream & stream, int = 0) const = 0;
};
template <class T, class Distribution>
class RandomDistributionProxy : public RandomDistribution<T> {
public:
explicit RandomDistributionProxy(Distribution dist)
: distribution(std::move(dist)) {}
T operator()(RandomGenerator<UInt> & gen) override {
return distribution(gen);
}
std::unique_ptr<RandomDistribution<T>> make_unique() const override {
return std::make_unique<RandomDistributionProxy<T, Distribution>>(
distribution);
}
void printself(std::ostream & stream, int = 0) const override {
RandomDistributionTypeHelper<T, Distribution>::printself(stream);
stream << " [ " << distribution << " ]";
}
private:
Distribution distribution;
};
/* -------------------------------------------------------------------------- */
/* RandomParameter */
/* -------------------------------------------------------------------------- */
template <typename T> class RandomParameter {
public:
template <class Distribution>
explicit RandomParameter(T base_value, Distribution dist)
: base_value(base_value),
type(RandomDistributionType(
RandomDistributionTypeHelper<T, Distribution>::value)),
distribution_proxy(
std::make_unique<RandomDistributionProxy<T, Distribution>>(
std::move(dist))) {}
explicit RandomParameter(T base_value)
: base_value(base_value),
type(RandomDistributionType(
RandomDistributionTypeHelper<
T, std::uniform_real_distribution<T>>::value)),
distribution_proxy(
std::make_unique<
RandomDistributionProxy<T, std::uniform_real_distribution<T>>>(
std::uniform_real_distribution<T>(0., 0.))) {}
RandomParameter(const RandomParameter & other)
: base_value(other.base_value), type(other.type),
distribution_proxy(other.distribution_proxy->make_unique()) {}
RandomParameter & operator=(const RandomParameter & other) {
distribution_proxy = other.distribution_proxy->make_unique();
base_value = other.base_value;
type = other.type;
return *this;
}
virtual ~RandomParameter() = default;
inline void setBaseValue(const T & value) { this->base_value = value; }
inline T getBaseValue() const { return this->base_value; }
template <template <typename> class Generator, class iterator>
void setValues(iterator it, iterator end) {
RandomGenerator<UInt> gen;
for (; it != end; ++it)
*it = this->base_value + (*distribution_proxy)(gen);
}
virtual void printself(std::ostream & stream,
__attribute__((unused)) int indent = 0) const {
stream << base_value;
stream << " + " << *distribution_proxy;
}
private:
/// Value with no random variations
T base_value;
/// Random distribution type
RandomDistributionType type;
/// Proxy to store a std random distribution
std::unique_ptr<RandomDistribution<T>> distribution_proxy;
};
/* -------------------------------------------------------------------------- */
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
RandomDistribution<T> & _this) {
_this.printself(stream);
return stream;
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
RandomParameter<T> & _this) {
_this.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_RANDOM_GENERATOR_HH__ */
diff --git a/src/common/aka_safe_enum.hh b/src/common/aka_safe_enum.hh
index 2fd2a57bb..bfb67884e 100644
--- a/src/common/aka_safe_enum.hh
+++ b/src/common/aka_safe_enum.hh
@@ -1,86 +1,86 @@
/**
* @file aka_safe_enum.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Feb 21 2013
* @date last modification: Tue Nov 07 2017
*
* @brief Safe enums type (see More C++ Idioms/Type Safe Enum on Wikibooks
* http://en.wikibooks.org/wiki/More_C%2B%2B_Idioms/Type_Safe_Enum)
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_SAFE_ENUM_HH__
#define __AKANTU_AKA_SAFE_ENUM_HH__
namespace akantu {
/// Safe enumerated type
template <typename def, typename inner = typename def::type>
class safe_enum : public def {
using type = typename def::type;
public:
explicit safe_enum(type v = def::_end_) : val(v) {}
safe_enum(safe_enum && other) = default;
safe_enum & operator=(safe_enum && other) = default;
inner underlying() const { return val; }
bool operator==(const safe_enum & s) const { return this->val == s.val; }
bool operator!=(const safe_enum & s) const { return this->val != s.val; }
bool operator<(const safe_enum & s) const { return this->val < s.val; }
bool operator<=(const safe_enum & s) const { return this->val <= s.val; }
bool operator>(const safe_enum & s) const { return this->val > s.val; }
bool operator>=(const safe_enum & s) const { return this->val >= s.val; }
operator inner() { return val; };
public:
// Works only if enumerations are contiguous.
class iterator {
public:
explicit iterator(type v) : it(v) {}
iterator & operator++() {
++it;
return *this;
}
safe_enum operator*() { return safe_enum(static_cast<type>(it)); }
bool operator!=(iterator const & it) { return it.it != this->it; }
private:
int it;
};
static iterator begin() { return iterator(def::_begin_); }
static iterator end() { return iterator(def::_end_); }
protected:
inner val;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_SAFE_ENUM_HH__ */
diff --git a/src/common/aka_static_memory.cc b/src/common/aka_static_memory.cc
index d6ed888ab..f592ba56a 100644
--- a/src/common/aka_static_memory.cc
+++ b/src/common/aka_static_memory.cc
@@ -1,160 +1,160 @@
/**
* @file aka_static_memory.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Memory management
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <sstream>
#include <stdexcept>
/* -------------------------------------------------------------------------- */
#include "aka_static_memory.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
bool StaticMemory::is_instantiated = false;
StaticMemory * StaticMemory::single_static_memory = nullptr;
UInt StaticMemory::nb_reference = 0;
/* -------------------------------------------------------------------------- */
StaticMemory & StaticMemory::getStaticMemory() {
if (!single_static_memory) {
single_static_memory = new StaticMemory();
is_instantiated = true;
}
nb_reference++;
return *single_static_memory;
}
/* -------------------------------------------------------------------------- */
void StaticMemory::destroy() {
nb_reference--;
if (nb_reference == 0) {
delete single_static_memory;
}
}
/* -------------------------------------------------------------------------- */
StaticMemory::~StaticMemory() {
AKANTU_DEBUG_IN();
MemoryMap::iterator memory_it;
for (memory_it = memories.begin(); memory_it != memories.end(); ++memory_it) {
ArrayMap::iterator vector_it;
for (vector_it = (memory_it->second).begin();
vector_it != (memory_it->second).end(); ++vector_it) {
delete vector_it->second;
}
(memory_it->second).clear();
}
memories.clear();
is_instantiated = false;
StaticMemory::single_static_memory = nullptr;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void StaticMemory::sfree(const MemoryID & memory_id, const ID & name) {
AKANTU_DEBUG_IN();
try {
auto & vectors = const_cast<ArrayMap &>(getMemory(memory_id));
ArrayMap::iterator vector_it;
vector_it = vectors.find(name);
if (vector_it != vectors.end()) {
AKANTU_DEBUG_INFO("Array " << name
<< " removed from the static memory number "
<< memory_id);
delete vector_it->second;
vectors.erase(vector_it);
AKANTU_DEBUG_OUT();
return;
}
} catch (debug::Exception & e) {
AKANTU_EXCEPTION("The memory "
<< memory_id << " does not exist (perhaps already freed) ["
<< e.what() << "]");
AKANTU_DEBUG_OUT();
return;
}
AKANTU_DEBUG_INFO("The vector " << name
<< " does not exist (perhaps already freed)");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void StaticMemory::printself(std::ostream & stream, int indent) const {
std::string space = "";
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
std::streamsize prec = stream.precision();
stream.precision(2);
stream << space << "StaticMemory [" << std::endl;
UInt nb_memories = memories.size();
stream << space << " + nb memories : " << nb_memories << std::endl;
Real tot_size = 0;
MemoryMap::const_iterator memory_it;
for (memory_it = memories.begin(); memory_it != memories.end(); ++memory_it) {
Real mem_size = 0;
stream << space << AKANTU_INDENT << "Memory [" << std::endl;
UInt mem_id = memory_it->first;
stream << space << AKANTU_INDENT << " + memory id : " << mem_id
<< std::endl;
UInt nb_vectors = (memory_it->second).size();
stream << space << AKANTU_INDENT << " + nb vectors : " << nb_vectors
<< std::endl;
stream.precision(prec);
ArrayMap::const_iterator vector_it;
for (vector_it = (memory_it->second).begin();
vector_it != (memory_it->second).end(); ++vector_it) {
(vector_it->second)->printself(stream, indent + 2);
mem_size += (vector_it->second)->getMemorySize();
}
stream << space << AKANTU_INDENT
<< " + total size : " << printMemorySize<char>(mem_size)
<< std::endl;
stream << space << AKANTU_INDENT << "]" << std::endl;
tot_size += mem_size;
}
stream << space << " + total size : " << printMemorySize<char>(tot_size)
<< std::endl;
stream << space << "]" << std::endl;
stream.precision(prec);
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/common/aka_typelist.hh b/src/common/aka_typelist.hh
index aa295594d..0b8180164 100644
--- a/src/common/aka_typelist.hh
+++ b/src/common/aka_typelist.hh
@@ -1,155 +1,155 @@
/**
* @file aka_typelist.hh
*
* @author Alejandro M. Aragón <alejandro.aragon@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Mon Jun 19 2017
*
* @brief Objects that support the visitor design pattern
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TYPELIST_HH__
#define __AKANTU_TYPELIST_HH__
#include "aka_common.hh"
namespace akantu {
struct Empty_type {};
class Null_type {};
template <class T, class U> struct Typelist {
typedef T Head;
typedef U Tail;
};
template <typename T1 = Null_type, typename T2 = Null_type,
typename T3 = Null_type, typename T4 = Null_type,
typename T5 = Null_type, typename T6 = Null_type,
typename T7 = Null_type, typename T8 = Null_type,
typename T9 = Null_type, typename T10 = Null_type,
typename T11 = Null_type, typename T12 = Null_type,
typename T13 = Null_type, typename T14 = Null_type,
typename T15 = Null_type, typename T16 = Null_type,
typename T17 = Null_type, typename T18 = Null_type,
typename T19 = Null_type, typename T20 = Null_type>
struct MakeTypelist {
private:
typedef typename MakeTypelist<T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12,
T13, T14, T15, T16, T17, T18, T19, T20>::Result
TailResult;
public:
typedef Typelist<T1, TailResult> Result;
};
template <> struct MakeTypelist<> { typedef Null_type Result; };
////////////////////////////////////////////////////////////////////////////////
// class template Length
// Computes the length of a typelist
// Invocation (TList is a typelist):
// Length<TList>::value
// returns a compile-time constant containing the length of TList, not counting
// the end terminator (which by convention is Null_type)
////////////////////////////////////////////////////////////////////////////////
template <class TList> struct Length;
template <> struct Length<Null_type> {
enum { value = 0 };
};
template <class T, class U> struct Length<Typelist<T, U>> {
enum { value = 1 + Length<U>::value };
};
////////////////////////////////////////////////////////////////////////////////
// class template TypeAt
// Finds the type at a given index in a typelist
// Invocation (TList is a typelist and index is a compile-time integral
// constant):
// TypeAt<TList, index>::Result
// returns the type in position 'index' in TList
// If you pass an out-of-bounds index, the result is a compile-time error
////////////////////////////////////////////////////////////////////////////////
template <class TList, unsigned int index> struct TypeAt;
template <class Head, class Tail> struct TypeAt<Typelist<Head, Tail>, 0> {
typedef Head Result;
};
template <class Head, class Tail, unsigned int i>
struct TypeAt<Typelist<Head, Tail>, i> {
typedef typename TypeAt<Tail, i - 1>::Result Result;
};
////////////////////////////////////////////////////////////////////////////////
// class template Erase
// Erases the first occurence, if any, of a type in a typelist
// Invocation (TList is a typelist and T is a type):
// Erase<TList, T>::Result
// returns a typelist that is TList without the first occurence of T
////////////////////////////////////////////////////////////////////////////////
template <class TList, class T> struct Erase;
template <class T> // Specialization 1
struct Erase<Null_type, T> {
typedef Null_type Result;
};
template <class T, class Tail> // Specialization 2
struct Erase<Typelist<T, Tail>, T> {
typedef Tail Result;
};
template <class Head, class Tail, class T> // Specialization 3
struct Erase<Typelist<Head, Tail>, T> {
typedef Typelist<Head, typename Erase<Tail, T>::Result> Result;
};
template <class TList, class T> struct IndexOf;
template <class T> struct IndexOf<Null_type, T> {
enum { value = -1 };
};
template <class T, class Tail> struct IndexOf<Typelist<T, Tail>, T> {
enum { value = 0 };
};
template <class Head, class Tail, class T>
struct IndexOf<Typelist<Head, Tail>, T> {
private:
enum { temp = IndexOf<Tail, T>::value };
public:
enum { value = (temp == -1 ? -1 : 1 + temp) };
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_TYPELIST_HH__ */
diff --git a/src/common/aka_types.hh b/src/common/aka_types.hh
index 01a56a872..32bf6ffd7 100644
--- a/src/common/aka_types.hh
+++ b/src/common/aka_types.hh
@@ -1,1486 +1,1504 @@
/**
* @file aka_types.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Feb 17 2011
* @date last modification: Tue Feb 20 2018
*
* @brief description of the "simple" types
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_error.hh"
#include "aka_fwd.hh"
#include "aka_math.hh"
/* -------------------------------------------------------------------------- */
#include <initializer_list>
#include <iomanip>
#include <type_traits>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_TYPES_HH__
#define __AKANTU_AKA_TYPES_HH__
namespace akantu {
enum NormType { L_1 = 1, L_2 = 2, L_inf = UInt(-1) };
/**
* DimHelper is a class to generalize the setup of a dim array from 3
* values. This gives a common interface in the TensorStorage class
* independently of its derived inheritance (Vector, Matrix, Tensor3)
* @tparam dim
*/
template <UInt dim> struct DimHelper {
static inline void setDims(UInt m, UInt n, UInt p, UInt dims[dim]);
};
/* -------------------------------------------------------------------------- */
template <> struct DimHelper<1> {
static inline void setDims(UInt m, __attribute__((unused)) UInt n,
__attribute__((unused)) UInt p, UInt dims[1]) {
dims[0] = m;
}
};
/* -------------------------------------------------------------------------- */
template <> struct DimHelper<2> {
static inline void setDims(UInt m, UInt n, __attribute__((unused)) UInt p,
UInt dims[2]) {
dims[0] = m;
dims[1] = n;
}
};
/* -------------------------------------------------------------------------- */
template <> struct DimHelper<3> {
static inline void setDims(UInt m, UInt n, UInt p, UInt dims[3]) {
dims[0] = m;
dims[1] = n;
dims[2] = p;
}
};
/* -------------------------------------------------------------------------- */
template <typename T, UInt ndim, class RetType> class TensorStorage;
/* -------------------------------------------------------------------------- */
/* Proxy classes */
/* -------------------------------------------------------------------------- */
namespace tensors {
template <class A, class B> struct is_copyable {
enum : bool { value = false };
};
template <class A> struct is_copyable<A, A> {
enum : bool { value = true };
};
template <class A> struct is_copyable<A, typename A::RetType> {
enum : bool { value = true };
};
template <class A> struct is_copyable<A, typename A::RetType::proxy> {
enum : bool { value = true };
};
} // namespace tensors
+
+/* -------------------------------------------------------------------------- */
+/* -------------------------------------------------------------------------- */
+namespace types {
+ namespace details {
+ template <typename reference_> class vector_iterator {
+ public:
+ using difference_type = std::ptrdiff_t;
+ using value_type = std::decay_t<reference_>;
+ using pointer = value_type *;
+ using reference = reference_;
+ using iterator_category = std::input_iterator_tag;
+
+ vector_iterator(pointer ptr) : ptr(ptr) {}
+
+ // input iterator ++it
+ vector_iterator & operator++() {
+ ++ptr;
+ return *this;
+ }
+ // input iterator it++
+ vector_iterator operator++(int) {
+ auto cpy = *this;
+ ++ptr;
+ return cpy;
+ }
+ vector_iterator & operator+=(int n) {
+ ptr += n;
+ return *this;
+ }
+
+ vector_iterator operator+(int n) {
+ vector_iterator cpy(*this);
+ cpy += n;
+ return cpy;
+ }
+
+ // input iterator it != other_it
+ bool operator!=(const vector_iterator & other) const {
+ return ptr != other.ptr;
+ }
+ bool operator==(const vector_iterator & other) const {
+ return ptr == other.ptr;
+ }
+
+ difference_type operator-(const vector_iterator & other) const {
+ return this->ptr - other.ptr;
+ }
+
+ // input iterator dereference *it
+ reference operator*() { return *ptr; }
+ pointer operator->() { return ptr; }
+
+ private:
+ pointer ptr;
+ };
+ } // namespace details
+} // namespace types
+
/**
* @class TensorProxy aka_types.hh
* @desc The TensorProxy class is a proxy class to the TensorStorage it handles
* the
* wrapped case. That is to say if an accessor should give access to a Tensor
* wrapped on some data, like the Array<T>::iterator they can return a
* TensorProxy that will be automatically transformed as a TensorStorage wrapped
* on the same data
* @tparam T stored type
* @tparam ndim order of the tensor
* @tparam RetType real derived type
*/
-template <typename T, UInt ndim, class _RetType> class TensorProxy {
+template <typename T, UInt ndim, class _RetType> class TensorProxy : public TensorProxyTrait {
protected:
using RetTypeProxy = typename _RetType::proxy;
constexpr TensorProxy(T * data, UInt m, UInt n, UInt p) {
DimHelper<ndim>::setDims(m, n, p, this->n);
this->values = data;
}
template <class Other, typename = std::enable_if_t<
tensors::is_copyable<TensorProxy, Other>::value>>
explicit TensorProxy(const Other & other) {
this->values = other.storage();
for (UInt i = 0; i < ndim; ++i)
this->n[i] = other.size(i);
}
public:
using RetType = _RetType;
UInt size(UInt i) const {
AKANTU_DEBUG_ASSERT(i < ndim, "This tensor has only " << ndim
<< " dimensions, not "
<< (i + 1));
return n[i];
}
inline UInt size() const {
UInt _size = 1;
for (UInt d = 0; d < ndim; ++d)
_size *= this->n[d];
return _size;
}
T * storage() const { return values; }
template <class Other, typename = std::enable_if_t<
tensors::is_copyable<TensorProxy, Other>::value>>
inline TensorProxy & operator=(const Other & other) {
AKANTU_DEBUG_ASSERT(
other.size() == this->size(),
"You are trying to copy two tensors with different sizes");
memcpy(this->values, other.storage(), this->size() * sizeof(T));
return *this;
}
// template <class Other, typename = std::enable_if_t<
// tensors::is_copyable<TensorProxy, Other>::value>>
// inline TensorProxy & operator=(const Other && other) {
// AKANTU_DEBUG_ASSERT(
// other.size() == this->size(),
// "You are trying to copy two tensors with different sizes");
// memcpy(this->values, other.storage(), this->size() * sizeof(T));
// return *this;
// }
template <typename O> inline RetTypeProxy & operator*=(const O & o) {
RetType(*this) *= o;
return static_cast<RetTypeProxy &>(*this);
}
template <typename O> inline RetTypeProxy & operator/=(const O & o) {
RetType(*this) /= o;
return static_cast<RetTypeProxy &>(*this);
}
protected:
T * values;
UInt n[ndim];
};
/* -------------------------------------------------------------------------- */
template <typename T> class VectorProxy : public TensorProxy<T, 1, Vector<T>> {
using parent = TensorProxy<T, 1, Vector<T>>;
using type = Vector<T>;
public:
constexpr VectorProxy(T * data, UInt n) : parent(data, n, 0, 0) {}
template <class Other> explicit VectorProxy(Other & src) : parent(src) {}
/* ---------------------------------------------------------------------- */
template <class Other>
inline VectorProxy<T> & operator=(const Other & other) {
parent::operator=(other);
return *this;
}
// inline VectorProxy<T> & operator=(const VectorProxy && other) {
// parent::operator=(other);
// return *this;
// }
+ using iterator = types::details::vector_iterator<T &>;
+ using const_iterator = types::details::vector_iterator<const T &>;
+
+ iterator begin() { return iterator(this->storage()); }
+ iterator end() { return iterator(this->storage() + this->size()); }
+
+ const_iterator begin() const { return const_iterator(this->storage()); }
+ const_iterator end() const {
+ return const_iterator(this->storage() + this->size());
+ }
/* ------------------------------------------------------------------------ */
T & operator()(UInt index) { return this->values[index]; };
const T & operator()(UInt index) const { return this->values[index]; };
};
template <typename T> class MatrixProxy : public TensorProxy<T, 2, Matrix<T>> {
using parent = TensorProxy<T, 2, Matrix<T>>;
using type = Matrix<T>;
public:
MatrixProxy(T * data, UInt m, UInt n) : parent(data, m, n, 0) {}
template <class Other> explicit MatrixProxy(Other & src) : parent(src) {}
/* ---------------------------------------------------------------------- */
template <class Other>
inline MatrixProxy<T> & operator=(const Other & other) {
parent::operator=(other);
return *this;
}
};
template <typename T>
class Tensor3Proxy : public TensorProxy<T, 3, Tensor3<T>> {
using parent = TensorProxy<T, 3, Tensor3<T>>;
using type = Tensor3<T>;
public:
Tensor3Proxy(const T * data, UInt m, UInt n, UInt k)
: parent(data, m, n, k) {}
Tensor3Proxy(const Tensor3Proxy & src) : parent(src) {}
Tensor3Proxy(const Tensor3<T> & src) : parent(src) {}
/* ---------------------------------------------------------------------- */
template <class Other>
inline Tensor3Proxy<T> & operator=(const Other & other) {
parent::operator=(other);
return *this;
}
};
/* -------------------------------------------------------------------------- */
/* Tensor base class */
/* -------------------------------------------------------------------------- */
template <typename T, UInt ndim, class RetType>
class TensorStorage : public TensorTrait {
public:
using value_type = T;
friend class Array<T>;
protected:
template <class TensorType> void copySize(const TensorType & src) {
for (UInt d = 0; d < ndim; ++d)
this->n[d] = src.size(d);
this->_size = src.size();
}
TensorStorage() : values(nullptr) {
for (UInt d = 0; d < ndim; ++d)
this->n[d] = 0;
_size = 0;
}
TensorStorage(const TensorProxy<T, ndim, RetType> & proxy) {
this->copySize(proxy);
this->values = proxy.storage();
this->wrapped = true;
}
public:
TensorStorage(const TensorStorage & src) = delete;
TensorStorage(const TensorStorage & src, bool deep_copy) : values(nullptr) {
if (deep_copy)
this->deepCopy(src);
else
this->shallowCopy(src);
}
protected:
TensorStorage(UInt m, UInt n, UInt p, const T & def) {
static_assert(std::is_trivially_constructible<T>{},
"Cannot create a tensor on non trivial types");
DimHelper<ndim>::setDims(m, n, p, this->n);
this->computeSize();
this->values = new T[this->_size];
this->set(def);
this->wrapped = false;
}
TensorStorage(T * data, UInt m, UInt n, UInt p) {
DimHelper<ndim>::setDims(m, n, p, this->n);
this->computeSize();
this->values = data;
this->wrapped = true;
}
public:
/* ------------------------------------------------------------------------ */
template <class TensorType> inline void shallowCopy(const TensorType & src) {
this->copySize(src);
if (!this->wrapped)
delete[] this->values;
this->values = src.storage();
this->wrapped = true;
}
/* ------------------------------------------------------------------------ */
template <class TensorType> inline void deepCopy(const TensorType & src) {
this->copySize(src);
if (!this->wrapped)
delete[] this->values;
static_assert(std::is_trivially_constructible<T>{},
"Cannot create a tensor on non trivial types");
this->values = new T[this->_size];
static_assert(std::is_trivially_copyable<T>{},
"Cannot copy a tensor on non trivial types");
memcpy((void *)this->values, (void *)src.storage(),
this->_size * sizeof(T));
this->wrapped = false;
}
virtual ~TensorStorage() {
if (!this->wrapped)
delete[] this->values;
}
/* ------------------------------------------------------------------------ */
inline TensorStorage & operator=(const TensorStorage & src) {
return this->operator=(aka::as_type<RetType>(src));
}
/* ------------------------------------------------------------------------ */
inline TensorStorage & operator=(const RetType & src) {
if (this != &src) {
if (this->wrapped) {
static_assert(std::is_trivially_copyable<T>{},
"Cannot copy a tensor on non trivial types");
// this test is not sufficient for Tensor of order higher than 1
AKANTU_DEBUG_ASSERT(this->_size == src.size(),
"Tensors of different size ("
- << this->_size << " != " << src.size() << ")");
+ << this->_size << " != " << src.size() << ")");
memcpy((void *)this->values, (void *)src.storage(),
this->_size * sizeof(T));
} else {
deepCopy(src);
}
}
return *this;
}
/* ------------------------------------------------------------------------ */
template <class R>
inline RetType & operator+=(const TensorStorage<T, ndim, R> & other) {
T * a = this->storage();
T * b = other.storage();
AKANTU_DEBUG_ASSERT(
_size == other.size(),
"The two tensors do not have the same size, they cannot be subtracted");
for (UInt i = 0; i < _size; ++i)
*(a++) += *(b++);
return *(static_cast<RetType *>(this));
}
/* ------------------------------------------------------------------------ */
template <class R>
inline RetType & operator-=(const TensorStorage<T, ndim, R> & other) {
T * a = this->storage();
T * b = other.storage();
AKANTU_DEBUG_ASSERT(
_size == other.size(),
"The two tensors do not have the same size, they cannot be subtracted");
for (UInt i = 0; i < _size; ++i)
*(a++) -= *(b++);
return *(static_cast<RetType *>(this));
}
/* ------------------------------------------------------------------------ */
inline RetType & operator+=(const T & x) {
T * a = this->values;
for (UInt i = 0; i < _size; ++i)
*(a++) += x;
return *(static_cast<RetType *>(this));
}
/* ------------------------------------------------------------------------ */
inline RetType & operator-=(const T & x) {
T * a = this->values;
for (UInt i = 0; i < _size; ++i)
*(a++) -= x;
return *(static_cast<RetType *>(this));
}
/* ------------------------------------------------------------------------ */
inline RetType & operator*=(const T & x) {
T * a = this->storage();
for (UInt i = 0; i < _size; ++i)
*(a++) *= x;
return *(static_cast<RetType *>(this));
}
/* ---------------------------------------------------------------------- */
inline RetType & operator/=(const T & x) {
T * a = this->values;
for (UInt i = 0; i < _size; ++i)
*(a++) /= x;
return *(static_cast<RetType *>(this));
}
/// Y = \alpha X + Y
inline RetType & aXplusY(const TensorStorage & other, const T & alpha = 1.) {
AKANTU_DEBUG_ASSERT(
_size == other.size(),
"The two tensors do not have the same size, they cannot be subtracted");
Math::aXplusY(this->_size, alpha, other.storage(), this->storage());
return *(static_cast<RetType *>(this));
}
/* ------------------------------------------------------------------------ */
T * storage() const { return values; }
UInt size() const { return _size; }
UInt size(UInt i) const {
AKANTU_DEBUG_ASSERT(i < ndim, "This tensor has only " << ndim
<< " dimensions, not "
<< (i + 1));
return n[i];
};
/* ------------------------------------------------------------------------ */
inline void clear() { memset(values, 0, _size * sizeof(T)); };
inline void set(const T & t) { std::fill_n(values, _size, t); };
template <class TensorType> inline void copy(const TensorType & other) {
AKANTU_DEBUG_ASSERT(
_size == other.size(),
"The two tensors do not have the same size, they cannot be copied");
memcpy(values, other.storage(), _size * sizeof(T));
}
bool isWrapped() const { return this->wrapped; }
protected:
inline void computeSize() {
_size = 1;
for (UInt d = 0; d < ndim; ++d)
_size *= this->n[d];
}
protected:
template <typename R, NormType norm_type> struct NormHelper {
template <class Ten> static R norm(const Ten & ten) {
R _norm = 0.;
R * it = ten.storage();
R * end = ten.storage() + ten.size();
for (; it < end; ++it)
_norm += std::pow(std::abs(*it), norm_type);
return std::pow(_norm, 1. / norm_type);
}
};
template <typename R> struct NormHelper<R, L_1> {
template <class Ten> static R norm(const Ten & ten) {
R _norm = 0.;
R * it = ten.storage();
R * end = ten.storage() + ten.size();
for (; it < end; ++it)
_norm += std::abs(*it);
return _norm;
}
};
template <typename R> struct NormHelper<R, L_2> {
template <class Ten> static R norm(const Ten & ten) {
R _norm = 0.;
R * it = ten.storage();
R * end = ten.storage() + ten.size();
for (; it < end; ++it)
_norm += *it * *it;
return sqrt(_norm);
}
};
template <typename R> struct NormHelper<R, L_inf> {
template <class Ten> static R norm(const Ten & ten) {
R _norm = 0.;
R * it = ten.storage();
R * end = ten.storage() + ten.size();
for (; it < end; ++it)
_norm = std::max(std::abs(*it), _norm);
return _norm;
}
};
public:
/*----------------------------------------------------------------------- */
/// "Entrywise" norm norm<L_p> @f[ \|\boldsymbol{T}\|_p = \left(
/// \sum_i^{n[0]}\sum_j^{n[1]}\sum_k^{n[2]} |T_{ijk}|^p \right)^{\frac{1}{p}}
/// @f]
template <NormType norm_type> inline T norm() const {
return NormHelper<T, norm_type>::norm(*this);
}
protected:
UInt n[ndim];
UInt _size;
T * values;
bool wrapped{false};
};
-/* -------------------------------------------------------------------------- */
-/* -------------------------------------------------------------------------- */
-namespace types {
- namespace details {
- template <typename reference_> class vector_iterator {
- public:
- using difference_type = std::ptrdiff_t;
- using value_type = std::decay_t<reference_>;
- using pointer = value_type *;
- using reference = reference_;
- using iterator_category = std::input_iterator_tag;
-
- vector_iterator(pointer ptr) : ptr(ptr) {}
-
- // input iterator ++it
- vector_iterator & operator++() {
- ++ptr;
- return *this;
- }
- // input iterator it++
- vector_iterator operator++(int) {
- auto cpy = *this;
- ++ptr;
- return cpy;
- }
- vector_iterator & operator+=(int n) {
- ptr += n;
- return *this;
- }
-
- vector_iterator operator+(int n) {
- vector_iterator cpy(*this);
- cpy += n;
- return cpy;
- }
-
- // input iterator it != other_it
- bool operator!=(const vector_iterator & other) const {
- return ptr != other.ptr;
- }
- bool operator==(const vector_iterator & other) const {
- return ptr == other.ptr;
- }
-
- difference_type operator-(const vector_iterator & other) const {
- return this->ptr - other.ptr;
- }
-
- // input iterator dereference *it
- reference operator*() { return *ptr; }
- pointer operator->() { return ptr; }
-
- private:
- pointer ptr;
- };
- } // namespace details
-} // namespace types
/* -------------------------------------------------------------------------- */
/* Vector */
/* -------------------------------------------------------------------------- */
template <typename T> class Vector : public TensorStorage<T, 1, Vector<T>> {
using parent = TensorStorage<T, 1, Vector<T>>;
public:
using value_type = typename parent::value_type;
using proxy = VectorProxy<T>;
public:
Vector() : parent() {}
explicit Vector(UInt n, const T & def = T()) : parent(n, 0, 0, def) {}
Vector(T * data, UInt n) : parent(data, n, 0, 0) {}
Vector(const Vector & src, bool deep_copy = true) : parent(src, deep_copy) {}
Vector(const TensorProxy<T, 1, Vector> & src) : parent(src) {}
Vector(std::initializer_list<T> list) : parent(list.size(), 0, 0, T()) {
UInt i = 0;
for (auto val : list) {
operator()(i++) = val;
}
}
public:
using iterator = types::details::vector_iterator<T &>;
using const_iterator = types::details::vector_iterator<const T &>;
iterator begin() { return iterator(this->storage()); }
iterator end() { return iterator(this->storage() + this->size()); }
const_iterator begin() const { return const_iterator(this->storage()); }
const_iterator end() const {
return const_iterator(this->storage() + this->size());
}
public:
~Vector() override = default;
/* ------------------------------------------------------------------------ */
inline Vector & operator=(const Vector & src) {
parent::operator=(src);
return *this;
}
/* ------------------------------------------------------------------------ */
inline T & operator()(UInt i) {
AKANTU_DEBUG_ASSERT((i < this->n[0]),
"Access out of the vector! "
<< "Index (" << i
<< ") is out of the vector of size (" << this->n[0]
<< ")");
return *(this->values + i);
}
inline const T & operator()(UInt i) const {
AKANTU_DEBUG_ASSERT((i < this->n[0]),
"Access out of the vector! "
<< "Index (" << i
<< ") is out of the vector of size (" << this->n[0]
<< ")");
return *(this->values + i);
}
inline T & operator[](UInt i) { return this->operator()(i); }
inline const T & operator[](UInt i) const { return this->operator()(i); }
/* ------------------------------------------------------------------------ */
inline Vector<T> & operator*=(Real x) { return parent::operator*=(x); }
inline Vector<T> & operator/=(Real x) { return parent::operator/=(x); }
/* ------------------------------------------------------------------------ */
inline Vector<T> & operator*=(const Vector<T> & vect) {
AKANTU_DEBUG_ASSERT(this->_size == vect._size,
"The vectors have non matching sizes");
T * a = this->storage();
T * b = vect.storage();
for (UInt i = 0; i < this->_size; ++i)
*(a++) *= *(b++);
return *this;
}
/* ------------------------------------------------------------------------ */
inline Real dot(const Vector<T> & vect) const {
return Math::vectorDot(this->values, vect.storage(), this->_size);
}
/* ------------------------------------------------------------------------ */
inline Real mean() const {
Real mean = 0;
T * a = this->storage();
for (UInt i = 0; i < this->_size; ++i)
mean += *(a++);
return mean / this->_size;
}
/* ------------------------------------------------------------------------ */
inline Vector & crossProduct(const Vector<T> & v1, const Vector<T> & v2) {
AKANTU_DEBUG_ASSERT(this->size() == 3,
"crossProduct is only defined in 3D (n=" << this->size()
<< ")");
AKANTU_DEBUG_ASSERT(
this->size() == v1.size() && this->size() == v2.size(),
"crossProduct is not a valid operation non matching size vectors");
Math::vectorProduct3(v1.storage(), v2.storage(), this->values);
return *this;
}
inline Vector crossProduct(const Vector<T> & v) {
Vector<T> tmp(this->size());
tmp.crossProduct(*this, v);
return tmp;
}
/* ------------------------------------------------------------------------ */
inline void solve(const Matrix<T> & A, const Vector<T> & b) {
AKANTU_DEBUG_ASSERT(
this->size() == A.rows() && this->_size == A.cols(),
"The size of the solution vector mismatches the size of the matrix");
AKANTU_DEBUG_ASSERT(
this->_size == b._size,
"The rhs vector has a mismatch in size with the matrix");
Math::solve(this->_size, A.storage(), this->values, b.storage());
}
/* ------------------------------------------------------------------------ */
template <bool tr_A>
inline void mul(const Matrix<T> & A, const Vector<T> & x, Real alpha = 1.0);
/* ------------------------------------------------------------------------ */
inline Real norm() const { return parent::template norm<L_2>(); }
template <NormType nt> inline Real norm() const {
return parent::template norm<nt>();
}
/* ------------------------------------------------------------------------ */
inline Vector<Real> & normalize() {
Real n = norm();
operator/=(n);
return *this;
}
/* ------------------------------------------------------------------------ */
/// norm of (*this - x)
inline Real distance(const Vector<T> & y) const {
Real * vx = this->values;
Real * vy = y.storage();
Real sum_2 = 0;
for (UInt i = 0; i < this->_size; ++i, ++vx, ++vy)
sum_2 += (*vx - *vy) * (*vx - *vy);
return sqrt(sum_2);
}
/* ------------------------------------------------------------------------ */
inline bool equal(const Vector<T> & v,
Real tolerance = Math::getTolerance()) const {
T * a = this->storage();
T * b = v.storage();
UInt i = 0;
while (i < this->_size && (std::abs(*(a++) - *(b++)) < tolerance))
++i;
return i == this->_size;
}
/* ------------------------------------------------------------------------ */
inline short compare(const Vector<T> & v,
Real tolerance = Math::getTolerance()) const {
T * a = this->storage();
T * b = v.storage();
for (UInt i(0); i < this->_size; ++i, ++a, ++b) {
if (std::abs(*a - *b) > tolerance)
return (((*a - *b) > tolerance) ? 1 : -1);
}
return 0;
}
/* ------------------------------------------------------------------------ */
inline bool operator==(const Vector<T> & v) const { return equal(v); }
inline bool operator!=(const Vector<T> & v) const { return !operator==(v); }
inline bool operator<(const Vector<T> & v) const { return compare(v) == -1; }
inline bool operator>(const Vector<T> & v) const { return compare(v) == 1; }
template <typename Func, typename Acc>
decltype(auto) accumulate(const Vector<T> & v, Acc && accumulator,
Func && func) const {
T * a = this->storage();
T * b = v.storage();
for (UInt i(0); i < this->_size; ++i, ++a, ++b) {
accumulator = func(*a, *b, std::forward<Acc>(accumulator));
}
return accumulator;
}
inline bool operator<=(const Vector<T> & v) const {
bool res = true;
return accumulate(v, res, [](auto && a, auto && b, auto && accumulator) {
return accumulator & (a <= b);
});
}
inline bool operator>=(const Vector<T> & v) const {
bool res = true;
return accumulate(v, res, [](auto && a, auto && b, auto && accumulator) {
return accumulator & (a >= b);
});
}
/* ------------------------------------------------------------------------ */
/// function to print the containt of the class
virtual void printself(std::ostream & stream, int indent = 0) const {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << "[";
for (UInt i = 0; i < this->_size; ++i) {
if (i != 0)
stream << ", ";
stream << this->values[i];
}
stream << "]";
}
/* ---------------------------------------------------------------------- */
static inline Vector<T> zeros(UInt n) {
Vector<T> tmp(n);
tmp.set(T());
return tmp;
}
};
using RVector = Vector<Real>;
/* ------------------------------------------------------------------------ */
template <>
inline bool Vector<UInt>::equal(const Vector<UInt> & v,
__attribute__((unused)) Real tolerance) const {
UInt * a = this->storage();
UInt * b = v.storage();
UInt i = 0;
while (i < this->_size && (*(a++) == *(b++)))
++i;
return i == this->_size;
}
/* -------------------------------------------------------------------------- */
namespace types {
namespace details {
template <typename Mat> class column_iterator {
public:
using difference_type = std::ptrdiff_t;
using value_type = decltype(std::declval<Mat>().operator()(0));
using pointer = value_type *;
using reference = value_type &;
using iterator_category = std::input_iterator_tag;
-
column_iterator(Mat & mat, UInt col) : mat(mat), col(col) {}
decltype(auto) operator*() { return mat(col); }
decltype(auto) operator++() {
++col;
AKANTU_DEBUG_ASSERT(col <= mat.cols(), "The iterator is out of bound");
return *this;
}
decltype(auto) operator++(int) {
auto tmp = *this;
++col;
AKANTU_DEBUG_ASSERT(col <= mat.cols(), "The iterator is out of bound");
return tmp;
}
bool operator!=(const column_iterator & other) const {
return col != other.col;
}
bool operator==(const column_iterator & other) const {
return not operator!=(other);
}
private:
Mat & mat;
UInt col;
};
} // namespace details
} // namespace types
/* ------------------------------------------------------------------------ */
/* Matrix */
/* ------------------------------------------------------------------------ */
template <typename T> class Matrix : public TensorStorage<T, 2, Matrix<T>> {
using parent = TensorStorage<T, 2, Matrix<T>>;
public:
using value_type = typename parent::value_type;
using proxy = MatrixProxy<T>;
public:
Matrix() : parent() {}
Matrix(UInt m, UInt n, const T & def = T()) : parent(m, n, 0, def) {}
Matrix(T * data, UInt m, UInt n) : parent(data, m, n, 0) {}
Matrix(const Matrix & src, bool deep_copy = true) : parent(src, deep_copy) {}
Matrix(const MatrixProxy<T> & src) : parent(src) {}
Matrix(std::initializer_list<std::initializer_list<T>> list) {
static_assert(std::is_trivially_copyable<T>{},
"Cannot create a tensor on non trivial types");
std::size_t n = 0;
std::size_t m = list.size();
for (auto row : list) {
n = std::max(n, row.size());
}
DimHelper<2>::setDims(m, n, 0, this->n);
this->computeSize();
this->values = new T[this->_size];
this->set(0);
UInt i = 0, j = 0;
for (auto & row : list) {
for (auto & val : row) {
at(i, j++) = val;
}
++i;
j = 0;
}
}
~Matrix() override = default;
/* ------------------------------------------------------------------------ */
inline Matrix & operator=(const Matrix & src) {
parent::operator=(src);
return *this;
}
public:
/* ---------------------------------------------------------------------- */
UInt rows() const { return this->n[0]; }
UInt cols() const { return this->n[1]; }
/* ---------------------------------------------------------------------- */
inline T & at(UInt i, UInt j) {
AKANTU_DEBUG_ASSERT(((i < this->n[0]) && (j < this->n[1])),
"Access out of the matrix! "
<< "Index (" << i << ", " << j
<< ") is out of the matrix of size (" << this->n[0]
<< ", " << this->n[1] << ")");
return *(this->values + i + j * this->n[0]);
}
inline const T & at(UInt i, UInt j) const {
AKANTU_DEBUG_ASSERT(((i < this->n[0]) && (j < this->n[1])),
"Access out of the matrix! "
<< "Index (" << i << ", " << j
<< ") is out of the matrix of size (" << this->n[0]
<< ", " << this->n[1] << ")");
return *(this->values + i + j * this->n[0]);
}
/* ------------------------------------------------------------------------ */
inline T & operator()(UInt i, UInt j) { return this->at(i, j); }
inline const T & operator()(UInt i, UInt j) const { return this->at(i, j); }
/// give a line vector wrapped on the column i
inline VectorProxy<T> operator()(UInt j) {
AKANTU_DEBUG_ASSERT(j < this->n[1],
"Access out of the matrix! "
<< "You are trying to access the column vector "
<< j << " in a matrix of size (" << this->n[0]
<< ", " << this->n[1] << ")");
return VectorProxy<T>(this->values + j * this->n[0], this->n[0]);
}
inline const VectorProxy<T> operator()(UInt j) const {
AKANTU_DEBUG_ASSERT(j < this->n[1],
"Access out of the matrix! "
<< "You are trying to access the column vector "
<< j << " in a matrix of size (" << this->n[0]
<< ", " << this->n[1] << ")");
return VectorProxy<T>(this->values + j * this->n[0], this->n[0]);
}
public:
decltype(auto) begin() {
return types::details::column_iterator<Matrix<T>>(*this, 0);
}
decltype(auto) begin() const {
return types::details::column_iterator<const Matrix<T>>(*this, 0);
}
decltype(auto) end() {
return types::details::column_iterator<Matrix<T>>(*this, this->cols());
}
decltype(auto) end() const {
return types::details::column_iterator<const Matrix<T>>(*this,
this->cols());
}
/* ------------------------------------------------------------------------ */
inline void block(const Matrix & block, UInt pos_i, UInt pos_j) {
AKANTU_DEBUG_ASSERT(pos_i + block.rows() <= rows(),
"The block size or position are not correct");
AKANTU_DEBUG_ASSERT(pos_i + block.cols() <= cols(),
"The block size or position are not correct");
for (UInt i = 0; i < block.rows(); ++i)
for (UInt j = 0; j < block.cols(); ++j)
this->at(i + pos_i, j + pos_j) = block(i, j);
}
inline Matrix block(UInt pos_i, UInt pos_j, UInt block_rows,
UInt block_cols) const {
AKANTU_DEBUG_ASSERT(pos_i + block_rows <= rows(),
"The block size or position are not correct");
AKANTU_DEBUG_ASSERT(pos_i + block_cols <= cols(),
"The block size or position are not correct");
Matrix block(block_rows, block_cols);
for (UInt i = 0; i < block_rows; ++i)
for (UInt j = 0; j < block_cols; ++j)
block(i, j) = this->at(i + pos_i, j + pos_j);
return block;
}
inline T & operator[](UInt idx) { return *(this->values + idx); };
inline const T & operator[](UInt idx) const { return *(this->values + idx); };
/* ---------------------------------------------------------------------- */
inline Matrix operator*(const Matrix & B) {
Matrix C(this->rows(), B.cols());
C.mul<false, false>(*this, B);
return C;
}
/* ----------------------------------------------------------------------- */
inline Matrix & operator*=(const T & x) { return parent::operator*=(x); }
inline Matrix & operator*=(const Matrix & B) {
Matrix C(*this);
this->mul<false, false>(C, B);
return *this;
}
/* ---------------------------------------------------------------------- */
template <bool tr_A, bool tr_B>
inline void mul(const Matrix & A, const Matrix & B, T alpha = 1.0) {
UInt k = A.cols();
if (tr_A)
k = A.rows();
#ifndef AKANTU_NDEBUG
if (tr_B) {
AKANTU_DEBUG_ASSERT(k == B.cols(),
"matrices to multiply have no fit dimensions");
AKANTU_DEBUG_ASSERT(this->cols() == B.rows(),
"matrices to multiply have no fit dimensions");
} else {
AKANTU_DEBUG_ASSERT(k == B.rows(),
"matrices to multiply have no fit dimensions");
AKANTU_DEBUG_ASSERT(this->cols() == B.cols(),
"matrices to multiply have no fit dimensions");
}
if (tr_A) {
AKANTU_DEBUG_ASSERT(this->rows() == A.cols(),
"matrices to multiply have no fit dimensions");
} else {
AKANTU_DEBUG_ASSERT(this->rows() == A.rows(),
"matrices to multiply have no fit dimensions");
}
#endif // AKANTU_NDEBUG
Math::matMul<tr_A, tr_B>(this->rows(), this->cols(), k, alpha, A.storage(),
B.storage(), 0., this->storage());
}
/* ---------------------------------------------------------------------- */
inline void outerProduct(const Vector<T> & A, const Vector<T> & B) {
AKANTU_DEBUG_ASSERT(
A.size() == this->rows() && B.size() == this->cols(),
"A and B are not compatible with the size of the matrix");
for (UInt i = 0; i < this->rows(); ++i) {
for (UInt j = 0; j < this->cols(); ++j) {
this->values[i + j * this->rows()] += A[i] * B[j];
}
}
}
private:
class EigenSorter {
public:
EigenSorter(const Vector<T> & eigs) : eigs(eigs) {}
bool operator()(const UInt & a, const UInt & b) const {
return (eigs(a) > eigs(b));
}
private:
const Vector<T> & eigs;
};
public:
/* ---------------------------------------------------------------------- */
- inline void eig(Vector<T> & eigenvalues, Matrix<T> & eigenvectors) const {
+ inline void eig(Vector<T> & eigenvalues, Matrix<T> & eigenvectors,
+ bool sort = true) const {
AKANTU_DEBUG_ASSERT(this->cols() == this->rows(),
"eig is not a valid operation on a rectangular matrix");
AKANTU_DEBUG_ASSERT(eigenvalues.size() == this->cols(),
"eigenvalues should be of size " << this->cols()
<< ".");
#ifndef AKANTU_NDEBUG
if (eigenvectors.storage() != nullptr)
AKANTU_DEBUG_ASSERT((eigenvectors.rows() == eigenvectors.cols()) &&
(eigenvectors.rows() == this->cols()),
"Eigenvectors needs to be a square matrix of size "
<< this->cols() << " x " << this->cols() << ".");
#endif
Matrix<T> tmp = *this;
Vector<T> tmp_eigs(eigenvalues.size());
Matrix<T> tmp_eig_vects(eigenvectors.rows(), eigenvectors.cols());
if (tmp_eig_vects.rows() == 0 || tmp_eig_vects.cols() == 0)
Math::matrixEig(tmp.cols(), tmp.storage(), tmp_eigs.storage());
else
Math::matrixEig(tmp.cols(), tmp.storage(), tmp_eigs.storage(),
tmp_eig_vects.storage());
+ if (not sort) {
+ eigenvalues = tmp_eigs;
+ eigenvectors = tmp_eig_vects;
+ return;
+ }
+
Vector<UInt> perm(eigenvalues.size());
for (UInt i = 0; i < perm.size(); ++i)
perm(i) = i;
std::sort(perm.storage(), perm.storage() + perm.size(),
EigenSorter(tmp_eigs));
for (UInt i = 0; i < perm.size(); ++i)
eigenvalues(i) = tmp_eigs(perm(i));
if (tmp_eig_vects.rows() != 0 && tmp_eig_vects.cols() != 0)
for (UInt i = 0; i < perm.size(); ++i) {
for (UInt j = 0; j < eigenvectors.rows(); ++j) {
eigenvectors(j, i) = tmp_eig_vects(j, perm(i));
}
}
}
/* ---------------------------------------------------------------------- */
inline void eig(Vector<T> & eigenvalues) const {
Matrix<T> empty;
eig(eigenvalues, empty);
}
/* ---------------------------------------------------------------------- */
inline void eye(T alpha = 1.) {
AKANTU_DEBUG_ASSERT(this->cols() == this->rows(),
"eye is not a valid operation on a rectangular matrix");
this->clear();
for (UInt i = 0; i < this->cols(); ++i) {
this->values[i + i * this->rows()] = alpha;
}
}
/* ---------------------------------------------------------------------- */
static inline Matrix<T> eye(UInt m, T alpha = 1.) {
Matrix<T> tmp(m, m);
tmp.eye(alpha);
return tmp;
}
/* ---------------------------------------------------------------------- */
inline T trace() const {
AKANTU_DEBUG_ASSERT(
this->cols() == this->rows(),
"trace is not a valid operation on a rectangular matrix");
T trace = 0.;
for (UInt i = 0; i < this->rows(); ++i) {
trace += this->values[i + i * this->rows()];
}
return trace;
}
/* ---------------------------------------------------------------------- */
inline Matrix transpose() const {
Matrix tmp(this->cols(), this->rows());
for (UInt i = 0; i < this->rows(); ++i) {
for (UInt j = 0; j < this->cols(); ++j) {
tmp(j, i) = operator()(i, j);
}
}
return tmp;
}
/* ---------------------------------------------------------------------- */
inline void inverse(const Matrix & A) {
AKANTU_DEBUG_ASSERT(A.cols() == A.rows(),
"inv is not a valid operation on a rectangular matrix");
AKANTU_DEBUG_ASSERT(this->cols() == A.cols(),
"the matrix should have the same size as its inverse");
if (this->cols() == 1)
*this->values = 1. / *A.storage();
else if (this->cols() == 2)
Math::inv2(A.storage(), this->values);
else if (this->cols() == 3)
Math::inv3(A.storage(), this->values);
else
Math::inv(this->cols(), A.storage(), this->values);
}
inline Matrix inverse() {
Matrix inv(this->rows(), this->cols());
inv.inverse(*this);
return inv;
}
/* --------------------------------------------------------------------- */
inline T det() const {
AKANTU_DEBUG_ASSERT(this->cols() == this->rows(),
"inv is not a valid operation on a rectangular matrix");
if (this->cols() == 1)
return *(this->values);
else if (this->cols() == 2)
return Math::det2(this->values);
else if (this->cols() == 3)
return Math::det3(this->values);
else
return Math::det(this->cols(), this->values);
}
/* --------------------------------------------------------------------- */
inline T doubleDot(const Matrix<T> & other) const {
AKANTU_DEBUG_ASSERT(
this->cols() == this->rows(),
"doubleDot is not a valid operation on a rectangular matrix");
if (this->cols() == 1)
return *(this->values) * *(other.storage());
else if (this->cols() == 2)
return Math::matrixDoubleDot22(this->values, other.storage());
else if (this->cols() == 3)
return Math::matrixDoubleDot33(this->values, other.storage());
else
AKANTU_ERROR("doubleDot is not defined for other spatial dimensions"
<< " than 1, 2 or 3.");
return T();
}
/* ---------------------------------------------------------------------- */
/// function to print the containt of the class
virtual void printself(std::ostream & stream, int indent = 0) const {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << "[";
for (UInt i = 0; i < this->n[0]; ++i) {
if (i != 0)
stream << ", ";
stream << "[";
for (UInt j = 0; j < this->n[1]; ++j) {
if (j != 0)
stream << ", ";
stream << operator()(i, j);
}
stream << "]";
}
stream << "]";
};
};
/* ------------------------------------------------------------------------ */
template <typename T>
template <bool tr_A>
inline void Vector<T>::mul(const Matrix<T> & A, const Vector<T> & x,
Real alpha) {
#ifndef AKANTU_NDEBUG
UInt n = x.size();
if (tr_A) {
AKANTU_DEBUG_ASSERT(n == A.rows(),
"matrix and vector to multiply have no fit dimensions");
AKANTU_DEBUG_ASSERT(this->size() == A.cols(),
"matrix and vector to multiply have no fit dimensions");
} else {
AKANTU_DEBUG_ASSERT(n == A.cols(),
"matrix and vector to multiply have no fit dimensions");
AKANTU_DEBUG_ASSERT(this->size() == A.rows(),
"matrix and vector to multiply have no fit dimensions");
}
#endif
Math::matVectMul<tr_A>(A.rows(), A.cols(), alpha, A.storage(), x.storage(),
0., this->storage());
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const Matrix<T> & _this) {
_this.printself(stream);
return stream;
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const Vector<T> & _this) {
_this.printself(stream);
return stream;
}
/* ------------------------------------------------------------------------ */
/* Tensor3 */
/* ------------------------------------------------------------------------ */
template <typename T> class Tensor3 : public TensorStorage<T, 3, Tensor3<T>> {
using parent = TensorStorage<T, 3, Tensor3<T>>;
public:
using value_type = typename parent::value_type;
using proxy = Tensor3Proxy<T>;
public:
Tensor3() : parent(){};
Tensor3(UInt m, UInt n, UInt p, const T & def = T()) : parent(m, n, p, def) {}
Tensor3(T * data, UInt m, UInt n, UInt p) : parent(data, m, n, p) {}
Tensor3(const Tensor3 & src, bool deep_copy = true)
: parent(src, deep_copy) {}
Tensor3(const proxy & src) : parent(src) {}
public:
/* ------------------------------------------------------------------------ */
inline Tensor3 & operator=(const Tensor3 & src) {
parent::operator=(src);
return *this;
}
/* ---------------------------------------------------------------------- */
inline T & operator()(UInt i, UInt j, UInt k) {
AKANTU_DEBUG_ASSERT(
(i < this->n[0]) && (j < this->n[1]) && (k < this->n[2]),
"Access out of the tensor3! "
<< "You are trying to access the element "
<< "(" << i << ", " << j << ", " << k << ") in a tensor of size ("
<< this->n[0] << ", " << this->n[1] << ", " << this->n[2] << ")");
return *(this->values + (k * this->n[0] + i) * this->n[1] + j);
}
inline const T & operator()(UInt i, UInt j, UInt k) const {
AKANTU_DEBUG_ASSERT(
(i < this->n[0]) && (j < this->n[1]) && (k < this->n[2]),
"Access out of the tensor3! "
<< "You are trying to access the element "
<< "(" << i << ", " << j << ", " << k << ") in a tensor of size ("
<< this->n[0] << ", " << this->n[1] << ", " << this->n[2] << ")");
return *(this->values + (k * this->n[0] + i) * this->n[1] + j);
}
inline MatrixProxy<T> operator()(UInt k) {
AKANTU_DEBUG_ASSERT((k < this->n[2]),
"Access out of the tensor3! "
<< "You are trying to access the slice " << k
<< " in a tensor3 of size (" << this->n[0] << ", "
<< this->n[1] << ", " << this->n[2] << ")");
return MatrixProxy<T>(this->values + k * this->n[0] * this->n[1],
this->n[0], this->n[1]);
}
inline const MatrixProxy<T> operator()(UInt k) const {
AKANTU_DEBUG_ASSERT((k < this->n[2]),
"Access out of the tensor3! "
<< "You are trying to access the slice " << k
<< " in a tensor3 of size (" << this->n[0] << ", "
<< this->n[1] << ", " << this->n[2] << ")");
return MatrixProxy<T>(this->values + k * this->n[0] * this->n[1],
this->n[0], this->n[1]);
}
inline MatrixProxy<T> operator[](UInt k) {
return MatrixProxy<T>(this->values + k * this->n[0] * this->n[1],
this->n[0], this->n[1]);
}
inline const MatrixProxy<T> operator[](UInt k) const {
return MatrixProxy<T>(this->values + k * this->n[0] * this->n[1],
this->n[0], this->n[1]);
}
};
/* -------------------------------------------------------------------------- */
// support operations for the creation of other vectors
/* -------------------------------------------------------------------------- */
template <typename T>
Vector<T> operator*(const T & scalar, const Vector<T> & a) {
Vector<T> r(a);
r *= scalar;
return r;
}
template <typename T>
Vector<T> operator*(const Vector<T> & a, const T & scalar) {
Vector<T> r(a);
r *= scalar;
return r;
}
template <typename T>
Vector<T> operator/(const Vector<T> & a, const T & scalar) {
Vector<T> r(a);
r /= scalar;
return r;
}
template <typename T>
Vector<T> operator*(const Vector<T> & a, const Vector<T> & b) {
Vector<T> r(a);
r *= b;
return r;
}
template <typename T>
Vector<T> operator+(const Vector<T> & a, const Vector<T> & b) {
Vector<T> r(a);
r += b;
return r;
}
template <typename T>
Vector<T> operator-(const Vector<T> & a, const Vector<T> & b) {
Vector<T> r(a);
r -= b;
return r;
}
template <typename T>
Vector<T> operator*(const Matrix<T> & A, const Vector<T> & b) {
Vector<T> r(b.size());
r.template mul<false>(A, b);
return r;
}
/* -------------------------------------------------------------------------- */
template <typename T>
Matrix<T> operator*(const T & scalar, const Matrix<T> & a) {
Matrix<T> r(a);
r *= scalar;
return r;
}
template <typename T>
Matrix<T> operator*(const Matrix<T> & a, const T & scalar) {
Matrix<T> r(a);
r *= scalar;
return r;
}
template <typename T>
Matrix<T> operator/(const Matrix<T> & a, const T & scalar) {
Matrix<T> r(a);
r /= scalar;
return r;
}
template <typename T>
Matrix<T> operator+(const Matrix<T> & a, const Matrix<T> & b) {
Matrix<T> r(a);
r += b;
return r;
}
template <typename T>
Matrix<T> operator-(const Matrix<T> & a, const Matrix<T> & b) {
Matrix<T> r(a);
r -= b;
return r;
}
} // namespace akantu
#include <iterator>
namespace std {
template <typename R>
struct iterator_traits<::akantu::types::details::vector_iterator<R>> {
protected:
using iterator = ::akantu::types::details::vector_iterator<R>;
public:
using iterator_category = typename iterator::iterator_category;
using value_type = typename iterator::value_type;
using difference_type = typename iterator::difference_type;
using pointer = typename iterator::pointer;
using reference = typename iterator::reference;
};
template <typename Mat>
struct iterator_traits<::akantu::types::details::column_iterator<Mat>> {
protected:
using iterator = ::akantu::types::details::column_iterator<Mat>;
public:
using iterator_category = typename iterator::iterator_category;
using value_type = typename iterator::value_type;
using difference_type = typename iterator::difference_type;
using pointer = typename iterator::pointer;
using reference = typename iterator::reference;
};
} // namespace std
#endif /* __AKANTU_AKA_TYPES_HH__ */
diff --git a/src/common/aka_visitor.hh b/src/common/aka_visitor.hh
index ad43690ff..30bb4ec45 100644
--- a/src/common/aka_visitor.hh
+++ b/src/common/aka_visitor.hh
@@ -1,164 +1,164 @@
/**
* @file aka_visitor.hh
*
* @author Alejandro M. Aragón <alejandro.aragon@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Mon Jun 19 2017
*
* @brief Objects that support the visitor design pattern
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_VISITOR_HH__
#define __AKANTU_VISITOR_HH__
#include "aka_typelist.hh"
namespace akantu {
///////////////////////////////////////////////////////////////////////////
// visitor class template, adapted from the Andrei Alexandrescu's
// "Modern C++ Design"
enum Visit_type { Mutable, Immutable };
template <class T, typename R = void, Visit_type = Mutable> class StrictVisitor;
template <class T, typename R> class StrictVisitor<T, R, Mutable> {
public:
typedef R ReturnType;
typedef T ParamType;
virtual ~StrictVisitor() {}
virtual ReturnType Visit(ParamType &) = 0;
};
template <class T, typename R> class StrictVisitor<T, R, Immutable> {
public:
typedef R ReturnType;
typedef const T ParamType;
virtual ~StrictVisitor() {}
virtual ReturnType Visit(ParamType &) = 0;
};
/// class template StrictVisitor (specialization)
template <class Head, class Tail, typename R>
class StrictVisitor<Typelist<Head, Tail>, R, Mutable>
: public StrictVisitor<Head, R, Mutable>,
public StrictVisitor<Tail, R, Mutable> {
public:
typedef R ReturnType;
typedef Head ParamType;
// using StrictVisitor<Head, R>::Visit;
// using StrictVisitor<Tail, R>::Visit;
};
template <class Head, typename R>
class StrictVisitor<Typelist<Head, Null_type>, R, Mutable>
: public StrictVisitor<Head, R, Mutable> {
public:
typedef R ReturnType;
typedef Head ParamType;
using StrictVisitor<Head, R, Mutable>::Visit;
};
template <class Head, class Tail, typename R>
class StrictVisitor<Typelist<Head, Tail>, R, Immutable>
: public StrictVisitor<Head, R, Immutable>,
public StrictVisitor<Tail, R, Immutable> {
public:
typedef R ReturnType;
typedef Head ParamType;
// using StrictVisitor<Head, R>::Visit;
// using StrictVisitor<Tail, R>::Visit;
};
template <class Head, typename R>
class StrictVisitor<Typelist<Head, Null_type>, R, Immutable>
: public StrictVisitor<Head, R, Immutable> {
public:
typedef R ReturnType;
typedef Head ParamType;
using StrictVisitor<Head, R, Immutable>::Visit;
};
////////////////////////////////////////////////////////////////////////////////
// class template NonStrictVisitor
// Implements non-strict visitation (you can implement only part of the Visit
// functions)
//
template <class R> struct DefaultFunctor {
template <class T> R operator()(T &) { return R(); }
};
template <class T, typename R = void, Visit_type V = Mutable,
class F = DefaultFunctor<R>>
class BaseVisitorImpl;
template <class Head, class Tail, typename R, Visit_type V, class F>
class BaseVisitorImpl<Typelist<Head, Tail>, R, V, F>
: public StrictVisitor<Head, R, V>, public BaseVisitorImpl<Tail, R, V, F> {
public:
typedef typename StrictVisitor<Head, R, V>::ParamType ParamType;
virtual R Visit(ParamType & h) { return F()(h); }
};
template <class Head, typename R, Visit_type V, class F>
class BaseVisitorImpl<Typelist<Head, Null_type>, R, V, F>
: public StrictVisitor<Head, R, V> {
public:
typedef typename StrictVisitor<Head, R, V>::ParamType ParamType;
virtual R Visit(ParamType & h) { return F()(h); }
};
/// Visitor
template <class R> struct Strict {};
template <typename R, class TList, Visit_type V = Mutable,
template <class> class FunctorPolicy = DefaultFunctor>
class Visitor : public BaseVisitorImpl<TList, R, V, FunctorPolicy<R>> {
public:
typedef R ReturnType;
template <class Visited> ReturnType GenericVisit(Visited & host) {
StrictVisitor<Visited, ReturnType, V> & subObj = *this;
return subObj.Visit(host);
}
};
template <typename R, class TList, Visit_type V>
class Visitor<R, TList, V, Strict> : public StrictVisitor<TList, R, V> {
public:
typedef R ReturnType;
template <class Visited> ReturnType GenericVisit(Visited & host) {
StrictVisitor<Visited, ReturnType, V> & subObj = *this;
return subObj.Visit(host);
}
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_VISITOR_HH__ */
diff --git a/src/common/aka_voigthelper.cc b/src/common/aka_voigthelper.cc
index ddf66d62e..56aa8e3c6 100644
--- a/src/common/aka_voigthelper.cc
+++ b/src/common/aka_voigthelper.cc
@@ -1,68 +1,68 @@
/**
* @file aka_voigthelper.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Dec 20 2013
* @date last modification: Mon Jun 19 2017
*
* @brief Voigt indices
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_voigthelper.hh"
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/* clang-format off */
template <> const UInt VoigtHelper<1>::mat[][1] = {{0}};
template <> const UInt VoigtHelper<2>::mat[][2] = {{0, 2},
{3, 1}};
template <> const UInt VoigtHelper<3>::mat[][3] = {{0, 5, 4},
{8, 1, 3},
{7, 6, 2}};
template <> const UInt VoigtHelper<1>::vec[][2] = {{0, 0}};
template <> const UInt VoigtHelper<2>::vec[][2] = {{0, 0},
{1, 1},
{0, 1},
{1, 0}};
template <> const UInt VoigtHelper<3>::vec[][2] = {{0, 0},
{1, 1},
{2, 2},
{1, 2},
{0, 2},
{0, 1},
{2, 1},
{2, 0},
{1, 0}};
template <> const Real VoigtHelper<1>::factors[] = {1.};
template <> const Real VoigtHelper<2>::factors[] = {1., 1., 2.};
template <> const Real VoigtHelper<3>::factors[] = {1., 1., 1.,
2., 2., 2.};
/* clang-format on */
-} // akantu
+} // namespace akantu
diff --git a/src/common/aka_voigthelper.hh b/src/common/aka_voigthelper.hh
index ac3dfd893..535aec8c6 100644
--- a/src/common/aka_voigthelper.hh
+++ b/src/common/aka_voigthelper.hh
@@ -1,79 +1,79 @@
/**
* @file aka_voigthelper.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Dec 20 2013
* @date last modification: Mon Jan 29 2018
*
* @brief Helper file for Voigt notation
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKA_VOIGTHELPER_HH__
#define __AKA_VOIGTHELPER_HH__
#include "aka_common.hh"
#include "aka_types.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim> class VoigtHelper {
static_assert(dim != 0, "Cannot be 0D");
public:
/// transfer the B matrix to a Voigt notation B matrix
inline static void transferBMatrixToSymVoigtBMatrix(
const Matrix<Real> & B, Matrix<Real> & Bvoigt, UInt nb_nodes_per_element);
/// transfer the BNL matrix to a Voigt notation B matrix (See Bathe et al.
/// IJNME vol 9, 1975)
inline static void transferBMatrixToBNL(const Matrix<Real> & B,
Matrix<Real> & Bvoigt,
UInt nb_nodes_per_element);
/// transfer the BL2 matrix to a Voigt notation B matrix (See Bathe et al.
/// IJNME vol 9, 1975)
inline static void transferBMatrixToBL2(const Matrix<Real> & B,
const Matrix<Real> & grad_u,
Matrix<Real> & Bvoigt,
UInt nb_nodes_per_element);
public:
static constexpr UInt size{(dim * (dim - 1)) / 2 + dim};
// matrix of vector index I as function of tensor indices i,j
static const UInt mat[dim][dim];
// array of matrix indices ij as function of vector index I
static const UInt vec[dim * dim][2];
// factors to multiply the strain by for voigt notation
static const Real factors[size];
};
-} // akantu
+} // namespace akantu
#include "aka_voigthelper_tmpl.hh"
#endif
diff --git a/src/common/aka_voigthelper_tmpl.hh b/src/common/aka_voigthelper_tmpl.hh
index a7f977c1e..ede9b9ab8 100644
--- a/src/common/aka_voigthelper_tmpl.hh
+++ b/src/common/aka_voigthelper_tmpl.hh
@@ -1,178 +1,178 @@
/**
* @file aka_voigthelper_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Dec 20 2013
* @date last modification: Wed Dec 06 2017
*
* @brief implementation of the voight helper
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/**
* @file aka_voigthelper_tmpl.hh
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @date Wed Nov 16 12:22:58 2016
*/
/* -------------------------------------------------------------------------- */
#include "aka_voigthelper.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AKA_VOIGTHELPER_TMPL_HH__
#define __AKANTU_AKA_VOIGTHELPER_TMPL_HH__
namespace akantu {
template <UInt dim> constexpr UInt VoigtHelper<dim>::size;
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void VoigtHelper<dim>::transferBMatrixToSymVoigtBMatrix(
const Matrix<Real> & B, Matrix<Real> & Bvoigt, UInt nb_nodes_per_element) {
Bvoigt.clear();
for (UInt i = 0; i < dim; ++i)
for (UInt n = 0; n < nb_nodes_per_element; ++n)
Bvoigt(i, i + n * dim) = B(i, n);
if (dim == 2) {
/// in 2D, fill the @f$ [\frac{\partial N_i}{\partial x}, \frac{\partial
/// N_i}{\partial y}]@f$ row
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
Bvoigt(2, 1 + n * 2) = B(0, n);
Bvoigt(2, 0 + n * 2) = B(1, n);
}
}
if (dim == 3) {
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
Real dndx = B(0, n);
Real dndy = B(1, n);
Real dndz = B(2, n);
/// in 3D, fill the @f$ [0, \frac{\partial N_i}{\partial y},
/// \frac{N_i}{\partial z}]@f$ row
Bvoigt(3, 1 + n * 3) = dndz;
Bvoigt(3, 2 + n * 3) = dndy;
/// in 3D, fill the @f$ [\frac{\partial N_i}{\partial x}, 0,
/// \frac{N_i}{\partial z}]@f$ row
Bvoigt(4, 0 + n * 3) = dndz;
Bvoigt(4, 2 + n * 3) = dndx;
/// in 3D, fill the @f$ [\frac{\partial N_i}{\partial x},
/// \frac{N_i}{\partial y}, 0]@f$ row
Bvoigt(5, 0 + n * 3) = dndy;
Bvoigt(5, 1 + n * 3) = dndx;
}
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void VoigtHelper<dim>::transferBMatrixToBNL(const Matrix<Real> & B,
Matrix<Real> & Bvoigt,
UInt nb_nodes_per_element) {
Bvoigt.clear();
// see Finite element formulations for large deformation dynamic analysis,
// Bathe et al. IJNME vol 9, 1975, page 364 B_{NL}
for (UInt i = 0; i < dim; ++i) {
for (UInt m = 0; m < nb_nodes_per_element; ++m) {
for (UInt n = 0; n < dim; ++n) {
// std::cout << B(n, m) << std::endl;
Bvoigt(i * dim + n, m * dim + i) = B(n, m);
}
}
}
// TODO: Verify the 2D and 1D case
}
/* -------------------------------------------------------------------------- */
template <>
inline void VoigtHelper<1>::transferBMatrixToBL2(const Matrix<Real> & B,
const Matrix<Real> & grad_u,
Matrix<Real> & Bvoigt,
UInt nb_nodes_per_element) {
Bvoigt.clear();
for (UInt j = 0; j < nb_nodes_per_element; ++j)
Bvoigt(0, j) = grad_u(0, 0) * B(0, j);
}
/* -------------------------------------------------------------------------- */
template <>
inline void VoigtHelper<3>::transferBMatrixToBL2(const Matrix<Real> & B,
const Matrix<Real> & grad_u,
Matrix<Real> & Bvoigt,
UInt nb_nodes_per_element) {
Bvoigt.clear();
for (UInt i = 0; i < 3; ++i)
for (UInt j = 0; j < nb_nodes_per_element; ++j)
for (UInt k = 0; k < 3; ++k)
Bvoigt(i, j * 3 + k) = grad_u(k, i) * B(i, j);
for (UInt i = 3; i < 6; ++i) {
for (UInt j = 0; j < nb_nodes_per_element; ++j) {
for (UInt k = 0; k < 3; ++k) {
UInt aux = i - 3;
for (UInt m = 0; m < 3; ++m) {
if (m != aux) {
UInt index1 = m;
UInt index2 = 3 - m - aux;
Bvoigt(i, j * 3 + k) += grad_u(k, index1) * B(index2, j);
}
}
}
}
}
}
/* -------------------------------------------------------------------------- */
template <>
inline void VoigtHelper<2>::transferBMatrixToBL2(const Matrix<Real> & B,
const Matrix<Real> & grad_u,
Matrix<Real> & Bvoigt,
UInt nb_nodes_per_element) {
Bvoigt.clear();
for (UInt i = 0; i < 2; ++i)
for (UInt j = 0; j < nb_nodes_per_element; ++j)
for (UInt k = 0; k < 2; ++k)
Bvoigt(i, j * 2 + k) = grad_u(k, i) * B(i, j);
for (UInt j = 0; j < nb_nodes_per_element; ++j) {
for (UInt k = 0; k < 2; ++k) {
for (UInt m = 0; m < 2; ++m) {
UInt index1 = m;
UInt index2 = (2 - 1) - m;
Bvoigt(2, j * 2 + k) += grad_u(k, index1) * B(index2, j);
}
}
}
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_AKA_VOIGTHELPER_TMPL_HH__ */
diff --git a/src/fe_engine/element.hh b/src/fe_engine/element.hh
index 03c29f28d..4ae23a2cf 100644
--- a/src/fe_engine/element.hh
+++ b/src/fe_engine/element.hh
@@ -1,118 +1,118 @@
/**
* @file element.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Tue Jan 23 2018
*
* @brief Element helper class
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_HH__
#define __AKANTU_ELEMENT_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Element */
/* -------------------------------------------------------------------------- */
class Element {
public:
ElementType type;
UInt element;
GhostType ghost_type;
// ElementKind kind;
// ElementType type{_not_defined};
// UInt element{0};
// GhostType ghost_type{_not_ghost};
// ElementKind kind{_ek_regular};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
inline ElementKind kind() const;
inline bool operator==(const Element & elem) const {
return std::tie(type, element, ghost_type) ==
std::tie(elem.type, elem.element, elem.ghost_type);
}
inline bool operator!=(const Element & elem) const {
return std::tie(type, element, ghost_type) !=
std::tie(elem.type, elem.element, elem.ghost_type);
}
// inline bool operator==(const Element & elem) const {
// return ((element == elem.element) && (type == elem.type) &&
// (ghost_type == elem.ghost_type) && (kind == elem.kind));
// }
// inline bool operator!=(const Element & elem) const {
// return ((element != elem.element) || (type != elem.type) ||
// (ghost_type != elem.ghost_type) || (kind != elem.kind));
// }
inline bool operator<(const Element & rhs) const;
};
namespace {
const Element ElementNull{_not_defined, UInt(-1), _casper};
// Element{_not_defined, 0, _casper, _ek_not_defined};
-}
+} // namespace
/* -------------------------------------------------------------------------- */
inline bool Element::operator<(const Element & rhs) const {
// bool res =
// (rhs == ElementNull) ||
// ((this->kind < rhs.kind) ||
// ((this->kind == rhs.kind) &&
// ((this->ghost_type < rhs.ghost_type) ||
// ((this->ghost_type == rhs.ghost_type) &&
// ((this->type < rhs.type) ||
// ((this->type == rhs.type) && (this->element < rhs.element)))))));
return ((rhs == ElementNull) ||
std::tie(ghost_type, type, element) <
std::tie(rhs.ghost_type, rhs.type, rhs.element));
}
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream, const Element & _this) {
- if(_this == ElementNull) {
+ if (_this == ElementNull) {
stream << "ElementNull";
return stream;
}
stream << "Element [" << _this.type << ", " << _this.element << ", "
<< _this.ghost_type << "]";
return stream;
}
} // namespace akantu
#endif /* __AKANTU_ELEMENT_HH__ */
diff --git a/src/fe_engine/element_class.hh b/src/fe_engine/element_class.hh
index f7bdd966d..ebbd7cc3a 100644
--- a/src/fe_engine/element_class.hh
+++ b/src/fe_engine/element_class.hh
@@ -1,420 +1,420 @@
/**
* @file element_class.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief Declaration of the ElementClass main class and the
* Integration and Interpolation elements
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_types.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_CLASS_HH__
#define __AKANTU_ELEMENT_CLASS_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/// default element class structure
template <ElementType element_type> struct ElementClassProperty {
static const GeometricalType geometrical_type{_gt_not_defined};
static const InterpolationType interpolation_type{_itp_not_defined};
static const ElementKind element_kind{_ek_regular};
static const UInt spatial_dimension{0};
static const GaussIntegrationType gauss_integration_type{_git_not_defined};
static const UInt polynomial_degree{0};
};
/// Macro to generate the element class structures for different element types
#define AKANTU_DEFINE_ELEMENT_CLASS_PROPERTY(elem_type, geom_type, \
interp_type, elem_kind, sp, \
gauss_int_type, min_int_order) \
template <> struct ElementClassProperty<elem_type> { \
static const GeometricalType geometrical_type{geom_type}; \
static const InterpolationType interpolation_type{interp_type}; \
static const ElementKind element_kind{elem_kind}; \
static const UInt spatial_dimension{sp}; \
static const GaussIntegrationType gauss_integration_type{gauss_int_type}; \
static const UInt polynomial_degree{min_int_order}; \
}
/* -------------------------------------------------------------------------- */
/* Geometry */
/* -------------------------------------------------------------------------- */
/// Default GeometricalShape structure
template <GeometricalType geometrical_type> struct GeometricalShape {
static const GeometricalShapeType shape{_gst_point};
};
/// Templated GeometricalShape with function contains
template <GeometricalShapeType shape> struct GeometricalShapeContains {
/// Check if the point (vector in 2 and 3D) at natural coordinate coor
template <class vector_type>
static inline bool contains(const vector_type & coord);
};
/// Macro to generate the GeometricalShape structures for different geometrical
/// types
#define AKANTU_DEFINE_SHAPE(geom_type, geom_shape) \
template <> struct GeometricalShape<geom_type> { \
static const GeometricalShapeType shape{geom_shape}; \
}
AKANTU_DEFINE_SHAPE(_gt_hexahedron_20, _gst_square);
AKANTU_DEFINE_SHAPE(_gt_hexahedron_8, _gst_square);
AKANTU_DEFINE_SHAPE(_gt_pentahedron_15, _gst_prism);
AKANTU_DEFINE_SHAPE(_gt_pentahedron_6, _gst_prism);
AKANTU_DEFINE_SHAPE(_gt_point, _gst_point);
AKANTU_DEFINE_SHAPE(_gt_quadrangle_4, _gst_square);
AKANTU_DEFINE_SHAPE(_gt_quadrangle_8, _gst_square);
AKANTU_DEFINE_SHAPE(_gt_segment_2, _gst_square);
AKANTU_DEFINE_SHAPE(_gt_segment_3, _gst_square);
AKANTU_DEFINE_SHAPE(_gt_tetrahedron_10, _gst_triangle);
AKANTU_DEFINE_SHAPE(_gt_tetrahedron_4, _gst_triangle);
AKANTU_DEFINE_SHAPE(_gt_triangle_3, _gst_triangle);
AKANTU_DEFINE_SHAPE(_gt_triangle_6, _gst_triangle);
/* -------------------------------------------------------------------------- */
template <GeometricalType geometrical_type>
struct GeometricalElementProperty {};
template <ElementType element_type>
struct ElementClassExtraGeometryProperties {};
/* -------------------------------------------------------------------------- */
/// Templated GeometricalElement with function getInradius
template <GeometricalType geometrical_type,
GeometricalShapeType shape =
GeometricalShape<geometrical_type>::shape>
class GeometricalElement {
using geometrical_property = GeometricalElementProperty<geometrical_type>;
public:
/// compute the in-radius: \todo should be renamed for characteristic length
static inline Real getInradius(__attribute__((unused))
const Matrix<Real> & coord) {
AKANTU_TO_IMPLEMENT();
}
/// true if the natural coordinates are in the element
template <class vector_type>
static inline bool contains(const vector_type & coord);
public:
static AKANTU_GET_MACRO_NOT_CONST(SpatialDimension,
geometrical_property::spatial_dimension,
UInt);
static AKANTU_GET_MACRO_NOT_CONST(NbNodesPerElement,
geometrical_property::nb_nodes_per_element,
UInt);
static inline constexpr auto getNbFacetTypes() {
return geometrical_property::nb_facet_types;
};
static inline UInt getNbFacetsPerElement(UInt t);
static inline UInt getNbFacetsPerElement();
static inline constexpr auto getFacetLocalConnectivityPerElement(UInt t = 0);
};
/* -------------------------------------------------------------------------- */
/* Interpolation */
/* -------------------------------------------------------------------------- */
/// default InterpolationProperty structure
template <InterpolationType interpolation_type> struct InterpolationProperty {};
/// Macro to generate the InterpolationProperty structures for different
/// interpolation types
#define AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(itp_type, itp_kind, \
nb_nodes, ndim) \
template <> struct InterpolationProperty<itp_type> { \
static constexpr InterpolationKind kind{itp_kind}; \
static constexpr UInt nb_nodes_per_element{nb_nodes}; \
static constexpr UInt natural_space_dimension{ndim}; \
}
/* -------------------------------------------------------------------------- */
/// Generic (templated by the enum InterpolationType which specifies the order
/// and the dimension of the interpolation) class handling the elemental
/// interpolation
template <InterpolationType interpolation_type,
InterpolationKind kind =
InterpolationProperty<interpolation_type>::kind>
class InterpolationElement {
public:
using interpolation_property = InterpolationProperty<interpolation_type>;
/// compute the shape values for a given set of points in natural coordinates
static inline void computeShapes(const Matrix<Real> & natural_coord,
Matrix<Real> & N);
/// compute the shape values for a given point in natural coordinates
template <class vector_type>
static inline void computeShapes(const vector_type &, vector_type &) {
AKANTU_TO_IMPLEMENT();
}
/**
* compute @f$ B_{ij} = \frac{\partial N_j}{\partial S_i} @f$ the variation of
* shape functions along with variation of natural coordinates on a given set
* of points in natural coordinates
*/
static inline void computeDNDS(const Matrix<Real> & natural_coord,
Tensor3<Real> & dnds);
/**
* compute @f$ B_{ij} = \frac{\partial N_j}{\partial S_i} @f$ the variation of
* shape functions along with
* variation of natural coordinates on a given point in natural
* coordinates
*/
template <class vector_type, class matrix_type>
static inline void computeDNDS(const vector_type &, matrix_type &) {
AKANTU_TO_IMPLEMENT();
}
/**
* compute @f$ @f$
**/
static inline void computeDN2DS2(const Matrix<Real> & natural_coord,
Tensor3<Real> & dn2ds2);
/**
* compute @f$ B_{ij} = \frac{\partial N_j}{\partial S_i} @f$ the
* second variation of
* shape functions along with
* variation of natural coordinates on a given point in natural
* coordinates
*/
template <class vector_type, class matrix_type>
static inline void computeDN2DS2(const vector_type &, matrix_type &) {
AKANTU_TO_IMPLEMENT();
}
/// compute jacobian (or integration variable change factor) for a given point
/// in the case of spatial_dimension != natural_space_dimension
static inline void computeSpecialJacobian(const Matrix<Real> &, Real &) {
AKANTU_TO_IMPLEMENT();
}
/// interpolate a field given (arbitrary) natural coordinates
static inline void
interpolateOnNaturalCoordinates(const Vector<Real> & natural_coords,
const Matrix<Real> & nodal_values,
Vector<Real> & interpolated);
/// interpolate a field given the shape functions on the interpolation point
static inline void interpolate(const Matrix<Real> & nodal_values,
const Vector<Real> & shapes,
Vector<Real> & interpolated);
/// interpolate a field given the shape functions on the interpolations points
static inline void interpolate(const Matrix<Real> & nodal_values,
const Matrix<Real> & shapes,
Matrix<Real> & interpolated);
/// compute the gradient of a given field on the given natural coordinates
static inline void
gradientOnNaturalCoordinates(const Vector<Real> & natural_coords,
const Matrix<Real> & f, Matrix<Real> & gradient);
public:
static AKANTU_GET_MACRO_NOT_CONST(
ShapeSize,
InterpolationProperty<interpolation_type>::nb_nodes_per_element, UInt);
static AKANTU_GET_MACRO_NOT_CONST(
ShapeDerivativesSize,
(InterpolationProperty<interpolation_type>::nb_nodes_per_element *
InterpolationProperty<interpolation_type>::natural_space_dimension),
UInt);
static AKANTU_GET_MACRO_NOT_CONST(
NaturalSpaceDimension,
InterpolationProperty<interpolation_type>::natural_space_dimension, UInt);
static AKANTU_GET_MACRO_NOT_CONST(
NbNodesPerInterpolationElement,
InterpolationProperty<interpolation_type>::nb_nodes_per_element, UInt);
};
/* -------------------------------------------------------------------------- */
/* Integration */
/* -------------------------------------------------------------------------- */
template <GaussIntegrationType git_class, UInt nb_points>
struct GaussIntegrationTypeData {
/// quadrature points in natural coordinates
static Real quad_positions[];
/// weights for the Gauss integration
static Real quad_weights[];
};
template <ElementType type,
UInt n = ElementClassProperty<type>::polynomial_degree>
class GaussIntegrationElement {
public:
static UInt getNbQuadraturePoints();
static const Matrix<Real> getQuadraturePoints();
static const Vector<Real> getWeights();
};
/* -------------------------------------------------------------------------- */
/* ElementClass */
/* -------------------------------------------------------------------------- */
template <ElementType element_type,
ElementKind element_kind =
ElementClassProperty<element_type>::element_kind>
class ElementClass
: public GeometricalElement<
ElementClassProperty<element_type>::geometrical_type>,
public InterpolationElement<
ElementClassProperty<element_type>::interpolation_type> {
protected:
using geometrical_element =
GeometricalElement<ElementClassProperty<element_type>::geometrical_type>;
using interpolation_element = InterpolationElement<
ElementClassProperty<element_type>::interpolation_type>;
using element_property = ElementClassProperty<element_type>;
using interpolation_property =
typename interpolation_element::interpolation_property;
public:
/**
* compute @f$ J = \frac{\partial x_j}{\partial s_i} @f$ the variation of real
* coordinates along with variation of natural coordinates on a given point in
* natural coordinates
*/
static inline void computeJMat(const Matrix<Real> & dnds,
const Matrix<Real> & node_coords,
Matrix<Real> & J);
/**
* compute the Jacobian matrix by computing the variation of real coordinates
* along with variation of natural coordinates on a given set of points in
* natural coordinates
*/
static inline void computeJMat(const Tensor3<Real> & dnds,
const Matrix<Real> & node_coords,
Tensor3<Real> & J);
/// compute the jacobians of a serie of natural coordinates
static inline void computeJacobian(const Matrix<Real> & natural_coords,
const Matrix<Real> & node_coords,
Vector<Real> & jacobians);
/// compute jacobian (or integration variable change factor) for a set of
/// points
static inline void computeJacobian(const Tensor3<Real> & J,
Vector<Real> & jacobians);
/// compute jacobian (or integration variable change factor) for a given point
static inline void computeJacobian(const Matrix<Real> & J, Real & jacobians);
/// compute shape derivatives (input is dxds) for a set of points
static inline void computeShapeDerivatives(const Tensor3<Real> & J,
const Tensor3<Real> & dnds,
Tensor3<Real> & shape_deriv);
/// compute shape derivatives (input is dxds) for a given point
static inline void computeShapeDerivatives(const Matrix<Real> & J,
const Matrix<Real> & dnds,
Matrix<Real> & shape_deriv);
/// compute the normal of a surface defined by the function f
static inline void
computeNormalsOnNaturalCoordinates(const Matrix<Real> & coord,
Matrix<Real> & f, Matrix<Real> & normals);
/// get natural coordinates from real coordinates
static inline void inverseMap(const Vector<Real> & real_coords,
const Matrix<Real> & node_coords,
Vector<Real> & natural_coords,
Real tolerance = 1e-10);
/// get natural coordinates from real coordinates
static inline void inverseMap(const Matrix<Real> & real_coords,
const Matrix<Real> & node_coords,
Matrix<Real> & natural_coords,
Real tolerance = 1e-10);
public:
static AKANTU_GET_MACRO_NOT_CONST(Kind, element_kind, ElementKind);
static constexpr AKANTU_GET_MACRO_NOT_CONST(
SpatialDimension, ElementClassProperty<element_type>::spatial_dimension,
UInt);
using element_class_extra_geom_property =
ElementClassExtraGeometryProperties<element_type>;
static constexpr auto getP1ElementType() {
return element_class_extra_geom_property::p1_type;
}
static constexpr auto getFacetType(UInt t = 0) {
return element_class_extra_geom_property::facet_type[t];
}
static constexpr auto getFacetTypes();
};
/* -------------------------------------------------------------------------- */
} // namespace akantu
/* -------------------------------------------------------------------------- */
#include "geometrical_element_property.hh"
#include "interpolation_element_tmpl.hh"
/* -------------------------------------------------------------------------- */
#include "element_class_tmpl.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
+#include "element_class_hexahedron_8_inline_impl.cc"
#include "element_class_pentahedron_6_inline_impl.cc"
/* keep order */
-#include "element_class_hexahedron_8_inline_impl.cc"
#include "element_class_hexahedron_20_inline_impl.cc"
#include "element_class_pentahedron_15_inline_impl.cc"
#include "element_class_point_1_inline_impl.cc"
#include "element_class_quadrangle_4_inline_impl.cc"
#include "element_class_quadrangle_8_inline_impl.cc"
#include "element_class_segment_2_inline_impl.cc"
#include "element_class_segment_3_inline_impl.cc"
#include "element_class_tetrahedron_10_inline_impl.cc"
#include "element_class_tetrahedron_4_inline_impl.cc"
#include "element_class_triangle_3_inline_impl.cc"
#include "element_class_triangle_6_inline_impl.cc"
} // namespace akantu
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_STRUCTURAL_MECHANICS)
#include "element_class_structural.hh"
#endif
#if defined(AKANTU_COHESIVE_ELEMENT)
#include "cohesive_element.hh"
#endif
#if defined(AKANTU_IGFEM)
#include "element_class_igfem.hh"
#endif
#endif /* __AKANTU_ELEMENT_CLASS_HH__ */
diff --git a/src/fe_engine/element_classes/element_class_hermite_inline_impl.cc b/src/fe_engine/element_classes/element_class_hermite_inline_impl.cc
index 33ac526aa..715e11fa2 100644
--- a/src/fe_engine/element_classes/element_class_hermite_inline_impl.cc
+++ b/src/fe_engine/element_classes/element_class_hermite_inline_impl.cc
@@ -1,179 +1,179 @@
/**
* @file element_class_hermite_inline_impl.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Nov 10 2017
* @date last modification: Mon Feb 19 2018
*
* @brief Specialization of the element_class class for the type
* _hermite
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
*
* You should have received a copy of the GNU Lesser General Public License
along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* @verbatim
--x-----q1----|----q2-----x---> x
-1 0 1
@endverbatim
*
* @subsection shapes Shape functions
* @f[
* \begin{array}{ll}
* M_1(\xi) &= 1/4(\xi^{3}/-3\xi+2)\\
* M_2(\xi) &= -1/4(\xi^{3}-3\xi-2)
* \end{array}
*
* \begin{array}{ll}
* L_1(\xi) &= 1/4(\xi^{3}-\xi^{2}-\xi+1)\\
* L_2(\xi) &= 1/4(\xi^{3}+\xi^{2}-\xi-1)
* \end{array}
*
* \begin{array}{ll}
* M'_1(\xi) &= 3/4(\xi^{2}-1)\\
* M'_2(\xi) &= -3/4(\xi^{2}-1)
* \end{array}
*
* \begin{array}{ll}
* L'_1(\xi) &= 1/4(3\xi^{2}-2\xi-1)\\
* L'_2(\xi) &= 1/4(3\xi^{2}+2\xi-1)
* \end{array}
*@f]
*
* @subsection dnds Shape derivatives
*
*@f[
* \begin{array}{ll}
* N'_1(\xi) &= -1/2\\
* N'_2(\xi) &= 1/2
* \end{array}]
*
* \begin{array}{ll}
* -M''_1(\xi) &= -3\xi/2\\
* -M''_2(\xi) &= 3\xi/2\\
* \end{array}
*
* \begin{array}{ll}
* -L''_1(\xi) &= -1/2a(3\xi/a-1)\\
* -L''_2(\xi) &= -1/2a(3\xi/a+1)
* \end{array}
*@f]
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_static_if.hh"
#include "element_class_structural.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_CLASS_HERMITE_INLINE_IMPL_CC__
#define __AKANTU_ELEMENT_CLASS_HERMITE_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_STRUCTURAL_INTERPOLATION_TYPE_PROPERTY(_itp_hermite_2,
_itp_lagrange_segment_2, 2,
1, 4);
/* -------------------------------------------------------------------------- */
namespace {
namespace details {
inline Real computeLength(const Matrix<Real> & real_coord) {
Vector<Real> x1 = real_coord(0);
Vector<Real> x2 = real_coord(1);
return x1.distance(x2);
}
inline void computeShapes(const Vector<Real> & natural_coords, Real a,
Matrix<Real> & N) {
/// natural coordinate
Real xi = natural_coords(0);
// Cubic Hermite splines interpolating displacement
auto M1 = 1. / 4. * Math::pow<2>(xi - 1) * (xi + 2);
auto M2 = 1. / 4. * Math::pow<2>(xi + 1) * (2 - xi);
auto L1 = a / 4. * Math::pow<2>(xi - 1) * (xi + 1);
auto L2 = a / 4. * Math::pow<2>(xi + 1) * (xi - 1);
#if 1 // Version where we also interpolate the rotations
// Derivatives (with respect to x) of previous functions interpolating
// rotations
auto M1_ = 3. / (4. * a) * (xi * xi - 1);
auto M2_ = 3. / (4. * a) * (1 - xi * xi);
auto L1_ = 1 / 4. * (3 * xi * xi - 2 * xi - 1);
auto L2_ = 1 / 4. * (3 * xi * xi + 2 * xi - 1);
// clang-format off
// v1 t1 v2 t2
N = {{M1 , L1 , M2 , L2}, // displacement interpolation
{M1_, L1_, M2_, L2_}}; // rotation interpolation
-// clang-format on
+ // clang-format on
#else // Version where we only interpolate displacements
// clang-format off
// v1 t1 v2 t2
N = {{M1, L1, M2, L2}};
// clang-format on
#endif
}
/* ---------------------------------------------------------------------- */
inline void computeDNDS(const Vector<Real> & natural_coords, Real a,
Matrix<Real> & B) {
// natural coordinate
Real xi = natural_coords(0);
// Derivatives with respect to xi for rotations
auto M1__ = 3. / 2. * xi;
auto M2__ = 3. / 2. * (-xi);
auto L1__ = a / 2. * (3 * xi - 1);
auto L2__ = a / 2. * (3 * xi + 1);
// v1 t1 v2 t2
B = {{M1__, L1__, M2__, L2__}}; // computing curvature : {chi} = [B]{d}
B /= a; // to account for first order deriv w/r to x
}
} // namespace details
} // namespace
/* -------------------------------------------------------------------------- */
template <>
inline void
InterpolationElement<_itp_hermite_2, _itk_structural>::computeShapes(
const Vector<Real> & natural_coords, const Matrix<Real> & real_coord,
Matrix<Real> & N) {
auto L = details::computeLength(real_coord);
details::computeShapes(natural_coords, L / 2, N);
}
/* -------------------------------------------------------------------------- */
template <>
inline void InterpolationElement<_itp_hermite_2, _itk_structural>::computeDNDS(
const Vector<Real> & natural_coords, const Matrix<Real> & real_coord,
Matrix<Real> & B) {
auto L = details::computeLength(real_coord);
details::computeDNDS(natural_coords, L / 2, B);
}
} // namespace akantu
#endif /* __AKANTU_ELEMENT_CLASS_HERMITE_INLINE_IMPL_CC__ */
diff --git a/src/fe_engine/element_classes/element_class_hexahedron_20_inline_impl.cc b/src/fe_engine/element_classes/element_class_hexahedron_20_inline_impl.cc
index 25e757570..6e4dfb5aa 100644
--- a/src/fe_engine/element_classes/element_class_hexahedron_20_inline_impl.cc
+++ b/src/fe_engine/element_classes/element_class_hexahedron_20_inline_impl.cc
@@ -1,220 +1,220 @@
/**
* @file element_class_hexahedron_20_inline_impl.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Sacha Laffely <sacha.laffely@epfl.ch>
* @author Damien Scantamburlo <damien.scantamburlo@epfl.ch>
*
* @date creation: Tue Mar 31 2015
* @date last modification: Wed Oct 11 2017
*
* @brief Specialization of the element_class class for the type _hexahedron_20
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
*
* You should have received a copy of the GNU Lesser General Public License
along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* @verbatim
\y
\z /
| /
7-----|18--------6
/| | / /|
/ | | / / |
19 | | / 17 |
/ 15 | / / 14
/ | | / / |
4-------16---/---5 |
| | +----|------------\x
| 3-------10-|-----2
| / | /
12 / 13 /
| 11 | 9
| / | /
|/ |/
0--------8-------1
x y z
* N0 -1 -1 -1
* N1 1 -1 -1
* N2 1 1 -1
* N3 -1 1 -1
* N4 -1 -1 1
* N5 1 -1 1
* N6 1 1 1
* N7 -1 1 1
* N8 0 -1 -1
* N9 1 0 -1
* N10 0 1 -1
* N11 -1 0 -1
* N12 -1 -1 0
* N13 1 -1 0
* N14 1 1 0
* N15 -1 1 0
* N16 0 -1 1
* N17 1 0 1
* N18 0 1 1
* N19 -1 0 1
*/
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_ELEMENT_CLASS_PROPERTY(_hexahedron_20, _gt_hexahedron_20,
_itp_serendip_hexahedron_20, _ek_regular,
3, _git_segment, 3);
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type>
inline void InterpolationElement<_itp_serendip_hexahedron_20>::computeShapes(
const vector_type & c, vector_type & N) {
// Shape function , Natural coordinates
N(0) =
0.125 * (1 - c(0)) * (1 - c(1)) * (1 - c(2)) * (-2 - c(0) - c(1) - c(2));
N(1) =
0.125 * (1 + c(0)) * (1 - c(1)) * (1 - c(2)) * (-2 + c(0) - c(1) - c(2));
N(2) =
0.125 * (1 + c(0)) * (1 + c(1)) * (1 - c(2)) * (-2 + c(0) + c(1) - c(2));
N(3) =
0.125 * (1 - c(0)) * (1 + c(1)) * (1 - c(2)) * (-2 - c(0) + c(1) - c(2));
N(4) =
0.125 * (1 - c(0)) * (1 - c(1)) * (1 + c(2)) * (-2 - c(0) - c(1) + c(2));
N(5) =
0.125 * (1 + c(0)) * (1 - c(1)) * (1 + c(2)) * (-2 + c(0) - c(1) + c(2));
N(6) =
0.125 * (1 + c(0)) * (1 + c(1)) * (1 + c(2)) * (-2 + c(0) + c(1) + c(2));
N(7) =
0.125 * (1 - c(0)) * (1 + c(1)) * (1 + c(2)) * (-2 - c(0) + c(1) + c(2));
N(8) = 0.25 * (1 - c(0) * c(0)) * (1 - c(1)) * (1 - c(2));
N(9) = 0.25 * (1 - c(1) * c(1)) * (1 + c(0)) * (1 - c(2));
N(10) = 0.25 * (1 - c(0) * c(0)) * (1 + c(1)) * (1 - c(2));
N(11) = 0.25 * (1 - c(1) * c(1)) * (1 - c(0)) * (1 - c(2));
N(12) = 0.25 * (1 - c(2) * c(2)) * (1 - c(0)) * (1 - c(1));
N(13) = 0.25 * (1 - c(2) * c(2)) * (1 + c(0)) * (1 - c(1));
N(14) = 0.25 * (1 - c(2) * c(2)) * (1 + c(0)) * (1 + c(1));
N(15) = 0.25 * (1 - c(2) * c(2)) * (1 - c(0)) * (1 + c(1));
N(16) = 0.25 * (1 - c(0) * c(0)) * (1 - c(1)) * (1 + c(2));
N(17) = 0.25 * (1 - c(1) * c(1)) * (1 + c(0)) * (1 + c(2));
N(18) = 0.25 * (1 - c(0) * c(0)) * (1 + c(1)) * (1 + c(2));
N(19) = 0.25 * (1 - c(1) * c(1)) * (1 - c(0)) * (1 + c(2));
}
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type, class matrix_type>
inline void InterpolationElement<_itp_serendip_hexahedron_20>::computeDNDS(
const vector_type & c, matrix_type & dnds) {
// derivatives
// ddx
dnds(0, 0) =
0.25 * (c(0) + 0.5 * (c(1) + c(2) + 1)) * (c(1) - 1) * (c(2) - 1);
dnds(0, 1) =
0.25 * (c(0) - 0.5 * (c(1) + c(2) + 1)) * (c(1) - 1) * (c(2) - 1);
dnds(0, 2) =
-0.25 * (c(0) + 0.5 * (c(1) - c(2) - 1)) * (c(1) + 1) * (c(2) - 1);
dnds(0, 3) =
-0.25 * (c(0) - 0.5 * (c(1) - c(2) - 1)) * (c(1) + 1) * (c(2) - 1);
dnds(0, 4) =
-0.25 * (c(0) + 0.5 * (c(1) - c(2) + 1)) * (c(1) - 1) * (c(2) + 1);
dnds(0, 5) =
-0.25 * (c(0) - 0.5 * (c(1) - c(2) + 1)) * (c(1) - 1) * (c(2) + 1);
dnds(0, 6) =
0.25 * (c(0) + 0.5 * (c(1) + c(2) - 1)) * (c(1) + 1) * (c(2) + 1);
dnds(0, 7) =
0.25 * (c(0) - 0.5 * (c(1) + c(2) - 1)) * (c(1) + 1) * (c(2) + 1);
dnds(0, 8) = -0.5 * c(0) * (c(1) - 1) * (c(2) - 1);
dnds(0, 9) = 0.25 * (c(1) * c(1) - 1) * (c(2) - 1);
dnds(0, 10) = 0.5 * c(0) * (c(1) + 1) * (c(2) - 1);
dnds(0, 11) = -0.25 * (c(1) * c(1) - 1) * (c(2) - 1);
dnds(0, 12) = -0.25 * (c(2) * c(2) - 1) * (c(1) - 1);
dnds(0, 13) = 0.25 * (c(1) - 1) * (c(2) * c(2) - 1);
dnds(0, 14) = -0.25 * (c(1) + 1) * (c(2) * c(2) - 1);
dnds(0, 15) = 0.25 * (c(1) + 1) * (c(2) * c(2) - 1);
dnds(0, 16) = 0.5 * c(0) * (c(1) - 1) * (c(2) + 1);
dnds(0, 17) = -0.25 * (c(2) + 1) * (c(1) * c(1) - 1);
dnds(0, 18) = -0.5 * c(0) * (c(1) + 1) * (c(2) + 1);
dnds(0, 19) = 0.25 * (c(2) + 1) * (c(1) * c(1) - 1);
// ddy
dnds(1, 0) =
0.25 * (c(1) + 0.5 * (c(0) + c(2) + 1)) * (c(0) - 1) * (c(2) - 1);
dnds(1, 1) =
-0.25 * (c(1) - 0.5 * (c(0) - c(2) - 1)) * (c(0) + 1) * (c(2) - 1);
dnds(1, 2) =
-0.25 * (c(1) + 0.5 * (c(0) - c(2) - 1)) * (c(0) + 1) * (c(2) - 1);
dnds(1, 3) =
0.25 * (c(1) - 0.5 * (c(0) + c(2) + 1)) * (c(0) - 1) * (c(2) - 1);
dnds(1, 4) =
-0.25 * (c(1) + 0.5 * (c(0) - c(2) + 1)) * (c(0) - 1) * (c(2) + 1);
dnds(1, 5) =
0.25 * (c(1) - 0.5 * (c(0) + c(2) - 1)) * (c(0) + 1) * (c(2) + 1);
dnds(1, 6) =
0.25 * (c(1) + 0.5 * (c(0) + c(2) - 1)) * (c(0) + 1) * (c(2) + 1);
dnds(1, 7) =
-0.25 * (c(1) - 0.5 * (c(0) - c(2) + 1)) * (c(0) - 1) * (c(2) + 1);
dnds(1, 8) = -0.25 * (c(0) * c(0) - 1) * (c(2) - 1);
dnds(1, 9) = 0.5 * c(1) * (c(0) + 1) * (c(2) - 1);
dnds(1, 10) = 0.25 * (c(0) * c(0) - 1) * (c(2) - 1);
dnds(1, 11) = -0.5 * c(1) * (c(0) - 1) * (c(2) - 1);
dnds(1, 12) = -0.25 * (c(2) * c(2) - 1) * (c(0) - 1);
dnds(1, 13) = 0.25 * (c(0) + 1) * (c(2) * c(2) - 1);
dnds(1, 14) = -0.25 * (c(0) + 1) * (c(2) * c(2) - 1);
dnds(1, 15) = 0.25 * (c(0) - 1) * (c(2) * c(2) - 1);
dnds(1, 16) = 0.25 * (c(2) + 1) * (c(0) * c(0) - 1);
dnds(1, 17) = -0.5 * c(1) * (c(0) + 1) * (c(2) + 1);
dnds(1, 18) = -0.25 * (c(2) + 1) * (c(0) * c(0) - 1);
dnds(1, 19) = 0.5 * c(1) * (c(0) - 1) * (c(2) + 1);
// ddz
dnds(2, 0) =
0.25 * (c(2) + 0.5 * (c(0) + c(1) + 1)) * (c(0) - 1) * (c(1) - 1);
dnds(2, 1) =
-0.25 * (c(2) - 0.5 * (c(0) - c(1) - 1)) * (c(0) + 1) * (c(1) - 1);
dnds(2, 2) =
0.25 * (c(2) - 0.5 * (c(0) + c(1) - 1)) * (c(0) + 1) * (c(1) + 1);
dnds(2, 3) =
-0.25 * (c(2) + 0.5 * (c(0) - c(1) + 1)) * (c(0) - 1) * (c(1) + 1);
dnds(2, 4) =
0.25 * (c(2) - 0.5 * (c(0) + c(1) + 1)) * (c(0) - 1) * (c(1) - 1);
dnds(2, 5) =
-0.25 * (c(2) + 0.5 * (c(0) - c(1) - 1)) * (c(0) + 1) * (c(1) - 1);
dnds(2, 6) =
0.25 * (c(2) + 0.5 * (c(0) + c(1) - 1)) * (c(0) + 1) * (c(1) + 1);
dnds(2, 7) =
-0.25 * (c(2) - 0.5 * (c(0) - c(1) + 1)) * (c(0) - 1) * (c(1) + 1);
dnds(2, 8) = -0.25 * (c(0) * c(0) - 1) * (c(1) - 1);
dnds(2, 9) = 0.25 * (c(1) * c(1) - 1) * (c(0) + 1);
dnds(2, 10) = 0.25 * (c(0) * c(0) - 1) * (c(1) + 1);
dnds(2, 11) = -0.25 * (c(1) * c(1) - 1) * (c(0) - 1);
dnds(2, 12) = -0.5 * c(2) * (c(1) - 1) * (c(0) - 1);
dnds(2, 13) = 0.5 * c(2) * (c(0) + 1) * (c(1) - 1);
dnds(2, 14) = -0.5 * c(2) * (c(0) + 1) * (c(1) + 1);
dnds(2, 15) = 0.5 * c(2) * (c(0) - 1) * (c(1) + 1);
dnds(2, 16) = 0.25 * (c(1) - 1) * (c(0) * c(0) - 1);
dnds(2, 17) = -0.25 * (c(0) + 1) * (c(1) * c(1) - 1);
dnds(2, 18) = -0.25 * (c(1) + 1) * (c(0) * c(0) - 1);
dnds(2, 19) = 0.25 * (c(0) - 1) * (c(1) * c(1) - 1);
}
/* -------------------------------------------------------------------------- */
template <>
inline Real
GeometricalElement<_gt_hexahedron_20>::getInradius(const Matrix<Real> & coord) {
- return GeometricalElement<_gt_hexahedron_8>::getInradius(coord)*0.5;
+ return GeometricalElement<_gt_hexahedron_8>::getInradius(coord) * 0.5;
}
diff --git a/src/fe_engine/element_classes/element_class_kirchhoff_shell_inline_impl.cc b/src/fe_engine/element_classes/element_class_kirchhoff_shell_inline_impl.cc
index 1f75e71c8..3152fd5b7 100644
--- a/src/fe_engine/element_classes/element_class_kirchhoff_shell_inline_impl.cc
+++ b/src/fe_engine/element_classes/element_class_kirchhoff_shell_inline_impl.cc
@@ -1,214 +1,214 @@
/**
* @file element_class_kirchhoff_shell_inline_impl.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Damien Spielmann <damien.spielmann@epfl.ch>
*
* @date creation: Fri Jul 04 2014
* @date last modification: Wed Feb 21 2018
*
* @brief Element class Kirchhoff Shell
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_class_structural.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_CLASS_KIRCHHOFF_SHELL_INLINE_IMPL_CC__
#define __AKANTU_ELEMENT_CLASS_KIRCHHOFF_SHELL_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_STRUCTURAL_INTERPOLATION_TYPE_PROPERTY(
_itp_discrete_kirchhoff_triangle_18, _itp_lagrange_triangle_3, 6, 6, 21);
AKANTU_DEFINE_STRUCTURAL_ELEMENT_CLASS_PROPERTY(
_discrete_kirchhoff_triangle_18, _gt_triangle_3,
_itp_discrete_kirchhoff_triangle_18, _triangle_3, _ek_structural, 3,
_git_triangle, 2);
/* -------------------------------------------------------------------------- */
namespace detail {
inline void computeBasisChangeMatrix(Matrix<Real> & P,
const Matrix<Real> & X) {
Vector<Real> X1 = X(0);
Vector<Real> X2 = X(1);
Vector<Real> X3 = X(2);
Vector<Real> a1 = X2 - X1;
Vector<Real> a2 = X3 - X1;
a1.normalize();
Vector<Real> e3 = a1.crossProduct(a2);
e3.normalize();
Vector<Real> e2 = e3.crossProduct(a1);
P(0) = a1;
P(1) = e2;
P(2) = e3;
P = P.transpose();
}
-}
+} // namespace detail
/* -------------------------------------------------------------------------- */
template <>
inline void
ElementClass<_discrete_kirchhoff_triangle_18>::computeRotationMatrix(
Matrix<Real> & R, const Matrix<Real> & X, const Vector<Real> &) {
auto dim = X.rows();
Matrix<Real> P(dim, dim);
detail::computeBasisChangeMatrix(P, X);
R.clear();
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
R(i + dim, j + dim) = R(i, j) = P(i, j);
}
/* -------------------------------------------------------------------------- */
template <>
inline void
InterpolationElement<_itp_discrete_kirchhoff_triangle_18>::computeShapes(
const Vector<Real> & /*natural_coords*/,
const Matrix<Real> & /*real_coord*/, Matrix<Real> & /*N*/) {}
/* -------------------------------------------------------------------------- */
template <>
inline void
InterpolationElement<_itp_discrete_kirchhoff_triangle_18>::computeDNDS(
const Vector<Real> & natural_coords, const Matrix<Real> & real_coordinates,
Matrix<Real> & B) {
auto dim = real_coordinates.cols();
Matrix<Real> P(dim, dim);
detail::computeBasisChangeMatrix(P, real_coordinates);
auto X = P * real_coordinates;
Vector<Real> X1 = X(0);
Vector<Real> X2 = X(1);
Vector<Real> X3 = X(2);
std::array<Vector<Real>, 3> A = {X2 - X1, X3 - X2, X1 - X3};
std::array<Real, 3> L, C, S;
// Setting all last coordinates to 0
std::for_each(A.begin(), A.end(), [](auto & a) { a(2) = 0; });
// Computing lengths
std::transform(A.begin(), A.end(), L.begin(),
[](auto & a) { return a.template norm<L_2>(); });
// Computing cosines
std::transform(A.begin(), A.end(), L.begin(), C.begin(),
[](auto & a, auto & l) { return a(0) / l; });
// Computing sines
std::transform(A.begin(), A.end(), L.begin(), S.begin(),
[](auto & a, auto & l) { return a(1) / l; });
// Natural coordinates
Real xi = natural_coords(0);
Real eta = natural_coords(1);
// Derivative of quadratic interpolation functions
Matrix<Real> dP = {{4 * (1 - 2 * xi - eta), 4 * eta, -4 * eta},
{-4 * xi, 4 * xi, 4 * (1 - xi - 2 * eta)}};
Matrix<Real> dNx1 = {
{3. / 2 * (dP(0, 0) * C[0] / L[0] - dP(0, 2) * C[2] / L[2]),
3. / 2 * (dP(0, 1) * C[1] / L[1] - dP(0, 0) * C[0] / L[0]),
3. / 2 * (dP(0, 2) * C[2] / L[2] - dP(0, 1) * C[1] / L[1])},
{3. / 2 * (dP(1, 0) * C[0] / L[0] - dP(1, 2) * C[2] / L[2]),
3. / 2 * (dP(1, 1) * C[1] / L[1] - dP(1, 0) * C[0] / L[0]),
3. / 2 * (dP(1, 2) * C[2] / L[2] - dP(1, 1) * C[1] / L[1])}};
Matrix<Real> dNx2 = {
// clang-format off
{-1 - 3. / 4 * (dP(0, 0) * C[0] * C[0] + dP(0, 2) * C[2] * C[2]),
1 - 3. / 4 * (dP(0, 1) * C[1] * C[1] + dP(0, 0) * C[0] * C[0]),
- 3. / 4 * (dP(0, 2) * C[2] * C[2] + dP(0, 1) * C[1] * C[1])},
{-1 - 3. / 4 * (dP(1, 0) * C[0] * C[0] + dP(1, 2) * C[2] * C[2]),
- 3. / 4 * (dP(1, 1) * C[1] * C[1] + dP(1, 0) * C[0] * C[0]),
1 - 3. / 4 * (dP(1, 2) * C[2] * C[2] + dP(1, 1) * C[1] * C[1])}};
// clang-format on
Matrix<Real> dNx3 = {
{-3. / 4 * (dP(0, 0) * C[0] * S[0] + dP(0, 2) * C[2] * S[2]),
-3. / 4 * (dP(0, 1) * C[1] * S[1] + dP(0, 0) * C[0] * S[0]),
-3. / 4 * (dP(0, 2) * C[2] * S[2] + dP(0, 1) * C[1] * S[1])},
{-3. / 4 * (dP(1, 0) * C[0] * S[0] + dP(1, 2) * C[2] * S[2]),
-3. / 4 * (dP(1, 1) * C[1] * S[1] + dP(1, 0) * C[0] * S[0]),
-3. / 4 * (dP(1, 2) * C[2] * S[2] + dP(1, 1) * C[1] * S[1])}};
Matrix<Real> dNy1 = {
{3. / 2 * (dP(0, 0) * S[0] / L[0] - dP(0, 2) * S[2] / L[2]),
3. / 2 * (dP(0, 1) * S[1] / L[1] - dP(0, 0) * S[0] / L[0]),
3. / 2 * (dP(0, 2) * S[2] / L[2] - dP(0, 1) * S[1] / L[1])},
{3. / 2 * (dP(1, 0) * S[0] / L[0] - dP(1, 2) * S[2] / L[2]),
3. / 2 * (dP(1, 1) * S[1] / L[1] - dP(1, 0) * S[0] / L[0]),
3. / 2 * (dP(1, 2) * S[2] / L[2] - dP(1, 1) * S[1] / L[1])}};
Matrix<Real> dNy2 = dNx3;
Matrix<Real> dNy3 = {
// clang-format off
{-1 - 3. / 4 * (dP(0, 0) * S[0] * S[0] + dP(0, 2) * S[2] * S[2]),
1 - 3. / 4 * (dP(0, 1) * S[1] * S[1] + dP(0, 0) * S[0] * S[0]),
- 3. / 4 * (dP(0, 2) * S[2] * S[2] + dP(0, 1) * S[1] * S[1])},
{-1 - 3. / 4 * (dP(1, 0) * S[0] * S[0] + dP(1, 2) * S[2] * S[2]),
- 3. / 4 * (dP(1, 1) * S[1] * S[1] + dP(1, 0) * S[0] * S[0]),
1 - 3. / 4 * (dP(1, 2) * S[2] * S[2] + dP(1, 1) * S[1] * S[1])}};
// clang-format on
// Derivative of linear (membrane mode) functions
Matrix<Real> dNm(2, 3);
InterpolationElement<_itp_lagrange_triangle_3, _itk_lagrangian>::computeDNDS(
natural_coords, dNm);
UInt i = 0;
for (const Matrix<Real> & mat : {dNm, dNx1, dNx2, dNx3, dNy1, dNy2, dNy3}) {
B.block(mat, 0, i);
i += mat.cols();
}
}
/* -------------------------------------------------------------------------- */
template <>
inline void
InterpolationElement<_itp_discrete_kirchhoff_triangle_18,
_itk_structural>::arrangeInVoigt(const Matrix<Real> & dnds,
Matrix<Real> & B) {
Matrix<Real> dNm(2, 3), dNx1(2, 3), dNx2(2, 3), dNx3(2, 3), dNy1(2, 3),
dNy2(2, 3), dNy3(2, 3);
UInt i = 0;
for (Matrix<Real> * mat : {&dNm, &dNx1, &dNx2, &dNx3, &dNy1, &dNy2, &dNy3}) {
*mat = dnds.block(0, i, 2, 3);
i += mat->cols();
}
for (UInt i = 0; i < 3; ++i) {
// clang-format off
Matrix<Real> Bm = {{dNm(0, i), 0, 0, 0, 0, 0},
{0, dNm(1, i), 0, 0, 0, 0},
{dNm(1, i), dNm(0, i), 0, 0, 0, 0}};
Matrix<Real> Bf = {{0, 0, dNx1(0, i), -dNx3(0, i), dNx2(0, i), 0},
{0, 0, dNy1(1, i), -dNy3(1, i), dNy2(1, i), 0},
{0, 0, dNx1(1, i) + dNy1(0, i), -dNx3(1, i) - dNy3(0, i), dNx2(1, i) + dNy2(0, i), 0}};
// clang-format on
B.block(Bm, 0, i * 6);
B.block(Bf, 3, i * 6);
}
}
} // namespace akantu
#endif /* __AKANTU_ELEMENT_CLASS_KIRCHHOFF_SHELL_INLINE_IMPL_CC__ */
diff --git a/src/fe_engine/element_classes/element_class_pentahedron_15_inline_impl.cc b/src/fe_engine/element_classes/element_class_pentahedron_15_inline_impl.cc
index 2166124e2..99ceba26f 100644
--- a/src/fe_engine/element_classes/element_class_pentahedron_15_inline_impl.cc
+++ b/src/fe_engine/element_classes/element_class_pentahedron_15_inline_impl.cc
@@ -1,173 +1,173 @@
/**
* @file element_class_pentahedron_15_inline_impl.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Sacha Laffely <sacha.laffely@epfl.ch>
* @author Damien Scantamburlo <damien.scantamburlo@epfl.ch>
*
* @date creation: Tue Mar 31 2015
* @date last modification: Thu Dec 28 2017
*
* @brief Specialization of the element_class class for the type
* _pentahedron_15
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
*
* You should have received a copy of the GNU Lesser General Public License
along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* @verbatim
z
^
|
|
| 1
| /|\
|/ | \
10 7 6
/ | \
/ | \
4 2--8--0
| \ / /
| \11 /
13 12 9---------->y
| / \ /
|/ \ /
5--14--3
/
/
/
v
x
x y z
* N0 -1 1 0
* N1 -1 0 1
* N2 -1 0 0
* N3 1 1 0
* N4 1 0 1
* N5 1 0 0
* N6 -1 0.5 0.5
* N7 -1 0 0.5
* N8 -1 0.5 0
* N9 0 1 0
* N10 0 0 1
* N11 0 0 0
* N12 1 0.5 0.5
* N13 1 0 0.5
* N14 1 0.5 0
*/
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_ELEMENT_CLASS_PROPERTY(_pentahedron_15, _gt_pentahedron_15,
_itp_lagrange_pentahedron_15, _ek_regular,
3, _git_pentahedron, 2);
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type>
inline void InterpolationElement<_itp_lagrange_pentahedron_15>::computeShapes(
const vector_type & c, vector_type & N) {
auto & x = c(0);
auto & y = c(1);
auto & z = c(2);
// Shape Functions, Natural coordinates
N(0) = 0.5 * y * (1 - x) * (2 * y - 2 - x);
N(1) = 0.5 * z * (1 - x) * (2 * z - 2 - x);
N(2) = 0.5 * (x - 1) * (1 - y - z) * (x + 2 * y + 2 * z);
N(3) = 0.5 * y * (1 + x) * (2 * y - 2 + x);
N(4) = 0.5 * z * (1 + x) * (2 * z - 2 + x);
N(5) = 0.5 * (-x - 1) * (1 - y - z) * (-x + 2 * y + 2 * z);
N(6) = 2.0 * y * z * (1 - x);
N(7) = 2.0 * z * (1 - y - z) * (1 - x);
N(8) = 2.0 * y * (1 - x) * (1 - y - z);
N(9) = y * (1 - x * x);
N(10) = z * (1 - x * x);
N(11) = (1 - y - z) * (1 - x * x);
N(12) = 2.0 * y * z * (1 + x);
N(13) = 2.0 * z * (1 - y - z) * (1 + x);
N(14) = 2.0 * y * (1 - y - z) * (1 + x);
}
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type, class matrix_type>
inline void InterpolationElement<_itp_lagrange_pentahedron_15>::computeDNDS(
const vector_type & c, matrix_type & dnds) {
auto & x = c(0);
auto & y = c(1);
auto & z = c(2);
// ddx
dnds(0, 0) = 0.5 * y * (2 * x - 2 * y + 1);
dnds(0, 1) = 0.5 * z * (2 * x - 2 * z + 1);
dnds(0, 2) = -0.5 * (2 * x + 2 * y + 2 * z - 1) * (y + z - 1);
dnds(0, 3) = 0.5 * y * (2 * x + 2 * y - 1);
dnds(0, 4) = 0.5 * z * (2 * x + 2 * z - 1);
dnds(0, 5) = -0.5 * (y + z - 1) * (2 * x - 2 * y - 2 * z + 1);
dnds(0, 6) = -2.0 * y * z;
dnds(0, 7) = 2.0 * z * (y + z - 1);
dnds(0, 8) = 2.0 * y * (y + z - 1);
dnds(0, 9) = -2.0 * x * y;
dnds(0, 10) = -2.0 * x * z;
dnds(0, 11) = 2.0 * x * (y + z - 1);
dnds(0, 12) = 2.0 * y * z;
dnds(0, 13) = -2.0 * z * (y + z - 1);
dnds(0, 14) = -2.0 * y * (y + z - 1);
// ddy
dnds(1, 0) = -0.5 * (x - 1) * (4 * y - x - 2);
dnds(1, 1) = 0.0;
dnds(1, 2) = -0.5 * (x - 1) * (4 * y + x + 2 * (2 * z - 1));
dnds(1, 3) = 0.5 * (x + 1) * (4 * y + x - 2);
dnds(1, 4) = 0.0;
dnds(1, 5) = 0.5 * (x + 1) * (4 * y - x + 2 * (2 * z - 1));
dnds(1, 6) = -2.0 * (x - 1) * z;
dnds(1, 7) = 2.0 * z * (x - 1);
dnds(1, 8) = 2.0 * (2 * y + z - 1) * (x - 1);
dnds(1, 9) = -(x * x - 1);
dnds(1, 10) = 0.0;
dnds(1, 11) = (x * x - 1);
dnds(1, 12) = 2.0 * z * (x + 1);
dnds(1, 13) = -2.0 * z * (x + 1);
dnds(1, 14) = -2.0 * (2 * y + z - 1) * (x + 1);
// ddz
dnds(2, 0) = 0.0;
dnds(2, 1) = -0.5 * (x - 1) * (4 * z - x - 2);
dnds(2, 2) = -0.5 * (x - 1) * (4 * z + x + 2 * (2 * y - 1));
dnds(2, 3) = 0.0;
dnds(2, 4) = 0.5 * (x + 1) * (4 * z + x - 2);
dnds(2, 5) = 0.5 * (x + 1) * (4 * z - x + 2 * (2 * y - 1));
dnds(2, 6) = -2.0 * (x - 1) * y;
dnds(2, 7) = 2.0 * (x - 1) * (2 * z + y - 1);
dnds(2, 8) = 2.0 * y * (x - 1);
dnds(2, 9) = 0.0;
dnds(2, 10) = -(x * x - 1);
dnds(2, 11) = (x * x - 1);
dnds(2, 12) = 2.0 * (x + 1) * y;
dnds(2, 13) = -2.0 * (x + 1) * (2 * z + y - 1);
dnds(2, 14) = -2.0 * (x + 1) * y;
}
/* -------------------------------------------------------------------------- */
template <>
inline Real GeometricalElement<_gt_pentahedron_15>::getInradius(
const Matrix<Real> & coord) {
- return GeometricalElement<_gt_pentahedron_6>::getInradius(coord)*0.5;
+ return GeometricalElement<_gt_pentahedron_6>::getInradius(coord) * 0.5;
}
diff --git a/src/fe_engine/element_classes/element_class_pentahedron_6_inline_impl.cc b/src/fe_engine/element_classes/element_class_pentahedron_6_inline_impl.cc
index 12e362214..accd39feb 100644
--- a/src/fe_engine/element_classes/element_class_pentahedron_6_inline_impl.cc
+++ b/src/fe_engine/element_classes/element_class_pentahedron_6_inline_impl.cc
@@ -1,158 +1,159 @@
/**
* @file element_class_pentahedron_6_inline_impl.cc
*
* @author Marion Estelle Chambart <mchambart@stucky.ch>
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Thomas Menouillard <tmenouillard@stucky.ch>
*
* @date creation: Mon Mar 14 2011
* @date last modification: Wed Oct 11 2017
*
* @brief Specialization of the element_class class for the type _pentahedron_6
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
*
* You should have received a copy of the GNU Lesser General Public License
along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* @verbatim
/z
|
|
| 1
| /|\
|/ | \
/ | \
/ | \
/ | \
4 2-----0
| \ / /
| \/ /
| \ /----------/y
| / \ /
|/ \ /
5---.--3
/
/
/
\x
x y z
* N0 -1 1 0
* N1 -1 0 1
* N2 -1 0 0
* N3 1 1 0
* N4 1 0 1
* N5 1 0 0
*/
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_ELEMENT_CLASS_PROPERTY(_pentahedron_6, _gt_pentahedron_6,
_itp_lagrange_pentahedron_6, _ek_regular,
3, _git_pentahedron, 1);
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type>
inline void InterpolationElement<_itp_lagrange_pentahedron_6>::computeShapes(
const vector_type & c, vector_type & N) {
/// Natural coordinates
N(0) = 0.5 * c(1) * (1 - c(0)); // N1(q)
N(1) = 0.5 * c(2) * (1 - c(0)); // N2(q)
N(2) = 0.5 * (1 - c(1) - c(2)) * (1 - c(0)); // N3(q)
N(3) = 0.5 * c(1) * (1 + c(0)); // N4(q)
N(4) = 0.5 * c(2) * (1 + c(0)); // N5(q)
N(5) = 0.5 * (1 - c(1) - c(2)) * (1 + c(0)); // N6(q)
}
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type, class matrix_type>
inline void InterpolationElement<_itp_lagrange_pentahedron_6>::computeDNDS(
const vector_type & c, matrix_type & dnds) {
dnds(0, 0) = -0.5 * c(1);
dnds(0, 1) = -0.5 * c(2);
dnds(0, 2) = -0.5 * (1 - c(1) - c(2));
dnds(0, 3) = 0.5 * c(1);
dnds(0, 4) = 0.5 * c(2);
dnds(0, 5) = 0.5 * (1 - c(1) - c(2));
dnds(1, 0) = 0.5 * (1 - c(0));
dnds(1, 1) = 0.0;
dnds(1, 2) = -0.5 * (1 - c(0));
dnds(1, 3) = 0.5 * (1 + c(0));
dnds(1, 4) = 0.0;
dnds(1, 5) = -0.5 * (1 + c(0));
dnds(2, 0) = 0.0;
dnds(2, 1) = 0.5 * (1 - c(0));
dnds(2, 2) = -0.5 * (1 - c(0));
dnds(2, 3) = 0.0;
dnds(2, 4) = 0.5 * (1 + c(0));
dnds(2, 5) = -0.5 * (1 + c(0));
}
/* -------------------------------------------------------------------------- */
// I have to duplicate this code since the Real * coords do not know their size
// in the Math module.
// If later we use eigen or Vector to implement this function
// there should be only one function in akantu::Math
// -> this is temporary for the release deadline which was so extended
inline Real triangle_inradius(const Real * coord1, const Real * coord2,
const Real * coord3) {
/**
* @f{eqnarray*}{
* r &=& A / s \\
* A &=& 1/4 * \sqrt{(a + b + c) * (a - b + c) * (a + b - c) (-a + b + c)} \\
* s &=& \frac{a + b + c}{2}
* @f}
*/
Real a, b, c;
a = Math::distance_3d(coord1, coord2);
b = Math::distance_3d(coord2, coord3);
c = Math::distance_3d(coord1, coord3);
Real s;
s = (a + b + c) * 0.5;
return sqrt((s - a) * (s - b) * (s - c) / s);
}
/* -------------------------------------------------------------------------- */
template <>
inline Real
GeometricalElement<_gt_pentahedron_6>::getInradius(const Matrix<Real> & coord) {
Vector<Real> u0 = coord(0);
Vector<Real> u1 = coord(1);
Vector<Real> u2 = coord(2);
Vector<Real> u3 = coord(3);
Vector<Real> u4 = coord(4);
Vector<Real> u5 = coord(5);
Real inradius_triangle_1 =
triangle_inradius(u0.storage(), u1.storage(), u2.storage());
Real inradius_triangle_2 =
triangle_inradius(u3.storage(), u4.storage(), u5.storage());
Real d1 = u3.distance(u0) * 0.5;
Real d2 = u5.distance(u2) * 0.5;
Real d3 = u4.distance(u1) * 0.5;
- Real p = 2.*std::min({inradius_triangle_1, inradius_triangle_2, d1, d2, d3});
+ Real p =
+ 2. * std::min({inradius_triangle_1, inradius_triangle_2, d1, d2, d3});
return p;
}
diff --git a/src/fe_engine/element_classes/element_class_triangle_6_inline_impl.cc b/src/fe_engine/element_classes/element_class_triangle_6_inline_impl.cc
index 4c4081d6e..08ca8c2c7 100644
--- a/src/fe_engine/element_classes/element_class_triangle_6_inline_impl.cc
+++ b/src/fe_engine/element_classes/element_class_triangle_6_inline_impl.cc
@@ -1,207 +1,207 @@
/**
* @file element_class_triangle_6_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jul 16 2010
* @date last modification: Wed Oct 11 2017
*
* @brief Specialization of the element_class class for the type _triangle_6
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
terms of the GNU Lesser General Public License as published by the Free
Software Foundation, either version 3 of the License, or (at your option) any
later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
details.
*
* You should have received a copy of the GNU Lesser General Public License
along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* @verbatim
\eta
^
|
x 2
| `
| `
| . `
| q2 `
5 x x 4
| `
| `
| .q0 q1. `
| `
x---------x---------x-----> \xi
0 3 1
@endverbatim
*
* @subsection coords Nodes coordinates
*
* @f[
* \begin{array}{ll}
* \xi_{0} = 0 & \eta_{0} = 0 \\
* \xi_{1} = 1 & \eta_{1} = 0 \\
* \xi_{2} = 0 & \eta_{2} = 1 \\
* \xi_{3} = 1/2 & \eta_{3} = 0 \\
* \xi_{4} = 1/2 & \eta_{4} = 1/2 \\
* \xi_{5} = 0 & \eta_{5} = 1/2
* \end{array}
* @f]
*
* @subsection shapes Shape functions
* @f[
* \begin{array}{lll}
* N1 = -(1 - \xi - \eta) (1 - 2 (1 - \xi - \eta))
* & \frac{\partial N1}{\partial \xi} = 1 - 4(1 - \xi - \eta)
* & \frac{\partial N1}{\partial \eta} = 1 - 4(1 - \xi - \eta) \\
* N2 = - \xi (1 - 2 \xi)
* & \frac{\partial N2}{\partial \xi} = - 1 + 4 \xi
* & \frac{\partial N2}{\partial \eta} = 0 \\
* N3 = - \eta (1 - 2 \eta)
* & \frac{\partial N3}{\partial \xi} = 0
* & \frac{\partial N3}{\partial \eta} = - 1 + 4 \eta \\
* N4 = 4 \xi (1 - \xi - \eta)
* & \frac{\partial N4}{\partial \xi} = 4 (1 - 2 \xi - \eta)
* & \frac{\partial N4}{\partial \eta} = - 4 \xi \\
* N5 = 4 \xi \eta
* & \frac{\partial N5}{\partial \xi} = 4 \eta
* & \frac{\partial N5}{\partial \eta} = 4 \xi \\
* N6 = 4 \eta (1 - \xi - \eta)
* & \frac{\partial N6}{\partial \xi} = - 4 \eta
* & \frac{\partial N6}{\partial \eta} = 4 (1 - \xi - 2 \eta)
* \end{array}
* @f]
*
* @subsection quad_points Position of quadrature points
* @f{eqnarray*}{
* \xi_{q0} &=& 1/6 \qquad \eta_{q0} = 1/6 \\
* \xi_{q1} &=& 2/3 \qquad \eta_{q1} = 1/6 \\
* \xi_{q2} &=& 1/6 \qquad \eta_{q2} = 2/3
* @f}
*/
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_ELEMENT_CLASS_PROPERTY(_triangle_6, _gt_triangle_6,
_itp_lagrange_triangle_6, _ek_regular, 2,
_git_triangle, 2);
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type>
inline void InterpolationElement<_itp_lagrange_triangle_6>::computeShapes(
const vector_type & natural_coords, vector_type & N) {
/// Natural coordinates
Real c0 =
1 - natural_coords(0) - natural_coords(1); /// @f$ c0 = 1 - \xi - \eta @f$
Real c1 = natural_coords(0); /// @f$ c1 = \xi @f$
Real c2 = natural_coords(1); /// @f$ c2 = \eta @f$
N(0) = c0 * (2 * c0 - 1.);
N(1) = c1 * (2 * c1 - 1.);
N(2) = c2 * (2 * c2 - 1.);
N(3) = 4 * c0 * c1;
N(4) = 4 * c1 * c2;
N(5) = 4 * c2 * c0;
}
/* -------------------------------------------------------------------------- */
template <>
template <class vector_type, class matrix_type>
inline void InterpolationElement<_itp_lagrange_triangle_6>::computeDNDS(
const vector_type & natural_coords, matrix_type & dnds) {
/**
* @f[
* dnds = \left(
* \begin{array}{cccccc}
* \frac{\partial N1}{\partial \xi}
* & \frac{\partial N2}{\partial \xi}
* & \frac{\partial N3}{\partial \xi}
* & \frac{\partial N4}{\partial \xi}
* & \frac{\partial N5}{\partial \xi}
* & \frac{\partial N6}{\partial \xi} \\
*
* \frac{\partial N1}{\partial \eta}
* & \frac{\partial N2}{\partial \eta}
* & \frac{\partial N3}{\partial \eta}
* & \frac{\partial N4}{\partial \eta}
* & \frac{\partial N5}{\partial \eta}
* & \frac{\partial N6}{\partial \eta}
* \end{array}
* \right)
* @f]
*/
/// Natural coordinates
Real c0 =
1 - natural_coords(0) - natural_coords(1); /// @f$ c0 = 1 - \xi - \eta @f$
Real c1 = natural_coords(0); /// @f$ c1 = \xi @f$
Real c2 = natural_coords(1); /// @f$ c2 = \eta @f$
dnds(0, 0) = 1 - 4 * c0;
dnds(0, 1) = 4 * c1 - 1.;
dnds(0, 2) = 0.;
dnds(0, 3) = 4 * (c0 - c1);
dnds(0, 4) = 4 * c2;
dnds(0, 5) = -4 * c2;
dnds(1, 0) = 1 - 4 * c0;
dnds(1, 1) = 0.;
dnds(1, 2) = 4 * c2 - 1.;
dnds(1, 3) = -4 * c1;
dnds(1, 4) = 4 * c1;
dnds(1, 5) = 4 * (c0 - c2);
}
/* -------------------------------------------------------------------------- */
template <>
inline void
InterpolationElement<_itp_lagrange_triangle_6>::computeSpecialJacobian(
const Matrix<Real> & J, Real & jac) {
Vector<Real> vprod(J.cols());
Matrix<Real> Jt(J.transpose(), true);
vprod.crossProduct(Jt(0), Jt(1));
jac = vprod.norm();
}
/* -------------------------------------------------------------------------- */
template <>
inline Real
GeometricalElement<_gt_triangle_6>::getInradius(const Matrix<Real> & coord) {
UInt triangles[4][3] = {{0, 3, 5}, {3, 1, 4}, {3, 4, 5}, {5, 4, 2}};
Real inradius = std::numeric_limits<Real>::max();
for (UInt t = 0; t < 4; t++) {
Real ir;
if (coord.rows() == 2) {
ir = Math::triangle_inradius_2d(coord(triangles[t][0]).storage(),
coord(triangles[t][1]).storage(),
coord(triangles[t][2]).storage());
}
else {
ir = Math::triangle_inradius_3d(coord(triangles[t][0]).storage(),
coord(triangles[t][1]).storage(),
coord(triangles[t][2]).storage());
}
inradius = std::min(ir, inradius);
}
- return 2.*inradius;
+ return 2. * inradius;
}
/* -------------------------------------------------------------------------- */
// template<> inline bool ElementClass<_triangle_6>::contains(const Vector<Real>
// & natural_coords) {
// return ElementClass<_triangle_3>::contains(natural_coords);
// }
diff --git a/src/fe_engine/fe_engine.hh b/src/fe_engine/fe_engine.hh
index 87c99fc4a..d663f30df 100644
--- a/src/fe_engine/fe_engine.hh
+++ b/src/fe_engine/fe_engine.hh
@@ -1,353 +1,356 @@
/**
* @file fe_engine.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief FEM class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_memory.hh"
#include "element_type_map.hh"
#include "mesh_events.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_FE_ENGINE_HH__
#define __AKANTU_FE_ENGINE_HH__
namespace akantu {
class Mesh;
class Integrator;
class ShapeFunctions;
class DOFManager;
class Element;
} // namespace akantu
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/**
* The generic FEEngine class derived in a FEEngineTemplate class
* containing the
* shape functions and the integration method
*/
class FEEngine : protected Memory, public MeshEventHandler {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
FEEngine(Mesh & mesh, UInt spatial_dimension = _all_dimensions,
const ID & id = "fem", MemoryID memory_id = 0);
~FEEngine() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// pre-compute all the shape functions, their derivatives and the jacobians
virtual void
initShapeFunctions(const GhostType & ghost_type = _not_ghost) = 0;
/// extract the nodal values and store them per element
template <typename T>
static void extractNodalToElementField(
const Mesh & mesh, const Array<T> & nodal_f, Array<T> & elemental_f,
const ElementType & type, const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter);
/// filter a field
template <typename T>
static void
filterElementalData(const Mesh & mesh, const Array<T> & quad_f,
Array<T> & filtered_f, const ElementType & type,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter);
/* ------------------------------------------------------------------------ */
/* Integration method bridges */
/* ------------------------------------------------------------------------ */
/// integrate f for all elements of type "type"
virtual void
integrate(const Array<Real> & f, Array<Real> & intf,
UInt nb_degree_of_freedom, const ElementType & type,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// integrate a scalar value f on all elements of type "type"
virtual Real
integrate(const Array<Real> & f, const ElementType & type,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// integrate f for all integration points of type "type" but don't sum over
/// all integration points
virtual void integrateOnIntegrationPoints(
const Array<Real> & f, Array<Real> & intf, UInt nb_degree_of_freedom,
const ElementType & type, const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// integrate one element scalar value on all elements of type "type"
virtual Real integrate(const Vector<Real> & f, const ElementType & type,
UInt index,
const GhostType & ghost_type = _not_ghost) const = 0;
-/* ------------------------------------------------------------------------ */
-/* compatibility with old FEEngine fashion */
-/* ------------------------------------------------------------------------ */
+ /* ------------------------------------------------------------------------ */
+ /* compatibility with old FEEngine fashion */
+ /* ------------------------------------------------------------------------ */
/// get the number of integration points
virtual UInt
getNbIntegrationPoints(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const = 0;
/// get the precomputed shapes
const virtual Array<Real> &
getShapes(const ElementType & type, const GhostType & ghost_type = _not_ghost,
UInt id = 0) const = 0;
/// get the derivatives of shapes
const virtual Array<Real> &
getShapesDerivatives(const ElementType & type,
const GhostType & ghost_type = _not_ghost,
UInt id = 0) const = 0;
/// get integration points
const virtual Matrix<Real> &
getIntegrationPoints(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const = 0;
/* ------------------------------------------------------------------------ */
/* Shape method bridges */
/* ------------------------------------------------------------------------ */
/// Compute the gradient nablauq on the integration points of an element type
/// from nodal values u
virtual void gradientOnIntegrationPoints(
const Array<Real> & u, Array<Real> & nablauq,
const UInt nb_degree_of_freedom, const ElementType & type,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// Interpolate a nodal field u at the integration points of an element type
/// -> uq
virtual void interpolateOnIntegrationPoints(
const Array<Real> & u, Array<Real> & uq, UInt nb_degree_of_freedom,
const ElementType & type, const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// Interpolate a nodal field u at the integration points of many element
/// types -> uq
virtual void interpolateOnIntegrationPoints(
const Array<Real> & u, ElementTypeMapArray<Real> & uq,
const ElementTypeMapArray<UInt> * filter_elements = nullptr) const = 0;
/// pre multiplies a tensor by the shapes derivaties
virtual void
computeBtD(const Array<Real> & Ds, Array<Real> & BtDs,
- const ElementType & type, const GhostType & ghost_type,
+ const ElementType & type,
+ const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// left and right multiplies a tensor by the shapes derivaties
virtual void
computeBtDB(const Array<Real> & Ds, Array<Real> & BtDBs, UInt order_d,
- const ElementType & type, const GhostType & ghost_type,
+ const ElementType & type,
+ const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// left multiples a vector by the shape functions
- virtual void computeNtb(const Array<Real> & bs, Array<Real> & Ntbs,
- const ElementType & type,
- const GhostType & ghost_type,
- const Array<UInt> & filter_elements) const = 0;
+ virtual void
+ computeNtb(const Array<Real> & bs, Array<Real> & Ntbs,
+ const ElementType & type,
+ const GhostType & ghost_type = _not_ghost,
+ const Array<UInt> & filter_elements = empty_filter) const = 0;
/// Compute the interpolation point position in the global coordinates for
/// many element types
virtual void computeIntegrationPointsCoordinates(
ElementTypeMapArray<Real> & integration_points_coordinates,
const ElementTypeMapArray<UInt> * filter_elements = nullptr) const = 0;
/// Compute the interpolation point position in the global coordinates for an
/// element type
virtual void computeIntegrationPointsCoordinates(
Array<Real> & integration_points_coordinates, const ElementType & type,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// Build pre-computed matrices for interpolation of field form integration
/// points at other given positions (interpolation_points)
virtual void initElementalFieldInterpolationFromIntegrationPoints(
const ElementTypeMapArray<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
ElementTypeMapArray<Real> & integration_points_coordinates_inv_matrices,
const ElementTypeMapArray<UInt> * element_filter) const = 0;
/// interpolate field at given position (interpolation_points) from given
/// values of this field at integration points (field)
virtual void interpolateElementalFieldFromIntegrationPoints(
const ElementTypeMapArray<Real> & field,
const ElementTypeMapArray<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & result, const GhostType ghost_type,
const ElementTypeMapArray<UInt> * element_filter) const = 0;
/// Interpolate field at given position from given values of this field at
/// integration points (field)
/// using matrices precomputed with
/// initElementalFieldInterplationFromIntegrationPoints
virtual void interpolateElementalFieldFromIntegrationPoints(
const ElementTypeMapArray<Real> & field,
const ElementTypeMapArray<Real> &
interpolation_points_coordinates_matrices,
const ElementTypeMapArray<Real> &
integration_points_coordinates_inv_matrices,
ElementTypeMapArray<Real> & result, const GhostType ghost_type,
const ElementTypeMapArray<UInt> * element_filter) const = 0;
/// interpolate on a phyiscal point inside an element
virtual void interpolate(const Vector<Real> & real_coords,
const Matrix<Real> & nodal_values,
Vector<Real> & interpolated,
const Element & element) const = 0;
/// compute the shape on a provided point
virtual void
computeShapes(const Vector<Real> & real_coords, UInt elem,
const ElementType & type, Vector<Real> & shapes,
const GhostType & ghost_type = _not_ghost) const = 0;
/// compute the shape derivatives on a provided point
virtual void
computeShapeDerivatives(const Vector<Real> & real__coords, UInt element,
const ElementType & type,
Matrix<Real> & shape_derivatives,
const GhostType & ghost_type = _not_ghost) const = 0;
/* ------------------------------------------------------------------------ */
/* Other methods */
/* ------------------------------------------------------------------------ */
/// pre-compute normals on integration points
virtual void computeNormalsOnIntegrationPoints(
const GhostType & ghost_type = _not_ghost) = 0;
/// pre-compute normals on integration points
virtual void computeNormalsOnIntegrationPoints(
__attribute__((unused)) const Array<Real> & field,
__attribute__((unused)) const GhostType & ghost_type = _not_ghost) {
AKANTU_TO_IMPLEMENT();
}
/// pre-compute normals on integration points
virtual void computeNormalsOnIntegrationPoints(
__attribute__((unused)) const Array<Real> & field,
__attribute__((unused)) Array<Real> & normal,
__attribute__((unused)) const ElementType & type,
__attribute__((unused)) const GhostType & ghost_type = _not_ghost) const {
AKANTU_TO_IMPLEMENT();
}
/// function to print the containt of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
private:
/// initialise the class
void init();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
using ElementTypesIteratorHelper =
ElementTypeMapArray<Real, ElementType>::ElementTypesIteratorHelper;
ElementTypesIteratorHelper elementTypes(UInt dim = _all_dimensions,
GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_regular) const;
/// get the dimension of the element handeled by this fe_engine object
AKANTU_GET_MACRO(ElementDimension, element_dimension, UInt);
/// get the mesh contained in the fem object
AKANTU_GET_MACRO(Mesh, mesh, const Mesh &);
/// get the mesh contained in the fem object
AKANTU_GET_MACRO_NOT_CONST(Mesh, mesh, Mesh &);
/// get the in-radius of an element
static inline Real getElementInradius(const Matrix<Real> & coord,
const ElementType & type);
/// get the normals on integration points
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(NormalsOnIntegrationPoints,
normals_on_integration_points, Real);
/// get cohesive element type for a given facet type
static inline ElementType
getCohesiveElementType(const ElementType & type_facet);
/// get igfem element type for a given regular type
static inline Vector<ElementType>
getIGFEMElementTypes(const ElementType & type);
/// get the interpolation element associated to an element type
static inline InterpolationType
getInterpolationType(const ElementType & el_type);
/// get the shape function class (probably useless: see getShapeFunction in
/// fe_engine_template.hh)
virtual const ShapeFunctions & getShapeFunctionsInterface() const = 0;
/// get the integrator class (probably useless: see getIntegrator in
/// fe_engine_template.hh)
virtual const Integrator & getIntegratorInterface() const = 0;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// spatial dimension of the problem
UInt element_dimension;
/// the mesh on which all computation are made
Mesh & mesh;
/// normals at integration points
ElementTypeMapArray<Real> normals_on_integration_points;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const FEEngine & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "fe_engine_inline_impl.cc"
#include "fe_engine_template.hh"
#endif /* __AKANTU_FE_ENGINE_HH__ */
diff --git a/src/fe_engine/fe_engine_inline_impl.cc b/src/fe_engine/fe_engine_inline_impl.cc
index a04ec296e..b3fec52b3 100644
--- a/src/fe_engine/fe_engine_inline_impl.cc
+++ b/src/fe_engine/fe_engine_inline_impl.cc
@@ -1,199 +1,199 @@
/**
* @file fe_engine_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jul 20 2010
* @date last modification: Sun Aug 13 2017
*
* @brief Implementation of the inline functions of the FEEngine Class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_class.hh"
#include "fe_engine.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#include "element_type_conversion.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_FE_ENGINE_INLINE_IMPL_CC__
#define __AKANTU_FE_ENGINE_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline Real FEEngine::getElementInradius(const Matrix<Real> & coord,
const ElementType & type) {
AKANTU_DEBUG_IN();
Real inradius = 0;
#define GET_INRADIUS(type) inradius = ElementClass<type>::getInradius(coord);
AKANTU_BOOST_ALL_ELEMENT_SWITCH(GET_INRADIUS);
#undef GET_INRADIUS
AKANTU_DEBUG_OUT();
return inradius;
}
/* -------------------------------------------------------------------------- */
inline InterpolationType
FEEngine::getInterpolationType(const ElementType & type) {
return convertType<ElementType, InterpolationType>(type);
}
/* -------------------------------------------------------------------------- */
/// @todo rewrite this function in order to get the cohesive element
/// type directly from the facet
#if defined(AKANTU_COHESIVE_ELEMENT)
inline ElementType FEEngine::getCohesiveElementType(const ElementType & type) {
AKANTU_DEBUG_IN();
ElementType ctype;
#define GET_COHESIVE_TYPE(type) \
ctype = CohesiveFacetProperty<type>::cohesive_type;
AKANTU_BOOST_ALL_ELEMENT_SWITCH(GET_COHESIVE_TYPE);
#undef GET_COHESIVE_TYPE
AKANTU_DEBUG_OUT();
return ctype;
}
#else
inline ElementType
FEEngine::getCohesiveElementType(__attribute__((unused))
const ElementType & type_facet) {
return _not_defined;
}
#endif
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_IGFEM)
} // akantu
#include "igfem_helper.hh"
namespace akantu {
inline Vector<ElementType>
FEEngine::getIGFEMElementTypes(const ElementType & type) {
#define GET_IGFEM_ELEMENT_TYPES(type) \
return IGFEMHelper::getIGFEMElementTypes<type>();
AKANTU_BOOST_REGULAR_ELEMENT_SWITCH(GET_IGFEM_ELEMENT_TYPES);
#undef GET_IGFEM_ELEMENT_TYPES
}
#endif
/* -------------------------------------------------------------------------- */
template <typename T>
void FEEngine::extractNodalToElementField(const Mesh & mesh,
const Array<T> & nodal_f,
Array<T> & elemental_f,
const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) {
AKANTU_DEBUG_IN();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_degree_of_freedom = nodal_f.getNbComponent();
UInt nb_element = mesh.getNbElement(type, ghost_type);
UInt * conn_val = mesh.getConnectivity(type, ghost_type).storage();
if (filter_elements != empty_filter) {
nb_element = filter_elements.size();
}
elemental_f.resize(nb_element);
T * nodal_f_val = nodal_f.storage();
T * f_val = elemental_f.storage();
UInt * el_conn;
for (UInt el = 0; el < nb_element; ++el) {
if (filter_elements != empty_filter)
el_conn = conn_val + filter_elements(el) * nb_nodes_per_element;
else
el_conn = conn_val + el * nb_nodes_per_element;
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
UInt node = *(el_conn + n);
std::copy(nodal_f_val + node * nb_degree_of_freedom,
nodal_f_val + (node + 1) * nb_degree_of_freedom, f_val);
f_val += nb_degree_of_freedom;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void FEEngine::filterElementalData(const Mesh & mesh, const Array<T> & elem_f,
Array<T> & filtered_f,
const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) {
AKANTU_DEBUG_IN();
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (nb_element == 0) {
filtered_f.resize(0);
return;
}
UInt nb_degree_of_freedom = elem_f.getNbComponent();
UInt nb_data_per_element = elem_f.size() / nb_element;
if (filter_elements != empty_filter) {
nb_element = filter_elements.size();
}
filtered_f.resize(nb_element * nb_data_per_element);
T * elem_f_val = elem_f.storage();
T * f_val = filtered_f.storage();
UInt el_offset;
for (UInt el = 0; el < nb_element; ++el) {
if (filter_elements != empty_filter)
el_offset = filter_elements(el);
else
el_offset = el;
std::copy(elem_f_val +
el_offset * nb_data_per_element * nb_degree_of_freedom,
elem_f_val +
(el_offset + 1) * nb_data_per_element * nb_degree_of_freedom,
f_val);
f_val += nb_degree_of_freedom * nb_data_per_element;
}
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_FE_ENGINE_INLINE_IMPL_CC__ */
diff --git a/src/fe_engine/fe_engine_template_cohesive.cc b/src/fe_engine/fe_engine_template_cohesive.cc
index 297fda14e..73f1b869e 100644
--- a/src/fe_engine/fe_engine_template_cohesive.cc
+++ b/src/fe_engine/fe_engine_template_cohesive.cc
@@ -1,132 +1,132 @@
/**
* @file fe_engine_template_cohesive.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Oct 31 2012
* @date last modification: Tue Feb 20 2018
*
* @brief Specialization of the FEEngineTemplate for cohesive element
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fe_engine_template.hh"
#include "integrator_gauss.hh"
#include "shape_cohesive.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/* compatibility functions */
/* -------------------------------------------------------------------------- */
template <>
Real FEEngineTemplate<IntegratorGauss, ShapeLagrange, _ek_cohesive,
DefaultIntegrationOrderFunctor>::
integrate(const Array<Real> & f, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
#ifndef AKANTU_NDEBUG
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
UInt nb_quadrature_points = getNbIntegrationPoints(type);
AKANTU_DEBUG_ASSERT(f.size() == nb_element * nb_quadrature_points,
"The vector f(" << f.getID()
<< ") has not the good size.");
AKANTU_DEBUG_ASSERT(f.getNbComponent() == 1,
"The vector f("
<< f.getID()
<< ") has not the good number of component.");
#endif
Real integral = 0.;
#define INTEGRATE(type) \
integral = integrator.integrate<type>(f, ghost_type, filter_elements);
AKANTU_BOOST_COHESIVE_ELEMENT_SWITCH(INTEGRATE);
#undef INTEGRATE
AKANTU_DEBUG_OUT();
return integral;
}
/* -------------------------------------------------------------------------- */
template <>
void FEEngineTemplate<IntegratorGauss, ShapeLagrange, _ek_cohesive,
DefaultIntegrationOrderFunctor>::
integrate(const Array<Real> & f, Array<Real> & intf,
UInt nb_degree_of_freedom, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
#ifndef AKANTU_NDEBUG
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
UInt nb_quadrature_points = getNbIntegrationPoints(type);
AKANTU_DEBUG_ASSERT(f.size() == nb_element * nb_quadrature_points,
"The vector f(" << f.getID() << " size " << f.size()
<< ") has not the good size ("
<< nb_element << ").");
AKANTU_DEBUG_ASSERT(f.getNbComponent() == nb_degree_of_freedom,
"The vector f("
<< f.getID()
<< ") has not the good number of component.");
AKANTU_DEBUG_ASSERT(intf.getNbComponent() == nb_degree_of_freedom,
"The vector intf("
<< intf.getID()
<< ") has not the good number of component.");
AKANTU_DEBUG_ASSERT(intf.size() == nb_element,
"The vector intf(" << intf.getID()
<< ") has not the good size.");
#endif
#define INTEGRATE(type) \
integrator.integrate<type>(f, intf, nb_degree_of_freedom, ghost_type, \
filter_elements);
AKANTU_BOOST_COHESIVE_ELEMENT_SWITCH(INTEGRATE);
#undef INTEGRATE
}
/* -------------------------------------------------------------------------- */
template <>
void FEEngineTemplate<IntegratorGauss, ShapeLagrange, _ek_cohesive,
DefaultIntegrationOrderFunctor>::
gradientOnIntegrationPoints(const Array<Real> &, Array<Real> &, const UInt,
const ElementType &, const GhostType &,
const Array<UInt> &) const {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/fe_engine/fe_engine_template_tmpl.hh b/src/fe_engine/fe_engine_template_tmpl.hh
index 8d5495c1e..7d520b481 100644
--- a/src/fe_engine/fe_engine_template_tmpl.hh
+++ b/src/fe_engine/fe_engine_template_tmpl.hh
@@ -1,1402 +1,1403 @@
/**
* @file fe_engine_template_tmpl.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Feb 15 2011
* @date last modification: Tue Feb 20 2018
*
* @brief Template implementation of FEEngineTemplate
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "dof_manager.hh"
#include "fe_engine_template.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::FEEngineTemplate(
Mesh & mesh, UInt spatial_dimension, ID id, MemoryID memory_id)
: FEEngine(mesh, spatial_dimension, id, memory_id),
- integrator(mesh, id, memory_id), shape_functions(mesh, id, memory_id) {}
+ integrator(mesh, spatial_dimension, id, memory_id),
+ shape_functions(mesh, spatial_dimension, id, memory_id) {}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::~FEEngineTemplate() =
default;
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct GradientOnIntegrationPointsHelper {
template <class S>
static void call(const S &, Mesh &, const Array<Real> &, Array<Real> &,
const UInt, const ElementType &, const GhostType &,
const Array<UInt> &) {
AKANTU_TO_IMPLEMENT();
}
};
#define COMPUTE_GRADIENT(type) \
if (element_dimension == ElementClass<type>::getSpatialDimension()) \
shape_functions.template gradientOnIntegrationPoints<type>( \
u, nablauq, nb_degree_of_freedom, ghost_type, filter_elements);
#define AKANTU_SPECIALIZE_GRADIENT_ON_INTEGRATION_POINTS_HELPER(kind) \
template <> struct GradientOnIntegrationPointsHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, Mesh & mesh, \
const Array<Real> & u, Array<Real> & nablauq, \
const UInt nb_degree_of_freedom, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
UInt element_dimension = mesh.getSpatialDimension(type); \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_GRADIENT, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(
AKANTU_SPECIALIZE_GRADIENT_ON_INTEGRATION_POINTS_HELPER,
AKANTU_FE_ENGINE_LIST_GRADIENT_ON_INTEGRATION_POINTS)
#undef AKANTU_SPECIALIZE_GRADIENT_ON_INTEGRATION_POINTS_HELPER
#undef COMPUTE_GRADIENT
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
gradientOnIntegrationPoints(const Array<Real> & u, Array<Real> & nablauq,
const UInt nb_degree_of_freedom,
const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
UInt nb_points =
shape_functions.getIntegrationPoints(type, ghost_type).cols();
#ifndef AKANTU_NDEBUG
UInt element_dimension = mesh.getSpatialDimension(type);
AKANTU_DEBUG_ASSERT(u.size() == mesh.getNbNodes(),
"The vector u(" << u.getID()
<< ") has not the good size.");
AKANTU_DEBUG_ASSERT(u.getNbComponent() == nb_degree_of_freedom,
"The vector u("
<< u.getID()
<< ") has not the good number of component.");
AKANTU_DEBUG_ASSERT(
nablauq.getNbComponent() == nb_degree_of_freedom * element_dimension,
"The vector nablauq(" << nablauq.getID()
<< ") has not the good number of component.");
// AKANTU_DEBUG_ASSERT(nablauq.size() == nb_element * nb_points,
// "The vector nablauq(" << nablauq.getID()
// << ") has not the good size.");
#endif
nablauq.resize(nb_element * nb_points);
fe_engine::details::GradientOnIntegrationPointsHelper<kind>::call(
shape_functions, mesh, u, nablauq, nb_degree_of_freedom, type, ghost_type,
filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::initShapeFunctions(
const GhostType & ghost_type) {
initShapeFunctions(mesh.getNodes(), ghost_type);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::initShapeFunctions(
const Array<Real> & nodes, const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
for (auto & type : mesh.elementTypes(element_dimension, ghost_type, kind)) {
integrator.initIntegrator(nodes, type, ghost_type);
const auto & control_points = getIntegrationPoints(type, ghost_type);
shape_functions.initShapeFunctions(nodes, control_points, type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct IntegrateHelper {};
#define INTEGRATE(type) \
integrator.template integrate<type>(f, intf, nb_degree_of_freedom, \
ghost_type, filter_elements);
#define AKANTU_SPECIALIZE_INTEGRATE_HELPER(kind) \
template <> struct IntegrateHelper<kind> { \
template <class I> \
static void call(const I & integrator, const Array<Real> & f, \
Array<Real> & intf, UInt nb_degree_of_freedom, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INTEGRATE, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_INTEGRATE_HELPER)
#undef AKANTU_SPECIALIZE_INTEGRATE_HELPER
#undef INTEGRATE
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & f, Array<Real> & intf, UInt nb_degree_of_freedom,
const ElementType & type, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
#ifndef AKANTU_NDEBUG
UInt nb_quadrature_points = getNbIntegrationPoints(type);
AKANTU_DEBUG_ASSERT(f.size() == nb_element * nb_quadrature_points,
"The vector f(" << f.getID() << " size " << f.size()
<< ") has not the good size ("
<< nb_element << ").");
AKANTU_DEBUG_ASSERT(f.getNbComponent() == nb_degree_of_freedom,
"The vector f("
<< f.getID()
<< ") has not the good number of component.");
AKANTU_DEBUG_ASSERT(intf.getNbComponent() == nb_degree_of_freedom,
"The vector intf("
<< intf.getID()
<< ") has not the good number of component.");
#endif
intf.resize(nb_element);
fe_engine::details::IntegrateHelper<kind>::call(integrator, f, intf,
nb_degree_of_freedom, type,
ghost_type, filter_elements);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct IntegrateScalarHelper {};
#define INTEGRATE(type) \
integral = \
integrator.template integrate<type>(f, ghost_type, filter_elements);
#define AKANTU_SPECIALIZE_INTEGRATE_SCALAR_HELPER(kind) \
template <> struct IntegrateScalarHelper<kind> { \
template <class I> \
static Real call(const I & integrator, const Array<Real> & f, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
Real integral = 0.; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INTEGRATE, kind); \
return integral; \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_INTEGRATE_SCALAR_HELPER)
#undef AKANTU_SPECIALIZE_INTEGRATE_SCALAR_HELPER
#undef INTEGRATE
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
Real FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & f, const ElementType & type,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
#ifndef AKANTU_NDEBUG
// std::stringstream sstr; sstr << ghost_type;
// AKANTU_DEBUG_ASSERT(sstr.str() == nablauq.getTag(),
// "The vector " << nablauq.getID() << " is not taged " <<
// ghost_type);
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
UInt nb_quadrature_points = getNbIntegrationPoints(type, ghost_type);
AKANTU_DEBUG_ASSERT(
f.size() == nb_element * nb_quadrature_points,
"The vector f(" << f.getID() << ") has not the good size. (" << f.size()
<< "!=" << nb_quadrature_points * nb_element << ")");
AKANTU_DEBUG_ASSERT(f.getNbComponent() == 1,
"The vector f("
<< f.getID()
<< ") has not the good number of component.");
#endif
Real integral = fe_engine::details::IntegrateScalarHelper<kind>::call(
integrator, f, type, ghost_type, filter_elements);
AKANTU_DEBUG_OUT();
return integral;
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct IntegrateScalarOnOneElementHelper {};
#define INTEGRATE(type) \
res = integrator.template integrate<type>(f, index, ghost_type);
#define AKANTU_SPECIALIZE_INTEGRATE_SCALAR_ON_ONE_ELEMENT_HELPER(kind) \
template <> struct IntegrateScalarOnOneElementHelper<kind> { \
template <class I> \
static Real call(const I & integrator, const Vector<Real> & f, \
const ElementType & type, UInt index, \
const GhostType & ghost_type) { \
Real res = 0.; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INTEGRATE, kind); \
return res; \
} \
};
AKANTU_BOOST_ALL_KIND(
AKANTU_SPECIALIZE_INTEGRATE_SCALAR_ON_ONE_ELEMENT_HELPER)
#undef AKANTU_SPECIALIZE_INTEGRATE_SCALAR_ON_ONE_ELEMENT_HELPER
#undef INTEGRATE
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
Real FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::integrate(
const Vector<Real> & f, const ElementType & type, UInt index,
const GhostType & ghost_type) const {
Real res = fe_engine::details::IntegrateScalarOnOneElementHelper<kind>::call(
integrator, f, type, index, ghost_type);
return res;
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct IntegrateOnIntegrationPointsHelper {};
#define INTEGRATE(type) \
integrator.template integrateOnIntegrationPoints<type>( \
f, intf, nb_degree_of_freedom, ghost_type, filter_elements);
#define AKANTU_SPECIALIZE_INTEGRATE_ON_INTEGRATION_POINTS_HELPER(kind) \
template <> struct IntegrateOnIntegrationPointsHelper<kind> { \
template <class I> \
static void call(const I & integrator, const Array<Real> & f, \
Array<Real> & intf, UInt nb_degree_of_freedom, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INTEGRATE, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(
AKANTU_SPECIALIZE_INTEGRATE_ON_INTEGRATION_POINTS_HELPER)
#undef AKANTU_SPECIALIZE_INTEGRATE_ON_INTEGRATION_POINTS_HELPER
#undef INTEGRATE
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
integrateOnIntegrationPoints(const Array<Real> & f, Array<Real> & intf,
UInt nb_degree_of_freedom,
const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
UInt nb_quadrature_points = getNbIntegrationPoints(type);
#ifndef AKANTU_NDEBUG
// std::stringstream sstr; sstr << ghost_type;
// AKANTU_DEBUG_ASSERT(sstr.str() == nablauq.getTag(),
// "The vector " << nablauq.getID() << " is not taged " <<
// ghost_type);
AKANTU_DEBUG_ASSERT(f.size() == nb_element * nb_quadrature_points,
"The vector f(" << f.getID() << " size " << f.size()
<< ") has not the good size ("
<< nb_element << ").");
AKANTU_DEBUG_ASSERT(f.getNbComponent() == nb_degree_of_freedom,
"The vector f("
<< f.getID()
<< ") has not the good number of component.");
AKANTU_DEBUG_ASSERT(intf.getNbComponent() == nb_degree_of_freedom,
"The vector intf("
<< intf.getID()
<< ") has not the good number of component.");
#endif
intf.resize(nb_element * nb_quadrature_points);
fe_engine::details::IntegrateOnIntegrationPointsHelper<kind>::call(
integrator, f, intf, nb_degree_of_freedom, type, ghost_type,
filter_elements);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct InterpolateOnIntegrationPointsHelper {
template <class S>
static void call(const S &, const Array<Real> &, Array<Real> &,
const UInt, const ElementType &, const GhostType &,
const Array<UInt> &) {
AKANTU_TO_IMPLEMENT();
}
};
#define INTERPOLATE(type) \
shape_functions.template interpolateOnIntegrationPoints<type>( \
u, uq, nb_degree_of_freedom, ghost_type, filter_elements);
#define AKANTU_SPECIALIZE_INTERPOLATE_ON_INTEGRATION_POINTS_HELPER(kind) \
template <> struct InterpolateOnIntegrationPointsHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, const Array<Real> & u, \
Array<Real> & uq, const UInt nb_degree_of_freedom, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INTERPOLATE, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(
AKANTU_SPECIALIZE_INTERPOLATE_ON_INTEGRATION_POINTS_HELPER,
AKANTU_FE_ENGINE_LIST_INTERPOLATE_ON_INTEGRATION_POINTS)
#undef AKANTU_SPECIALIZE_INTERPOLATE_ON_INTEGRATION_POINTS_HELPER
#undef INTERPOLATE
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
interpolateOnIntegrationPoints(const Array<Real> & u, Array<Real> & uq,
const UInt nb_degree_of_freedom,
const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt nb_points =
shape_functions.getIntegrationPoints(type, ghost_type).cols();
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
#ifndef AKANTU_NDEBUG
AKANTU_DEBUG_ASSERT(u.size() == mesh.getNbNodes(),
"The vector u(" << u.getID()
<< ") has not the good size.");
AKANTU_DEBUG_ASSERT(u.getNbComponent() == nb_degree_of_freedom,
"The vector u("
<< u.getID()
<< ") has not the good number of component.");
AKANTU_DEBUG_ASSERT(uq.getNbComponent() == nb_degree_of_freedom,
"The vector uq("
<< uq.getID()
<< ") has not the good number of component.");
#endif
uq.resize(nb_element * nb_points);
fe_engine::details::InterpolateOnIntegrationPointsHelper<kind>::call(
shape_functions, u, uq, nb_degree_of_freedom, type, ghost_type,
filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
interpolateOnIntegrationPoints(
const Array<Real> & u, ElementTypeMapArray<Real> & uq,
const ElementTypeMapArray<UInt> * filter_elements) const {
AKANTU_DEBUG_IN();
const Array<UInt> * filter = nullptr;
for (auto ghost_type : ghost_types) {
for (auto & type : uq.elementTypes(_all_dimensions, ghost_type, kind)) {
UInt nb_quad_per_element = getNbIntegrationPoints(type, ghost_type);
UInt nb_element = 0;
if (filter_elements) {
filter = &((*filter_elements)(type, ghost_type));
nb_element = filter->size();
} else {
filter = &empty_filter;
nb_element = mesh.getNbElement(type, ghost_type);
}
UInt nb_tot_quad = nb_quad_per_element * nb_element;
Array<Real> & quad = uq(type, ghost_type);
quad.resize(nb_tot_quad);
interpolateOnIntegrationPoints(u, quad, quad.getNbComponent(), type,
ghost_type, *filter);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ComputeBtDHelper {};
#define COMPUTE_BTD(type) \
shape_functions.template computeBtD<type>(Ds, BtDs, ghost_type, \
filter_elements);
#define AKANTU_SPECIALIZE_COMPUTE_BtD_HELPER(kind) \
template <> struct ComputeBtDHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, const Array<Real> & Ds, \
Array<Real> & BtDs, const ElementType & type, \
const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_BTD, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_COMPUTE_BtD_HELPER)
#undef AKANTU_SPECIALIZE_COMPUTE_BtD_HELPER
#undef COMPUTE_BTD
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::computeBtD(
const Array<Real> & Ds, Array<Real> & BtDs, const ElementType & type,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
fe_engine::details::ComputeBtDHelper<kind>::call(
shape_functions, Ds, BtDs, type, ghost_type, filter_elements);
}
/* -------------------------------------------------------------------------- */
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ComputeBtDBHelper {};
#define COMPUTE_BTDB(type) \
shape_functions.template computeBtDB<type>(Ds, BtDBs, order_d, ghost_type, \
filter_elements);
#define AKANTU_SPECIALIZE_COMPUTE_BtDB_HELPER(kind) \
template <> struct ComputeBtDBHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, const Array<Real> & Ds, \
Array<Real> & BtDBs, UInt order_d, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_BTDB, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_COMPUTE_BtDB_HELPER)
#undef AKANTU_SPECIALIZE_COMPUTE_BtDB_HELPER
#undef COMPUTE_BTDB
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::computeBtDB(
const Array<Real> & Ds, Array<Real> & BtDBs, UInt order_d,
const ElementType & type, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
fe_engine::details::ComputeBtDBHelper<kind>::call(
shape_functions, Ds, BtDBs, order_d, type, ghost_type, filter_elements);
}
/* -------------------------------------------------------------------------- */
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ComputeNtbHelper {};
#define COMPUTE_Ntb(type) \
shape_functions.template computeNtb<type>(bs, Ntbs, ghost_type, \
filter_elements);
#define AKANTU_SPECIALIZE_COMPUTE_Ntb_HELPER(kind) \
template <> struct ComputeNtbHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, const Array<Real> & bs, \
Array<Real> & Ntbs, const ElementType & type, \
const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_Ntb, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_COMPUTE_Ntb_HELPER)
#undef AKANTU_SPECIALIZE_COMPUTE_Ntb_HELPER
#undef COMPUTE_Ntb
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::computeNtb(
const Array<Real> & bs, Array<Real> & Ntbs, const ElementType & type,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
fe_engine::details::ComputeNtbHelper<kind>::call(
shape_functions, bs, Ntbs, type, ghost_type, filter_elements);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeIntegrationPointsCoordinates(
ElementTypeMapArray<Real> & quadrature_points_coordinates,
const ElementTypeMapArray<UInt> * filter_elements) const {
const Array<Real> & nodes_coordinates = mesh.getNodes();
interpolateOnIntegrationPoints(
nodes_coordinates, quadrature_points_coordinates, filter_elements);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeIntegrationPointsCoordinates(
Array<Real> & quadrature_points_coordinates, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
const Array<Real> & nodes_coordinates = mesh.getNodes();
UInt spatial_dimension = mesh.getSpatialDimension();
interpolateOnIntegrationPoints(
nodes_coordinates, quadrature_points_coordinates, spatial_dimension, type,
ghost_type, filter_elements);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
initElementalFieldInterpolationFromIntegrationPoints(
const ElementTypeMapArray<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
const ElementTypeMapArray<UInt> * element_filter) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = this->mesh.getSpatialDimension();
ElementTypeMapArray<Real> quadrature_points_coordinates(
"quadrature_points_coordinates_for_interpolation", getID(),
getMemoryID());
quadrature_points_coordinates.initialize(*this,
_nb_component = spatial_dimension);
computeIntegrationPointsCoordinates(quadrature_points_coordinates,
element_filter);
shape_functions.initElementalFieldInterpolationFromIntegrationPoints(
interpolation_points_coordinates,
interpolation_points_coordinates_matrices,
quad_points_coordinates_inv_matrices, quadrature_points_coordinates,
element_filter);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
interpolateElementalFieldFromIntegrationPoints(
const ElementTypeMapArray<Real> & field,
const ElementTypeMapArray<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & result, const GhostType ghost_type,
const ElementTypeMapArray<UInt> * element_filter) const {
ElementTypeMapArray<Real> interpolation_points_coordinates_matrices(
"interpolation_points_coordinates_matrices", id, memory_id);
ElementTypeMapArray<Real> quad_points_coordinates_inv_matrices(
"quad_points_coordinates_inv_matrices", id, memory_id);
initElementalFieldInterpolationFromIntegrationPoints(
interpolation_points_coordinates,
interpolation_points_coordinates_matrices,
quad_points_coordinates_inv_matrices, element_filter);
interpolateElementalFieldFromIntegrationPoints(
field, interpolation_points_coordinates_matrices,
quad_points_coordinates_inv_matrices, result, ghost_type, element_filter);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
interpolateElementalFieldFromIntegrationPoints(
const ElementTypeMapArray<Real> & field,
const ElementTypeMapArray<Real> &
interpolation_points_coordinates_matrices,
const ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
ElementTypeMapArray<Real> & result, const GhostType ghost_type,
const ElementTypeMapArray<UInt> * element_filter) const {
shape_functions.interpolateElementalFieldFromIntegrationPoints(
field, interpolation_points_coordinates_matrices,
quad_points_coordinates_inv_matrices, result, ghost_type, element_filter);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct InterpolateHelper {
template <class S>
static void call(const S &, const Vector<Real> &, UInt,
const Matrix<Real> &, Vector<Real> &,
const ElementType &, const GhostType &) {
AKANTU_TO_IMPLEMENT();
}
};
#define INTERPOLATE(type) \
shape_functions.template interpolate<type>( \
real_coords, element, nodal_values, interpolated, ghost_type);
#define AKANTU_SPECIALIZE_INTERPOLATE_HELPER(kind) \
template <> struct InterpolateHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, \
const Vector<Real> & real_coords, UInt element, \
const Matrix<Real> & nodal_values, \
Vector<Real> & interpolated, const ElementType & type, \
const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INTERPOLATE, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(AKANTU_SPECIALIZE_INTERPOLATE_HELPER,
AKANTU_FE_ENGINE_LIST_INTERPOLATE)
#undef AKANTU_SPECIALIZE_INTERPOLATE_HELPER
#undef INTERPOLATE
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::interpolate(
const Vector<Real> & real_coords, const Matrix<Real> & nodal_values,
Vector<Real> & interpolated, const Element & element) const {
AKANTU_DEBUG_IN();
fe_engine::details::InterpolateHelper<kind>::call(
shape_functions, real_coords, element.element, nodal_values, interpolated,
element.type, element.ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeNormalsOnIntegrationPoints(const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
computeNormalsOnIntegrationPoints(mesh.getNodes(), ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeNormalsOnIntegrationPoints(const Array<Real> & field,
const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
// Real * coord = mesh.getNodes().storage();
UInt spatial_dimension = mesh.getSpatialDimension();
// allocate the normal arrays
normals_on_integration_points.initialize(
*this, _nb_component = spatial_dimension,
_spatial_dimension = element_dimension, _ghost_type = ghost_type,
_element_kind = kind);
// loop over the type to build the normals
for (auto & type : mesh.elementTypes(element_dimension, ghost_type, kind)) {
auto & normals_on_quad = normals_on_integration_points(type, ghost_type);
computeNormalsOnIntegrationPoints(field, normals_on_quad, type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ComputeNormalsOnIntegrationPoints {
template <template <ElementKind, class> class I,
template <ElementKind> class S, ElementKind k, class IOF>
static void call(const FEEngineTemplate<I, S, k, IOF> &,
const Array<Real> &, Array<Real> &, const ElementType &,
const GhostType &) {
AKANTU_TO_IMPLEMENT();
}
};
#define COMPUTE_NORMALS_ON_INTEGRATION_POINTS(type) \
fem.template computeNormalsOnIntegrationPoints<type>(field, normal, \
ghost_type);
#define AKANTU_SPECIALIZE_COMPUTE_NORMALS_ON_INTEGRATION_POINTS(kind) \
template <> struct ComputeNormalsOnIntegrationPoints<kind> { \
template <template <ElementKind, class> class I, \
template <ElementKind> class S, ElementKind k, class IOF> \
static void call(const FEEngineTemplate<I, S, k, IOF> & fem, \
const Array<Real> & field, Array<Real> & normal, \
const ElementType & type, const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_NORMALS_ON_INTEGRATION_POINTS, \
kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(
AKANTU_SPECIALIZE_COMPUTE_NORMALS_ON_INTEGRATION_POINTS,
AKANTU_FE_ENGINE_LIST_COMPUTE_NORMALS_ON_INTEGRATION_POINTS)
#undef AKANTU_SPECIALIZE_COMPUTE_NORMALS_ON_INTEGRATION_POINTS
#undef COMPUTE_NORMALS_ON_INTEGRATION_POINTS
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeNormalsOnIntegrationPoints(const Array<Real> & field,
Array<Real> & normal,
const ElementType & type,
const GhostType & ghost_type) const {
fe_engine::details::ComputeNormalsOnIntegrationPoints<kind>::call(
*this, field, normal, type, ghost_type);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeNormalsOnIntegrationPoints(const Array<Real> & field,
Array<Real> & normal,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
if (type == _point_1) {
computeNormalsOnIntegrationPointsPoint1(field, normal, ghost_type);
return;
}
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_points = getNbIntegrationPoints(type, ghost_type);
UInt nb_element = mesh.getConnectivity(type, ghost_type).size();
normal.resize(nb_element * nb_points);
Array<Real>::matrix_iterator normals_on_quad =
normal.begin_reinterpret(spatial_dimension, nb_points, nb_element);
Array<Real> f_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, field, f_el, type, ghost_type);
const Matrix<Real> & quads =
integrator.template getIntegrationPoints<type>(ghost_type);
Array<Real>::matrix_iterator f_it =
f_el.begin(spatial_dimension, nb_nodes_per_element);
for (UInt elem = 0; elem < nb_element; ++elem) {
ElementClass<type>::computeNormalsOnNaturalCoordinates(quads, *f_it,
*normals_on_quad);
++normals_on_quad;
++f_it;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
template <ElementKind kind> struct InverseMapHelper {
template <class S>
static void
call(const S & /*shape_functions*/, const Vector<Real> & /*real_coords*/,
UInt /*element*/, const ElementType & /*type*/,
Vector<Real> & /*natural_coords*/, const GhostType & /*ghost_type*/) {
AKANTU_TO_IMPLEMENT();
}
};
#define INVERSE_MAP(type) \
shape_functions.template inverseMap<type>(real_coords, element, \
natural_coords, ghost_type);
#define AKANTU_SPECIALIZE_INVERSE_MAP_HELPER(kind) \
template <> struct InverseMapHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, \
const Vector<Real> & real_coords, UInt element, \
const ElementType & type, Vector<Real> & natural_coords, \
const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INVERSE_MAP, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(AKANTU_SPECIALIZE_INVERSE_MAP_HELPER,
AKANTU_FE_ENGINE_LIST_INVERSE_MAP)
#undef AKANTU_SPECIALIZE_INVERSE_MAP_HELPER
#undef INVERSE_MAP
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::inverseMap(
const Vector<Real> & real_coords, UInt element, const ElementType & type,
Vector<Real> & natural_coords, const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
InverseMapHelper<kind>::call(shape_functions, real_coords, element, type,
natural_coords, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ContainsHelper {
template <class S>
static void call(const S &, const Vector<Real> &, UInt,
const ElementType &, const GhostType &) {
AKANTU_TO_IMPLEMENT();
}
};
#define CONTAINS(type) \
contain = shape_functions.template contains<type>(real_coords, element, \
ghost_type);
#define AKANTU_SPECIALIZE_CONTAINS_HELPER(kind) \
template <> struct ContainsHelper<kind> { \
template <template <ElementKind> class S, ElementKind k> \
static bool call(const S<k> & shape_functions, \
const Vector<Real> & real_coords, UInt element, \
const ElementType & type, const GhostType & ghost_type) { \
bool contain = false; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(CONTAINS, kind); \
return contain; \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(AKANTU_SPECIALIZE_CONTAINS_HELPER,
AKANTU_FE_ENGINE_LIST_CONTAINS)
#undef AKANTU_SPECIALIZE_CONTAINS_HELPER
#undef CONTAINS
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline bool FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::contains(
const Vector<Real> & real_coords, UInt element, const ElementType & type,
const GhostType & ghost_type) const {
return fe_engine::details::ContainsHelper<kind>::call(
shape_functions, real_coords, element, type, ghost_type);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ComputeShapesHelper {
template <class S>
static void call(const S &, const Vector<Real> &, UInt, const ElementType,
Vector<Real> &, const GhostType &) {
AKANTU_TO_IMPLEMENT();
}
};
#define COMPUTE_SHAPES(type) \
shape_functions.template computeShapes<type>(real_coords, element, shapes, \
ghost_type);
#define AKANTU_SPECIALIZE_COMPUTE_SHAPES_HELPER(kind) \
template <> struct ComputeShapesHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, \
const Vector<Real> & real_coords, UInt element, \
const ElementType type, Vector<Real> & shapes, \
const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_SHAPES, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(AKANTU_SPECIALIZE_COMPUTE_SHAPES_HELPER,
AKANTU_FE_ENGINE_LIST_COMPUTE_SHAPES)
#undef AKANTU_SPECIALIZE_COMPUTE_SHAPES_HELPER
#undef COMPUTE_SHAPES
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::computeShapes(
const Vector<Real> & real_coords, UInt element, const ElementType & type,
Vector<Real> & shapes, const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
fe_engine::details::ComputeShapesHelper<kind>::call(
shape_functions, real_coords, element, type, shapes, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct ComputeShapeDerivativesHelper {
template <class S>
static void call(__attribute__((unused)) const S & shape_functions,
__attribute__((unused)) const Vector<Real> & real_coords,
__attribute__((unused)) UInt element,
__attribute__((unused)) const ElementType type,
__attribute__((unused)) Matrix<Real> & shape_derivatives,
__attribute__((unused)) const GhostType & ghost_type) {
AKANTU_TO_IMPLEMENT();
}
};
#define COMPUTE_SHAPE_DERIVATIVES(type) \
Matrix<Real> coords_mat(real_coords.storage(), shape_derivatives.rows(), 1); \
Tensor3<Real> shapesd_tensor(shape_derivatives.storage(), \
shape_derivatives.rows(), \
shape_derivatives.cols(), 1); \
shape_functions.template computeShapeDerivatives<type>( \
coords_mat, element, shapesd_tensor, ghost_type);
#define AKANTU_SPECIALIZE_COMPUTE_SHAPE_DERIVATIVES_HELPER(kind) \
template <> struct ComputeShapeDerivativesHelper<kind> { \
template <class S> \
static void call(const S & shape_functions, \
const Vector<Real> & real_coords, UInt element, \
const ElementType type, Matrix<Real> & shape_derivatives, \
const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(COMPUTE_SHAPE_DERIVATIVES, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(
AKANTU_SPECIALIZE_COMPUTE_SHAPE_DERIVATIVES_HELPER,
AKANTU_FE_ENGINE_LIST_COMPUTE_SHAPES_DERIVATIVES)
#undef AKANTU_SPECIALIZE_COMPUTE_SHAPE_DERIVATIVES_HELPER
#undef COMPUTE_SHAPE_DERIVATIVES
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::computeShapeDerivatives(
const Vector<Real> & real_coords, UInt element, const ElementType & type,
Matrix<Real> & shape_derivatives, const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
fe_engine::details::ComputeShapeDerivativesHelper<kind>::call(
shape_functions, real_coords, element, type, shape_derivatives,
ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct GetNbIntegrationPointsHelper {};
#define GET_NB_INTEGRATION_POINTS(type) \
nb_quad_points = integrator.template getNbIntegrationPoints<type>(ghost_type);
#define AKANTU_SPECIALIZE_GET_NB_INTEGRATION_POINTS_HELPER(kind) \
template <> struct GetNbIntegrationPointsHelper<kind> { \
template <template <ElementKind, class> class I, ElementKind k, class IOF> \
static UInt call(const I<k, IOF> & integrator, const ElementType type, \
const GhostType & ghost_type) { \
UInt nb_quad_points = 0; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(GET_NB_INTEGRATION_POINTS, kind); \
return nb_quad_points; \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_GET_NB_INTEGRATION_POINTS_HELPER)
#undef AKANTU_SPECIALIZE_GET_NB_INTEGRATION_POINTS_HELPER
#undef GET_NB_INTEGRATION
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline UInt
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::getNbIntegrationPoints(
const ElementType & type, const GhostType & ghost_type) const {
return fe_engine::details::GetNbIntegrationPointsHelper<kind>::call(
integrator, type, ghost_type);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct GetShapesHelper {};
#define GET_SHAPES(type) ret = &(shape_functions.getShapes(type, ghost_type));
#define AKANTU_SPECIALIZE_GET_SHAPES_HELPER(kind) \
template <> struct GetShapesHelper<kind> { \
template <class S> \
static const Array<Real> & call(const S & shape_functions, \
const ElementType type, \
const GhostType & ghost_type) { \
const Array<Real> * ret = NULL; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(GET_SHAPES, kind); \
return *ret; \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_GET_SHAPES_HELPER)
#undef AKANTU_SPECIALIZE_GET_SHAPES_HELPER
#undef GET_SHAPES
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline const Array<Real> &
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::getShapes(
const ElementType & type, const GhostType & ghost_type,
__attribute__((unused)) UInt id) const {
return fe_engine::details::GetShapesHelper<kind>::call(shape_functions, type,
ghost_type);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct GetShapesDerivativesHelper {
template <template <ElementKind> class S, ElementKind k>
static const Array<Real> & call(const S<k> &, const ElementType &,
const GhostType &, UInt) {
AKANTU_TO_IMPLEMENT();
}
};
#define GET_SHAPES_DERIVATIVES(type) \
ret = &(shape_functions.getShapesDerivatives(type, ghost_type));
#define AKANTU_SPECIALIZE_GET_SHAPES_DERIVATIVES_HELPER(kind) \
template <> struct GetShapesDerivativesHelper<kind> { \
template <template <ElementKind> class S, ElementKind k> \
static const Array<Real> & \
call(const S<k> & shape_functions, const ElementType type, \
const GhostType & ghost_type, __attribute__((unused)) UInt id) { \
const Array<Real> * ret = NULL; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(GET_SHAPES_DERIVATIVES, kind); \
return *ret; \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(AKANTU_SPECIALIZE_GET_SHAPES_DERIVATIVES_HELPER,
AKANTU_FE_ENGINE_LIST_GET_SHAPES_DERIVATIVES)
#undef AKANTU_SPECIALIZE_GET_SHAPE_DERIVATIVES_HELPER
#undef GET_SHAPES_DERIVATIVES
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline const Array<Real> &
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::getShapesDerivatives(
const ElementType & type, const GhostType & ghost_type,
__attribute__((unused)) UInt id) const {
return fe_engine::details::GetShapesDerivativesHelper<kind>::call(
shape_functions, type, ghost_type, id);
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct GetIntegrationPointsHelper {};
#define GET_INTEGRATION_POINTS(type) \
ret = &(integrator.template getIntegrationPoints<type>(ghost_type));
#define AKANTU_SPECIALIZE_GET_INTEGRATION_POINTS_HELPER(kind) \
template <> struct GetIntegrationPointsHelper<kind> { \
template <template <ElementKind, class> class I, ElementKind k, class IOF> \
static const Matrix<Real> & call(const I<k, IOF> & integrator, \
const ElementType type, \
const GhostType & ghost_type) { \
const Matrix<Real> * ret = NULL; \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(GET_INTEGRATION_POINTS, kind); \
return *ret; \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_GET_INTEGRATION_POINTS_HELPER)
#undef AKANTU_SPECIALIZE_GET_INTEGRATION_POINTS_HELPER
#undef GET_INTEGRATION_POINTS
} // namespace details
} // namespace fe_engine
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline const Matrix<Real> &
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::getIntegrationPoints(
const ElementType & type, const GhostType & ghost_type) const {
return fe_engine::details::GetIntegrationPointsHelper<kind>::call(
integrator, type, ghost_type);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::printself(
std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "FEEngineTemplate [" << std::endl;
stream << space << " + parent [" << std::endl;
FEEngine::printself(stream, indent + 3);
stream << space << " ]" << std::endl;
stream << space << " + shape functions [" << std::endl;
shape_functions.printself(stream, indent + 3);
stream << space << " ]" << std::endl;
stream << space << " + integrator [" << std::endl;
integrator.printself(stream, indent + 3);
stream << space << " ]" << std::endl;
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::onElementsAdded(
const Array<Element> & new_elements, const NewElementsEvent &) {
integrator.onElementsAdded(new_elements);
shape_functions.onElementsAdded(new_elements);
}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::onElementsRemoved(
const Array<Element> &, const ElementTypeMapArray<UInt> &,
const RemovedElementsEvent &) {}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::onElementsChanged(
const Array<Element> &, const Array<Element> &,
const ElementTypeMapArray<UInt> &, const ChangedElementsEvent &) {}
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
inline void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
computeNormalsOnIntegrationPointsPoint1(
const Array<Real> &, Array<Real> & normal,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(mesh.getSpatialDimension() == 1,
"Mesh dimension must be 1 to compute normals on points!");
const auto type = _point_1;
auto spatial_dimension = mesh.getSpatialDimension();
// UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
auto nb_points = getNbIntegrationPoints(type, ghost_type);
const auto & connectivity = mesh.getConnectivity(type, ghost_type);
auto nb_element = connectivity.size();
normal.resize(nb_element * nb_points);
auto normals_on_quad =
normal.begin_reinterpret(spatial_dimension, nb_points, nb_element);
const auto & segments = mesh.getElementToSubelement(type, ghost_type);
const auto & coords = mesh.getNodes();
const Mesh * mesh_segment;
if (mesh.isMeshFacets())
mesh_segment = &(mesh.getMeshParent());
else
mesh_segment = &mesh;
for (UInt elem = 0; elem < nb_element; ++elem) {
UInt nb_segment = segments(elem).size();
AKANTU_DEBUG_ASSERT(
nb_segment > 0,
"Impossible to compute a normal on a point connected to 0 segments");
Real normal_value = 1;
if (nb_segment == 1) {
auto point = connectivity(elem);
const auto segment = segments(elem)[0];
const auto & segment_connectivity =
mesh_segment->getConnectivity(segment.type, segment.ghost_type);
Vector<UInt> segment_points = segment_connectivity.begin(
Mesh::getNbNodesPerElement(segment.type))[segment.element];
Real difference;
if (segment_points(0) == point) {
difference = coords(elem) - coords(segment_points(1));
} else {
difference = coords(elem) - coords(segment_points(0));
}
normal_value = difference / std::abs(difference);
}
for (UInt n(0); n < nb_points; ++n) {
(*normals_on_quad)(0, n) = normal_value;
}
++normals_on_quad;
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/fe_engine/fe_engine_template_tmpl_field.hh b/src/fe_engine/fe_engine_template_tmpl_field.hh
index b8b45e5b8..64e47ec73 100644
--- a/src/fe_engine/fe_engine_template_tmpl_field.hh
+++ b/src/fe_engine/fe_engine_template_tmpl_field.hh
@@ -1,428 +1,427 @@
/**
* @file fe_engine_template_tmpl_field.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 09 2017
* @date last modification: Thu Dec 07 2017
*
* @brief implementation of the assemble field s functions
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fe_engine_template.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_FE_ENGINE_TEMPLATE_TMPL_FIELD_HH__
#define __AKANTU_FE_ENGINE_TEMPLATE_TMPL_FIELD_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Matrix lumping functions */
/* -------------------------------------------------------------------------- */
namespace fe_engine {
namespace details {
namespace {
template <class Functor>
void fillField(const Functor & field_funct, Array<Real> & field,
UInt nb_element, UInt nb_integration_points,
const ElementType & type, const GhostType & ghost_type) {
UInt nb_degree_of_freedom = field.getNbComponent();
field.resize(nb_integration_points * nb_element);
auto field_it = field.begin_reinterpret(
nb_degree_of_freedom, nb_integration_points, nb_element);
Element el{type, 0, ghost_type};
for (; el.element < nb_element; ++el.element, ++field_it) {
field_funct(*field_it, el);
}
}
} // namespace
} // namespace details
} // namespace fe_engine
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct AssembleLumpedTemplateHelper {};
#define ASSEMBLE_LUMPED(type) \
fem.template assembleFieldLumped<Functor, type>(field_funct, lumped, dof_id, \
dof_manager, ghost_type)
#define AKANTU_SPECIALIZE_ASSEMBLE_HELPER(kind) \
template <> struct AssembleLumpedTemplateHelper<kind> { \
template <template <ElementKind, class> class I, \
template <ElementKind> class S, ElementKind k, class IOF, \
class Functor> \
static void call(const FEEngineTemplate<I, S, k, IOF> & fem, \
const Functor & field_funct, const ID & lumped, \
const ID & dof_id, DOFManager & dof_manager, \
ElementType type, const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(ASSEMBLE_LUMPED, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_ASSEMBLE_HELPER)
#undef AKANTU_SPECIALIZE_ASSEMBLE_HELPER
#undef ASSEMBLE_LUMPED
} // namespace details
} // namespace fe_engine
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IOF>
template <class Functor>
void FEEngineTemplate<I, S, kind, IOF>::assembleFieldLumped(
const Functor & field_funct, const ID & matrix_id, const ID & dof_id,
DOFManager & dof_manager, ElementType type,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
fe_engine::details::AssembleLumpedTemplateHelper<kind>::call(
*this, field_funct, matrix_id, dof_id, dof_manager, type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
template <class Functor, ElementType type>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::assembleFieldLumped(
const Functor & field_funct, const ID & matrix_id, const ID & dof_id,
DOFManager & dof_manager, const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt nb_degree_of_freedom = dof_manager.getDOFs(dof_id).getNbComponent();
UInt nb_element = mesh.getNbElement(type, ghost_type);
UInt nb_integration_points = this->getNbIntegrationPoints(type);
Array<Real> field(0, nb_degree_of_freedom);
fe_engine::details::fillField(field_funct, field, nb_element,
nb_integration_points, type, ghost_type);
switch (type) {
case _triangle_6:
case _quadrangle_8:
case _tetrahedron_10:
case _hexahedron_20:
case _pentahedron_15:
this->template assembleLumpedDiagonalScaling<type>(field, matrix_id, dof_id,
dof_manager, ghost_type);
break;
default:
this->template assembleLumpedRowSum<type>(field, matrix_id, dof_id,
dof_manager, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* @f$ \tilde{M}_{i} = \sum_j M_{ij} = \sum_j \int \rho \varphi_i \varphi_j dV =
* \int \rho \varphi_i dV @f$
*/
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
assembleLumpedRowSum(const Array<Real> & field, const ID & matrix_id,
const ID & dof_id, DOFManager & dof_manager,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt shapes_size = ElementClass<type>::getShapeSize();
UInt nb_degree_of_freedom = field.getNbComponent();
Array<Real> * field_times_shapes =
new Array<Real>(0, shapes_size * nb_degree_of_freedom);
shape_functions.template computeNtb<type>(field, *field_times_shapes,
ghost_type);
UInt nb_element = mesh.getNbElement(type, ghost_type);
Array<Real> * int_field_times_shapes = new Array<Real>(
nb_element, shapes_size * nb_degree_of_freedom, "inte_rho_x_shapes");
integrator.template integrate<type>(
*field_times_shapes, *int_field_times_shapes,
nb_degree_of_freedom * shapes_size, ghost_type, empty_filter);
delete field_times_shapes;
dof_manager.assembleElementalArrayToLumpedMatrix(
dof_id, *int_field_times_shapes, matrix_id, type, ghost_type);
delete int_field_times_shapes;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* @f$ \tilde{M}_{i} = c * M_{ii} = \int_{V_e} \rho dV @f$
*/
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::
assembleLumpedDiagonalScaling(const Array<Real> & field,
const ID & matrix_id, const ID & dof_id,
DOFManager & dof_manager,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
const ElementType & type_p1 = ElementClass<type>::getP1ElementType();
UInt nb_nodes_per_element_p1 = Mesh::getNbNodesPerElement(type_p1);
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_degree_of_freedom = field.getNbComponent();
UInt nb_element = mesh.getNbElement(type, ghost_type);
Vector<Real> nodal_factor(nb_nodes_per_element);
#define ASSIGN_WEIGHT_TO_NODES(corner, mid) \
{ \
for (UInt n = 0; n < nb_nodes_per_element_p1; n++) \
nodal_factor(n) = corner; \
for (UInt n = nb_nodes_per_element_p1; n < nb_nodes_per_element; n++) \
nodal_factor(n) = mid; \
}
if (type == _triangle_6)
ASSIGN_WEIGHT_TO_NODES(1. / 12., 1. / 4.);
if (type == _tetrahedron_10)
ASSIGN_WEIGHT_TO_NODES(1. / 32., 7. / 48.);
if (type == _quadrangle_8)
ASSIGN_WEIGHT_TO_NODES(
3. / 76.,
16. / 76.); /** coeff. derived by scaling
* the diagonal terms of the corresponding
* consistent mass computed with 3x3 gauss points;
* coeff. are (1./36., 8./36.) for 2x2 gauss points */
if (type == _hexahedron_20)
ASSIGN_WEIGHT_TO_NODES(
- 7. / 248.,
- 16. / 248.); /** coeff. derived by scaling
- * the diagonal terms of the corresponding
- * consistent mass computed with 3x3x3 gauss points;
- * coeff. are (1./40.,
- * 1./15.) for 2x2x2 gauss points */
+ 7. / 248., 16. / 248.); /** coeff. derived by scaling
+ * the diagonal terms of the corresponding
+ * consistent mass computed with 3x3x3 gauss
+ * points; coeff. are (1./40.,
+ * 1./15.) for 2x2x2 gauss points */
if (type == _pentahedron_15) {
// coefficients derived by scaling the diagonal terms of the corresponding
// consistent mass computed with 8 gauss points;
for (UInt n = 0; n < nb_nodes_per_element_p1; n++)
nodal_factor(n) = 51. / 2358.;
Real mid_triangle = 192. / 2358.;
Real mid_quadrangle = 300. / 2358.;
nodal_factor(6) = mid_triangle;
nodal_factor(7) = mid_triangle;
nodal_factor(8) = mid_triangle;
nodal_factor(9) = mid_quadrangle;
nodal_factor(10) = mid_quadrangle;
nodal_factor(11) = mid_quadrangle;
nodal_factor(12) = mid_triangle;
nodal_factor(13) = mid_triangle;
nodal_factor(14) = mid_triangle;
}
if (nb_element == 0) {
AKANTU_DEBUG_OUT();
return;
}
#undef ASSIGN_WEIGHT_TO_NODES
/// compute @f$ \int \rho dV = \rho V @f$ for each element
auto int_field = std::make_unique<Array<Real>>(
field.size(), nb_degree_of_freedom, "inte_rho_x");
integrator.template integrate<type>(field, *int_field, nb_degree_of_freedom,
ghost_type, empty_filter);
/// distribute the mass of the element to the nodes
auto lumped_per_node = std::make_unique<Array<Real>>(
nb_element, nb_degree_of_freedom * nb_nodes_per_element, "mass_per_node");
auto int_field_it = int_field->begin(nb_degree_of_freedom);
auto lumped_per_node_it =
lumped_per_node->begin(nb_degree_of_freedom, nb_nodes_per_element);
for (UInt e = 0; e < nb_element; ++e) {
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
Vector<Real> l = (*lumped_per_node_it)(n);
l = *int_field_it;
l *= nodal_factor(n);
}
++int_field_it;
++lumped_per_node_it;
}
dof_manager.assembleElementalArrayToLumpedMatrix(dof_id, *lumped_per_node,
matrix_id, type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Helper class to be able to write a partial specialization on the element kind
*/
namespace fe_engine {
namespace details {
template <ElementKind kind> struct AssembleFieldMatrixHelper {};
#define ASSEMBLE_MATRIX(type) \
fem.template assembleFieldMatrix<Functor, type>( \
field_funct, matrix_id, dof_id, dof_manager, ghost_type)
#define AKANTU_SPECIALIZE_ASSEMBLE_FIELD_MATRIX_HELPER(kind) \
template <> struct AssembleFieldMatrixHelper<kind> { \
template <template <ElementKind, class> class I, \
template <ElementKind> class S, ElementKind k, class IOF, \
class Functor> \
static void call(const FEEngineTemplate<I, S, k, IOF> & fem, \
const Functor & field_funct, const ID & matrix_id, \
const ID & dof_id, DOFManager & dof_manager, \
ElementType type, const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(ASSEMBLE_MATRIX, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_ASSEMBLE_FIELD_MATRIX_HELPER)
#undef AKANTU_SPECIALIZE_ASSEMBLE_FIELD_MATRIX_HELPER
#undef ASSEMBLE_MATRIX
} // namespace details
} // namespace fe_engine
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IOF>
template <class Functor>
void FEEngineTemplate<I, S, kind, IOF>::assembleFieldMatrix(
const Functor & field_funct, const ID & matrix_id, const ID & dof_id,
DOFManager & dof_manager, ElementType type,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
fe_engine::details::AssembleFieldMatrixHelper<kind>::template call(
*this, field_funct, matrix_id, dof_id, dof_manager, type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* @f$ \tilde{M}_{i} = \sum_j M_{ij} = \sum_j \int \rho \varphi_i \varphi_j dV =
* \int \rho \varphi_i dV @f$
*/
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
template <class Functor, ElementType type>
void FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::assembleFieldMatrix(
const Functor & field_funct, const ID & matrix_id, const ID & dof_id,
DOFManager & dof_manager, const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt shapes_size = ElementClass<type>::getShapeSize();
UInt nb_degree_of_freedom = dof_manager.getDOFs(dof_id).getNbComponent();
UInt lmat_size = nb_degree_of_freedom * shapes_size;
UInt nb_element = mesh.getNbElement(type, ghost_type);
// \int N * N so degree 2 * degree of N
const UInt polynomial_degree =
2 * ElementClassProperty<type>::polynomial_degree;
// getting the integration points
Matrix<Real> integration_points =
integrator.template getIntegrationPoints<type, polynomial_degree>();
UInt nb_integration_points = integration_points.cols();
UInt vect_size = nb_integration_points * nb_element;
// getting the shapes on the integration points
Array<Real> shapes(0, shapes_size);
shape_functions.template computeShapesOnIntegrationPoints<type>(
mesh.getNodes(), integration_points, shapes, ghost_type);
// Extending the shape functions
/// \TODO move this in the shape functions as Voigt format shapes to have the
/// code in common with the structural elements
Array<Real> modified_shapes(vect_size, lmat_size * nb_degree_of_freedom, 0.);
Array<Real> local_mat(vect_size, lmat_size * lmat_size);
auto mshapes_it = modified_shapes.begin(nb_degree_of_freedom, lmat_size);
auto shapes_it = shapes.begin(shapes_size);
for (UInt q = 0; q < vect_size; ++q, ++mshapes_it, ++shapes_it) {
for (UInt d = 0; d < nb_degree_of_freedom; ++d) {
for (UInt s = 0; s < shapes_size; ++s) {
(*mshapes_it)(d, s * nb_degree_of_freedom + d) = (*shapes_it)(s);
}
}
}
// getting the value to assemble on the integration points
Array<Real> field(vect_size, nb_degree_of_freedom);
fe_engine::details::fillField(field_funct, field, nb_element,
nb_integration_points, type, ghost_type);
// computing \rho * N
mshapes_it = modified_shapes.begin(nb_degree_of_freedom, lmat_size);
auto lmat = local_mat.begin(lmat_size, lmat_size);
auto field_it = field.begin_reinterpret(nb_degree_of_freedom, field.size());
for (UInt q = 0; q < vect_size; ++q, ++lmat, ++mshapes_it, ++field_it) {
const auto & rho = *field_it;
const auto & N = *mshapes_it;
auto & mat = *lmat;
Matrix<Real> Nt = N.transpose();
for (UInt d = 0; d < Nt.cols(); ++d) {
Nt(d) *= rho(d);
}
mat.template mul<false, false>(Nt, N);
}
// integrate the elemental values
Array<Real> int_field_times_shapes(nb_element, lmat_size * lmat_size,
"inte_rho_x_shapes");
this->integrator.template integrate<type, polynomial_degree>(
local_mat, int_field_times_shapes, lmat_size * lmat_size, ghost_type);
// assemble the elemental values to the matrix
dof_manager.assembleElementalMatricesToMatrix(
matrix_id, dof_id, int_field_times_shapes, type, ghost_type);
AKANTU_DEBUG_OUT();
}
} // namespace akantu
#endif /* __AKANTU_FE_ENGINE_TEMPLATE_TMPL_FIELD_HH__ */
diff --git a/src/fe_engine/fe_engine_template_tmpl_struct.hh b/src/fe_engine/fe_engine_template_tmpl_struct.hh
index 16854018f..e2f58e455 100644
--- a/src/fe_engine/fe_engine_template_tmpl_struct.hh
+++ b/src/fe_engine/fe_engine_template_tmpl_struct.hh
@@ -1,99 +1,101 @@
/**
* @file fe_engine_template_tmpl_struct.hh
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Sébastien Hartmann <sebastien.hartmann@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jul 07 2014
* @date last modification: Tue Feb 20 2018
*
* @brief Template implementation of FEEngineTemplate for Structural Element
* Kinds
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_structural.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <ElementKind kind, typename = void>
struct AssembleFieldMatrixStructHelper {};
template <ElementKind kind>
struct AssembleFieldMatrixStructHelper<
kind, typename std::enable_if<kind == _ek_structural>::type> {
template <template <ElementKind, class> class I,
template <ElementKind> class S, ElementKind k, class IOF>
static void call(const FEEngineTemplate<I, S, k, IOF> & fem,
const Array<Real> & field_1, UInt nb_degree_of_freedom,
SparseMatrix & M, Array<Real> * n,
ElementTypeMapArray<Real> & rotation_mat,
const ElementType & type, const GhostType & ghost_type) {
#define ASSEMBLE_MATRIX(type) \
fem.template assembleFieldMatrix<type>(field_1, nb_degree_of_freedom, M, n, \
rotation_mat, ghost_type)
AKANTU_BOOST_KIND_ELEMENT_SWITCH(ASSEMBLE_MATRIX, _ek_structural);
#undef ASSEMBLE_MATRIX
}
};
-// template <template <ElementKind, class> class I, template <ElementKind> class S,
+// template <template <ElementKind, class> class I, template <ElementKind> class
+// S,
// ElementKind kind, class IntegrationOrderFunctor>
// inline void
// FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::assembleFieldMatrix(
// const Array<Real> & field_1, UInt nb_degree_of_freedom, SparseMatrix & M,
// Array<Real> * n, ElementTypeMapArray<Real> & rotation_mat,
// const ElementType & type, const GhostType & ghost_type) const {
// AKANTU_DEBUG_IN();
// AssembleFieldMatrixStructHelper<kind>::template call(
// *this, field_1, nb_degree_of_freedom, M, n, rotation_mat, type,
// ghost_type);
// AKANTU_DEBUG_OUT();
// }
-// /* -------------------------------------------------------------------------- */
-// template <template <ElementKind, class> class I, template <ElementKind> class S,
+// /* --------------------------------------------------------------------------
+// */ template <template <ElementKind, class> class I, template <ElementKind>
+// class S,
// ElementKind kind, class IntegrationOrderFunctor>
// inline void
// FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::computeShapesMatrix(
// const ElementType &, UInt, UInt, Array<Real> *, UInt, UInt, UInt,
// const bool, const GhostType &) const {
// AKANTU_TO_IMPLEMENT();
// }
/* -------------------------------------------------------------------------- */
template <template <ElementKind, class> class I, template <ElementKind> class S,
ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline void
FEEngineTemplate<I, S, kind, IntegrationOrderFunctor>::assembleFieldMatrix(
const Array<Real> &, UInt, SparseMatrix &, Array<Real> *,
ElementTypeMapArray<Real> &, const GhostType &) const {
AKANTU_TO_IMPLEMENT();
}
-} // akantu
+} // namespace akantu
diff --git a/src/fe_engine/gauss_integration_tmpl.hh b/src/fe_engine/gauss_integration_tmpl.hh
index 7e9a17e10..f663b34f1 100644
--- a/src/fe_engine/gauss_integration_tmpl.hh
+++ b/src/fe_engine/gauss_integration_tmpl.hh
@@ -1,273 +1,273 @@
/**
* @file gauss_integration_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue May 10 2016
* @date last modification: Wed Nov 29 2017
*
* @brief implementation of the gauss integration helpers
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_GAUSS_INTEGRATION_TMPL_HH__
#define __AKANTU_GAUSS_INTEGRATION_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* GaussIntegrationElement */
/* -------------------------------------------------------------------------- */
namespace _aka_gauss_helpers {
template <GaussIntegrationType type, UInt n>
struct GaussIntegrationNbPoints {};
template <UInt n> struct GaussIntegrationNbPoints<_git_not_defined, n> {
static const UInt nb_points = 0;
};
template <UInt n> struct GaussIntegrationNbPoints<_git_point, n> {
static const UInt nb_points = 1;
};
template <UInt n> struct GaussIntegrationNbPoints<_git_segment, n> {
static const UInt nb_points = (n + 1) / 2 + ((n + 1) % 2 ? 1 : 0);
};
#define DECLARE_GAUSS_NB_POINTS(type, order, points) \
template <> struct GaussIntegrationNbPoints<type, order> { \
static const UInt nb_points = points; \
}
#define DECLARE_GAUSS_NB_POINTS_PENT(type, order, xo, yo) \
template <> struct GaussIntegrationNbPoints<type, order> { \
static const UInt x_order = xo; \
static const UInt yz_order = yo; \
static const UInt nb_points = 1; \
}
DECLARE_GAUSS_NB_POINTS(_git_triangle, 1, 1);
DECLARE_GAUSS_NB_POINTS(_git_triangle, 2, 3);
DECLARE_GAUSS_NB_POINTS(_git_triangle, 3, 4);
DECLARE_GAUSS_NB_POINTS(_git_triangle, 4, 6);
DECLARE_GAUSS_NB_POINTS(_git_triangle, 5, 7);
DECLARE_GAUSS_NB_POINTS(_git_tetrahedron, 1, 1);
DECLARE_GAUSS_NB_POINTS(_git_tetrahedron, 2, 4);
DECLARE_GAUSS_NB_POINTS(_git_tetrahedron, 3, 5);
DECLARE_GAUSS_NB_POINTS(_git_tetrahedron, 4, 15);
DECLARE_GAUSS_NB_POINTS(_git_tetrahedron, 5, 15);
DECLARE_GAUSS_NB_POINTS_PENT(_git_pentahedron, 1, 3,
2); // order 3 in x, order 2 in y and z
DECLARE_GAUSS_NB_POINTS_PENT(_git_pentahedron, 2, 3,
2); // order 3 in x, order 2 in y and z
DECLARE_GAUSS_NB_POINTS_PENT(_git_pentahedron, 3, 3,
3); // order 3 in x, order 3 in y and z
DECLARE_GAUSS_NB_POINTS_PENT(_git_pentahedron, 4, 5,
5); // order 5 in x, order 5 in y and z
DECLARE_GAUSS_NB_POINTS_PENT(_git_pentahedron, 5, 5,
5); // order 5 in x, order 5 in y and z
template <GaussIntegrationType type, UInt n, UInt on = n,
bool end_recurse = false>
struct GaussIntegrationNbPointsHelper {
static const UInt pnp = GaussIntegrationNbPoints<type, n>::nb_points;
static const UInt order = n;
static const UInt nb_points = pnp;
};
template <GaussIntegrationType type, UInt n, UInt on>
struct GaussIntegrationNbPointsHelper<type, n, on, true> {
static const UInt nb_points = 0;
};
/* ------------------------------------------------------------------------ */
/* Generic helper */
/* ------------------------------------------------------------------------ */
template <GaussIntegrationType type, UInt dimension, UInt n>
struct GaussIntegrationTypeDataHelper {
using git_np = GaussIntegrationNbPoints<type, n>;
using git_data = GaussIntegrationTypeData<type, git_np::nb_points>;
static UInt getNbQuadraturePoints() { return git_np::nb_points; }
static const Matrix<Real> getQuadraturePoints() {
return Matrix<Real>(git_data::quad_positions, dimension,
git_np::nb_points);
}
static const Vector<Real> getWeights() {
return Vector<Real>(git_data::quad_weights, git_np::nb_points);
}
};
/* ------------------------------------------------------------------------ */
/* helper for _segment _quadrangle _hexahedron */
/* ------------------------------------------------------------------------ */
template <UInt dimension, UInt dp>
struct GaussIntegrationTypeDataHelper<_git_segment, dimension, dp> {
using git_np = GaussIntegrationNbPoints<_git_segment, dp>;
using git_data = GaussIntegrationTypeData<_git_segment, git_np::nb_points>;
static UInt getNbQuadraturePoints() {
return Math::pow<dimension>(git_np::nb_points);
}
static const Matrix<Real> getQuadraturePoints() {
UInt tot_nquad = getNbQuadraturePoints();
UInt nquad = git_np::nb_points;
Matrix<Real> quads(dimension, tot_nquad);
Vector<Real> pos(git_data::quad_positions, nquad);
UInt offset = 1;
for (UInt d = 0; d < dimension; ++d) {
for (UInt n = 0, q = 0; n < tot_nquad; ++n, q += offset) {
UInt rq = q % tot_nquad + q / tot_nquad;
quads(d, rq) = pos(n % nquad);
}
offset *= nquad;
}
return quads;
}
static const Vector<Real> getWeights() {
UInt tot_nquad = getNbQuadraturePoints();
UInt nquad = git_np::nb_points;
Vector<Real> quads_weights(tot_nquad, 1.);
Vector<Real> weights(git_data::quad_weights, nquad);
UInt offset = 1;
for (UInt d = 0; d < dimension; ++d) {
for (UInt n = 0, q = 0; n < tot_nquad; ++n, q += offset) {
UInt rq = q % tot_nquad + q / tot_nquad;
quads_weights(rq) *= weights(n % nquad);
}
offset *= nquad;
}
return quads_weights;
}
};
/* ------------------------------------------------------------------------ */
/* helper for _pentahedron */
/* ------------------------------------------------------------------------ */
template <UInt dimension, UInt dp>
struct GaussIntegrationTypeDataHelper<_git_pentahedron, dimension, dp> {
using git_info = GaussIntegrationNbPoints<_git_pentahedron, dp>;
using git_np_seg =
GaussIntegrationNbPoints<_git_segment, git_info::x_order>;
using git_np_tri =
GaussIntegrationNbPoints<_git_triangle, git_info::yz_order>;
using git_data_seg =
GaussIntegrationTypeData<_git_segment, git_np_seg::nb_points>;
using git_data_tri =
GaussIntegrationTypeData<_git_triangle, git_np_tri::nb_points>;
static UInt getNbQuadraturePoints() {
return git_np_seg::nb_points * git_np_tri::nb_points;
}
static const Matrix<Real> getQuadraturePoints() {
UInt tot_nquad = getNbQuadraturePoints();
UInt nquad_seg = git_np_seg::nb_points;
UInt nquad_tri = git_np_tri::nb_points;
Matrix<Real> quads(dimension, tot_nquad);
Matrix<Real> pos_seg_w(git_data_seg::quad_positions, 1, nquad_seg);
Matrix<Real> pos_tri_w(git_data_tri::quad_positions, 2, nquad_tri);
for (UInt ns = 0, q = 0; ns < nquad_seg; ++ns) {
Vector<Real> pos_seg = pos_seg_w(ns);
for (UInt nt = 0; nt < nquad_tri; ++nt, ++q) {
Vector<Real> pos_tri = pos_tri_w(nt);
Vector<Real> quad = quads(q);
quad(_x) = pos_seg(_x);
quad(_y) = pos_tri(_x);
quad(_z) = pos_tri(_y);
}
}
return quads;
}
static const Vector<Real> getWeights() {
UInt tot_nquad = getNbQuadraturePoints();
UInt nquad_seg = git_np_seg::nb_points;
UInt nquad_tri = git_np_tri::nb_points;
Vector<Real> quads_weights(tot_nquad);
Vector<Real> weight_seg(git_data_seg::quad_weights, nquad_seg);
Vector<Real> weight_tri(git_data_tri::quad_weights, nquad_tri);
for (UInt ns = 0, q = 0; ns < nquad_seg; ++ns) {
for (UInt nt = 0; nt < nquad_tri; ++nt, ++q) {
quads_weights(q) = weight_seg(ns) * weight_tri(nt);
}
}
return quads_weights;
}
};
-}
+} // namespace _aka_gauss_helpers
template <ElementType element_type, UInt n>
const Matrix<Real>
GaussIntegrationElement<element_type, n>::getQuadraturePoints() {
const InterpolationType itp_type =
ElementClassProperty<element_type>::interpolation_type;
using interpolation_property = InterpolationProperty<itp_type>;
using data_helper = _aka_gauss_helpers::GaussIntegrationTypeDataHelper<
ElementClassProperty<element_type>::gauss_integration_type,
interpolation_property::natural_space_dimension, n>;
Matrix<Real> tmp(data_helper::getQuadraturePoints());
return tmp;
}
/* -------------------------------------------------------------------------- */
template <ElementType element_type, UInt n>
const Vector<Real> GaussIntegrationElement<element_type, n>::getWeights() {
const InterpolationType itp_type =
ElementClassProperty<element_type>::interpolation_type;
using interpolation_property = InterpolationProperty<itp_type>;
using data_helper = _aka_gauss_helpers::GaussIntegrationTypeDataHelper<
ElementClassProperty<element_type>::gauss_integration_type,
interpolation_property::natural_space_dimension, n>;
Vector<Real> tmp(data_helper::getWeights());
return tmp;
}
/* -------------------------------------------------------------------------- */
template <ElementType element_type, UInt n>
UInt GaussIntegrationElement<element_type, n>::getNbQuadraturePoints() {
const InterpolationType itp_type =
ElementClassProperty<element_type>::interpolation_type;
using interpolation_property = InterpolationProperty<itp_type>;
using data_helper = _aka_gauss_helpers::GaussIntegrationTypeDataHelper<
ElementClassProperty<element_type>::gauss_integration_type,
interpolation_property::natural_space_dimension, n>;
return data_helper::getNbQuadraturePoints();
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_GAUSS_INTEGRATION_TMPL_HH__ */
diff --git a/src/fe_engine/geometrical_element_property.cc b/src/fe_engine/geometrical_element_property.cc
index 60e7f11f8..71e2e7406 100644
--- a/src/fe_engine/geometrical_element_property.cc
+++ b/src/fe_engine/geometrical_element_property.cc
@@ -1,62 +1,62 @@
/**
* @file geometrical_element_property.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 29 2017
* @date last modification: Thu Nov 30 2017
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_class.hh"
/* -------------------------------------------------------------------------- */
#include <boost/preprocessor.hpp>
/* -------------------------------------------------------------------------- */
namespace akantu {
#define AKANTU_INSTANTIATE_TYPES(r, data, type) \
constexpr std::array<UInt, ElementClass<type>::getNbFacetTypes()> \
GeometricalElementProperty< \
ElementClassProperty<type>::geometrical_type>::nb_facets; \
constexpr std::array<UInt, ElementClass<type>::getNbFacetTypes()> \
GeometricalElementProperty< \
ElementClassProperty<type>::geometrical_type>::nb_nodes_per_facet; \
constexpr std::array< \
UInt, detail::sizeFacetConnectivity<GeometricalElementProperty< \
ElementClassProperty<type>::geometrical_type>>()> \
GeometricalElementProperty<ElementClassProperty< \
type>::geometrical_type>::facet_connectivity_vect; \
constexpr std::array<ElementType, ElementClass<type>::getNbFacetTypes()> \
ElementClassExtraGeometryProperties<type>::facet_type;
BOOST_PP_SEQ_FOR_EACH(AKANTU_INSTANTIATE_TYPES, _,
(_not_defined)AKANTU_ek_regular_ELEMENT_TYPE)
#if defined(AKANTU_COHESIVE_ELEMENT)
BOOST_PP_SEQ_FOR_EACH(AKANTU_INSTANTIATE_TYPES, _,
AKANTU_ek_cohesive_ELEMENT_TYPE)
#endif
-} // akantu
+} // namespace akantu
diff --git a/src/fe_engine/geometrical_element_property.hh b/src/fe_engine/geometrical_element_property.hh
index d3a70224b..4a2fdbfac 100644
--- a/src/fe_engine/geometrical_element_property.hh
+++ b/src/fe_engine/geometrical_element_property.hh
@@ -1,488 +1,488 @@
/**
* @file geometrical_element_property.hh
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Thomas Menouillard <tmenouillard@stucky.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 29 2017
*
* @brief Specialization of the geometrical types
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_class.hh"
/* -------------------------------------------------------------------------- */
#include <array>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_GEOMETRICAL_ELEMENT_PROPERTY_HH__
#define __AKANTU_GEOMETRICAL_ELEMENT_PROPERTY_HH__
namespace akantu {
namespace detail {
template <typename properties> constexpr size_t sizeFacetConnectivity() {
size_t s = 0;
for (size_t n = 0; n < properties::nb_facet_types; ++n) {
s += properties::nb_facets[n] * properties::nb_nodes_per_facet[n];
}
return s == 0 ? 1 : s;
}
-}
+} // namespace detail
template <> struct GeometricalElementProperty<_gt_not_defined> {
static constexpr UInt spatial_dimension{0};
static constexpr UInt nb_nodes_per_element{0};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{0}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{0}};
static constexpr std::array<UInt, 1> facet_connectivity_vect{{0}};
};
template <> struct GeometricalElementProperty<_gt_point> {
static constexpr UInt spatial_dimension{0};
static constexpr UInt nb_nodes_per_element{1};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{1}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{1}};
static constexpr std::array<UInt, 1> facet_connectivity_vect{{0}};
};
template <> struct GeometricalElementProperty<_gt_segment_2> {
static constexpr UInt spatial_dimension{1};
static constexpr UInt nb_nodes_per_element{2};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{1}};
static constexpr std::array<UInt, 2> facet_connectivity_vect{{0, 1}};
};
template <> struct GeometricalElementProperty<_gt_segment_3> {
static constexpr UInt spatial_dimension{1};
static constexpr UInt nb_nodes_per_element{3};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{1}};
// clang-format off
static constexpr std::array<UInt, 2> facet_connectivity_vect{{0, 1}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_triangle_3> {
static constexpr UInt spatial_dimension{2};
static constexpr UInt nb_nodes_per_element{3};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{3}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{2}};
// clang-format off
static constexpr std::array<UInt, 6> facet_connectivity_vect{{
0, 1, 2,
1, 2, 0}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_triangle_6> {
static constexpr UInt spatial_dimension{2};
static constexpr UInt nb_nodes_per_element{6};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{3}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{3}};
// clang-format off
static constexpr std::array<UInt, 9> facet_connectivity_vect{{
0, 1, 2,
1, 2, 0,
3, 4, 5}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_tetrahedron_4> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{4};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{4}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{3}};
// clang-format off
static constexpr std::array<UInt, 12> facet_connectivity_vect{{
0, 1, 2, 0,
2, 2, 0, 1,
1, 3, 3, 3}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_tetrahedron_10> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{10};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{4}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{6}};
// clang-format off
static constexpr std::array<UInt, 6*4> facet_connectivity_vect{{
0, 1, 2, 0,
2, 2, 0, 1,
1, 3, 3, 3,
6, 5, 6, 4,
5, 9, 7, 8,
4, 8, 9, 7}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_quadrangle_4> {
static constexpr UInt spatial_dimension{2};
static constexpr UInt nb_nodes_per_element{4};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{4}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{2}};
// clang-format off
static constexpr std::array<UInt, 2*4> facet_connectivity_vect{{
0, 1, 2, 3,
1, 2, 3, 0}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_quadrangle_8> {
static constexpr UInt spatial_dimension{2};
static constexpr UInt nb_nodes_per_element{8};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{4}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{3}};
// clang-format off
static constexpr std::array<UInt, 4*3> facet_connectivity_vect{{
0, 1, 2, 3,
1, 2, 3, 0,
4, 5, 6, 7}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_hexahedron_8> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{8};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{6}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{4}};
// clang-format off
static constexpr std::array<UInt, 4*6> facet_connectivity_vect{{
0, 0, 1, 2, 3, 4,
3, 1, 2, 3, 0, 5,
2, 5, 6, 7, 4, 6,
1, 4, 5, 6, 7, 7}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_hexahedron_20> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{20};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{6}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{8}};
// clang-format off
static constexpr std::array<UInt, 8*6> facet_connectivity_vect{{
0, 1, 2, 3, 0, 4,
1, 2, 3, 0, 3, 5,
5, 6, 7, 4, 2, 6,
4, 5, 6, 7, 1, 7,
8, 9, 10, 11, 11, 16,
13, 14, 15, 12, 10, 17,
16, 17, 18, 19, 9, 18,
12, 13, 14, 15, 8, 19}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_pentahedron_6> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{6};
static constexpr UInt nb_facet_types{2};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2, 3}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{3, 4}};
// clang-format off
static constexpr std::array<UInt, 3*2 + 4*3> facet_connectivity_vect{{
// first type
0, 3,
2, 4,
1, 5,
// second type
0, 0, 1,
1, 3, 2,
4, 5, 5,
3, 2, 4}};
// clang-format on
};
template <> struct GeometricalElementProperty<_gt_pentahedron_15> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{15};
static constexpr UInt nb_facet_types{2};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2, 3}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{6, 8}};
// clang-format off
static constexpr std::array<UInt, 6*2 + 8*3> facet_connectivity_vect{{
// first type
0, 3,
2, 4,
1, 5,
8, 12,
7, 13,
6, 14,
// second type
0, 0, 1,
1, 3, 2,
4, 5, 5,
3, 2, 4,
6, 9, 7,
10, 14, 11,
12, 11, 13,
9, 8, 10}};
// clang-format on
};
#if defined(AKANTU_COHESIVE_ELEMENT)
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_2d_4> {
static constexpr UInt spatial_dimension{2};
static constexpr UInt nb_nodes_per_element{4};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{2}};
// clang-format off
static constexpr std::array<UInt, 2 * 2> facet_connectivity_vect{{
0, 2,
1, 3}};
// clang-format on
};
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_2d_6> {
static constexpr UInt spatial_dimension{2};
static constexpr UInt nb_nodes_per_element{6};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{3}};
// clang-format off
static constexpr std::array<UInt, 3*2> facet_connectivity_vect{{
0, 3,
1, 4,
2, 5}};
// clang-format on
};
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_1d_2> {
static constexpr UInt spatial_dimension{1};
static constexpr UInt nb_nodes_per_element{2};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{1}};
// clang-format off
static constexpr std::array<UInt, 2> facet_connectivity_vect{{0, 1}};
// clang-format on
};
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_3d_6> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{6};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{3}};
// clang-format off
static constexpr std::array<UInt, 3*2> facet_connectivity_vect{{
0, 3,
1, 4,
2, 5}};
// clang-format on
};
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_3d_12> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{12};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{6}};
// clang-format off
static constexpr std::array<UInt, 6*2> facet_connectivity_vect{{
0, 6,
1, 7,
2, 8,
3, 9,
4, 10,
5, 11}};
// clang-format on
};
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_3d_8> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{8};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{4}};
// clang-format off
static constexpr std::array<UInt, 4*2> facet_connectivity_vect{{
0, 4,
1, 5,
2, 6,
3, 7}};
// clang-format on
};
/* --------------------------------------------------------------------------
*/
template <> struct GeometricalElementProperty<_gt_cohesive_3d_16> {
static constexpr UInt spatial_dimension{3};
static constexpr UInt nb_nodes_per_element{16};
static constexpr UInt nb_facet_types{1};
static constexpr std::array<UInt, nb_facet_types> nb_facets{{2}};
static constexpr std::array<UInt, nb_facet_types> nb_nodes_per_facet{{8}};
// clang-format off
static constexpr std::array<UInt, 8*2> facet_connectivity_vect{{
0, 8,
1, 9,
2, 10,
3, 11,
4, 12,
5, 13,
6, 14,
7, 15}};
// clang-format on
};
#endif // AKANTU_COHESIVE_ELEMENT
/* ------------------------------------------------------------------------ */
template <> struct ElementClassExtraGeometryProperties<_not_defined> {
static constexpr ElementType p1_type{_not_defined};
static constexpr std::array<ElementType, 1> facet_type{{_not_defined}};
};
template <> struct ElementClassExtraGeometryProperties<_point_1> {
static constexpr ElementType p1_type{_point_1};
static constexpr std::array<ElementType, 1> facet_type{{_point_1}};
};
template <> struct ElementClassExtraGeometryProperties<_segment_2> {
static constexpr ElementType p1_type{_segment_2};
static constexpr std::array<ElementType, 1> facet_type{{_point_1}};
};
template <> struct ElementClassExtraGeometryProperties<_segment_3> {
static constexpr ElementType p1_type{_segment_2};
static constexpr std::array<ElementType, 1> facet_type{{_point_1}};
};
template <> struct ElementClassExtraGeometryProperties<_triangle_3> {
static constexpr ElementType p1_type{_triangle_3};
static constexpr std::array<ElementType, 1> facet_type{{_segment_2}};
};
template <> struct ElementClassExtraGeometryProperties<_triangle_6> {
static constexpr ElementType p1_type{_triangle_3};
static constexpr std::array<ElementType, 1> facet_type{{_segment_3}};
};
template <> struct ElementClassExtraGeometryProperties<_tetrahedron_4> {
static constexpr ElementType p1_type{_tetrahedron_4};
static constexpr std::array<ElementType, 1> facet_type{{_triangle_3}};
};
template <> struct ElementClassExtraGeometryProperties<_tetrahedron_10> {
static constexpr ElementType p1_type{_tetrahedron_4};
static constexpr std::array<ElementType, 1> facet_type{{_triangle_6}};
};
template <> struct ElementClassExtraGeometryProperties<_quadrangle_4> {
static constexpr ElementType p1_type{_quadrangle_4};
static constexpr std::array<ElementType, 1> facet_type{{_segment_2}};
};
template <> struct ElementClassExtraGeometryProperties<_quadrangle_8> {
static constexpr ElementType p1_type{_quadrangle_4};
static constexpr std::array<ElementType, 1> facet_type{{_segment_3}};
};
template <> struct ElementClassExtraGeometryProperties<_hexahedron_8> {
static constexpr ElementType p1_type{_hexahedron_8};
static constexpr std::array<ElementType, 1> facet_type{{_quadrangle_4}};
};
template <> struct ElementClassExtraGeometryProperties<_hexahedron_20> {
static constexpr ElementType p1_type{_hexahedron_8};
static constexpr std::array<ElementType, 1> facet_type{{_quadrangle_8}};
};
template <> struct ElementClassExtraGeometryProperties<_pentahedron_6> {
static constexpr ElementType p1_type{_pentahedron_6};
static constexpr std::array<ElementType, 2> facet_type{
{_triangle_3, _quadrangle_4}};
};
template <> struct ElementClassExtraGeometryProperties<_pentahedron_15> {
static constexpr ElementType p1_type{_pentahedron_6};
static constexpr std::array<ElementType, 2> facet_type{
{_triangle_6, _quadrangle_8}};
};
#if defined(AKANTU_COHESIVE_ELEMENT)
template <> struct ElementClassExtraGeometryProperties<_cohesive_2d_4> {
static constexpr ElementType p1_type{_cohesive_2d_4};
static constexpr std::array<ElementType, 1> facet_type{{_segment_2}};
};
template <> struct ElementClassExtraGeometryProperties<_cohesive_2d_6> {
static constexpr ElementType p1_type{_cohesive_2d_4};
static constexpr std::array<ElementType, 1> facet_type{{_segment_3}};
};
template <> struct ElementClassExtraGeometryProperties<_cohesive_1d_2> {
static constexpr ElementType p1_type{_cohesive_1d_2};
static constexpr std::array<ElementType, 1> facet_type{{_point_1}};
};
template <> struct ElementClassExtraGeometryProperties<_cohesive_3d_6> {
static constexpr ElementType p1_type{_cohesive_3d_6};
static constexpr std::array<ElementType, 1> facet_type{{_triangle_3}};
};
template <> struct ElementClassExtraGeometryProperties<_cohesive_3d_12> {
static constexpr ElementType p1_type{_cohesive_3d_6};
static constexpr std::array<ElementType, 1> facet_type{{_triangle_6}};
};
template <> struct ElementClassExtraGeometryProperties<_cohesive_3d_8> {
static constexpr ElementType p1_type{_cohesive_3d_8};
static constexpr std::array<ElementType, 1> facet_type{{_quadrangle_4}};
};
template <> struct ElementClassExtraGeometryProperties<_cohesive_3d_16> {
static constexpr ElementType p1_type{_cohesive_3d_8};
static constexpr std::array<ElementType, 1> facet_type{{_quadrangle_8}};
};
#endif // AKANTU_COHESIVE_ELEMENT
} // namespace akantu
#endif /* __AKANTU_GEOMETRICAL_ELEMENT_PROPERTY_HH__ */
diff --git a/src/fe_engine/integration_point.hh b/src/fe_engine/integration_point.hh
index 0e09a5b89..b3a5dc3ca 100644
--- a/src/fe_engine/integration_point.hh
+++ b/src/fe_engine/integration_point.hh
@@ -1,170 +1,170 @@
/**
* @file integration_point.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Jun 17 2015
* @date last modification: Wed Nov 08 2017
*
* @brief definition of the class IntegrationPoint
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_types.hh"
#include "element.hh"
/* -------------------------------------------------------------------------- */
#ifndef AKANTU_QUADRATURE_POINT_H
#define AKANTU_QUADRATURE_POINT_H
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
class IntegrationPoint;
extern const IntegrationPoint IntegrationPointNull;
/* -------------------------------------------------------------------------- */
class IntegrationPoint : public Element {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
using position_type = Vector<Real>;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
IntegrationPoint(const Element & element, UInt num_point = 0,
UInt nb_quad_per_element = 0)
: Element(element), num_point(num_point),
global_num(element.element * nb_quad_per_element + num_point),
position(nullptr, 0){};
IntegrationPoint(ElementType type = _not_defined, UInt element = 0,
UInt num_point = 0, GhostType ghost_type = _not_ghost)
: Element{type, element, ghost_type}, num_point(num_point),
position(nullptr, 0){};
IntegrationPoint(UInt element, UInt num_point, UInt global_num,
const position_type & position, ElementType type,
GhostType ghost_type = _not_ghost)
: Element{type, element, ghost_type}, num_point(num_point),
global_num(global_num), position(nullptr, 0) {
this->position.shallowCopy(position);
};
IntegrationPoint(const IntegrationPoint & quad)
: Element(quad), num_point(quad.num_point), global_num(quad.global_num),
position(nullptr, 0) {
position.shallowCopy(quad.position);
};
virtual ~IntegrationPoint() = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
inline bool operator==(const IntegrationPoint & quad) const {
return Element::operator==(quad) && this->num_point == quad.num_point;
}
inline bool operator!=(const IntegrationPoint & quad) const {
return Element::operator!=(quad) || (num_point != quad.num_point) ||
(global_num != quad.global_num);
}
bool operator<(const IntegrationPoint & rhs) const {
bool res = Element::operator<(rhs) ||
(Element::operator==(rhs) && this->num_point < rhs.num_point);
return res;
}
inline IntegrationPoint & operator=(const IntegrationPoint & q) {
if (this != &q) {
element = q.element;
type = q.type;
ghost_type = q.ghost_type;
num_point = q.num_point;
global_num = q.global_num;
position.shallowCopy(q.position);
}
return *this;
}
/// get the position of the integration point
AKANTU_GET_MACRO(Position, position, const position_type &);
/// set the position of the integration point
void setPosition(const position_type & position) {
this->position.shallowCopy(position);
}
/// deep copy of the position of the integration point
void copyPosition(const position_type & position) {
this->position.deepCopy(position);
}
/// function to print the containt of the class
virtual void printself(std::ostream & stream, int indent = 0) const {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "IntegrationPoint [";
stream << *static_cast<const Element *>(this);
stream << ", " << num_point << "(" << global_num << ")"
<< "]";
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public:
/// number of quadrature point in the element
UInt num_point;
/// global number of the quadrature point
UInt global_num{0};
// TODO might be temporary: however this class should be tought maybe...
std::string material_id;
private:
/// position of the quadrature point
position_type position;
};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const IntegrationPoint & _this) {
_this.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
#endif /* AKANTU_QUADRATURE_POINT_H */
diff --git a/src/fe_engine/integrator.hh b/src/fe_engine/integrator.hh
index c751cfff4..1cc92d1f0 100644
--- a/src/fe_engine/integrator.hh
+++ b/src/fe_engine/integrator.hh
@@ -1,135 +1,139 @@
/**
* @file integrator.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief interface for integrator classes
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_INTEGRATOR_HH__
#define __AKANTU_INTEGRATOR_HH__
/* -------------------------------------------------------------------------- */
#include "aka_memory.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class Integrator : protected Memory {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- Integrator(const Mesh & mesh, const ID & id = "integrator",
- const MemoryID & memory_id = 0)
+ Integrator(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id = "integrator", const MemoryID & memory_id = 0)
: Memory(id, memory_id), mesh(mesh),
+ _spatial_dimension(spatial_dimension),
jacobians("jacobians", id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
};
~Integrator() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// empty method
template <ElementType type>
inline void precomputeJacobiansOnQuadraturePoints(__attribute__((unused))
GhostType ghost_type) {}
/// empty method
void integrateOnElement(const Array<Real> & /*f*/, Real * /*intf*/,
UInt /*nb_degree_of_freedom*/,
const Element & /*elem*/,
GhostType /*ghost_type*/) const {};
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "Integrator [" << std::endl;
jacobians.printself(stream, indent + 1);
stream << space << "]" << std::endl;
};
/* ------------------------------------------------------------------------ */
public:
virtual void onElementsAdded(const Array<Element> &) {}
virtual void
onElementsRemoved(const Array<Element> &,
const ElementTypeMapArray<UInt> & new_numbering) {
jacobians.onElementsRemoved(new_numbering);
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// access to the jacobians
Array<Real> & getJacobians(const ElementType & type,
const GhostType & ghost_type = _not_ghost) {
return jacobians(type, ghost_type);
};
/// access to the jacobians const
const Array<Real> &
getJacobians(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const {
return jacobians(type, ghost_type);
};
AKANTU_GET_MACRO(Jacobians, jacobians, const ElementTypeMapArray<Real> &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// mesh associated to the integrator
const Mesh & mesh;
+ // spatial dimension of the elements to consider
+ UInt _spatial_dimension;
+
/// jacobians for all elements
ElementTypeMapArray<Real> jacobians;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "integrator_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const Integrator & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AKANTU_INTEGRATOR_HH__ */
diff --git a/src/fe_engine/integrator_gauss.hh b/src/fe_engine/integrator_gauss.hh
index 0c00d4055..f05a6471f 100644
--- a/src/fe_engine/integrator_gauss.hh
+++ b/src/fe_engine/integrator_gauss.hh
@@ -1,205 +1,206 @@
/**
* @file integrator_gauss.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Gauss integration facilities
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "integrator.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_INTEGRATOR_GAUSS_HH__
#define __AKANTU_INTEGRATOR_GAUSS_HH__
namespace akantu {
namespace integrator {
namespace details {
template <ElementKind> struct GaussIntegratorComputeJacobiansHelper;
} // namespace details
-} // namespace fe_engine
+} // namespace integrator
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
class IntegratorGauss : public Integrator {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- IntegratorGauss(const Mesh & mesh, const ID & id = "integrator_gauss",
+ IntegratorGauss(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id = "integrator_gauss",
const MemoryID & memory_id = 0);
~IntegratorGauss() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initIntegrator(const Array<Real> & nodes, const ElementType & type,
const GhostType & ghost_type);
template <ElementType type>
inline void initIntegrator(const Array<Real> & nodes,
const GhostType & ghost_type);
/// integrate f on the element "elem" of type "type"
template <ElementType type>
inline void integrateOnElement(const Array<Real> & f, Real * intf,
UInt nb_degree_of_freedom, const UInt elem,
const GhostType & ghost_type) const;
/// integrate f for all elements of type "type"
template <ElementType type>
void integrate(const Array<Real> & in_f, Array<Real> & intf,
UInt nb_degree_of_freedom, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const;
/// integrate scalar field in_f
template <ElementType type, UInt polynomial_degree>
Real integrate(const Array<Real> & in_f,
const GhostType & ghost_type = _not_ghost) const;
/// integrate partially around a quadrature point (@f$ intf_q = f_q * J_q *
/// w_q @f$)
template <ElementType type>
Real integrate(const Vector<Real> & in_f, UInt index,
const GhostType & ghost_type) const;
/// integrate scalar field in_f
template <ElementType type>
Real integrate(const Array<Real> & in_f, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const;
/// integrate a field without using the pre-computed values
template <ElementType type, UInt polynomial_degree>
void integrate(const Array<Real> & in_f, Array<Real> & intf,
UInt nb_degree_of_freedom, const GhostType & ghost_type) const;
/// integrate partially around a quadrature point (@f$ intf_q = f_q * J_q *
/// w_q @f$)
template <ElementType type>
void integrateOnIntegrationPoints(const Array<Real> & in_f,
Array<Real> & intf,
UInt nb_degree_of_freedom,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const;
/// return a matrix with quadrature points natural coordinates
template <ElementType type>
const Matrix<Real> & getIntegrationPoints(const GhostType & ghost_type) const;
/// return number of quadrature points
template <ElementType type>
UInt getNbIntegrationPoints(const GhostType & ghost_type) const;
template <ElementType type, UInt n> Matrix<Real> getIntegrationPoints() const;
template <ElementType type, UInt n>
Vector<Real> getIntegrationWeights() const;
protected:
friend struct integrator::details::GaussIntegratorComputeJacobiansHelper<
kind>;
template <ElementType type>
void computeJacobiansOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & quad_points,
Array<Real> & jacobians, const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
void computeJacobiansOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & quad_points,
Array<Real> & jacobians, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
/// precompute jacobians on elements of type "type"
template <ElementType type>
void precomputeJacobiansOnQuadraturePoints(const Array<Real> & nodes,
const GhostType & ghost_type);
// multiply the jacobians by the integration weights and stores the results in
// jacobians
template <ElementType type, UInt polynomial_degree>
void multiplyJacobiansByWeights(
Array<Real> & jacobians,
const Array<UInt> & filter_elements = empty_filter) const;
/// compute the vector of quadrature points natural coordinates
template <ElementType type>
void computeQuadraturePoints(const GhostType & ghost_type);
/// check that the jacobians are not negative
template <ElementType type>
void checkJacobians(const GhostType & ghost_type) const;
/// internal integrate partially around a quadrature point (@f$ intf_q = f_q *
/// J_q *
/// w_q @f$)
void integrateOnIntegrationPoints(const Array<Real> & in_f,
Array<Real> & intf,
UInt nb_degree_of_freedom,
const Array<Real> & jacobians,
UInt nb_element) const;
void integrate(const Array<Real> & in_f, Array<Real> & intf,
UInt nb_degree_of_freedom, const Array<Real> & jacobians,
UInt nb_element) const;
public:
/// compute the jacobians on quad points for a given element
template <ElementType type>
void
computeJacobianOnQuadPointsByElement(const Matrix<Real> & node_coords,
const Matrix<Real> & integration_points,
Vector<Real> & jacobians) const;
public:
void onElementsAdded(const Array<Element> & elements) override;
template <ElementType type>
void onElementsAddedByType(const Array<UInt> & new_elements,
const GhostType & ghost_type);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// integrate the field f with the jacobian jac -> inte
inline void integrate(Real * f, Real * jac, Real * inte,
UInt nb_degree_of_freedom,
UInt nb_quadrature_points) const;
private:
/// ElementTypeMap of the quadrature points
ElementTypeMap<Matrix<Real>> quadrature_points;
};
} // namespace akantu
#include "integrator_gauss_inline_impl.cc"
#endif /* __AKANTU_INTEGRATOR_GAUSS_HH__ */
diff --git a/src/fe_engine/integrator_gauss_inline_impl.cc b/src/fe_engine/integrator_gauss_inline_impl.cc
index 1f6e8290f..c768696c7 100644
--- a/src/fe_engine/integrator_gauss_inline_impl.cc
+++ b/src/fe_engine/integrator_gauss_inline_impl.cc
@@ -1,755 +1,761 @@
/**
* @file integrator_gauss_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Feb 15 2011
* @date last modification: Tue Feb 20 2018
*
* @brief inline function of gauss integrator
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fe_engine.hh"
#include "mesh_iterators.hh"
#if defined(AKANTU_DEBUG_TOOLS)
#include "aka_debug_tools.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
namespace debug {
struct IntegratorGaussException : public Exception {};
} // namespace debug
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline void IntegratorGauss<kind, IntegrationOrderFunctor>::integrateOnElement(
const Array<Real> & f, Real * intf, UInt nb_degree_of_freedom,
const UInt elem, const GhostType & ghost_type) const {
Array<Real> & jac_loc = jacobians(type, ghost_type);
UInt nb_quadrature_points = ElementClass<type>::getNbQuadraturePoints();
AKANTU_DEBUG_ASSERT(f.getNbComponent() == nb_degree_of_freedom,
"The vector f do not have the good number of component.");
Real * f_val = f.storage() + elem * f.getNbComponent();
Real * jac_val = jac_loc.storage() + elem * nb_quadrature_points;
integrate(f_val, jac_val, intf, nb_degree_of_freedom, nb_quadrature_points);
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline Real IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
const Vector<Real> & in_f, UInt index, const GhostType & ghost_type) const {
const Array<Real> & jac_loc = jacobians(type, ghost_type);
UInt nb_quadrature_points =
GaussIntegrationElement<type>::getNbQuadraturePoints();
AKANTU_DEBUG_ASSERT(in_f.size() == nb_quadrature_points,
"The vector f do not have nb_quadrature_points entries.");
Real * jac_val = jac_loc.storage() + index * nb_quadrature_points;
Real intf;
integrate(in_f.storage(), jac_val, &intf, 1, nb_quadrature_points);
return intf;
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
inline void IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
Real * f, Real * jac, Real * inte, UInt nb_degree_of_freedom,
UInt nb_quadrature_points) const {
memset(inte, 0, nb_degree_of_freedom * sizeof(Real));
Real * cjac = jac;
for (UInt q = 0; q < nb_quadrature_points; ++q) {
for (UInt dof = 0; dof < nb_degree_of_freedom; ++dof) {
inte[dof] += *f * *cjac;
++f;
}
++cjac;
}
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline const Matrix<Real> &
IntegratorGauss<kind, IntegrationOrderFunctor>::getIntegrationPoints(
const GhostType & ghost_type) const {
AKANTU_DEBUG_ASSERT(
quadrature_points.exists(type, ghost_type),
"Quadrature points for type "
<< quadrature_points.printType(type, ghost_type)
<< " have not been initialized."
<< " Did you use 'computeQuadraturePoints' function ?");
return quadrature_points(type, ghost_type);
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline UInt
IntegratorGauss<kind, IntegrationOrderFunctor>::getNbIntegrationPoints(
const GhostType & ghost_type) const {
AKANTU_DEBUG_ASSERT(
quadrature_points.exists(type, ghost_type),
"Quadrature points for type "
<< quadrature_points.printType(type, ghost_type)
<< " have not been initialized."
<< " Did you use 'computeQuadraturePoints' function ?");
return quadrature_points(type, ghost_type).cols();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type, UInt polynomial_degree>
inline Matrix<Real>
IntegratorGauss<kind, IntegrationOrderFunctor>::getIntegrationPoints() const {
return GaussIntegrationElement<type,
polynomial_degree>::getQuadraturePoints();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type, UInt polynomial_degree>
inline Vector<Real>
IntegratorGauss<kind, IntegrationOrderFunctor>::getIntegrationWeights() const {
return GaussIntegrationElement<type, polynomial_degree>::getWeights();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline void
IntegratorGauss<kind, IntegrationOrderFunctor>::computeQuadraturePoints(
const GhostType & ghost_type) {
Matrix<Real> & quads = quadrature_points(type, ghost_type);
const UInt polynomial_degree =
IntegrationOrderFunctor::template getOrder<type>();
quads =
GaussIntegrationElement<type, polynomial_degree>::getQuadraturePoints();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline void IntegratorGauss<kind, IntegrationOrderFunctor>::
computeJacobianOnQuadPointsByElement(const Matrix<Real> & node_coords,
const Matrix<Real> & quad,
Vector<Real> & jacobians) const {
// jacobian
ElementClass<type>::computeJacobian(quad, node_coords, jacobians);
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
IntegratorGauss<kind, IntegrationOrderFunctor>::IntegratorGauss(
- const Mesh & mesh, const ID & id, const MemoryID & memory_id)
- : Integrator(mesh, id, memory_id) {
+ const Mesh & mesh, UInt spatial_dimension, const ID & id,
+ const MemoryID & memory_id)
+ : Integrator(mesh, spatial_dimension, id, memory_id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void IntegratorGauss<kind, IntegrationOrderFunctor>::checkJacobians(
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt nb_quadrature_points = this->quadrature_points(type, ghost_type).cols();
UInt nb_element = mesh.getConnectivity(type, ghost_type).size();
Real * jacobians_val = jacobians(type, ghost_type).storage();
for (UInt i = 0; i < nb_element * nb_quadrature_points;
++i, ++jacobians_val) {
if (*jacobians_val < 0)
AKANTU_CUSTOM_EXCEPTION_INFO(debug::IntegratorGaussException{},
"Negative jacobian computed,"
<< " possible problem in the element "
"node ordering (Quadrature Point "
<< i % nb_quadrature_points << ":"
<< i / nb_quadrature_points << ":"
<< type << ":" << ghost_type << ")");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void IntegratorGauss<kind, IntegrationOrderFunctor>::
computeJacobiansOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & quad_points,
Array<Real> & jacobians, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = quad_points.cols();
UInt nb_element = mesh.getNbElement(type, ghost_type);
jacobians.resize(nb_element * nb_quadrature_points);
auto jacobians_it =
jacobians.begin_reinterpret(nb_quadrature_points, nb_element);
auto jacobians_begin = jacobians_it;
Array<Real> x_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, x_el, type, ghost_type,
filter_elements);
auto x_it = x_el.begin(spatial_dimension, nb_nodes_per_element);
nb_element = x_el.size();
// Matrix<Real> local_coord(spatial_dimension, nb_nodes_per_element);
for (UInt elem = 0; elem < nb_element; ++elem, ++x_it) {
const Matrix<Real> & x = *x_it;
if (filter_elements != empty_filter) {
jacobians_it = jacobians_begin + filter_elements(elem);
}
Vector<Real> & J = *jacobians_it;
computeJacobianOnQuadPointsByElement<type>(x, quad_points, J);
if (filter_elements == empty_filter) {
++jacobians_it;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_STRUCTURAL_MECHANICS)
template <>
template <ElementType type>
void IntegratorGauss<_ek_structural, DefaultIntegrationOrderFunctor>::
computeJacobiansOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & quad_points,
Array<Real> & jacobians, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
const UInt spatial_dimension = mesh.getSpatialDimension();
const UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
const UInt nb_quadrature_points = quad_points.cols();
const UInt nb_dofs = ElementClass<type>::getNbDegreeOfFreedom();
UInt nb_element = mesh.getNbElement(type, ghost_type);
jacobians.resize(nb_element * nb_quadrature_points);
auto jacobians_it =
jacobians.begin_reinterpret(nb_quadrature_points, nb_element);
auto jacobians_begin = jacobians_it;
Array<Real> x_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, x_el, type, ghost_type,
filter_elements);
auto x_it = x_el.begin(spatial_dimension, nb_nodes_per_element);
nb_element = x_el.size();
const bool has_extra_normal =
mesh.hasData<Real>("extra_normal", type, ghost_type);
Array<Real>::const_vector_iterator extra_normal, extra_normal_begin;
if (has_extra_normal) {
extra_normal = mesh.getData<Real>("extra_normal", type, ghost_type)
.begin(spatial_dimension);
extra_normal_begin = extra_normal;
}
// Matrix<Real> local_coord(spatial_dimension, nb_nodes_per_element);
for (UInt elem = 0; elem < nb_element; ++elem, ++x_it) {
+ if (filter_elements != empty_filter) {
+ jacobians_it = jacobians_begin + filter_elements(elem);
+ extra_normal = extra_normal_begin + filter_elements(elem);
+ }
+
const Matrix<Real> & X = *x_it;
Vector<Real> & J = *jacobians_it;
Matrix<Real> R(nb_dofs, nb_dofs);
if (has_extra_normal)
ElementClass<type>::computeRotationMatrix(R, X, *extra_normal);
else
ElementClass<type>::computeRotationMatrix(R, X, Vector<Real>(X.rows()));
// Extracting relevant lines
auto x = (R.block(0, 0, spatial_dimension, spatial_dimension) * X)
.block(0, 0, ElementClass<type>::getNaturalSpaceDimension(),
ElementClass<type>::getNbNodesPerElement());
computeJacobianOnQuadPointsByElement<type>(x, quad_points, J);
if (filter_elements == empty_filter) {
++jacobians_it;
++extra_normal;
- } else {
- jacobians_it = jacobians_begin + filter_elements(elem);
- extra_normal = extra_normal_begin + filter_elements(elem);
}
}
AKANTU_DEBUG_OUT();
}
#endif
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_COHESIVE_ELEMENT)
template <>
template <ElementType type>
void IntegratorGauss<_ek_cohesive, DefaultIntegrationOrderFunctor>::
computeJacobiansOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & quad_points,
Array<Real> & jacobians, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = quad_points.cols();
UInt nb_element = mesh.getNbElement(type, ghost_type);
jacobians.resize(nb_element * nb_quadrature_points);
auto jacobians_begin =
jacobians.begin_reinterpret(nb_quadrature_points, nb_element);
Array<Real> x_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, x_el, type, ghost_type,
filter_elements);
auto x_it = x_el.begin(spatial_dimension, nb_nodes_per_element);
UInt nb_nodes_per_subelement = nb_nodes_per_element / 2;
Matrix<Real> x(spatial_dimension, nb_nodes_per_subelement);
nb_element = x_el.size();
UInt l_el = 0;
auto compute = [&](const auto & el) {
Vector<Real> J(jacobians_begin[el]);
Matrix<Real> X(x_it[l_el]);
++l_el;
for (UInt n = 0; n < nb_nodes_per_subelement; ++n)
Vector<Real>(x(n)) =
(Vector<Real>(X(n)) + Vector<Real>(X(n + nb_nodes_per_subelement))) /
2.;
if (type == _cohesive_1d_2)
J(0) = 1;
else
this->computeJacobianOnQuadPointsByElement<type>(x, quad_points, J);
};
for_each_element(nb_element, filter_elements, compute);
AKANTU_DEBUG_OUT();
}
#endif
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void IntegratorGauss<kind, IntegrationOrderFunctor>::
precomputeJacobiansOnQuadraturePoints(const Array<Real> & nodes,
const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
Array<Real> & jacobians_tmp = jacobians.alloc(0, 1, type, ghost_type);
this->computeJacobiansOnIntegrationPoints<type>(
nodes, quadrature_points(type, ghost_type), jacobians_tmp, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type, UInt polynomial_degree>
void IntegratorGauss<kind, IntegrationOrderFunctor>::multiplyJacobiansByWeights(
Array<Real> & jacobians, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt nb_quadrature_points =
GaussIntegrationElement<type, polynomial_degree>::getNbQuadraturePoints();
Vector<Real> weights =
GaussIntegrationElement<type, polynomial_degree>::getWeights();
auto && view = make_view(jacobians, nb_quadrature_points);
if (filter_elements != empty_filter) {
auto J_it = view.begin();
for (auto el : filter_elements) {
Vector<Real> J(J_it[el]);
J *= weights;
}
} else {
for (auto & J : make_view(jacobians, nb_quadrature_points)) {
J *= weights;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
void IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & in_f, Array<Real> & intf, UInt nb_degree_of_freedom,
const Array<Real> & jacobians, UInt nb_element) const {
AKANTU_DEBUG_IN();
intf.resize(nb_element);
if (nb_element == 0)
return;
UInt nb_points = jacobians.size() / nb_element;
Array<Real>::const_matrix_iterator J_it;
Array<Real>::matrix_iterator inte_it;
Array<Real>::const_matrix_iterator f_it;
f_it = in_f.begin_reinterpret(nb_degree_of_freedom, nb_points, nb_element);
inte_it = intf.begin_reinterpret(nb_degree_of_freedom, 1, nb_element);
J_it = jacobians.begin_reinterpret(nb_points, 1, nb_element);
for (UInt el = 0; el < nb_element; ++el, ++J_it, ++f_it, ++inte_it) {
const Matrix<Real> & f = *f_it;
const Matrix<Real> & J = *J_it;
Matrix<Real> & inte_f = *inte_it;
inte_f.mul<false, false>(f, J);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & in_f, Array<Real> & intf, UInt nb_degree_of_freedom,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(jacobians.exists(type, ghost_type),
"No jacobians for the type "
<< jacobians.printType(type, ghost_type));
const Array<Real> & jac_loc = jacobians(type, ghost_type);
if (filter_elements != empty_filter) {
UInt nb_element = filter_elements.size();
Array<Real> * filtered_J = new Array<Real>(0, jac_loc.getNbComponent());
FEEngine::filterElementalData(mesh, jac_loc, *filtered_J, type, ghost_type,
filter_elements);
this->integrate(in_f, intf, nb_degree_of_freedom, *filtered_J, nb_element);
delete filtered_J;
} else {
UInt nb_element = mesh.getNbElement(type, ghost_type);
this->integrate(in_f, intf, nb_degree_of_freedom, jac_loc, nb_element);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type, UInt polynomial_degree>
void IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & in_f, Array<Real> & intf, UInt nb_degree_of_freedom,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
Matrix<Real> quads = this->getIntegrationPoints<type, polynomial_degree>();
Array<Real> jacobians;
this->computeJacobiansOnIntegrationPoints<type>(mesh.getNodes(), quads,
jacobians, ghost_type);
this->multiplyJacobiansByWeights<type, polynomial_degree>(jacobians);
this->integrate(in_f, intf, nb_degree_of_freedom, jacobians,
mesh.getNbElement(type, ghost_type));
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type, UInt polynomial_degree>
Real IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & in_f, const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
Array<Real> intfv(0, 1);
integrate<type, polynomial_degree>(in_f, intfv, 1, ghost_type);
Real res = Math::reduce(intfv);
AKANTU_DEBUG_OUT();
return res;
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
Real IntegratorGauss<kind, IntegrationOrderFunctor>::integrate(
const Array<Real> & in_f, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(jacobians.exists(type, ghost_type),
"No jacobians for the type "
<< jacobians.printType(type, ghost_type));
Array<Real> intfv(0, 1);
integrate<type>(in_f, intfv, 1, ghost_type, filter_elements);
Real res = Math::reduce(intfv);
AKANTU_DEBUG_OUT();
return res;
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
void IntegratorGauss<kind, IntegrationOrderFunctor>::
integrateOnIntegrationPoints(const Array<Real> & in_f, Array<Real> & intf,
UInt nb_degree_of_freedom,
const Array<Real> & jacobians,
UInt nb_element) const {
AKANTU_DEBUG_IN();
UInt nb_points = jacobians.size() / nb_element;
intf.resize(nb_element * nb_points);
auto J_it = jacobians.begin();
auto f_it = in_f.begin(nb_degree_of_freedom);
auto inte_it = intf.begin(nb_degree_of_freedom);
for (UInt el = 0; el < nb_element; ++el, ++J_it, ++f_it, ++inte_it) {
const Real & J = *J_it;
const Vector<Real> & f = *f_it;
Vector<Real> & inte_f = *inte_it;
inte_f = f;
inte_f *= J;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
void IntegratorGauss<kind, IntegrationOrderFunctor>::
integrateOnIntegrationPoints(const Array<Real> & in_f, Array<Real> & intf,
UInt nb_degree_of_freedom,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(jacobians.exists(type, ghost_type),
"No jacobians for the type "
<< jacobians.printType(type, ghost_type));
const Array<Real> & jac_loc = this->jacobians(type, ghost_type);
if (filter_elements != empty_filter) {
UInt nb_element = filter_elements.size();
Array<Real> * filtered_J = new Array<Real>(0, jac_loc.getNbComponent());
FEEngine::filterElementalData(mesh, jac_loc, *filtered_J, type, ghost_type,
filter_elements);
this->integrateOnIntegrationPoints(in_f, intf, nb_degree_of_freedom,
*filtered_J, nb_element);
} else {
UInt nb_element = mesh.getNbElement(type, ghost_type);
this->integrateOnIntegrationPoints(in_f, intf, nb_degree_of_freedom,
jac_loc, nb_element);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline void
IntegratorGauss<kind, IntegrationOrderFunctor>::onElementsAddedByType(
const Array<UInt> & elements, const GhostType & ghost_type) {
const auto & nodes = mesh.getNodes();
if (not quadrature_points.exists(type, ghost_type)) {
computeQuadraturePoints<type>(ghost_type);
}
if (not jacobians.exists(type, ghost_type))
jacobians.alloc(0, 1, type, ghost_type);
this->computeJacobiansOnIntegrationPoints(
nodes, quadrature_points(type, ghost_type), jacobians(type, ghost_type),
type, ghost_type, elements);
constexpr UInt polynomial_degree =
IntegrationOrderFunctor::template getOrder<type>();
multiplyJacobiansByWeights<type, polynomial_degree>(
this->jacobians(type, ghost_type), elements);
}
/* -------------------------------------------------------------------------- */
namespace integrator {
namespace details {
template <ElementKind kind> struct IntegratorOnElementsAddedHelper {};
#define ON_ELEMENT_ADDED(type) \
integrator.template onElementsAddedByType<type>(elements, ghost_type);
#define AKANTU_SPECIALIZE_ON_ELEMENT_ADDED_HELPER(kind) \
template <> struct IntegratorOnElementsAddedHelper<kind> { \
template <class I> \
static void call(I & integrator, const Array<UInt> & elements, \
const ElementType & type, const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(ON_ELEMENT_ADDED, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_SPECIALIZE_ON_ELEMENT_ADDED_HELPER)
#undef AKANTU_SPECIALIZE_ON_ELEMENT_ADDED_HELPER
#undef ON_ELEMENT_ADDED
} // namespace details
} // namespace integrator
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
void IntegratorGauss<kind, IntegrationOrderFunctor>::onElementsAdded(
const Array<Element> & new_elements) {
for (auto elements_range : MeshElementsByTypes(new_elements)) {
auto type = elements_range.getType();
auto ghost_type = elements_range.getGhostType();
+ if (mesh.getSpatialDimension(type) != _spatial_dimension)
+ continue;
+
if (mesh.getKind(type) != kind)
continue;
integrator::details::IntegratorOnElementsAddedHelper<kind>::call(
*this, elements_range.getElements(), type, ghost_type);
}
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind, class IntegrationOrderFunctor>
template <ElementType type>
inline void IntegratorGauss<kind, IntegrationOrderFunctor>::initIntegrator(
const Array<Real> & nodes, const GhostType & ghost_type) {
computeQuadraturePoints<type>(ghost_type);
precomputeJacobiansOnQuadraturePoints<type>(nodes, ghost_type);
checkJacobians<type>(ghost_type);
constexpr UInt polynomial_degree =
IntegrationOrderFunctor::template getOrder<type>();
multiplyJacobiansByWeights<type, polynomial_degree>(
this->jacobians(type, ghost_type));
}
namespace integrator {
namespace details {
template <ElementKind kind> struct GaussIntegratorInitHelper {};
#define INIT_INTEGRATOR(type) \
_int.template initIntegrator<type>(nodes, ghost_type)
#define AKANTU_GAUSS_INTERGRATOR_INIT_HELPER(kind) \
template <> struct GaussIntegratorInitHelper<kind> { \
template <ElementKind k, class IOF> \
static void call(IntegratorGauss<k, IOF> & _int, \
const Array<Real> & nodes, const ElementType & type, \
const GhostType & ghost_type) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(INIT_INTEGRATOR, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_GAUSS_INTERGRATOR_INIT_HELPER)
#undef AKANTU_GAUSS_INTERGRATOR_INIT_HELPER
#undef INIT_INTEGRATOR
} // namespace details
} // namespace integrator
template <ElementKind kind, class IntegrationOrderFunctor>
inline void IntegratorGauss<kind, IntegrationOrderFunctor>::initIntegrator(
const Array<Real> & nodes, const ElementType & type,
const GhostType & ghost_type) {
integrator::details::GaussIntegratorInitHelper<kind>::call(*this, nodes, type,
ghost_type);
}
namespace integrator {
namespace details {
template <ElementKind kind> struct GaussIntegratorComputeJacobiansHelper {};
#define AKANTU_COMPUTE_JACOBIANS(type) \
_int.template computeJacobiansOnIntegrationPoints<type>( \
nodes, quad_points, jacobians, ghost_type, filter_elements);
#define AKANTU_GAUSS_INTERGRATOR_COMPUTE_JACOBIANS(kind) \
template <> struct GaussIntegratorComputeJacobiansHelper<kind> { \
template <ElementKind k, class IOF> \
static void \
call(const IntegratorGauss<k, IOF> & _int, const Array<Real> & nodes, \
const Matrix<Real> & quad_points, Array<Real> & jacobians, \
const ElementType & type, const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(AKANTU_COMPUTE_JACOBIANS, kind); \
} \
};
AKANTU_BOOST_ALL_KIND(AKANTU_GAUSS_INTERGRATOR_COMPUTE_JACOBIANS)
#undef AKANTU_GAUSS_INTERGRATOR_COMPUTE_JACOBIANS
#undef AKANTU_COMPUTE_JACOBIANS
} // namespace details
} // namespace integrator
template <ElementKind kind, class IntegrationOrderFunctor>
void IntegratorGauss<kind, IntegrationOrderFunctor>::
computeJacobiansOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & quad_points,
Array<Real> & jacobians, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
integrator::details::GaussIntegratorComputeJacobiansHelper<kind>::call(
*this, nodes, quad_points, jacobians, type, ghost_type, filter_elements);
}
} // namespace akantu
diff --git a/src/fe_engine/interpolation_element_tmpl.hh b/src/fe_engine/interpolation_element_tmpl.hh
index febbb6ddd..33a2348b3 100644
--- a/src/fe_engine/interpolation_element_tmpl.hh
+++ b/src/fe_engine/interpolation_element_tmpl.hh
@@ -1,73 +1,73 @@
/**
* @file interpolation_element_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Jun 06 2013
* @date last modification: Wed Nov 29 2017
*
* @brief interpolation property description
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_class.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_INTERPOLATION_ELEMENT_TMPL_HH__
#define __AKANTU_INTERPOLATION_ELEMENT_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Regular Elements */
/* -------------------------------------------------------------------------- */
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_not_defined, _itk_not_defined, 0,
0);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_point_1,
_itk_lagrangian, 1, 0);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_segment_2,
_itk_lagrangian, 2, 1);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_segment_3,
_itk_lagrangian, 3, 1);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_triangle_3,
_itk_lagrangian, 3, 2);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_triangle_6,
_itk_lagrangian, 6, 2);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_tetrahedron_4,
_itk_lagrangian, 4, 3);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_tetrahedron_10,
_itk_lagrangian, 10, 3);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_quadrangle_4,
_itk_lagrangian, 4, 2);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_serendip_quadrangle_8,
_itk_lagrangian, 8, 2);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_hexahedron_8,
_itk_lagrangian, 8, 3);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_serendip_hexahedron_20,
_itk_lagrangian, 20, 3);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_pentahedron_6,
_itk_lagrangian, 6, 3);
AKANTU_DEFINE_INTERPOLATION_TYPE_PROPERTY(_itp_lagrange_pentahedron_15,
_itk_lagrangian, 15, 3);
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_INTERPOLATION_ELEMENT_TMPL_HH__ */
diff --git a/src/fe_engine/shape_cohesive.hh b/src/fe_engine/shape_cohesive.hh
index 1423ac790..953611653 100644
--- a/src/fe_engine/shape_cohesive.hh
+++ b/src/fe_engine/shape_cohesive.hh
@@ -1,183 +1,185 @@
/**
* @file shape_cohesive.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Feb 15 2011
* @date last modification: Tue Feb 20 2018
*
* @brief shape functions for cohesive elements description
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "shape_lagrange.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_COHESIVE_HH__
#define __AKANTU_SHAPE_COHESIVE_HH__
namespace akantu {
struct CohesiveReduceFunctionMean {
inline Real operator()(Real u_plus, Real u_minus) {
return .5 * (u_plus + u_minus);
}
};
struct CohesiveReduceFunctionOpening {
inline Real operator()(Real u_plus, Real u_minus) {
return (u_plus - u_minus);
}
};
template <> class ShapeLagrange<_ek_cohesive> : public ShapeLagrangeBase {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- ShapeLagrange(const Mesh & mesh, const ID & id = "shape_cohesive",
+ ShapeLagrange(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id = "shape_cohesive",
const MemoryID & memory_id = 0);
~ShapeLagrange() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
inline void initShapeFunctions(const Array<Real> & nodes,
const Matrix<Real> & integration_points,
const ElementType & type,
const GhostType & ghost_type);
/// extract the nodal values and store them per element
template <ElementType type, class ReduceFunction>
void extractNodalToElementField(
const Array<Real> & nodal_f, Array<Real> & elemental_f,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
/// computes the shape functions derivatives for given interpolation points
template <ElementType type>
void computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
void computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const override;
/// pre compute all shapes on the element integration points from natural
/// coordinates
template <ElementType type>
void precomputeShapesOnIntegrationPoints(const Array<Real> & nodes,
GhostType ghost_type);
/// pre compute all shape derivatives on the element integration points from
/// natural coordinates
template <ElementType type>
void precomputeShapeDerivativesOnIntegrationPoints(const Array<Real> & nodes,
GhostType ghost_type);
/// interpolate nodal values on the integration points
template <ElementType type, class ReduceFunction>
void interpolateOnIntegrationPoints(
const Array<Real> & u, Array<Real> & uq, UInt nb_degree_of_freedom,
const GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
template <ElementType type>
void interpolateOnIntegrationPoints(
const Array<Real> & u, Array<Real> & uq, UInt nb_degree_of_freedom,
const GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const {
interpolateOnIntegrationPoints<type, CohesiveReduceFunctionMean>(
u, uq, nb_degree_of_freedom, ghost_type, filter_elements);
}
/// compute the gradient of u on the integration points in the natural
/// coordinates
template <ElementType type>
void gradientOnIntegrationPoints(
const Array<Real> & u, Array<Real> & nablauq, UInt nb_degree_of_freedom,
GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const {
variationOnIntegrationPoints<type, CohesiveReduceFunctionMean>(
u, nablauq, nb_degree_of_freedom, ghost_type, filter_elements);
}
/* ------------------------------------------------------------------------ */
template <ElementType type>
void computeBtD(const Array<Real> & /*Ds*/, Array<Real> & /*BtDs*/,
GhostType /*ghost_type*/,
const Array<UInt> & /*filter_elements*/) const {
AKANTU_TO_IMPLEMENT();
}
template <ElementType type>
void computeBtDB(const Array<Real> & /*Ds*/, Array<Real> & /*BtDBs*/,
UInt /*order_d*/, GhostType /*ghost_type*/,
const Array<UInt> & /*filter_elements*/) const {
AKANTU_TO_IMPLEMENT();
}
/// multiply a field by shape functions
template <ElementType type>
- void computeNtb(const Array<Real> & /*bs*/, Array<Real> & /*Ntbs*/,
- const GhostType & /*ghost_type*/,
- const Array<UInt> & /*filter_elements*/ = empty_filter) const {
+ void
+ computeNtb(const Array<Real> & /*bs*/, Array<Real> & /*Ntbs*/,
+ const GhostType & /*ghost_type*/,
+ const Array<UInt> & /*filter_elements*/ = empty_filter) const {
AKANTU_TO_IMPLEMENT();
}
/* ------------------------------------------------------------------------ */
/// compute the gradient of u on the integration points
template <ElementType type, class ReduceFunction>
void variationOnIntegrationPoints(
const Array<Real> & u, Array<Real> & nablauq, UInt nb_degree_of_freedom,
GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
/// compute the normals to the field u on integration points
template <ElementType type, class ReduceFunction>
void computeNormalsOnIntegrationPoints(
const Array<Real> & u, Array<Real> & normals_u,
GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
};
/// standard output stream operator
template <class ShapeFunction>
inline std::ostream & operator<<(std::ostream & stream,
const ShapeCohesive<ShapeFunction> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "shape_cohesive_inline_impl.cc"
#endif /* __AKANTU_SHAPE_COHESIVE_HH__ */
diff --git a/src/fe_engine/shape_cohesive_inline_impl.cc b/src/fe_engine/shape_cohesive_inline_impl.cc
index f34742efd..35aa13ca2 100644
--- a/src/fe_engine/shape_cohesive_inline_impl.cc
+++ b/src/fe_engine/shape_cohesive_inline_impl.cc
@@ -1,329 +1,331 @@
/**
* @file shape_cohesive_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Feb 03 2012
* @date last modification: Mon Feb 19 2018
*
* @brief ShapeCohesive inline implementation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
-#include "shape_cohesive.hh"
#include "mesh_iterators.hh"
+#include "shape_cohesive.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_COHESIVE_INLINE_IMPL_CC__
#define __AKANTU_SHAPE_COHESIVE_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline ShapeLagrange<_ek_cohesive>::ShapeLagrange(const Mesh & mesh,
+ UInt spatial_dimension,
const ID & id,
const MemoryID & memory_id)
- : ShapeLagrangeBase(mesh, _ek_cohesive, id, memory_id) {}
+ : ShapeLagrangeBase(mesh, spatial_dimension, _ek_cohesive, id, memory_id) {}
#define INIT_SHAPE_FUNCTIONS(type) \
setIntegrationPointsByType<type>(integration_points, ghost_type); \
precomputeShapesOnIntegrationPoints<type>(nodes, ghost_type); \
precomputeShapeDerivativesOnIntegrationPoints<type>(nodes, ghost_type);
/* -------------------------------------------------------------------------- */
inline void ShapeLagrange<_ek_cohesive>::initShapeFunctions(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
const ElementType & type, const GhostType & ghost_type) {
AKANTU_BOOST_COHESIVE_ELEMENT_SWITCH(INIT_SHAPE_FUNCTIONS);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <ElementType type>
void ShapeLagrange<_ek_cohesive>::computeShapeDerivativesOnIntegrationPoints(
const Array<Real> &, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt size_of_shapesd = ElementClass<type>::getShapeDerivativesSize();
UInt spatial_dimension = ElementClass<type>::getNaturalSpaceDimension();
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
UInt nb_points = integration_points.cols();
UInt nb_element = mesh.getConnectivity(type, ghost_type).size();
AKANTU_DEBUG_ASSERT(shape_derivatives.getNbComponent() == size_of_shapesd,
"The shapes_derivatives array does not have the correct "
<< "number of component");
shape_derivatives.resize(nb_element * nb_points);
Real * shapesd_val = shape_derivatives.storage();
auto compute = [&](const auto & el) {
auto ptr = shapesd_val + el * nb_points * size_of_shapesd;
Tensor3<Real> B(ptr, spatial_dimension, nb_nodes_per_element, nb_points);
ElementClass<type>::computeDNDS(integration_points, B);
};
for_each_element(nb_element, filter_elements, compute);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
inline void
ShapeLagrange<_ek_cohesive>::computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const ElementType & type,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
#define AKANTU_COMPUTE_SHAPES(type) \
computeShapeDerivativesOnIntegrationPoints<type>( \
nodes, integration_points, shape_derivatives, ghost_type, \
filter_elements);
AKANTU_BOOST_COHESIVE_ELEMENT_SWITCH(AKANTU_COMPUTE_SHAPES);
#undef AKANTU_COMPUTE_SHAPES
}
/* -------------------------------------------------------------------------- */
template <ElementType type>
void ShapeLagrange<_ek_cohesive>::precomputeShapesOnIntegrationPoints(
const Array<Real> & nodes, GhostType ghost_type) {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
Matrix<Real> & natural_coords = integration_points(type, ghost_type);
UInt size_of_shapes = ElementClass<type>::getShapeSize();
Array<Real> & shapes_tmp =
shapes.alloc(0, size_of_shapes, itp_type, ghost_type);
this->computeShapesOnIntegrationPoints<type>(nodes, natural_coords,
shapes_tmp, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementType type>
void ShapeLagrange<_ek_cohesive>::precomputeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, GhostType ghost_type) {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
Matrix<Real> & natural_coords = integration_points(type, ghost_type);
UInt size_of_shapesd = ElementClass<type>::getShapeDerivativesSize();
Array<Real> & shapes_derivatives_tmp =
shapes_derivatives.alloc(0, size_of_shapesd, itp_type, ghost_type);
this->computeShapeDerivativesOnIntegrationPoints<type>(
nodes, natural_coords, shapes_derivatives_tmp, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementType type, class ReduceFunction>
void ShapeLagrange<_ek_cohesive>::extractNodalToElementField(
const Array<Real> & nodal_f, Array<Real> & elemental_f,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt nb_nodes_per_itp_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
UInt nb_degree_of_freedom = nodal_f.getNbComponent();
UInt nb_element = this->mesh.getNbElement(type, ghost_type);
const auto & conn_array = this->mesh.getConnectivity(type, ghost_type);
auto conn = conn_array.begin(conn_array.getNbComponent() / 2, 2);
if (filter_elements != empty_filter) {
nb_element = filter_elements.size();
}
elemental_f.resize(nb_element);
Array<Real>::matrix_iterator u_it =
elemental_f.begin(nb_degree_of_freedom, nb_nodes_per_itp_element);
ReduceFunction reduce_function;
auto compute = [&](const auto & el) {
Matrix<Real> & u = *u_it;
Matrix<UInt> el_conn(conn[el]);
// compute the average/difference of the nodal field loaded from cohesive
// element
for (UInt n = 0; n < el_conn.rows(); ++n) {
UInt node_plus = el_conn(n, 0);
UInt node_minus = el_conn(n, 1);
for (UInt d = 0; d < nb_degree_of_freedom; ++d) {
Real u_plus = nodal_f(node_plus, d);
Real u_minus = nodal_f(node_minus, d);
u(d, n) = reduce_function(u_plus, u_minus);
}
}
++u_it;
};
for_each_element(nb_element, filter_elements, compute);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementType type, class ReduceFunction>
void ShapeLagrange<_ek_cohesive>::interpolateOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_uq, UInt nb_degree_of_freedom,
GhostType ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
AKANTU_DEBUG_ASSERT(this->shapes.exists(itp_type, ghost_type),
"No shapes for the type "
<< this->shapes.printType(itp_type, ghost_type));
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
Array<Real> u_el(0, nb_degree_of_freedom * nb_nodes_per_element);
this->extractNodalToElementField<type, ReduceFunction>(in_u, u_el, ghost_type,
filter_elements);
this->template interpolateElementalFieldOnIntegrationPoints<type>(
u_el, out_uq, ghost_type, shapes(itp_type, ghost_type), filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementType type, class ReduceFunction>
void ShapeLagrange<_ek_cohesive>::variationOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & nablauq, UInt nb_degree_of_freedom,
GhostType ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
AKANTU_DEBUG_ASSERT(
this->shapes_derivatives.exists(itp_type, ghost_type),
"No shapes for the type "
<< this->shapes_derivatives.printType(itp_type, ghost_type));
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
Array<Real> u_el(0, nb_degree_of_freedom * nb_nodes_per_element);
this->extractNodalToElementField<type, ReduceFunction>(in_u, u_el, ghost_type,
filter_elements);
this->template gradientElementalFieldOnIntegrationPoints<type>(
u_el, nablauq, ghost_type, shapes_derivatives(itp_type, ghost_type),
filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementType type, class ReduceFunction>
void ShapeLagrange<_ek_cohesive>::computeNormalsOnIntegrationPoints(
const Array<Real> & u, Array<Real> & normals_u, GhostType ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt nb_element = this->mesh.getNbElement(type, ghost_type);
UInt nb_points = this->integration_points(type, ghost_type).cols();
UInt spatial_dimension = this->mesh.getSpatialDimension();
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
normals_u.resize(nb_points * nb_element);
Array<Real> tangents_u(0, (spatial_dimension * (spatial_dimension - 1)));
if (spatial_dimension > 1) {
tangents_u.resize(nb_element * nb_points);
this->template variationOnIntegrationPoints<type, ReduceFunction>(
u, tangents_u, spatial_dimension, ghost_type, filter_elements);
}
Real * tangent = tangents_u.storage();
if (spatial_dimension == 3) {
for (auto & normal : make_view(normals_u, spatial_dimension)) {
Math::vectorProduct3(tangent, tangent + spatial_dimension,
normal.storage());
normal /= normal.norm();
tangent += spatial_dimension * 2;
}
} else if (spatial_dimension == 2) {
for (auto & normal : make_view(normals_u, spatial_dimension)) {
Vector<Real> a1(tangent, spatial_dimension);
normal(0) = -a1(1);
normal(1) = a1(0);
normal.normalize();
tangent += spatial_dimension;
}
} else if (spatial_dimension == 1) {
const auto facet_type = Mesh::getFacetType(type);
const auto & mesh_facets = mesh.getMeshFacets();
const auto & facets = mesh_facets.getSubelementToElement(type, ghost_type);
const auto & segments =
mesh_facets.getElementToSubelement(facet_type, ghost_type);
Real values[2];
for (auto el : arange(nb_element)) {
if (filter_elements != empty_filter)
el = filter_elements(el);
for (UInt p = 0; p < 2; ++p) {
Element facet = facets(el, p);
Element segment = segments(facet.element)[0];
Vector<Real> barycenter(values + p, 1);
mesh.getBarycenter(segment, barycenter);
}
Real difference = values[0] - values[1];
AKANTU_DEBUG_ASSERT(difference != 0.,
"Error in normal computation for cohesive elements");
normals_u(el) = difference / std::abs(difference);
}
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
+
#endif /* __AKANTU_SHAPE_COHESIVE_INLINE_IMPL_CC__ */
diff --git a/src/fe_engine/shape_functions.cc b/src/fe_engine/shape_functions.cc
index ae1eebadc..34ebb6586 100644
--- a/src/fe_engine/shape_functions.cc
+++ b/src/fe_engine/shape_functions.cc
@@ -1,233 +1,235 @@
/**
* @file shape_functions.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 09 2017
* @date last modification: Wed Oct 11 2017
*
* @brief implementation of th shape functions interface
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_functions.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
-ShapeFunctions::ShapeFunctions(const Mesh & mesh, const ID & id,
- const MemoryID & memory_id)
+ShapeFunctions::ShapeFunctions(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id, const MemoryID & memory_id)
: Memory(id, memory_id), shapes("shapes_generic", id, memory_id),
shapes_derivatives("shapes_derivatives_generic", id, memory_id),
- mesh(mesh) {}
+ mesh(mesh), _spatial_dimension(spatial_dimension) {}
/* -------------------------------------------------------------------------- */
template <ElementType type>
inline void
ShapeFunctions::initElementalFieldInterpolationFromIntegrationPoints(
const Array<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
const Array<Real> & quadrature_points_coordinates,
const GhostType & ghost_type, const Array<UInt> & element_filter) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = this->mesh.getSpatialDimension();
UInt nb_element = this->mesh.getNbElement(type, ghost_type);
UInt nb_element_filter;
if (element_filter == empty_filter)
nb_element_filter = nb_element;
else
nb_element_filter = element_filter.size();
UInt nb_quad_per_element =
GaussIntegrationElement<type>::getNbQuadraturePoints();
UInt nb_interpolation_points_per_elem =
interpolation_points_coordinates.size() / nb_element;
AKANTU_DEBUG_ASSERT(interpolation_points_coordinates.size() % nb_element == 0,
"Number of interpolation points should be a multiple of "
"total number of elements");
if (!quad_points_coordinates_inv_matrices.exists(type, ghost_type))
quad_points_coordinates_inv_matrices.alloc(
nb_element_filter, nb_quad_per_element * nb_quad_per_element, type,
ghost_type);
else
quad_points_coordinates_inv_matrices(type, ghost_type)
.resize(nb_element_filter);
if (!interpolation_points_coordinates_matrices.exists(type, ghost_type))
interpolation_points_coordinates_matrices.alloc(
nb_element_filter,
nb_interpolation_points_per_elem * nb_quad_per_element, type,
ghost_type);
else
interpolation_points_coordinates_matrices(type, ghost_type)
.resize(nb_element_filter);
Array<Real> & quad_inv_mat =
quad_points_coordinates_inv_matrices(type, ghost_type);
Array<Real> & interp_points_mat =
interpolation_points_coordinates_matrices(type, ghost_type);
Matrix<Real> quad_coord_matrix(nb_quad_per_element, nb_quad_per_element);
Array<Real>::const_matrix_iterator quad_coords_it =
quadrature_points_coordinates.begin_reinterpret(
spatial_dimension, nb_quad_per_element, nb_element_filter);
Array<Real>::const_matrix_iterator points_coords_begin =
interpolation_points_coordinates.begin_reinterpret(
spatial_dimension, nb_interpolation_points_per_elem, nb_element);
Array<Real>::matrix_iterator inv_quad_coord_it =
quad_inv_mat.begin(nb_quad_per_element, nb_quad_per_element);
Array<Real>::matrix_iterator int_points_mat_it = interp_points_mat.begin(
nb_interpolation_points_per_elem, nb_quad_per_element);
/// loop over the elements of the current material and element type
for (UInt el = 0; el < nb_element_filter;
++el, ++inv_quad_coord_it, ++int_points_mat_it, ++quad_coords_it) {
/// matrix containing the quadrature points coordinates
const Matrix<Real> & quad_coords = *quad_coords_it;
/// matrix to store the matrix inversion result
Matrix<Real> & inv_quad_coord_matrix = *inv_quad_coord_it;
/// insert the quad coordinates in a matrix compatible with the
/// interpolation
buildElementalFieldInterpolationMatrix<type>(quad_coords,
quad_coord_matrix);
/// invert the interpolation matrix
inv_quad_coord_matrix.inverse(quad_coord_matrix);
/// matrix containing the interpolation points coordinates
const Matrix<Real> & points_coords =
points_coords_begin[element_filter(el)];
/// matrix to store the interpolation points coordinates
/// compatible with these functions
Matrix<Real> & inv_points_coord_matrix = *int_points_mat_it;
/// insert the quad coordinates in a matrix compatible with the
/// interpolation
buildElementalFieldInterpolationMatrix<type>(points_coords,
inv_points_coord_matrix);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void ShapeFunctions::initElementalFieldInterpolationFromIntegrationPoints(
const ElementTypeMapArray<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
const ElementTypeMapArray<Real> & quadrature_points_coordinates,
const ElementTypeMapArray<UInt> * element_filter) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = this->mesh.getSpatialDimension();
for (auto ghost_type : ghost_types) {
auto types_iterable = mesh.elementTypes(spatial_dimension, ghost_type);
if (element_filter) {
- types_iterable = element_filter->elementTypes(spatial_dimension, ghost_type);
+ types_iterable =
+ element_filter->elementTypes(spatial_dimension, ghost_type);
}
for (auto type : types_iterable) {
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (nb_element == 0)
continue;
const Array<UInt> * elem_filter;
if (element_filter)
elem_filter = &((*element_filter)(type, ghost_type));
else
elem_filter = &(empty_filter);
#define AKANTU_INIT_ELEMENTAL_FIELD_INTERPOLATION_FROM_C_POINTS(type) \
this->initElementalFieldInterpolationFromIntegrationPoints<type>( \
interpolation_points_coordinates(type, ghost_type), \
interpolation_points_coordinates_matrices, \
quad_points_coordinates_inv_matrices, \
quadrature_points_coordinates(type, ghost_type), ghost_type, \
*elem_filter)
AKANTU_BOOST_REGULAR_ELEMENT_SWITCH(
AKANTU_INIT_ELEMENTAL_FIELD_INTERPOLATION_FROM_C_POINTS);
#undef AKANTU_INIT_ELEMENTAL_FIELD_INTERPOLATION_FROM_C_POINTS
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void ShapeFunctions::interpolateElementalFieldFromIntegrationPoints(
const ElementTypeMapArray<Real> & field,
const ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
const ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
ElementTypeMapArray<Real> & result, const GhostType & ghost_type,
const ElementTypeMapArray<UInt> * element_filter) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = this->mesh.getSpatialDimension();
auto types_iterable = mesh.elementTypes(spatial_dimension, ghost_type);
if (element_filter) {
- types_iterable = element_filter->elementTypes(spatial_dimension, ghost_type);
+ types_iterable =
+ element_filter->elementTypes(spatial_dimension, ghost_type);
}
for (auto type : types_iterable) {
UInt nb_element = mesh.getNbElement(type, ghost_type);
if (nb_element == 0)
continue;
const Array<UInt> * elem_filter;
if (element_filter)
elem_filter = &((*element_filter)(type, ghost_type));
else
elem_filter = &(empty_filter);
#define AKANTU_INTERPOLATE_ELEMENTAL_FIELD_FROM_C_POINTS(type) \
interpolateElementalFieldFromIntegrationPoints<type>( \
field(type, ghost_type), \
interpolation_points_coordinates_matrices(type, ghost_type), \
quad_points_coordinates_inv_matrices(type, ghost_type), result, \
ghost_type, *elem_filter)
AKANTU_BOOST_REGULAR_ELEMENT_SWITCH(
AKANTU_INTERPOLATE_ELEMENTAL_FIELD_FROM_C_POINTS);
#undef AKANTU_INTERPOLATE_ELEMENTAL_FIELD_FROM_C_POINTS
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/fe_engine/shape_functions.hh b/src/fe_engine/shape_functions.hh
index ba7d2ef7b..1db568c9e 100644
--- a/src/fe_engine/shape_functions.hh
+++ b/src/fe_engine/shape_functions.hh
@@ -1,212 +1,215 @@
/**
* @file shape_functions.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief shape function class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_memory.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_FUNCTIONS_HH__
#define __AKANTU_SHAPE_FUNCTIONS_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
class ShapeFunctions : protected Memory {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- ShapeFunctions(const Mesh & mesh, const ID & id = "shape",
- const MemoryID & memory_id = 0);
+ ShapeFunctions(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id = "shape", const MemoryID & memory_id = 0);
~ShapeFunctions() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "Shapes [" << std::endl;
integration_points.printself(stream, indent + 1);
// shapes.printself(stream, indent + 1);
// shapes_derivatives.printself(stream, indent + 1);
stream << space << "]" << std::endl;
}
/// set the integration points for a given element
template <ElementType type>
void setIntegrationPointsByType(const Matrix<Real> & integration_points,
const GhostType & ghost_type);
/// Build pre-computed matrices for interpolation of field form integration
/// points at other given positions (interpolation_points)
void initElementalFieldInterpolationFromIntegrationPoints(
const ElementTypeMapArray<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
const ElementTypeMapArray<Real> & quadrature_points_coordinates,
const ElementTypeMapArray<UInt> * element_filter) const;
/// Interpolate field at given position from given values of this field at
/// integration points (field)
/// using matrices precomputed with
/// initElementalFieldInterplationFromIntegrationPoints
void interpolateElementalFieldFromIntegrationPoints(
const ElementTypeMapArray<Real> & field,
const ElementTypeMapArray<Real> &
interpolation_points_coordinates_matrices,
const ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
ElementTypeMapArray<Real> & result, const GhostType & ghost_type,
const ElementTypeMapArray<UInt> * element_filter) const;
protected:
/// interpolate nodal values stored by element on the integration points
template <ElementType type>
void interpolateElementalFieldOnIntegrationPoints(
const Array<Real> & u_el, Array<Real> & uq, const GhostType & ghost_type,
const Array<Real> & shapes,
const Array<UInt> & filter_elements = empty_filter) const;
/// gradient of nodal values stored by element on the control points
template <ElementType type>
void gradientElementalFieldOnIntegrationPoints(
const Array<Real> & u_el, Array<Real> & out_nablauq,
const GhostType & ghost_type, const Array<Real> & shapes_derivatives,
const Array<UInt> & filter_elements) const;
protected:
/// By element versions of non-templated eponym methods
template <ElementType type>
inline void interpolateElementalFieldFromIntegrationPoints(
const Array<Real> & field,
const Array<Real> & interpolation_points_coordinates_matrices,
const Array<Real> & quad_points_coordinates_inv_matrices,
ElementTypeMapArray<Real> & result, const GhostType & ghost_type,
const Array<UInt> & element_filter) const;
/// Interpolate field at given position from given values of this field at
/// integration points (field)
/// using matrices precomputed with
/// initElementalFieldInterplationFromIntegrationPoints
template <ElementType type>
inline void initElementalFieldInterpolationFromIntegrationPoints(
const Array<Real> & interpolation_points_coordinates,
ElementTypeMapArray<Real> & interpolation_points_coordinates_matrices,
ElementTypeMapArray<Real> & quad_points_coordinates_inv_matrices,
const Array<Real> & quadrature_points_coordinates,
const GhostType & ghost_type, const Array<UInt> & element_filter) const;
/// build matrix for the interpolation of field form integration points
template <ElementType type>
inline void buildElementalFieldInterpolationMatrix(
const Matrix<Real> & coordinates, Matrix<Real> & coordMatrix,
UInt integration_order =
ElementClassProperty<type>::polynomial_degree) const;
/// build the so called interpolation matrix (first collumn is 1, then the
/// other collumns are the traansposed coordinates)
inline void buildInterpolationMatrix(const Matrix<Real> & coordinates,
Matrix<Real> & coordMatrix,
UInt integration_order) const;
public:
virtual void onElementsAdded(const Array<Element> &) {
AKANTU_TO_IMPLEMENT();
}
virtual void onElementsRemoved(const Array<Element> &,
const ElementTypeMapArray<UInt> &) {
AKANTU_TO_IMPLEMENT();
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get the size of the shapes returned by the element class
static inline UInt getShapeSize(const ElementType & type);
/// get the size of the shapes derivatives returned by the element class
static inline UInt getShapeDerivativesSize(const ElementType & type);
inline const Matrix<Real> &
getIntegrationPoints(const ElementType & type,
const GhostType & ghost_type) const {
return integration_points(type, ghost_type);
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get a the shapes vector
inline const Array<Real> &
getShapes(const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
/// get a the shapes derivatives vector
inline const Array<Real> &
getShapesDerivatives(const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// shape functions for all elements
ElementTypeMapArray<Real, InterpolationType> shapes;
/// shape functions derivatives for all elements
ElementTypeMapArray<Real, InterpolationType> shapes_derivatives;
/// associated mesh
const Mesh & mesh;
+ // spatial dimension of the elements to consider
+ UInt _spatial_dimension;
+
/// shape functions for all elements
ElementTypeMap<Matrix<Real>> integration_points;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const ShapeFunctions & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "shape_functions_inline_impl.cc"
#endif /* __AKANTU_SHAPE_FUNCTIONS_HH__ */
diff --git a/src/fe_engine/shape_lagrange.hh b/src/fe_engine/shape_lagrange.hh
index 18a08b964..84aef3ff2 100644
--- a/src/fe_engine/shape_lagrange.hh
+++ b/src/fe_engine/shape_lagrange.hh
@@ -1,172 +1,173 @@
/**
* @file shape_lagrange.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Feb 15 2011
* @date last modification: Mon Jan 29 2018
*
* @brief lagrangian shape functions class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_lagrange_base.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_LAGRANGE_HH__
#define __AKANTU_SHAPE_LAGRANGE_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Shape> class ShapeCohesive;
class ShapeIGFEM;
template <ElementKind kind> class ShapeLagrange : public ShapeLagrangeBase {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- ShapeLagrange(const Mesh & mesh, const ID & id = "shape_lagrange",
+ ShapeLagrange(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id = "shape_lagrange",
const MemoryID & memory_id = 0);
~ShapeLagrange() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialization function for structural elements not yet implemented
inline void initShapeFunctions(const Array<Real> & nodes,
const Matrix<Real> & integration_points,
const ElementType & type,
const GhostType & ghost_type);
/// computes the shape functions derivatives for given interpolation points
template <ElementType type>
void computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
void computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements) const override;
/// pre compute all shapes on the element integration points from natural
/// coordinates
template <ElementType type>
void precomputeShapesOnIntegrationPoints(const Array<Real> & nodes,
const GhostType & ghost_type);
/// pre compute all shape derivatives on the element integration points from
/// natural coordinates
template <ElementType type>
void
precomputeShapeDerivativesOnIntegrationPoints(const Array<Real> & nodes,
const GhostType & ghost_type);
/// interpolate nodal values on the integration points
template <ElementType type>
void interpolateOnIntegrationPoints(
const Array<Real> & u, Array<Real> & uq, UInt nb_degree_of_freedom,
GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
template <ElementType type>
void interpolateOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_uq, UInt nb_degree_of_freedom,
const Array<Real> & shapes, GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
/// interpolate on physical point
template <ElementType type>
void interpolate(const Vector<Real> & real_coords, UInt elem,
const Matrix<Real> & nodal_values,
Vector<Real> & interpolated,
const GhostType & ghost_type) const;
/// compute the gradient of u on the integration points
template <ElementType type>
void gradientOnIntegrationPoints(
const Array<Real> & u, Array<Real> & nablauq, UInt nb_degree_of_freedom,
GhostType ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
template <ElementType type>
void computeBtD(const Array<Real> & Ds, Array<Real> & BtDs,
GhostType ghost_type,
const Array<UInt> & filter_elements) const;
template <ElementType type>
void computeBtDB(const Array<Real> & Ds, Array<Real> & BtDBs, UInt order_d,
GhostType ghost_type,
const Array<UInt> & filter_elements) const;
/// multiply a field by shape functions @f$ fts_{ij} = f_i * \varphi_j @f$
template <ElementType type>
void computeNtb(const Array<Real> & bs, Array<Real> & Ntbs,
GhostType ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
/// find natural coords from real coords provided an element
template <ElementType type>
void inverseMap(const Vector<Real> & real_coords, UInt element,
Vector<Real> & natural_coords,
const GhostType & ghost_type = _not_ghost) const;
/// return true if the coordinates provided are inside the element, false
/// otherwise
template <ElementType type>
bool contains(const Vector<Real> & real_coords, UInt elem,
const GhostType & ghost_type) const;
/// compute the shape on a provided point
template <ElementType type>
void computeShapes(const Vector<Real> & real_coords, UInt elem,
Vector<Real> & shapes, const GhostType & ghost_type) const;
/// compute the shape derivatives on a provided point
template <ElementType type>
void computeShapeDerivatives(const Matrix<Real> & real_coords, UInt elem,
Tensor3<Real> & shapes,
const GhostType & ghost_type) const;
protected:
/// compute the shape derivatives on integration points for a given element
template <ElementType type>
inline void
computeShapeDerivativesOnCPointsByElement(const Matrix<Real> & node_coords,
const Matrix<Real> & natural_coords,
Tensor3<Real> & shapesd) const;
};
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "shape_lagrange_inline_impl.cc"
#endif /* __AKANTU_SHAPE_LAGRANGE_HH__ */
diff --git a/src/fe_engine/shape_lagrange_base.cc b/src/fe_engine/shape_lagrange_base.cc
index f8484b988..fc7eadd07 100644
--- a/src/fe_engine/shape_lagrange_base.cc
+++ b/src/fe_engine/shape_lagrange_base.cc
@@ -1,163 +1,173 @@
/**
* @file shape_lagrange_base.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 09 2017
* @date last modification: Tue Feb 20 2018
*
* @brief common par for the shape lagrange
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_lagrange_base.hh"
#include "mesh_iterators.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
-ShapeLagrangeBase::ShapeLagrangeBase(const Mesh & mesh,
+ShapeLagrangeBase::ShapeLagrangeBase(const Mesh & mesh, UInt spatial_dimension,
const ElementKind & kind, const ID & id,
const MemoryID & memory_id)
- : ShapeFunctions(mesh, id, memory_id), _kind(kind) {}
+ : ShapeFunctions(mesh, spatial_dimension, id, memory_id), _kind(kind) {}
/* -------------------------------------------------------------------------- */
ShapeLagrangeBase::~ShapeLagrangeBase() = default;
/* -------------------------------------------------------------------------- */
#define AKANTU_COMPUTE_SHAPES(type) \
_this.template computeShapesOnIntegrationPoints<type>( \
nodes, integration_points, shapes, ghost_type, filter_elements)
namespace shape_lagrange {
namespace details {
template <ElementKind kind> struct Helper {
template <class S>
static void call(const S &, const Array<Real> &, const Matrix<Real> &,
Array<Real> &, const ElementType &, const GhostType &,
const Array<UInt> &) {
AKANTU_TO_IMPLEMENT();
}
};
#define AKANTU_COMPUTE_SHAPES_KIND(kind) \
template <> struct Helper<kind> { \
template <class S> \
static void call(const S & _this, const Array<Real> & nodes, \
const Matrix<Real> & integration_points, \
Array<Real> & shapes, const ElementType & type, \
const GhostType & ghost_type, \
const Array<UInt> & filter_elements) { \
AKANTU_BOOST_KIND_ELEMENT_SWITCH(AKANTU_COMPUTE_SHAPES, kind); \
} \
};
AKANTU_BOOST_ALL_KIND_LIST(AKANTU_COMPUTE_SHAPES_KIND,
AKANTU_FE_ENGINE_LIST_LAGRANGE_BASE)
} // namespace details
} // namespace shape_lagrange
/* -------------------------------------------------------------------------- */
void ShapeLagrangeBase::computeShapesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shapes, const ElementType & type,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
auto kind = Mesh::getKind(type);
#define AKANTU_COMPUTE_SHAPES_KIND_SWITCH(kind) \
shape_lagrange::details::Helper<kind>::call( \
*this, nodes, integration_points, shapes, type, ghost_type, \
filter_elements);
AKANTU_BOOST_LIST_SWITCH(
AKANTU_COMPUTE_SHAPES_KIND_SWITCH,
BOOST_PP_LIST_TO_SEQ(AKANTU_FE_ENGINE_LIST_LAGRANGE_BASE), kind);
#undef AKANTU_COMPUTE_SHAPES
#undef AKANTU_COMPUTE_SHAPES_KIND
#undef AKANTU_COMPUTE_SHAPES_KIND_SWITCH
}
/* -------------------------------------------------------------------------- */
void ShapeLagrangeBase::onElementsAdded(const Array<Element> & new_elements) {
AKANTU_DEBUG_IN();
const auto & nodes = mesh.getNodes();
for (auto elements_range : MeshElementsByTypes(new_elements)) {
auto type = elements_range.getType();
auto ghost_type = elements_range.getGhostType();
+ if (mesh.getSpatialDimension(type) != _spatial_dimension)
+ continue;
+
if (mesh.getKind(type) != _kind)
continue;
auto & elements = elements_range.getElements();
auto itp_type = FEEngine::getInterpolationType(type);
- if (not this->shapes_derivatives.exists(itp_type, ghost_type)) {
- auto size_of_shapesd = this->getShapeDerivativesSize(type);
- this->shapes_derivatives.alloc(0, size_of_shapesd, itp_type, ghost_type);
- }
-
if (not shapes.exists(itp_type, ghost_type)) {
auto size_of_shapes = this->getShapeSize(type);
this->shapes.alloc(0, size_of_shapes, itp_type, ghost_type);
}
const auto & natural_coords = integration_points(type, ghost_type);
computeShapesOnIntegrationPoints(nodes, natural_coords,
shapes(itp_type, ghost_type), type,
ghost_type, elements);
- if (mesh.getSpatialDimension() == mesh.getNaturalSpaceDimension(type) ||
+
+ /* if (mesh.getSpatialDimension() == mesh.getNaturalSpaceDimension(type) ||
_kind != _ek_regular) {
computeShapeDerivativesOnIntegrationPoints(
nodes, natural_coords, shapes_derivatives(itp_type, ghost_type), type,
ghost_type, elements);
+ }*/
+
+ if (_spatial_dimension != mesh.getSpatialDimension())
+ continue;
+
+ if (not this->shapes_derivatives.exists(itp_type, ghost_type)) {
+ auto size_of_shapesd = this->getShapeDerivativesSize(type);
+ this->shapes_derivatives.alloc(0, size_of_shapesd, itp_type, ghost_type);
}
+
+ computeShapeDerivativesOnIntegrationPoints(
+ nodes, natural_coords, shapes_derivatives(itp_type, ghost_type), type,
+ ghost_type, elements);
}
-#undef INIT_SHAPE_FUNCTIONS
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void ShapeLagrangeBase::onElementsRemoved(
const Array<Element> &, const ElementTypeMapArray<UInt> & new_numbering) {
this->shapes.onElementsRemoved(new_numbering);
this->shapes_derivatives.onElementsRemoved(new_numbering);
}
/* -------------------------------------------------------------------------- */
void ShapeLagrangeBase::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "Shapes Lagrange [" << std::endl;
ShapeFunctions::printself(stream, indent + 1);
shapes.printself(stream, indent + 1);
shapes_derivatives.printself(stream, indent + 1);
stream << space << "]" << std::endl;
}
} // namespace akantu
diff --git a/src/fe_engine/shape_lagrange_base.hh b/src/fe_engine/shape_lagrange_base.hh
index c50b27689..39dae5598 100644
--- a/src/fe_engine/shape_lagrange_base.hh
+++ b/src/fe_engine/shape_lagrange_base.hh
@@ -1,92 +1,92 @@
/**
* @file shape_lagrange_base.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 09 2017
* @date last modification: Wed Nov 08 2017
*
* @brief Base class for the shape lagrange
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_functions.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_LAGRANGE_BASE_HH__
#define __AKANTU_SHAPE_LAGRANGE_BASE_HH__
namespace akantu {
class ShapeLagrangeBase : public ShapeFunctions {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- ShapeLagrangeBase(const Mesh & mesh, const ElementKind & kind,
- const ID & id = "shape_lagrange",
+ ShapeLagrangeBase(const Mesh & mesh, UInt spatial_dimension,
+ const ElementKind & kind, const ID & id = "shape_lagrange",
const MemoryID & memory_id = 0);
~ShapeLagrangeBase() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// computes the shape functions for given interpolation points
virtual void computeShapesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shapes, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
/// computes the shape functions derivatives for given interpolation points
virtual void computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const ElementType & type,
const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const = 0;
/// function to print the containt of the class
void printself(std::ostream & stream, int indent = 0) const override;
template <ElementType type>
void computeShapesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shapes, const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
public:
void onElementsAdded(const Array<Element> & elements) override;
void
onElementsRemoved(const Array<Element> & elements,
const ElementTypeMapArray<UInt> & new_numbering) override;
protected:
/// The kind to consider
ElementKind _kind;
};
} // namespace akantu
#include "shape_lagrange_base_inline_impl.cc"
#endif /* __AKANTU_SHAPE_LAGRANGE_BASE_HH__ */
diff --git a/src/fe_engine/shape_lagrange_inline_impl.cc b/src/fe_engine/shape_lagrange_inline_impl.cc
index b60d4f1ac..817fde29c 100644
--- a/src/fe_engine/shape_lagrange_inline_impl.cc
+++ b/src/fe_engine/shape_lagrange_inline_impl.cc
@@ -1,539 +1,538 @@
/**
* @file shape_lagrange_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Oct 27 2010
* @date last modification: Tue Feb 20 2018
*
* @brief ShapeLagrange inline implementation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_iterators.hh"
#include "aka_voigthelper.hh"
#include "fe_engine.hh"
#include "shape_lagrange.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_LAGRANGE_INLINE_IMPL_CC__
#define __AKANTU_SHAPE_LAGRANGE_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
#define INIT_SHAPE_FUNCTIONS(type) \
setIntegrationPointsByType<type>(integration_points, ghost_type); \
precomputeShapesOnIntegrationPoints<type>(nodes, ghost_type); \
if (ElementClass<type>::getNaturalSpaceDimension() == \
mesh.getSpatialDimension() || \
kind != _ek_regular) \
precomputeShapeDerivativesOnIntegrationPoints<type>(nodes, ghost_type);
template <ElementKind kind>
inline void ShapeLagrange<kind>::initShapeFunctions(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
const ElementType & type, const GhostType & ghost_type) {
AKANTU_BOOST_REGULAR_ELEMENT_SWITCH(INIT_SHAPE_FUNCTIONS);
}
#undef INIT_SHAPE_FUNCTIONS
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
inline void ShapeLagrange<kind>::computeShapeDerivativesOnCPointsByElement(
const Matrix<Real> & node_coords, const Matrix<Real> & natural_coords,
Tensor3<Real> & shapesd) const {
AKANTU_DEBUG_IN();
// compute dnds
Tensor3<Real> dnds(node_coords.rows(), node_coords.cols(),
natural_coords.cols());
ElementClass<type>::computeDNDS(natural_coords, dnds);
// compute jacobian
Tensor3<Real> J(node_coords.rows(), natural_coords.rows(),
natural_coords.cols());
ElementClass<type>::computeJMat(dnds, node_coords, J);
// compute dndx
ElementClass<type>::computeShapeDerivatives(J, dnds, shapesd);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::inverseMap(const Vector<Real> & real_coords,
UInt elem, Vector<Real> & natural_coords,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
UInt * elem_val = mesh.getConnectivity(type, ghost_type).storage();
Matrix<Real> nodes_coord(spatial_dimension, nb_nodes_per_element);
mesh.extractNodalValuesFromElement(mesh.getNodes(), nodes_coord.storage(),
elem_val + elem * nb_nodes_per_element,
nb_nodes_per_element, spatial_dimension);
ElementClass<type>::inverseMap(real_coords, nodes_coord, natural_coords);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
bool ShapeLagrange<kind>::contains(const Vector<Real> & real_coords, UInt elem,
const GhostType & ghost_type) const {
UInt spatial_dimension = mesh.getSpatialDimension();
Vector<Real> natural_coords(spatial_dimension);
inverseMap<type>(real_coords, elem, natural_coords, ghost_type);
return ElementClass<type>::contains(natural_coords);
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::interpolate(const Vector<Real> & real_coords,
UInt elem,
const Matrix<Real> & nodal_values,
Vector<Real> & interpolated,
const GhostType & ghost_type) const {
UInt nb_shapes = ElementClass<type>::getShapeSize();
Vector<Real> shapes(nb_shapes);
computeShapes<type>(real_coords, elem, shapes, ghost_type);
ElementClass<type>::interpolate(nodal_values, shapes, interpolated);
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::computeShapes(const Vector<Real> & real_coords,
UInt elem, Vector<Real> & shapes,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
Vector<Real> natural_coords(spatial_dimension);
inverseMap<type>(real_coords, elem, natural_coords, ghost_type);
ElementClass<type>::computeShapes(natural_coords, shapes);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::computeShapeDerivatives(
const Matrix<Real> & real_coords, UInt elem, Tensor3<Real> & shapesd,
const GhostType & ghost_type) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_points = real_coords.cols();
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
AKANTU_DEBUG_ASSERT(mesh.getSpatialDimension() == shapesd.size(0) &&
nb_nodes_per_element == shapesd.size(1),
"Shape size doesn't match");
AKANTU_DEBUG_ASSERT(nb_points == shapesd.size(2),
"Number of points doesn't match shapes size");
Matrix<Real> natural_coords(spatial_dimension, nb_points);
// Creates the matrix of natural coordinates
for (UInt i = 0; i < nb_points; i++) {
Vector<Real> real_point = real_coords(i);
Vector<Real> natural_point = natural_coords(i);
inverseMap<type>(real_point, elem, natural_point, ghost_type);
}
UInt * elem_val = mesh.getConnectivity(type, ghost_type).storage();
Matrix<Real> nodes_coord(spatial_dimension, nb_nodes_per_element);
mesh.extractNodalValuesFromElement(mesh.getNodes(), nodes_coord.storage(),
elem_val + elem * nb_nodes_per_element,
nb_nodes_per_element, spatial_dimension);
computeShapeDerivativesOnCPointsByElement<type>(nodes_coord, natural_coords,
shapesd);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
-ShapeLagrange<kind>::ShapeLagrange(const Mesh & mesh, const ID & id,
- const MemoryID & memory_id)
- : ShapeLagrangeBase(mesh, kind, id, memory_id) {}
+ShapeLagrange<kind>::ShapeLagrange(const Mesh & mesh, UInt spatial_dimension,
+ const ID & id, const MemoryID & memory_id)
+ : ShapeLagrangeBase(mesh, spatial_dimension, kind, id, memory_id) {}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
UInt nb_points = integration_points.cols();
UInt nb_element = mesh.getConnectivity(type, ghost_type).size();
UInt size_of_shapesd = ElementClass<type>::getShapeDerivativesSize();
AKANTU_DEBUG_ASSERT(shape_derivatives.getNbComponent() == size_of_shapesd,
"The shapes_derivatives array does not have the correct "
<< "number of component");
shape_derivatives.resize(nb_element * nb_points);
Array<Real> x_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, x_el, type, ghost_type,
filter_elements);
Real * shapesd_val = shape_derivatives.storage();
Array<Real>::matrix_iterator x_it =
x_el.begin(spatial_dimension, nb_nodes_per_element);
if (filter_elements != empty_filter)
nb_element = filter_elements.size();
for (UInt elem = 0; elem < nb_element; ++elem, ++x_it) {
if (filter_elements != empty_filter)
shapesd_val = shape_derivatives.storage() +
filter_elements(elem) * size_of_shapesd * nb_points;
Matrix<Real> & X = *x_it;
Tensor3<Real> B(shapesd_val, spatial_dimension, nb_nodes_per_element,
nb_points);
computeShapeDerivativesOnCPointsByElement<type>(X, integration_points, B);
if (filter_elements == empty_filter)
shapesd_val += size_of_shapesd * nb_points;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
void ShapeLagrange<kind>::computeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shape_derivatives, const ElementType & type,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
#define AKANTU_COMPUTE_SHAPES(type) \
computeShapeDerivativesOnIntegrationPoints<type>( \
nodes, integration_points, shape_derivatives, ghost_type, \
filter_elements);
AKANTU_BOOST_REGULAR_ELEMENT_SWITCH(AKANTU_COMPUTE_SHAPES);
#undef AKANTU_COMPUTE_SHAPES
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::precomputeShapesOnIntegrationPoints(
const Array<Real> & nodes, const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
Matrix<Real> & natural_coords = integration_points(type, ghost_type);
UInt size_of_shapes = ElementClass<type>::getShapeSize();
Array<Real> & shapes_tmp =
shapes.alloc(0, size_of_shapes, itp_type, ghost_type);
this->computeShapesOnIntegrationPoints<type>(nodes, natural_coords,
shapes_tmp, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::precomputeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
Matrix<Real> & natural_coords = integration_points(type, ghost_type);
UInt size_of_shapesd = ElementClass<type>::getShapeDerivativesSize();
Array<Real> & shapes_derivatives_tmp =
shapes_derivatives.alloc(0, size_of_shapesd, itp_type, ghost_type);
this->computeShapeDerivativesOnIntegrationPoints<type>(
nodes, natural_coords, shapes_derivatives_tmp, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::interpolateOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_uq, UInt nb_degree_of_freedom,
const Array<Real> & shapes, GhostType ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
Array<Real> u_el(0, nb_degree_of_freedom * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, in_u, u_el, type, ghost_type,
filter_elements);
this->interpolateElementalFieldOnIntegrationPoints<type>(
u_el, out_uq, ghost_type, shapes, filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::interpolateOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_uq, UInt nb_degree_of_freedom,
GhostType ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
AKANTU_DEBUG_ASSERT(shapes.exists(itp_type, ghost_type),
"No shapes for the type "
<< shapes.printType(itp_type, ghost_type));
this->interpolateOnIntegrationPoints<type>(in_u, out_uq, nb_degree_of_freedom,
shapes(itp_type, ghost_type),
ghost_type, filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::gradientOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_nablauq,
UInt nb_degree_of_freedom, GhostType ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
AKANTU_DEBUG_ASSERT(
shapes_derivatives.exists(itp_type, ghost_type),
"No shapes derivatives for the type "
<< shapes_derivatives.printType(itp_type, ghost_type));
UInt nb_nodes_per_element =
ElementClass<type>::getNbNodesPerInterpolationElement();
Array<Real> u_el(0, nb_degree_of_freedom * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, in_u, u_el, type, ghost_type,
filter_elements);
this->gradientElementalFieldOnIntegrationPoints<type>(
u_el, out_nablauq, ghost_type, shapes_derivatives(itp_type, ghost_type),
filter_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::computeBtD(
const Array<Real> & Ds, Array<Real> & BtDs, GhostType ghost_type,
const Array<UInt> & filter_elements) const {
auto itp_type = ElementClassProperty<type>::interpolation_type;
const auto & shapes_derivatives =
this->shapes_derivatives(itp_type, ghost_type);
auto spatial_dimension = mesh.getSpatialDimension();
auto nb_nodes_per_element = mesh.getNbNodesPerElement(type);
Array<Real> shapes_derivatives_filtered(0,
shapes_derivatives.getNbComponent());
auto && view =
make_view(shapes_derivatives, spatial_dimension, nb_nodes_per_element);
auto B_it = view.begin();
auto B_end = view.end();
if (filter_elements != empty_filter) {
FEEngine::filterElementalData(this->mesh, shapes_derivatives,
shapes_derivatives_filtered, type, ghost_type,
filter_elements);
auto && view = make_view(shapes_derivatives_filtered, spatial_dimension,
nb_nodes_per_element);
B_it = view.begin();
B_end = view.end();
}
for (auto && values :
zip(range(B_it, B_end),
make_view(Ds, Ds.getNbComponent() / spatial_dimension,
spatial_dimension),
make_view(BtDs, BtDs.getNbComponent() / nb_nodes_per_element,
nb_nodes_per_element))) {
const auto & B = std::get<0>(values);
const auto & D = std::get<1>(values);
auto & Bt_D = std::get<2>(values);
// transposed due to the storage layout of B
Bt_D.template mul<false, false>(D, B);
}
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::computeBtDB(
const Array<Real> & Ds, Array<Real> & BtDBs, UInt order_d,
GhostType ghost_type, const Array<UInt> & filter_elements) const {
auto itp_type = ElementClassProperty<type>::interpolation_type;
const auto & shapes_derivatives =
this->shapes_derivatives(itp_type, ghost_type);
constexpr auto dim = ElementClass<type>::getSpatialDimension();
auto nb_nodes_per_element = mesh.getNbNodesPerElement(type);
Array<Real> shapes_derivatives_filtered(0,
shapes_derivatives.getNbComponent());
auto && view = make_view(shapes_derivatives, dim, nb_nodes_per_element);
auto B_it = view.begin();
auto B_end = view.end();
if (filter_elements != empty_filter) {
FEEngine::filterElementalData(this->mesh, shapes_derivatives,
shapes_derivatives_filtered, type, ghost_type,
filter_elements);
auto && view =
make_view(shapes_derivatives_filtered, dim, nb_nodes_per_element);
B_it = view.begin();
B_end = view.end();
}
if (order_d == 4) {
UInt tangent_size = VoigtHelper<dim>::size;
Matrix<Real> B(tangent_size, dim * nb_nodes_per_element);
Matrix<Real> Bt_D(dim * nb_nodes_per_element, tangent_size);
for (auto && values :
zip(range(B_it, B_end), make_view(Ds, tangent_size, tangent_size),
make_view(BtDBs, dim * nb_nodes_per_element,
dim * nb_nodes_per_element))) {
const auto & Bfull = std::get<0>(values);
const auto & D = std::get<1>(values);
auto & Bt_D_B = std::get<2>(values);
VoigtHelper<dim>::transferBMatrixToSymVoigtBMatrix(Bfull, B,
nb_nodes_per_element);
Bt_D.template mul<true, false>(B, D);
Bt_D_B.template mul<false, false>(Bt_D, B);
}
} else if (order_d == 2) {
Matrix<Real> Bt_D(nb_nodes_per_element, dim);
for (auto && values :
zip(range(B_it, B_end), make_view(Ds, dim, dim),
make_view(BtDBs, nb_nodes_per_element, nb_nodes_per_element))) {
const auto & B = std::get<0>(values);
const auto & D = std::get<1>(values);
auto & Bt_D_B = std::get<2>(values);
Bt_D.template mul<true, false>(B, D);
Bt_D_B.template mul<false, false>(Bt_D, B);
}
}
}
template <>
template <>
inline void ShapeLagrange<_ek_regular>::computeBtDB<_point_1>(
const Array<Real> & /*Ds*/, Array<Real> & /*BtDBs*/, UInt /*order_d*/,
GhostType /*ghost_type*/, const Array<UInt> & /*filter_elements*/) const {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeLagrange<kind>::computeNtb(
const Array<Real> & bs, Array<Real> & Ntbs, GhostType ghost_type,
const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
Ntbs.resize(bs.size());
UInt size_of_shapes = ElementClass<type>::getShapeSize();
InterpolationType itp_type = ElementClassProperty<type>::interpolation_type;
UInt nb_degree_of_freedom = bs.getNbComponent();
Array<Real> shapes_filtered(0, size_of_shapes);
auto && view = make_view(shapes(itp_type, ghost_type), 1, size_of_shapes);
auto N_it = view.begin();
auto N_end = view.end();
-
if (filter_elements != empty_filter) {
FEEngine::filterElementalData(this->mesh, shapes(itp_type, ghost_type),
shapes_filtered, type, ghost_type,
filter_elements);
auto && view = make_view(shapes_filtered, 1, size_of_shapes);
N_it = view.begin();
N_end = view.end();
}
for (auto && values :
zip(make_view(bs, nb_degree_of_freedom, 1), range(N_it, N_end),
make_view(Ntbs, nb_degree_of_freedom, size_of_shapes))) {
const auto & b = std::get<0>(values);
const auto & N = std::get<1>(values);
auto & Ntb = std::get<2>(values);
Ntb.template mul<false, false>(b, N);
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
#endif /* __AKANTU_SHAPE_LAGRANGE_INLINE_IMPL_CC__ */
diff --git a/src/fe_engine/shape_structural.cc b/src/fe_engine/shape_structural.cc
index ef9b443c0..b3d405dce 100644
--- a/src/fe_engine/shape_structural.cc
+++ b/src/fe_engine/shape_structural.cc
@@ -1,53 +1,55 @@
/**
* @file shape_structural.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Feb 21 2013
* @date last modification: Thu Dec 21 2017
*
* @brief ShapeStructural implementation
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_structural.hh"
#include "aka_memory.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <>
-ShapeStructural<_ek_structural>::ShapeStructural(Mesh & mesh, const ID & id,
+ShapeStructural<_ek_structural>::ShapeStructural(Mesh & mesh,
+ UInt spatial_dimension,
+ const ID & id,
const MemoryID & memory_id)
- : ShapeFunctions(mesh, id, memory_id),
+ : ShapeFunctions(mesh, spatial_dimension, id, memory_id),
rotation_matrices("rotation_matrices", id, memory_id) {}
/* -------------------------------------------------------------------------- */
template <> ShapeStructural<_ek_structural>::~ShapeStructural() = default;
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/fe_engine/shape_structural.hh b/src/fe_engine/shape_structural.hh
index efaff4042..d0877fb55 100644
--- a/src/fe_engine/shape_structural.hh
+++ b/src/fe_engine/shape_structural.hh
@@ -1,177 +1,178 @@
/**
* @file shape_structural.hh
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Feb 15 2011
* @date last modification: Tue Feb 20 2018
*
* @brief shape class for element with different set of shapes functions
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "shape_functions.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_STRUCTURAL_HH__
#define __AKANTU_SHAPE_STRUCTURAL_HH__
namespace akantu {
template <ElementKind kind> class ShapeStructural : public ShapeFunctions {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
// Ctors/Dtors should be explicitely implemented for _ek_structural
public:
- ShapeStructural(Mesh & mesh, const ID & id = "shape_structural",
+ ShapeStructural(Mesh & mesh, UInt spatial_dimension,
+ const ID & id = "shape_structural",
const MemoryID & memory_id = 0);
~ShapeStructural() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// function to print the contain of the class
void printself(std::ostream & stream, int indent = 0) const override {
std::string space;
for (Int i = 0; i < indent; i++, space += AKANTU_INDENT)
;
stream << space << "ShapesStructural [" << std::endl;
rotation_matrices.printself(stream, indent + 1);
ShapeFunctions::printself(stream, indent + 1);
stream << space << "]" << std::endl;
}
/// compute shape functions on given integration points
template <ElementType type>
void computeShapesOnIntegrationPoints(
const Array<Real> &, const Matrix<Real> & integration_points,
Array<Real> & shapes, const GhostType & ghost_type,
const Array<UInt> & filter_elements = empty_filter) const;
/// initialization function for structural elements
inline void initShapeFunctions(const Array<Real> & nodes,
const Matrix<Real> & integration_points,
const ElementType & type,
const GhostType & ghost_type);
/// precompute the rotation matrices for the elements dofs
template <ElementType type>
void precomputeRotationMatrices(const Array<Real> & nodes,
const GhostType & ghost_type);
/// pre compute all shapes on the element integration points from natural
/// coordinates
template <ElementType type>
void precomputeShapesOnIntegrationPoints(const Array<Real> & nodes,
const GhostType & ghost_type);
/// pre compute all shapes on the element integration points from natural
/// coordinates
template <ElementType type>
void
precomputeShapeDerivativesOnIntegrationPoints(const Array<Real> & nodes,
const GhostType & ghost_type);
/// interpolate nodal values on the integration points
template <ElementType type>
void interpolateOnIntegrationPoints(
const Array<Real> & u, Array<Real> & uq, UInt nb_degree_of_freedom,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
/// compute the gradient of u on the integration points
template <ElementType type>
void gradientOnIntegrationPoints(
const Array<Real> & u, Array<Real> & nablauq, UInt nb_degree_of_freedom,
const GhostType & ghost_type = _not_ghost,
const Array<UInt> & filter_elements = empty_filter) const;
/// interpolate on physical point
template <ElementType type>
void interpolate(const Vector<Real> & /*real_coords*/, UInt /*elem*/,
const Matrix<Real> & /*nodal_values*/,
Vector<Real> & /*interpolated*/,
const GhostType & /*ghost_type*/) const {
AKANTU_TO_IMPLEMENT();
}
/// compute the shapes on a provided point
template <ElementType type>
void computeShapes(const Vector<Real> & /*real_coords*/, UInt /*elem*/,
Vector<Real> & /*shapes*/,
const GhostType & /*ghost_type*/) const {
AKANTU_TO_IMPLEMENT();
}
/// compute the shape derivatives on a provided point
template <ElementType type>
void computeShapeDerivatives(const Matrix<Real> & /*real_coords*/,
UInt /*elem*/, Tensor3<Real> & /*shapes*/,
const GhostType & /*ghost_type*/) const {
AKANTU_TO_IMPLEMENT();
}
/// get the rotations vector
inline const Array<Real> &
getRotations(const ElementType & el_type,
__attribute__((unused))
const GhostType & ghost_type = _not_ghost) const {
return rotation_matrices(el_type);
}
/* ------------------------------------------------------------------------ */
template <ElementType type>
void computeBtD(const Array<Real> & /*Ds*/, Array<Real> & /*BtDs*/,
GhostType /*ghost_type*/,
const Array<UInt> & /*filter_elements*/) const {
AKANTU_TO_IMPLEMENT();
}
template <ElementType type>
void computeBtDB(const Array<Real> & /*Ds*/, Array<Real> & /*BtDBs*/,
UInt /*order_d*/, GhostType /*ghost_type*/,
const Array<UInt> & /*filter_elements*/) const {
AKANTU_TO_IMPLEMENT();
}
/// multiply a field by shape functions
template <ElementType type>
void
computeNtb(const Array<Real> & /*bs*/, Array<Real> & /*Ntbs*/,
const GhostType & /*ghost_type*/,
const Array<UInt> & /*filter_elements*/ = empty_filter) const {
AKANTU_TO_IMPLEMENT();
}
protected:
ElementTypeMapArray<Real> rotation_matrices;
};
} // namespace akantu
#include "shape_structural_inline_impl.cc"
#endif /* __AKANTU_SHAPE_STRUCTURAL_HH__ */
diff --git a/src/fe_engine/shape_structural_inline_impl.cc b/src/fe_engine/shape_structural_inline_impl.cc
index b13bc8b4d..f7151a229 100644
--- a/src/fe_engine/shape_structural_inline_impl.cc
+++ b/src/fe_engine/shape_structural_inline_impl.cc
@@ -1,431 +1,433 @@
/**
* @file shape_structural_inline_impl.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Oct 11 2017
* @date last modification: Wed Feb 21 2018
*
* @brief ShapeStructural inline implementation
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_iterators.hh"
#include "shape_structural.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SHAPE_STRUCTURAL_INLINE_IMPL_CC__
#define __AKANTU_SHAPE_STRUCTURAL_INLINE_IMPL_CC__
namespace akantu {
namespace {
/// Extract nodal coordinates per elements
template <ElementType type>
std::unique_ptr<Array<Real>>
getNodesPerElement(const Mesh & mesh, const Array<Real> & nodes,
const GhostType & ghost_type) {
const auto dim = ElementClass<type>::getSpatialDimension();
const auto nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
auto nodes_per_element =
std::make_unique<Array<Real>>(0, dim * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, *nodes_per_element, type,
ghost_type);
return nodes_per_element;
}
-}
+} // namespace
template <ElementKind kind>
inline void ShapeStructural<kind>::initShapeFunctions(
const Array<Real> & /* unused */, const Matrix<Real> & /* unused */,
const ElementType & /* unused */, const GhostType & /* unused */) {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
#define INIT_SHAPE_FUNCTIONS(type) \
setIntegrationPointsByType<type>(integration_points, ghost_type); \
precomputeRotationMatrices<type>(nodes, ghost_type); \
precomputeShapesOnIntegrationPoints<type>(nodes, ghost_type); \
precomputeShapeDerivativesOnIntegrationPoints<type>(nodes, ghost_type);
template <>
inline void ShapeStructural<_ek_structural>::initShapeFunctions(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
const ElementType & type, const GhostType & ghost_type) {
AKANTU_BOOST_STRUCTURAL_ELEMENT_SWITCH(INIT_SHAPE_FUNCTIONS);
}
#undef INIT_SHAPE_FUNCTIONS
/* -------------------------------------------------------------------------- */
template <>
template <ElementType type>
void ShapeStructural<_ek_structural>::computeShapesOnIntegrationPoints(
const Array<Real> & nodes, const Matrix<Real> & integration_points,
Array<Real> & shapes, const GhostType & ghost_type,
const Array<UInt> & filter_elements) const {
UInt nb_points = integration_points.cols();
UInt nb_element = mesh.getConnectivity(type, ghost_type).size();
shapes.resize(nb_element * nb_points);
UInt ndof = ElementClass<type>::getNbDegreeOfFreedom();
#if !defined(AKANTU_NDEBUG)
UInt size_of_shapes = ElementClass<type>::getShapeSize();
AKANTU_DEBUG_ASSERT(shapes.getNbComponent() == size_of_shapes,
"The shapes array does not have the correct "
<< "number of component");
#endif
auto shapes_it = shapes.begin_reinterpret(
ElementClass<type>::getNbNodesPerInterpolationElement(), ndof, nb_points,
nb_element);
auto shapes_begin = shapes_it;
if (filter_elements != empty_filter) {
nb_element = filter_elements.size();
}
auto nodes_per_element = getNodesPerElement<type>(mesh, nodes, ghost_type);
auto nodes_it = nodes_per_element->begin(mesh.getSpatialDimension(),
Mesh::getNbNodesPerElement(type));
auto nodes_begin = nodes_it;
for (UInt elem = 0; elem < nb_element; ++elem) {
if (filter_elements != empty_filter) {
shapes_it = shapes_begin + filter_elements(elem);
nodes_it = nodes_begin + filter_elements(elem);
}
Tensor3<Real> & N = *shapes_it;
auto & real_coord = *nodes_it;
ElementClass<type>::computeShapes(integration_points, real_coord, N);
- if (filter_elements == empty_filter)
+ if (filter_elements == empty_filter) {
++shapes_it;
+ ++nodes_it;
+ }
}
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeStructural<kind>::precomputeRotationMatrices(
const Array<Real> & nodes, const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
const auto spatial_dimension = mesh.getSpatialDimension();
const auto nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
const auto nb_element = mesh.getNbElement(type, ghost_type);
const auto nb_dof = ElementClass<type>::getNbDegreeOfFreedom();
if (not this->rotation_matrices.exists(type, ghost_type)) {
this->rotation_matrices.alloc(0, nb_dof * nb_dof, type, ghost_type);
}
auto & rot_matrices = this->rotation_matrices(type, ghost_type);
rot_matrices.resize(nb_element);
Array<Real> x_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, x_el, type, ghost_type);
bool has_extra_normal = mesh.hasData<Real>("extra_normal", type, ghost_type);
Array<Real>::const_vector_iterator extra_normal;
if (has_extra_normal)
extra_normal = mesh.getData<Real>("extra_normal", type, ghost_type)
.begin(spatial_dimension);
for (auto && tuple :
zip(make_view(x_el, spatial_dimension, nb_nodes_per_element),
make_view(rot_matrices, nb_dof, nb_dof))) {
// compute shape derivatives
auto & X = std::get<0>(tuple);
auto & R = std::get<1>(tuple);
if (has_extra_normal) {
ElementClass<type>::computeRotationMatrix(R, X, *extra_normal);
++extra_normal;
} else {
ElementClass<type>::computeRotationMatrix(
R, X, Vector<Real>(spatial_dimension));
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeStructural<kind>::precomputeShapesOnIntegrationPoints(
const Array<Real> & nodes, const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
const auto & natural_coords = integration_points(type, ghost_type);
auto nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
auto nb_points = integration_points(type, ghost_type).cols();
auto nb_element = mesh.getNbElement(type, ghost_type);
auto nb_dof = ElementClass<type>::getNbDegreeOfFreedom();
const auto dim = ElementClass<type>::getSpatialDimension();
auto itp_type = FEEngine::getInterpolationType(type);
if (not shapes.exists(itp_type, ghost_type)) {
auto size_of_shapes = this->getShapeSize(type);
this->shapes.alloc(0, size_of_shapes, itp_type, ghost_type);
}
auto & shapes_ = this->shapes(itp_type, ghost_type);
shapes_.resize(nb_element * nb_points);
auto nodes_per_element = getNodesPerElement<type>(mesh, nodes, ghost_type);
for (auto && tuple :
zip(make_view(shapes_, nb_dof, nb_dof * nb_nodes_per_element, nb_points),
make_view(*nodes_per_element, dim, nb_nodes_per_element))) {
auto & N = std::get<0>(tuple);
auto & real_coord = std::get<1>(tuple);
ElementClass<type>::computeShapes(natural_coords, real_coord, N);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeStructural<kind>::precomputeShapeDerivativesOnIntegrationPoints(
const Array<Real> & nodes, const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
const auto & natural_coords = integration_points(type, ghost_type);
const auto spatial_dimension = mesh.getSpatialDimension();
const auto natural_spatial_dimension =
ElementClass<type>::getNaturalSpaceDimension();
const auto nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
const auto nb_points = natural_coords.cols();
const auto nb_dof = ElementClass<type>::getNbDegreeOfFreedom();
const auto nb_element = mesh.getNbElement(type, ghost_type);
const auto nb_stress_components = ElementClass<type>::getNbStressComponents();
auto itp_type = FEEngine::getInterpolationType(type);
if (not this->shapes_derivatives.exists(itp_type, ghost_type)) {
auto size_of_shapesd = this->getShapeDerivativesSize(type);
this->shapes_derivatives.alloc(0, size_of_shapesd, itp_type, ghost_type);
}
auto & rot_matrices = this->rotation_matrices(type, ghost_type);
Array<Real> x_el(0, spatial_dimension * nb_nodes_per_element);
FEEngine::extractNodalToElementField(mesh, nodes, x_el, type, ghost_type);
auto & shapesd = this->shapes_derivatives(itp_type, ghost_type);
shapesd.resize(nb_element * nb_points);
for (auto && tuple :
zip(make_view(x_el, spatial_dimension, nb_nodes_per_element),
make_view(shapesd, nb_stress_components,
nb_nodes_per_element * nb_dof, nb_points),
make_view(rot_matrices, nb_dof, nb_dof))) {
// compute shape derivatives
auto & X = std::get<0>(tuple);
auto & B = std::get<1>(tuple);
auto & RDOFs = std::get<2>(tuple);
Tensor3<Real> dnds(natural_spatial_dimension,
ElementClass<type>::interpolation_property::dnds_columns,
B.size(2));
ElementClass<type>::computeDNDS(natural_coords, X, dnds);
Tensor3<Real> J(natural_spatial_dimension, natural_spatial_dimension,
natural_coords.cols());
// Computing the coordinates of the element in the natural space
auto R = RDOFs.block(0, 0, spatial_dimension, spatial_dimension);
Matrix<Real> T(B.size(1), B.size(1), 0);
for (UInt i = 0; i < nb_nodes_per_element; ++i) {
T.block(RDOFs, i * RDOFs.rows(), i * RDOFs.rows());
}
// Rotate to local basis
auto x =
(R * X).block(0, 0, natural_spatial_dimension, nb_nodes_per_element);
ElementClass<type>::computeJMat(natural_coords, x, J);
ElementClass<type>::computeShapeDerivatives(J, dnds, T, B);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeStructural<kind>::interpolateOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_uq, UInt nb_dof,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(out_uq.getNbComponent() == nb_dof,
"The output array shape is not correct");
auto itp_type = FEEngine::getInterpolationType(type);
const auto & shapes_ = shapes(itp_type, ghost_type);
auto nb_element = mesh.getNbElement(type, ghost_type);
auto nb_nodes_per_element = ElementClass<type>::getNbNodesPerElement();
auto nb_quad_points_per_element = integration_points(type, ghost_type).cols();
Array<Real> u_el(0, nb_nodes_per_element * nb_dof);
FEEngine::extractNodalToElementField(mesh, in_u, u_el, type, ghost_type,
filter_elements);
auto nb_quad_points = nb_quad_points_per_element * u_el.size();
out_uq.resize(nb_quad_points);
auto out_it = out_uq.begin_reinterpret(nb_dof, 1, nb_quad_points_per_element,
u_el.size());
auto shapes_it =
shapes_.begin_reinterpret(nb_dof, nb_dof * nb_nodes_per_element,
nb_quad_points_per_element, nb_element);
auto u_it = u_el.begin_reinterpret(nb_dof * nb_nodes_per_element, 1,
nb_quad_points_per_element, u_el.size());
for_each_element(nb_element, filter_elements, [&](auto && el) {
auto & uq = *out_it;
const auto & u = *u_it;
auto N = Tensor3<Real>(shapes_it[el]);
for (auto && q : arange(uq.size(2))) {
auto uq_q = Matrix<Real>(uq(q));
auto u_q = Matrix<Real>(u(q));
auto N_q = Matrix<Real>(N(q));
uq_q.mul<false, false>(N_q, u_q);
}
++out_it;
++u_it;
});
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <ElementKind kind>
template <ElementType type>
void ShapeStructural<kind>::gradientOnIntegrationPoints(
const Array<Real> & in_u, Array<Real> & out_nablauq, UInt nb_dof,
const GhostType & ghost_type, const Array<UInt> & filter_elements) const {
AKANTU_DEBUG_IN();
auto itp_type = FEEngine::getInterpolationType(type);
const auto & shapesd = shapes_derivatives(itp_type, ghost_type);
auto nb_element = mesh.getNbElement(type, ghost_type);
auto element_dimension = ElementClass<type>::getSpatialDimension();
auto nb_quad_points_per_element = integration_points(type, ghost_type).cols();
auto nb_nodes_per_element = ElementClass<type>::getNbNodesPerElement();
Array<Real> u_el(0, nb_nodes_per_element * nb_dof);
FEEngine::extractNodalToElementField(mesh, in_u, u_el, type, ghost_type,
filter_elements);
auto nb_quad_points = nb_quad_points_per_element * u_el.size();
out_nablauq.resize(nb_quad_points);
auto out_it = out_nablauq.begin_reinterpret(
element_dimension, 1, nb_quad_points_per_element, u_el.size());
auto shapesd_it = shapesd.begin_reinterpret(
element_dimension, nb_dof * nb_nodes_per_element,
nb_quad_points_per_element, nb_element);
auto u_it = u_el.begin_reinterpret(nb_dof * nb_nodes_per_element, 1,
nb_quad_points_per_element, u_el.size());
for_each_element(nb_element, filter_elements, [&](auto && el) {
auto & nablau = *out_it;
const auto & u = *u_it;
auto B = Tensor3<Real>(shapesd_it[el]);
for (auto && q : arange(nablau.size(2))) {
auto nablau_q = Matrix<Real>(nablau(q));
auto u_q = Matrix<Real>(u(q));
auto B_q = Matrix<Real>(B(q));
nablau_q.mul<false, false>(B_q, u_q);
}
++out_it;
++u_it;
});
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <>
template <ElementType type>
void ShapeStructural<_ek_structural>::computeBtD(
const Array<Real> & Ds, Array<Real> & BtDs, GhostType ghost_type,
const Array<UInt> & filter_elements) const {
auto itp_type = ElementClassProperty<type>::interpolation_type;
auto nb_stress = ElementClass<type>::getNbStressComponents();
auto nb_dof_per_element = ElementClass<type>::getNbDegreeOfFreedom() *
mesh.getNbNodesPerElement(type);
const auto & shapes_derivatives =
this->shapes_derivatives(itp_type, ghost_type);
Array<Real> shapes_derivatives_filtered(0,
shapes_derivatives.getNbComponent());
auto && view = make_view(shapes_derivatives, nb_stress, nb_dof_per_element);
auto B_it = view.begin();
auto B_end = view.end();
if (filter_elements != empty_filter) {
FEEngine::filterElementalData(this->mesh, shapes_derivatives,
shapes_derivatives_filtered, type, ghost_type,
filter_elements);
auto && view =
make_view(shapes_derivatives_filtered, nb_stress, nb_dof_per_element);
B_it = view.begin();
B_end = view.end();
}
for (auto && values : zip(range(B_it, B_end), make_view(Ds, nb_stress),
make_view(BtDs, BtDs.getNbComponent()))) {
const auto & B = std::get<0>(values);
const auto & D = std::get<1>(values);
auto & Bt_D = std::get<2>(values);
Bt_D.template mul<true>(B, D);
}
}
} // namespace akantu
#endif /* __AKANTU_SHAPE_STRUCTURAL_INLINE_IMPL_CC__ */
diff --git a/src/geometry/aabb_primitives/aabb_primitive.cc b/src/geometry/aabb_primitives/aabb_primitive.cc
index 93c51c16b..2001bd141 100644
--- a/src/geometry/aabb_primitives/aabb_primitive.cc
+++ b/src/geometry/aabb_primitives/aabb_primitive.cc
@@ -1,49 +1,49 @@
/**
* @file aabb_primitive.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Wed Jan 31 2018
*
* @brief Macro classe (primitive) for AABB CGAL algos
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aabb_primitive.hh"
namespace akantu {
Triangle_primitive::Point Triangle_primitive::reference_point() const {
return primitive.vertex(0);
}
Line_arc_primitive::Point Line_arc_primitive::reference_point() const {
Real x = to_double(primitive.source().x());
Real y = to_double(primitive.source().y());
Real z = to_double(primitive.source().z());
return cgal::Spherical::Point_3(x, y, z);
}
-} // akantu
+} // namespace akantu
diff --git a/src/geometry/aabb_primitives/aabb_primitive.hh b/src/geometry/aabb_primitives/aabb_primitive.hh
index 9bae09a10..9bc2edbea 100644
--- a/src/geometry/aabb_primitives/aabb_primitive.hh
+++ b/src/geometry/aabb_primitives/aabb_primitive.hh
@@ -1,89 +1,89 @@
/**
* @file aabb_primitive.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Fri Mar 13 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Macro classe (primitive) for AABB CGAL algos
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_AABB_PRIMITIVE_HH__
#define __AKANTU_AABB_PRIMITIVE_HH__
#include "aka_common.hh"
#include "line_arc.hh"
#include "tetrahedron.hh"
#include "triangle.hh"
#include "mesh_geom_common.hh"
namespace akantu {
/**
* This macro defines a class that is used in the CGAL AABB tree algorithm.
* All the `typedef`s and methods are required by the AABB module.
*
* The member variables are
* - the id of the element associated to the primitive
* - the geometric primitive of the element
*
* @param name the name of the primitive type
* @param kernel the name of the kernel used
*/
#define AKANTU_AABB_CLASS(name, kernel) \
class name##_primitive { \
typedef std::list<name<kernel>>::iterator Iterator; \
\
public: \
typedef UInt Id; \
typedef kernel::Point_3 Point; \
typedef kernel::name##_3 Datum; \
\
public: \
name##_primitive() : meshId(0), primitive() {} \
name##_primitive(Iterator it) : meshId(it->id()), primitive(*it) {} \
\
public: \
const Datum & datum() const { return primitive; } \
Point reference_point() const; \
const Id & id() const { return meshId; } \
\
protected: \
Id meshId; \
name<kernel> primitive; \
}
// If the primitive is supported by CGAL::intersection() then the
// implementation process is really easy with this macro
AKANTU_AABB_CLASS(Triangle, cgal::Cartesian);
AKANTU_AABB_CLASS(Line_arc, cgal::Spherical);
#undef AKANTU_AABB_CLASS
-} // akantu
+} // namespace akantu
#endif // __AKANTU_AABB_PRIMITIVE_HH__
diff --git a/src/geometry/aabb_primitives/line_arc.hh b/src/geometry/aabb_primitives/line_arc.hh
index 611649790..34e547ace 100644
--- a/src/geometry/aabb_primitives/line_arc.hh
+++ b/src/geometry/aabb_primitives/line_arc.hh
@@ -1,77 +1,77 @@
/**
* @file line_arc.hh
*
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Mon Jun 19 2017
*
* @brief Segment classe (geometry) for AABB CGAL algos
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_LINE_ARC_HH__
#define __AKANTU_LINE_ARC_HH__
#include "aka_common.hh"
#include "mesh_geom_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
/// Class used for substitution of CGAL::Triangle_3 primitive
template <typename K> class Line_arc : public CGAL::Line_arc_3<K> {
public:
/// Default constructor
Line_arc() : CGAL::Line_arc_3<K>(), mesh_id(0), seg_id(0) {}
/// Copy constructor
Line_arc(const Line_arc & other)
: CGAL::Line_arc_3<K>(other), mesh_id(other.mesh_id),
seg_id(other.seg_id) {}
/// Construct from 3 points
// "CGAL-4.5/doc_html/Circular_kernel_3/classCGAL_1_1Line__arc__3.html"
Line_arc(const CGAL::Line_3<K> & l, const CGAL::Circular_arc_point_3<K> & a,
const CGAL::Circular_arc_point_3<K> & b)
: CGAL::Line_arc_3<K>(l, a, b), mesh_id(0), seg_id(0) {}
public:
UInt id() const { return mesh_id; }
UInt segId() const { return seg_id; }
void setId(UInt newId) { mesh_id = newId; }
void setSegId(UInt newId) { seg_id = newId; }
protected:
/// Id of the element represented by the primitive
UInt mesh_id;
/// Id of the segment represented by the primitive
UInt seg_id;
};
-} // akantu
+} // namespace akantu
#endif // __AKANTU_LINE_ARC_HH__
diff --git a/src/geometry/aabb_primitives/tetrahedron.hh b/src/geometry/aabb_primitives/tetrahedron.hh
index 64e7855a7..4222e8bc8 100644
--- a/src/geometry/aabb_primitives/tetrahedron.hh
+++ b/src/geometry/aabb_primitives/tetrahedron.hh
@@ -1,70 +1,70 @@
/**
* @file tetrahedron.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Feb 27 2015
* @date last modification: Mon Jun 19 2017
*
* @brief Tetrahedron classe (geometry) for AABB CGAL algos
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TETRAHEDRON_HH__
#define __AKANTU_TETRAHEDRON_HH__
#include "aka_common.hh"
#include "mesh_geom_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
/// Class used for substitution of CGAL::Tetrahedron_3 primitive
template <typename K> class Tetrahedron : public CGAL::Tetrahedron_3<K> {
public:
/// Default constructor
Tetrahedron() : CGAL::Tetrahedron_3<K>(), meshId(0) {}
/// Copy constructor
Tetrahedron(const Tetrahedron & other)
: CGAL::Tetrahedron_3<K>(other), meshId(other.meshId) {}
/// Construct from 4 points
Tetrahedron(const CGAL::Point_3<K> & a, const CGAL::Point_3<K> & b,
const CGAL::Point_3<K> & c, const CGAL::Point_3<K> & d)
: CGAL::Tetrahedron_3<K>(a, b, c, d), meshId(0) {}
public:
UInt id() const { return meshId; }
void setId(UInt newId) { meshId = newId; }
protected:
/// Id of the element represented by the primitive
UInt meshId;
};
-} // akantu
+} // namespace akantu
#endif
diff --git a/src/geometry/aabb_primitives/triangle.hh b/src/geometry/aabb_primitives/triangle.hh
index 17d7b194a..dd9a836b7 100644
--- a/src/geometry/aabb_primitives/triangle.hh
+++ b/src/geometry/aabb_primitives/triangle.hh
@@ -1,70 +1,70 @@
/**
* @file triangle.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Mon Jun 19 2017
*
* @brief Triangle classe (geometry) for AABB CGAL algos
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TRIANGLE_HH__
#define __AKANTU_TRIANGLE_HH__
#include "aka_common.hh"
#include "mesh_geom_common.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
/// Class used for substitution of CGAL::Triangle_3 primitive
template <typename K> class Triangle : public CGAL::Triangle_3<K> {
public:
/// Default constructor
Triangle() : CGAL::Triangle_3<K>(), meshId(0) {}
/// Copy constructor
Triangle(const Triangle & other)
: CGAL::Triangle_3<K>(other), meshId(other.meshId) {}
/// Construct from 3 points
Triangle(const CGAL::Point_3<K> & a, const CGAL::Point_3<K> & b,
const CGAL::Point_3<K> & c)
: CGAL::Triangle_3<K>(a, b, c), meshId(0) {}
public:
UInt id() const { return meshId; }
void setId(UInt newId) { meshId = newId; }
protected:
/// Id of the element represented by the primitive
UInt meshId;
};
-} // akantu
+} // namespace akantu
#endif // __AKANTU_TRIANGLE_HH__
diff --git a/src/geometry/geom_helper_functions.hh b/src/geometry/geom_helper_functions.hh
index f3cc29d22..e6bb128dc 100644
--- a/src/geometry/geom_helper_functions.hh
+++ b/src/geometry/geom_helper_functions.hh
@@ -1,112 +1,112 @@
/**
* @file geom_helper_functions.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Wed Jan 31 2018
*
* @brief Helper functions for the computational geometry algorithms
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef _AKANTU_GEOM_HELPER_FUNCTIONS_HH__
#define _AKANTU_GEOM_HELPER_FUNCTIONS_HH__
#include "aka_common.hh"
#include "aka_math.hh"
#include "tree_type_helper.hh"
#include "mesh_geom_common.hh"
namespace akantu {
/// Fuzzy compare of two points
template <class Point>
inline bool comparePoints(const Point & a, const Point & b) {
return Math::are_float_equal(a.x(), b.x()) &&
Math::are_float_equal(a.y(), b.y()) &&
Math::are_float_equal(a.z(), b.z());
}
template <>
inline bool comparePoints(const cgal::Spherical::Circular_arc_point_3 & a,
const cgal::Spherical::Circular_arc_point_3 & b) {
return Math::are_float_equal(CGAL::to_double(a.x()),
CGAL::to_double(b.x())) &&
Math::are_float_equal(CGAL::to_double(a.y()),
CGAL::to_double(b.y())) &&
Math::are_float_equal(CGAL::to_double(a.z()), CGAL::to_double(b.z()));
}
/// Fuzzy compare of two segments
template <class K>
inline bool compareSegments(const CGAL::Segment_3<K> & a,
const CGAL::Segment_3<K> & b) {
return (comparePoints(a.source(), b.source()) &&
comparePoints(a.target(), b.target())) ||
(comparePoints(a.source(), b.target()) &&
comparePoints(a.target(), b.source()));
}
/// Compare segment pairs
inline bool
compareSegmentPairs(const std::pair<cgal::Cartesian::Segment_3, UInt> & a,
const std::pair<cgal::Cartesian::Segment_3, UInt> & b) {
return compareSegments(a.first, b.first);
}
/// Pair ordering operator based on first member
struct segmentPairsLess {
inline bool
operator()(const std::pair<cgal::Cartesian::Segment_3, UInt> & a,
const std::pair<cgal::Cartesian::Segment_3, UInt> & b) {
return CGAL::compare_lexicographically(a.first.min(), b.first.min()) ||
CGAL::compare_lexicographically(a.first.max(), b.first.max());
}
};
/* -------------------------------------------------------------------------- */
/* Predicates */
/* -------------------------------------------------------------------------- */
/// Predicate used to determine if two segments are equal
class IsSameSegment {
public:
IsSameSegment(const cgal::Cartesian::Segment_3 & segment)
: segment(segment) {}
bool
operator()(const std::pair<cgal::Cartesian::Segment_3, UInt> & test_pair) {
return compareSegments(segment, test_pair.first);
}
protected:
const cgal::Cartesian::Segment_3 segment;
};
-} // akantu
+} // namespace akantu
#endif // _AKANTU_GEOM_HELPER_FUNCTIONS_HH__
diff --git a/src/geometry/mesh_abstract_intersector.hh b/src/geometry/mesh_abstract_intersector.hh
index 2bf1c1b29..e778efd89 100644
--- a/src/geometry/mesh_abstract_intersector.hh
+++ b/src/geometry/mesh_abstract_intersector.hh
@@ -1,121 +1,121 @@
/**
* @file mesh_abstract_intersector.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Apr 29 2015
* @date last modification: Mon Jun 19 2017
*
* @brief Abstract class for intersection computations
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_ABSTRACT_INTERSECTOR_HH__
#define __AKANTU_MESH_ABSTRACT_INTERSECTOR_HH__
#include "aka_common.hh"
#include "mesh_geom_abstract.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* @brief Class used to perform intersections on a mesh and construct output
* data
*/
template <class Query> class MeshAbstractIntersector : public MeshGeomAbstract {
public:
/// Construct from mesh
explicit MeshAbstractIntersector(Mesh & mesh);
/// Destructor
virtual ~MeshAbstractIntersector();
public:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get the new_node_per_elem array
AKANTU_GET_MACRO(NewNodePerElem, *new_node_per_elem, const Array<UInt> &);
/// get the intersection_points array
AKANTU_GET_MACRO(IntersectionPoints, intersection_points,
const Array<Real> *);
/// get the nb_seg_by_el UInt
AKANTU_GET_MACRO(NbSegByEl, nb_seg_by_el, UInt);
/**
* @brief Compute the intersection with a query object
*
* This function needs to be implemented for every subclass. It computes the
* intersections
* with the tree of primitives and creates the data for the user.
*
* @param query the CGAL primitive of the query object
*/
virtual void computeIntersectionQuery(const Query & query) = 0;
/// Compute intersection points between the mesh primitives (segments) and a
/// query (surface in 3D or a curve in 2D), double intersection points for the
/// same primitives are not considered. A maximum intersection node per
/// element is set : 2 in 2D and 4 in 3D
virtual void computeMeshQueryIntersectionPoint(const Query & query,
UInt nb_old_nodes) = 0;
/// Compute intersection between the mesh and a list of queries
virtual void
computeIntersectionQueryList(const std::list<Query> & query_list);
/// Compute intersection points between the mesh and a list of queries
virtual void
computeMeshQueryListIntersectionPoint(const std::list<Query> & query_list,
UInt nb_old_nodes);
/// Compute whatever result is needed from the user (should be move to the
/// appropriate specific classe for genericity)
virtual void
buildResultFromQueryList(const std::list<Query> & query_list) = 0;
protected:
/// new node per element (column 0: number of new nodes, then odd is the
/// intersection node number and even the ID of the intersected segment)
Array<UInt> * new_node_per_elem;
/// intersection output: new intersection points
/// (computeMeshQueryListIntersectionPoint)
Array<Real> * intersection_points;
/// number of segment in a considered element of the templated type of element
/// specialized intersector
const UInt nb_seg_by_el;
};
-} // akantu
+} // namespace akantu
#include "mesh_abstract_intersector_tmpl.hh"
#endif // __AKANTU_MESH_ABSTRACT_INTERSECTOR_HH__
diff --git a/src/geometry/mesh_abstract_intersector_tmpl.hh b/src/geometry/mesh_abstract_intersector_tmpl.hh
index ccd833882..dae4033ee 100644
--- a/src/geometry/mesh_abstract_intersector_tmpl.hh
+++ b/src/geometry/mesh_abstract_intersector_tmpl.hh
@@ -1,83 +1,83 @@
/**
* @file mesh_abstract_intersector_tmpl.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Apr 29 2015
* @date last modification: Mon Jun 19 2017
*
* @brief General class for intersection computations
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_ABSTRACT_INTERSECTOR_TMPL_HH__
#define __AKANTU_MESH_ABSTRACT_INTERSECTOR_TMPL_HH__
#include "aka_common.hh"
#include "mesh_abstract_intersector.hh"
namespace akantu {
template <class Query>
MeshAbstractIntersector<Query>::MeshAbstractIntersector(Mesh & mesh)
: MeshGeomAbstract(mesh), new_node_per_elem(NULL),
intersection_points(NULL), nb_seg_by_el(0) {}
template <class Query>
MeshAbstractIntersector<Query>::~MeshAbstractIntersector() {}
template <class Query>
void MeshAbstractIntersector<Query>::computeIntersectionQueryList(
const std::list<Query> & query_list) {
AKANTU_DEBUG_IN();
typename std::list<Query>::const_iterator query_it = query_list.begin(),
query_end = query_list.end();
for (; query_it != query_end; ++query_it) {
computeIntersectionQuery(*query_it);
}
AKANTU_DEBUG_OUT();
}
template <class Query>
void MeshAbstractIntersector<Query>::computeMeshQueryListIntersectionPoint(
const std::list<Query> & query_list, UInt nb_old_nodes) {
AKANTU_DEBUG_IN();
typename std::list<Query>::const_iterator query_it = query_list.begin(),
query_end = query_list.end();
for (; query_it != query_end; ++query_it) {
computeMeshQueryIntersectionPoint(*query_it, nb_old_nodes);
}
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
#endif // __AKANTU_MESH_ABSTRACT_INTERSECTOR_TMPL_HH__
diff --git a/src/geometry/mesh_geom_abstract.hh b/src/geometry/mesh_geom_abstract.hh
index 530924b48..83b798933 100644
--- a/src/geometry/mesh_geom_abstract.hh
+++ b/src/geometry/mesh_geom_abstract.hh
@@ -1,65 +1,65 @@
/**
* @file mesh_geom_abstract.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Mon Jun 19 2017
*
* @brief Class for constructing the CGAL primitives of a mesh
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_GEOM_ABSTRACT_HH__
#define __AKANTU_MESH_GEOM_ABSTRACT_HH__
#include "aka_common.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/// Abstract class for mesh geometry operations
class MeshGeomAbstract {
public:
/// Construct from mesh
explicit MeshGeomAbstract(Mesh & mesh) : mesh(mesh){};
/// Destructor
virtual ~MeshGeomAbstract(){};
public:
/// Construct geometric data for computational geometry algorithms
virtual void constructData(GhostType ghost_type = _not_ghost) = 0;
protected:
/// Mesh used to construct the primitives
Mesh & mesh;
};
-} // akantu
+} // namespace akantu
#endif // __AKANTU_MESH_GEOM_ABSTRACT_HH__
diff --git a/src/geometry/mesh_geom_common.hh b/src/geometry/mesh_geom_common.hh
index 528e965a8..74d687dc5 100644
--- a/src/geometry/mesh_geom_common.hh
+++ b/src/geometry/mesh_geom_common.hh
@@ -1,57 +1,57 @@
/**
* @file mesh_geom_common.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Wed Jan 31 2018
*
* @brief Common file for MeshGeom module
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_MESH_GEOM_COMMON_HH__
#define __AKANTU_MESH_GEOM_COMMON_HH__
#include "aka_common.hh"
#include <CGAL/MP_Float.h>
#include <CGAL/Quotient.h>
#include <CGAL/Algebraic_kernel_for_spheres_2_3.h>
#include <CGAL/Cartesian.h>
#include <CGAL/Simple_cartesian.h>
#include <CGAL/Spherical_kernel_3.h>
namespace akantu {
namespace cgal {
using Cartesian = CGAL::Simple_cartesian<Real>;
using Spherical = CGAL::Spherical_kernel_3<
CGAL::Simple_cartesian<CGAL::Quotient<CGAL::MP_Float>>,
CGAL::Algebraic_kernel_for_spheres_2_3<CGAL::Quotient<CGAL::MP_Float>>>;
-} // cgal
+} // namespace cgal
-} // akantu
+} // namespace akantu
#endif // __AKANTU_MESH_GEOM_COMMON_HH__
diff --git a/src/geometry/mesh_geom_factory.hh b/src/geometry/mesh_geom_factory.hh
index 1b31ea553..3036b41e1 100644
--- a/src/geometry/mesh_geom_factory.hh
+++ b/src/geometry/mesh_geom_factory.hh
@@ -1,107 +1,107 @@
/**
* @file mesh_geom_factory.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Feb 27 2015
* @date last modification: Mon Jun 19 2017
*
* @brief Class for constructing the CGAL primitives of a mesh
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_GEOM_FACTORY_HH__
#define __AKANTU_MESH_GEOM_FACTORY_HH__
#include "aka_common.hh"
#include "geom_helper_functions.hh"
#include "mesh.hh"
#include "mesh_geom_abstract.hh"
#include "tree_type_helper.hh"
#include <algorithm>
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* @brief Class used to construct AABB tree for intersection computations
*
* This class constructs a CGAL AABB tree of one type of element in a mesh
* for fast intersection computations.
*/
template <UInt dim, ElementType el_type, class Primitive, class Kernel>
class MeshGeomFactory : public MeshGeomAbstract {
public:
/// Construct from mesh
explicit MeshGeomFactory(Mesh & mesh);
/// Desctructor
virtual ~MeshGeomFactory();
public:
/// Construct AABB tree for fast intersection computing
virtual void constructData(GhostType ghost_type = _not_ghost);
/**
* @brief Construct a primitive and add it to a list of primitives
*
* This function needs to be specialized for every type that is wished to be
* supported.
* @param node_coordinates coordinates of the nodes making up the element
* @param id element number
* @param list the primitive list (not used inside MeshGeomFactory)
*/
inline void addPrimitive(
const Matrix<Real> & node_coordinates, UInt id,
typename TreeTypeHelper<Primitive, Kernel>::container_type & list);
inline void addPrimitive(const Matrix<Real> & node_coordinates, UInt id);
/// Getter for the AABB tree
const typename TreeTypeHelper<Primitive, Kernel>::tree & getTree() const {
return *data_tree;
}
/// Getter for primitive list
const typename TreeTypeHelper<Primitive, Kernel>::container_type &
getPrimitiveList() const {
return primitive_list;
}
protected:
/// AABB data tree
typename TreeTypeHelper<Primitive, Kernel>::tree * data_tree;
/// Primitive list
typename TreeTypeHelper<Primitive, Kernel>::container_type primitive_list;
};
-} // akantu
+} // namespace akantu
#include "mesh_geom_factory_tmpl.hh"
#endif // __AKANTU_MESH_GEOM_FACTORY_HH__
diff --git a/src/geometry/mesh_geom_factory_tmpl.hh b/src/geometry/mesh_geom_factory_tmpl.hh
index a7028a652..4ce1a10c3 100644
--- a/src/geometry/mesh_geom_factory_tmpl.hh
+++ b/src/geometry/mesh_geom_factory_tmpl.hh
@@ -1,271 +1,271 @@
/**
* @file mesh_geom_factory_tmpl.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Feb 27 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Class for constructing the CGAL primitives of a mesh
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_MESH_GEOM_FACTORY_TMPL_HH__
#define __AKANTU_MESH_GEOM_FACTORY_TMPL_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "mesh_geom_common.hh"
#include "mesh_geom_factory.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
template <UInt dim, ElementType type, class Primitive, class Kernel>
MeshGeomFactory<dim, type, Primitive, Kernel>::MeshGeomFactory(Mesh & mesh)
: MeshGeomAbstract(mesh), data_tree(NULL), primitive_list() {}
template <UInt dim, ElementType type, class Primitive, class Kernel>
MeshGeomFactory<dim, type, Primitive, Kernel>::~MeshGeomFactory() {
delete data_tree;
}
/**
* This function loops over the elements of `type` in the mesh and creates the
* AABB tree of geometrical primitves (`data_tree`).
*/
template <UInt dim, ElementType type, class Primitive, class Kernel>
void MeshGeomFactory<dim, type, Primitive, Kernel>::constructData(
GhostType ghost_type) {
AKANTU_DEBUG_IN();
primitive_list.clear();
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
const Array<UInt> & connectivity = mesh.getConnectivity(type, ghost_type);
const Array<Real> & nodes = mesh.getNodes();
UInt el_index = 0;
Array<UInt>::const_vector_iterator it =
connectivity.begin(nb_nodes_per_element);
Array<UInt>::const_vector_iterator end =
connectivity.end(nb_nodes_per_element);
Matrix<Real> node_coordinates(dim, nb_nodes_per_element);
// This loop builds the list of primitives
for (; it != end; ++it, ++el_index) {
const Vector<UInt> & el_connectivity = *it;
for (UInt i = 0; i < nb_nodes_per_element; i++)
for (UInt j = 0; j < dim; j++)
node_coordinates(j, i) = nodes(el_connectivity(i), j);
// the unique elemental id assigned to the primitive is the
// linearized element index over ghost type
addPrimitive(node_coordinates, el_index);
}
delete data_tree;
// This condition allows the use of the mesh geom module
// even if types are not compatible with AABB tree algorithm
if (TreeTypeHelper<Primitive, Kernel>::is_valid)
data_tree = new typename TreeTypeHelper<Primitive, Kernel>::tree(
primitive_list.begin(), primitive_list.end());
AKANTU_DEBUG_OUT();
}
template <UInt dim, ElementType type, class Primitive, class Kernel>
void MeshGeomFactory<dim, type, Primitive, Kernel>::addPrimitive(
const Matrix<Real> & node_coordinates, UInt id) {
this->addPrimitive(node_coordinates, id, this->primitive_list);
}
// (2D, _triangle_3) decomposed into Triangle<cgal::Cartesian>
template <>
inline void
MeshGeomFactory<2, _triangle_3, Triangle<cgal::Cartesian>, cgal::Cartesian>::
addPrimitive(const Matrix<Real> & node_coordinates, UInt id,
TreeTypeHelper<Triangle<cgal::Cartesian>,
cgal::Cartesian>::container_type & list) {
TreeTypeHelper<Triangle<cgal::Cartesian>, cgal::Cartesian>::point_type a(
node_coordinates(0, 0), node_coordinates(1, 0), 0.),
b(node_coordinates(0, 1), node_coordinates(1, 1), 0.),
c(node_coordinates(0, 2), node_coordinates(1, 2), 0.);
Triangle<cgal::Cartesian> t(a, b, c);
t.setId(id);
list.push_back(t);
}
// (2D, _triangle_6) decomposed into Triangle<cgal::Cartesian>
template <>
inline void
MeshGeomFactory<2, _triangle_6, Triangle<cgal::Cartesian>, cgal::Cartesian>::
addPrimitive(const Matrix<Real> & node_coordinates, UInt id,
TreeTypeHelper<Triangle<cgal::Cartesian>,
cgal::Cartesian>::container_type & list) {
TreeTypeHelper<Triangle<cgal::Cartesian>, cgal::Cartesian>::point_type a(
node_coordinates(0, 0), node_coordinates(1, 0), 0.),
b(node_coordinates(0, 1), node_coordinates(1, 1), 0.),
c(node_coordinates(0, 2), node_coordinates(1, 2), 0.);
Triangle<cgal::Cartesian> t(a, b, c);
t.setId(id);
list.push_back(t);
}
// (2D, _triangle_3) decomposed into Line_arc<cgal::Spherical>
template <>
inline void
MeshGeomFactory<2, _triangle_3, Line_arc<cgal::Spherical>, cgal::Spherical>::
addPrimitive(const Matrix<Real> & node_coordinates, UInt id,
TreeTypeHelper<Line_arc<cgal::Spherical>,
cgal::Spherical>::container_type & list) {
TreeTypeHelper<Line_arc<cgal::Spherical>, cgal::Spherical>::point_type a(
node_coordinates(0, 0), node_coordinates(1, 0), 0.),
b(node_coordinates(0, 1), node_coordinates(1, 1), 0.),
c(node_coordinates(0, 2), node_coordinates(1, 2), 0.);
/*std::cout << "elem " << id << " node 1 : x_node=" << node_coordinates(0, 0)
<< ", x_arc_node=" << a.x() << ", y_node=" << node_coordinates(1, 0)
<< ", y_arc_node=" << a.y() << std::endl ;
std::cout << "elem " << id << " node 2 : x_node=" << node_coordinates(0, 1)
<< ", x_arc_node=" << b.x() << ", y_node=" << node_coordinates(1, 1)
<< ", y_arc_node=" << b.y() << std::endl ;
std::cout << "elem " << id << " node 2 : x_node=" << node_coordinates(0, 2)
<< ", x_arc_node=" << c.x() << ", y_node=" << node_coordinates(1, 2)
<< ", y_arc_node=" << c.y() << std::endl ;*/
CGAL::Line_3<cgal::Spherical> l1(a, b), l2(b, c), l3(c, a);
Line_arc<cgal::Spherical> s1(l1, a, b), s2(l2, b, c), s3(l3, c, a);
s1.setId(id);
s1.setSegId(0);
s2.setId(id);
s2.setSegId(1);
s3.setId(id);
s3.setSegId(2);
list.push_back(s1);
list.push_back(s2);
list.push_back(s3);
}
#if defined(AKANTU_IGFEM)
// (2D, _igfem_triangle_4) decomposed into Line_arc<cgal::Spherical>
template <>
inline void MeshGeomFactory<2, _igfem_triangle_4, Line_arc<cgal::Spherical>,
cgal::Spherical>::
addPrimitive(const Matrix<Real> & node_coordinates, UInt id,
TreeTypeHelper<Line_arc<cgal::Spherical>,
cgal::Spherical>::container_type & list) {
TreeTypeHelper<Line_arc<cgal::Spherical>, cgal::Spherical>::point_type a(
node_coordinates(0, 0), node_coordinates(1, 0), 0.),
b(node_coordinates(0, 1), node_coordinates(1, 1), 0.),
c(node_coordinates(0, 2), node_coordinates(1, 2), 0.);
CGAL::Line_3<cgal::Spherical> l1(a, b), l2(b, c), l3(c, a);
Line_arc<cgal::Spherical> s1(l1, a, b), s2(l2, b, c), s3(l3, c, a);
s1.setId(id);
s1.setSegId(0);
s2.setId(id);
s2.setSegId(1);
s3.setId(id);
s3.setSegId(2);
list.push_back(s1);
list.push_back(s2);
list.push_back(s3);
}
// (2D, _igfem_triangle_4) decomposed into Line_arc<cgal::Spherical>
template <>
inline void MeshGeomFactory<2, _igfem_triangle_5, Line_arc<cgal::Spherical>,
cgal::Spherical>::
addPrimitive(const Matrix<Real> & node_coordinates, UInt id,
TreeTypeHelper<Line_arc<cgal::Spherical>,
cgal::Spherical>::container_type & list) {
TreeTypeHelper<Line_arc<cgal::Spherical>, cgal::Spherical>::point_type a(
node_coordinates(0, 0), node_coordinates(1, 0), 0.),
b(node_coordinates(0, 1), node_coordinates(1, 1), 0.),
c(node_coordinates(0, 2), node_coordinates(1, 2), 0.);
CGAL::Line_3<cgal::Spherical> l1(a, b), l2(b, c), l3(c, a);
Line_arc<cgal::Spherical> s1(l1, a, b), s2(l2, b, c), s3(l3, c, a);
s1.setId(id);
s1.setSegId(0);
s2.setId(id);
s2.setSegId(1);
s3.setId(id);
s3.setSegId(2);
list.push_back(s1);
list.push_back(s2);
list.push_back(s3);
}
#endif
// (3D, _tetrahedron_4) decomposed into Triangle<cgal::Cartesian>
template <>
inline void
MeshGeomFactory<3, _tetrahedron_4, Triangle<cgal::Cartesian>, cgal::Cartesian>::
addPrimitive(const Matrix<Real> & node_coordinates, UInt id,
TreeTypeHelper<Triangle<cgal::Cartesian>,
cgal::Cartesian>::container_type & list) {
TreeTypeHelper<Triangle<cgal::Cartesian>, cgal::Cartesian>::point_type a(
node_coordinates(0, 0), node_coordinates(1, 0), node_coordinates(2, 0)),
b(node_coordinates(0, 1), node_coordinates(1, 1), node_coordinates(2, 1)),
c(node_coordinates(0, 2), node_coordinates(1, 2), node_coordinates(2, 2)),
d(node_coordinates(0, 3), node_coordinates(1, 3), node_coordinates(2, 3));
Triangle<cgal::Cartesian> t1(a, b, c), t2(b, c, d), t3(c, d, a), t4(d, a, b);
t1.setId(id);
t2.setId(id);
t3.setId(id);
t4.setId(id);
list.push_back(t1);
list.push_back(t2);
list.push_back(t3);
list.push_back(t4);
}
-} // akantu
+} // namespace akantu
#endif // __AKANTU_MESH_GEOM_FACTORY_TMPL_HH__
diff --git a/src/geometry/mesh_geom_intersector.hh b/src/geometry/mesh_geom_intersector.hh
index a0082b077..dee6a9cf8 100644
--- a/src/geometry/mesh_geom_intersector.hh
+++ b/src/geometry/mesh_geom_intersector.hh
@@ -1,74 +1,74 @@
/**
* @file mesh_geom_intersector.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Apr 29 2015
* @date last modification: Mon Jun 19 2017
*
* @brief General class for intersection computations
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_GEOM_INTERSECTOR_HH__
#define __AKANTU_MESH_GEOM_INTERSECTOR_HH__
#include "aka_common.hh"
#include "mesh_abstract_intersector.hh"
#include "mesh_geom_factory.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* @brief Class used to perform intersections on a mesh and construct output
* data
*/
template <UInt dim, ElementType type, class Primitive, class Query,
class Kernel>
class MeshGeomIntersector : public MeshAbstractIntersector<Query> {
public:
/// Construct from mesh
explicit MeshGeomIntersector(Mesh & mesh);
/// Destructor
virtual ~MeshGeomIntersector();
public:
/// Construct the primitive tree object
virtual void constructData(GhostType ghost_type = _not_ghost);
protected:
/// Factory object containing the primitive tree
MeshGeomFactory<dim, type, Primitive, Kernel> factory;
};
-} // akantu
+} // namespace akantu
#include "mesh_geom_intersector_tmpl.hh"
#endif // __AKANTU_MESH_GEOM_INTERSECTOR_HH__
diff --git a/src/geometry/mesh_geom_intersector_tmpl.hh b/src/geometry/mesh_geom_intersector_tmpl.hh
index 7bedae20d..c88867295 100644
--- a/src/geometry/mesh_geom_intersector_tmpl.hh
+++ b/src/geometry/mesh_geom_intersector_tmpl.hh
@@ -1,64 +1,64 @@
/**
* @file mesh_geom_intersector_tmpl.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Wed Apr 29 2015
* @date last modification: Mon Jun 19 2017
*
* @brief General class for intersection computations
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_GEOM_INTERSECTOR_TMPL_HH__
#define __AKANTU_MESH_GEOM_INTERSECTOR_TMPL_HH__
#include "aka_common.hh"
#include "mesh_geom_intersector.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
template <UInt dim, ElementType type, class Primitive, class Query,
class Kernel>
MeshGeomIntersector<dim, type, Primitive, Query, Kernel>::MeshGeomIntersector(
Mesh & mesh)
: MeshAbstractIntersector<Query>(mesh), factory(mesh) {}
template <UInt dim, ElementType type, class Primitive, class Query,
class Kernel>
MeshGeomIntersector<dim, type, Primitive, Query,
Kernel>::~MeshGeomIntersector() {}
template <UInt dim, ElementType type, class Primitive, class Query,
class Kernel>
void MeshGeomIntersector<dim, type, Primitive, Query, Kernel>::constructData(
GhostType ghost_type) {
this->intersection_points->resize(0);
factory.constructData(ghost_type);
}
-} // akantu
+} // namespace akantu
#endif // __AKANTU_MESH_GEOM_INTERSECTOR_TMPL_HH__
diff --git a/src/geometry/mesh_segment_intersector.hh b/src/geometry/mesh_segment_intersector.hh
index b6691c10b..cae311c89 100644
--- a/src/geometry/mesh_segment_intersector.hh
+++ b/src/geometry/mesh_segment_intersector.hh
@@ -1,109 +1,109 @@
/**
* @file mesh_segment_intersector.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Apr 29 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Computation of mesh intersection with segments
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_SEGMENT_INTERSECTOR_HH__
#define __AKANTU_MESH_SEGMENT_INTERSECTOR_HH__
#include "aka_common.hh"
#include "mesh_geom_intersector.hh"
#include "mesh_geom_common.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
template <UInt dim, ElementType type>
class MeshSegmentIntersector
: public MeshGeomIntersector<dim, type, Triangle<cgal::Cartesian>,
cgal::Cartesian::Segment_3, cgal::Cartesian> {
using K = cgal::Cartesian;
/// Parent class type
typedef MeshGeomIntersector<dim, type, Triangle<K>, K::Segment_3, K>
parent_type;
/// Result of intersection function type
typedef typename IntersectionTypeHelper<TreeTypeHelper<Triangle<K>, K>,
K::Segment_3>::intersection_type
result_type;
/// Pair of segments and element id
typedef std::pair<K::Segment_3, UInt> pair_type;
public:
/// Construct from mesh
explicit MeshSegmentIntersector(Mesh & mesh, Mesh & result_mesh);
/// Destructor
virtual ~MeshSegmentIntersector();
public:
/**
* @brief Computes the intersection of the mesh with a segment
*
* @param query the segment to compute the intersections with the mesh
*/
virtual void computeIntersectionQuery(const K::Segment_3 & query);
/// Compute intersection points between the mesh and a query
virtual void computeMeshQueryIntersectionPoint(const K::Segment_3 & query,
UInt nb_old_nodes);
/// Compute the embedded mesh
virtual void
buildResultFromQueryList(const std::list<K::Segment_3> & query_list);
void setPhysicalName(const std::string & other) {
current_physical_name = other;
}
protected:
/// Compute segments from intersection list
void computeSegments(const std::list<result_type> & intersections,
std::set<pair_type, segmentPairsLess> & segments,
const K::Segment_3 & query);
protected:
/// Result mesh
Mesh & result_mesh;
/// Physical name of the current batch of queries
std::string current_physical_name;
};
-} // akantu
+} // namespace akantu
#include "mesh_segment_intersector_tmpl.hh"
#endif // __AKANTU_MESH_SEGMENT_INTERSECTOR_HH__
diff --git a/src/geometry/mesh_sphere_intersector.hh b/src/geometry/mesh_sphere_intersector.hh
index 4066d67c4..0cd051d30 100644
--- a/src/geometry/mesh_sphere_intersector.hh
+++ b/src/geometry/mesh_sphere_intersector.hh
@@ -1,119 +1,119 @@
/**
* @file mesh_sphere_intersector.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Jun 23 2015
* @date last modification: Tue Feb 20 2018
*
* @brief Computation of mesh intersection with sphere(s)
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_SPHERE_INTERSECTOR_HH__
#define __AKANTU_MESH_SPHERE_INTERSECTOR_HH__
#include "aka_common.hh"
#include "mesh_geom_intersector.hh"
#include "mesh_geom_common.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
template <UInt dim, ElementType type>
class MeshSphereIntersector
: public MeshGeomIntersector<dim, type, Line_arc<cgal::Spherical>,
cgal::Spherical::Sphere_3, cgal::Spherical> {
using SK = cgal::Spherical;
using K = cgal::Cartesian;
/// Parent class type
typedef MeshGeomIntersector<dim, type, Line_arc<SK>, SK::Sphere_3, SK>
parent_type;
/// Result of intersection function type
typedef typename IntersectionTypeHelper<TreeTypeHelper<Triangle<K>, K>,
K::Segment_3>::intersection_type
result_type;
/// Pair of intersection points and element id
typedef std::pair<SK::Circular_arc_point_3, UInt> pair_type;
public:
/// Construct from mesh
explicit MeshSphereIntersector(Mesh & mesh);
/// Destructor
virtual ~MeshSphereIntersector();
public:
/// Construct the primitive tree object
virtual void constructData(GhostType ghost_type = _not_ghost);
/**
* @brief Computes the intersection of the mesh with a sphere
*
* @param query (sphere) to compute the intersections with the mesh
*/
virtual void computeIntersectionQuery(const SK::Sphere_3 & /*query*/) {
AKANTU_ERROR("This function is not implemented for spheres (It was "
"to generic and has been replaced by "
"computeMeshQueryIntersectionPoint");
}
/// Compute intersection points between the mesh primitives (segments) and a
/// query (surface in 3D or a curve in 2D), double intersection points for the
/// same primitives are not considered. A maximum is set to the number of
/// intersection nodes per element: 2 in 2D and 4 in 3D
virtual void computeMeshQueryIntersectionPoint(const SK::Sphere_3 & query,
UInt nb_old_nodes);
/// Build the IGFEM mesh
virtual void
buildResultFromQueryList(const std::list<SK::Sphere_3> & /*query*/) {
AKANTU_ERROR("This function is no longer implemented to split "
"geometrical operations and dedicated result "
"construction");
}
/// Set the tolerance
void setToleranceIntersectionOnNode(UInt tol) {
this->tol_intersection_on_node = tol;
}
protected:
/// tolerance for which the intersection is considered on the mesh node
/// (relative to the segment lenght)
Real tol_intersection_on_node;
};
-} // akantu
+} // namespace akantu
#include "mesh_sphere_intersector_tmpl.hh"
#endif // __AKANTU_MESH_SPHERE_INTERSECTOR_HH__
diff --git a/src/geometry/mesh_sphere_intersector_tmpl.hh b/src/geometry/mesh_sphere_intersector_tmpl.hh
index d47d652ef..00d303766 100644
--- a/src/geometry/mesh_sphere_intersector_tmpl.hh
+++ b/src/geometry/mesh_sphere_intersector_tmpl.hh
@@ -1,215 +1,215 @@
/**
* @file mesh_sphere_intersector_tmpl.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Jun 23 2015
* @date last modification: Tue Feb 20 2018
*
* @brief Computation of mesh intersection with spheres
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_SPHERE_INTERSECTOR_TMPL_HH__
#define __AKANTU_MESH_SPHERE_INTERSECTOR_TMPL_HH__
#include "aka_common.hh"
#include "mesh_geom_common.hh"
#include "mesh_sphere_intersector.hh"
#include "tree_type_helper.hh"
namespace akantu {
template <UInt dim, ElementType type>
MeshSphereIntersector<dim, type>::MeshSphereIntersector(Mesh & mesh)
: parent_type(mesh), tol_intersection_on_node(1e-10) {
#if defined(AKANTU_IGFEM)
if ((type == _triangle_3) || (type == _igfem_triangle_4) ||
(type == _igfem_triangle_5)) {
const_cast<UInt &>(this->nb_seg_by_el) = 3;
} else {
AKANTU_ERROR("Not ready for mesh type " << type);
}
#else
if ((type != _triangle_3))
AKANTU_ERROR("Not ready for mesh type " << type);
#endif
// initialize the intersection pointsss array with the spatial dimension
this->intersection_points = new Array<Real>(0, dim);
// A maximum is set to the number of intersection nodes per element to limit
// the size of new_node_per_elem: 2 in 2D and 4 in 3D
this->new_node_per_elem = new Array<UInt>(0, 1 + 4 * (dim - 1));
}
template <UInt dim, ElementType type>
MeshSphereIntersector<dim, type>::~MeshSphereIntersector() {
delete this->new_node_per_elem;
delete this->intersection_points;
}
template <UInt dim, ElementType type>
void MeshSphereIntersector<dim, type>::constructData(GhostType ghost_type) {
this->new_node_per_elem->resize(this->mesh.getNbElement(type, ghost_type));
this->new_node_per_elem->clear();
MeshGeomIntersector<dim, type, Line_arc<SK>, SK::Sphere_3, SK>::constructData(
ghost_type);
}
template <UInt dim, ElementType type>
void MeshSphereIntersector<dim, type>::computeMeshQueryIntersectionPoint(
const SK::Sphere_3 & query, UInt nb_old_nodes) {
/// function to replace computeIntersectionQuery in a more generic geometry
/// module version
// The newNodeEvent is not send from this method who only compute the
// intersection points
AKANTU_DEBUG_IN();
Array<Real> & nodes = this->mesh.getNodes();
UInt nb_node = nodes.size() + this->intersection_points->size();
// Tolerance for proximity checks should be defined by user
Real global_tolerance = Math::getTolerance();
Math::setTolerance(tol_intersection_on_node);
typedef boost::variant<pair_type> sk_inter_res;
TreeTypeHelper<Line_arc<cgal::Spherical>, cgal::Spherical>::const_iterator
it = this->factory.getPrimitiveList().begin(),
end = this->factory.getPrimitiveList().end();
for (; it != end; ++it) { // loop on the primitives (segments)
std::list<sk_inter_res> s_results;
CGAL::intersection(*it, query, std::back_inserter(s_results));
if (s_results.size() == 1) { // just one point
if (pair_type * pair = boost::get<pair_type>(&s_results.front())) {
if (pair->second == 1) { // not a point tangent to the sphere
// the intersection point written as a vector
Vector<Real> new_node(dim, 0.0);
cgal::Cartesian::Point_3 point(CGAL::to_double(pair->first.x()),
CGAL::to_double(pair->first.y()),
CGAL::to_double(pair->first.z()));
for (UInt i = 0; i < dim; i++) {
new_node(i) = point[i];
}
/// boolean to decide wheter intersection point is on a standard node
/// of the mesh or not
bool is_on_mesh = false;
/// boolean to decide if this intersection point has been already
/// computed for a neighbor element
bool is_new = true;
/// check if intersection point has already been computed
UInt n = nb_old_nodes;
// check if we already compute this intersection and add it as a node
// for a neighboor element of another type
auto existing_node = nodes.begin(dim);
for (; n < nodes.size(); ++n) { // loop on the nodes from nb_old_nodes
if (Math::are_vector_equal(dim, new_node.storage(),
existing_node[n].storage())) {
is_new = false;
break;
}
}
if (is_new) {
auto intersection_points_it = this->intersection_points->begin(dim);
auto intersection_points_end = this->intersection_points->end(dim);
for (; intersection_points_it != intersection_points_end;
++intersection_points_it, ++n) {
if (Math::are_vector_equal(dim, new_node.storage(),
intersection_points_it->storage())) {
is_new = false;
break;
}
}
}
// get the initial and final points of the primitive (segment) and
// write them as vectors
cgal::Cartesian::Point_3 source_cgal(
CGAL::to_double(it->source().x()),
CGAL::to_double(it->source().y()),
CGAL::to_double(it->source().z()));
cgal::Cartesian::Point_3 target_cgal(
CGAL::to_double(it->target().x()),
CGAL::to_double(it->target().y()),
CGAL::to_double(it->target().z()));
Vector<Real> source(dim), target(dim);
for (UInt i = 0; i < dim; i++) {
source(i) = source_cgal[i];
target(i) = target_cgal[i];
}
// Check if we are close from a node of the primitive (segment)
if (Math::are_vector_equal(dim, source.storage(),
new_node.storage()) ||
Math::are_vector_equal(dim, target.storage(),
new_node.storage())) {
is_on_mesh = true;
is_new = false;
}
if (is_new) { // if the intersection point is a new one add it to the
// list
this->intersection_points->push_back(new_node);
nb_node++;
}
// deduce the element id
UInt element_id = it->id();
// fill the new_node_per_elem array
if (!is_on_mesh) { // if the node is not on a mesh node
UInt & nb_new_nodes_per_el =
(*this->new_node_per_elem)(element_id, 0);
nb_new_nodes_per_el += 1;
AKANTU_DEBUG_ASSERT(
2 * nb_new_nodes_per_el <
this->new_node_per_elem->getNbComponent(),
"You might have to interface crossing the same material");
(*this->new_node_per_elem)(element_id,
(2 * nb_new_nodes_per_el) - 1) = n;
(*this->new_node_per_elem)(element_id, 2 * nb_new_nodes_per_el) =
it->segId();
}
}
}
}
}
Math::setTolerance(global_tolerance);
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
#endif // __AKANTU_MESH_SPHERE_INTERSECTOR_TMPL_HH__
diff --git a/src/geometry/tree_type_helper.hh b/src/geometry/tree_type_helper.hh
index f0cf08c21..410a223c4 100644
--- a/src/geometry/tree_type_helper.hh
+++ b/src/geometry/tree_type_helper.hh
@@ -1,109 +1,109 @@
/**
* @file tree_type_helper.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Jan 04 2013
* @date last modification: Thu Feb 01 2018
*
* @brief Converts element types of a mesh to CGAL primitive types
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TREE_TYPE_HELPER_HH__
#define __AKANTU_TREE_TYPE_HELPER_HH__
#include "aka_common.hh"
#include "line_arc.hh"
#include "tetrahedron.hh"
#include "triangle.hh"
#include "aabb_primitive.hh"
#include "mesh_geom_common.hh"
#include <CGAL/AABB_traits.h>
#include <CGAL/AABB_tree.h>
namespace akantu {
/* -------------------------------------------------------------------------- */
/// Replacement class for algorithm that can't use the AABB tree types
template <typename iterator> struct VoidTree {
VoidTree(const iterator & /*begin*/, const iterator & /*end*/) {}
};
/// Helper class used to ease the use of CGAL AABB tree algorithm
template <class Primitive, class Kernel> struct TreeTypeHelper {
static const bool is_valid = false;
typedef Primitive primitive_type;
typedef typename std::list<primitive_type> container_type;
typedef typename container_type::iterator iterator;
typedef typename container_type::const_iterator const_iterator;
typedef typename CGAL::Point_3<Kernel> point_type;
typedef VoidTree<iterator> tree;
};
/// Helper class used to ease the use of intersections
template <class TTHelper, class Query> struct IntersectionTypeHelper;
/**
* Macro used to specialize TreeTypeHelper
* @param my_primitive associated primitive type
* @param my_query query_type
* @param my_kernel kernel type
*/
#define TREE_TYPE_HELPER_MACRO(my_primitive, my_query, my_kernel) \
template <> struct TreeTypeHelper<my_primitive<my_kernel>, my_kernel> { \
static const bool is_valid = true; \
typedef my_primitive<my_kernel> primitive_type; \
typedef my_primitive##_primitive aabb_primitive_type; \
typedef CGAL::Point_3<my_kernel> point_type; \
\
typedef std::list<primitive_type> container_type; \
typedef container_type::iterator iterator; \
typedef CGAL::AABB_traits<my_kernel, aabb_primitive_type> \
aabb_traits_type; \
typedef CGAL::AABB_tree<aabb_traits_type> tree; \
typedef tree::Primitive_id id_type; \
}; \
\
template <> \
struct IntersectionTypeHelper< \
TreeTypeHelper<my_primitive<my_kernel>, my_kernel>, my_query> { \
typedef boost::optional<TreeTypeHelper< \
my_primitive<my_kernel>, \
my_kernel>::tree::Intersection_and_primitive_id<my_query>::Type> \
intersection_type; \
}
TREE_TYPE_HELPER_MACRO(Triangle, cgal::Cartesian::Segment_3, cgal::Cartesian);
// TREE_TYPE_HELPER_MACRO(Line_arc, cgal::Spherical::Sphere_3, cgal::Spherical);
#undef TREE_TYPE_HELPER_MACRO
-} // akantu
+} // namespace akantu
#endif // __AKANTU_TREE_TYPE_HELPER_HH__
diff --git a/src/io/dumper/dumpable.cc b/src/io/dumper/dumpable.cc
index a840987bf..45fd4b8bd 100644
--- a/src/io/dumper/dumpable.cc
+++ b/src/io/dumper/dumpable.cc
@@ -1,285 +1,277 @@
/**
* @file dumpable.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Tue Feb 20 2018
*
* @brief Implementation of the dumpable interface
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumpable.hh"
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
#include <io_helper.hh>
namespace akantu {
/* -------------------------------------------------------------------------- */
Dumpable::Dumpable() : default_dumper("") {}
/* -------------------------------------------------------------------------- */
-Dumpable::~Dumpable() {
-
- auto it = dumpers.begin();
- auto end = dumpers.end();
-
- for (; it != end; ++it) {
- delete it->second;
- }
-}
+Dumpable::~Dumpable() = default;
/* -------------------------------------------------------------------------- */
-void Dumpable::registerExternalDumper(DumperIOHelper & dumper,
+void Dumpable::registerExternalDumper(std::shared_ptr<DumperIOHelper> dumper,
const std::string & dumper_name,
const bool is_default) {
- this->dumpers[dumper_name] = &dumper;
+ this->dumpers[dumper_name] = dumper;
if (is_default)
this->default_dumper = dumper_name;
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpMesh(const Mesh & mesh, UInt spatial_dimension,
const GhostType & ghost_type,
const ElementKind & element_kind) {
this->addDumpMeshToDumper(this->default_dumper, mesh, spatial_dimension,
ghost_type, element_kind);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpMeshToDumper(const std::string & dumper_name,
const Mesh & mesh, UInt spatial_dimension,
const GhostType & ghost_type,
const ElementKind & element_kind) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.registerMesh(mesh, spatial_dimension, ghost_type, element_kind);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFilteredMesh(
const Mesh & mesh, const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter, UInt spatial_dimension,
const GhostType & ghost_type, const ElementKind & element_kind) {
this->addDumpFilteredMeshToDumper(this->default_dumper, mesh, elements_filter,
nodes_filter, spatial_dimension, ghost_type,
element_kind);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFilteredMeshToDumper(
const std::string & dumper_name, const Mesh & mesh,
const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter, UInt spatial_dimension,
const GhostType & ghost_type, const ElementKind & element_kind) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.registerFilteredMesh(mesh, elements_filter, nodes_filter,
spatial_dimension, ghost_type, element_kind);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpField(const std::string & field_id) {
this->addDumpFieldToDumper(this->default_dumper, field_id);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldToDumper(__attribute__((unused))
const std::string & dumper_name,
__attribute__((unused))
const std::string & field_id) {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldExternal(const std::string & field_id,
std::shared_ptr<dumper::Field> field) {
this->addDumpFieldExternalToDumper(this->default_dumper, field_id, field);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldExternalToDumper(
const std::string & dumper_name, const std::string & field_id,
std::shared_ptr<dumper::Field> field) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.registerField(field_id, field);
}
/* -------------------------------------------------------------------------- */
void Dumpable::removeDumpField(const std::string & field_id) {
this->removeDumpFieldFromDumper(this->default_dumper, field_id);
}
/* -------------------------------------------------------------------------- */
void Dumpable::removeDumpFieldFromDumper(const std::string & dumper_name,
const std::string & field_id) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.unRegisterField(field_id);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldVector(const std::string & field_id) {
this->addDumpFieldVectorToDumper(this->default_dumper, field_id);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldVectorToDumper(__attribute__((unused))
const std::string & dumper_name,
__attribute__((unused))
const std::string & field_id) {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldTensor(const std::string & field_id) {
this->addDumpFieldTensorToDumper(this->default_dumper, field_id);
}
/* -------------------------------------------------------------------------- */
void Dumpable::addDumpFieldTensorToDumper(__attribute__((unused))
const std::string & dumper_name,
__attribute__((unused))
const std::string & field_id) {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
void Dumpable::setDirectory(const std::string & directory) {
this->setDirectoryToDumper(this->default_dumper, directory);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setDirectoryToDumper(const std::string & dumper_name,
const std::string & directory) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.setDirectory(directory);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setBaseName(const std::string & basename) {
this->setBaseNameToDumper(this->default_dumper, basename);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setBaseNameToDumper(const std::string & dumper_name,
const std::string & basename) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.setBaseName(basename);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setTimeStepToDumper(Real time_step) {
this->setTimeStepToDumper(this->default_dumper, time_step);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setTimeStepToDumper(const std::string & dumper_name,
Real time_step) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.setTimeStep(time_step);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setTextModeToDumper(const std::string & dumper_name) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.getDumper().setMode(iohelper::TEXT);
}
/* -------------------------------------------------------------------------- */
void Dumpable::setTextModeToDumper() {
DumperIOHelper & dumper = this->getDumper(this->default_dumper);
dumper.getDumper().setMode(iohelper::TEXT);
}
/* -------------------------------------------------------------------------- */
void Dumpable::dump(const std::string & dumper_name) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.dump();
}
/* -------------------------------------------------------------------------- */
void Dumpable::dump() { this->dump(this->default_dumper); }
/* -------------------------------------------------------------------------- */
void Dumpable::dump(const std::string & dumper_name, UInt step) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.dump(step);
}
/* -------------------------------------------------------------------------- */
void Dumpable::dump(UInt step) { this->dump(this->default_dumper, step); }
/* -------------------------------------------------------------------------- */
void Dumpable::dump(const std::string & dumper_name, Real time, UInt step) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.dump(time, step);
}
/* -------------------------------------------------------------------------- */
void Dumpable::dump(Real time, UInt step) {
this->dump(this->default_dumper, time, step);
}
/* -------------------------------------------------------------------------- */
void Dumpable::internalAddDumpFieldToDumper(
const std::string & dumper_name, const std::string & field_id,
std::shared_ptr<dumper::Field> field) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.registerField(field_id, field);
}
/* -------------------------------------------------------------------------- */
DumperIOHelper & Dumpable::getDumper() {
return this->getDumper(this->default_dumper);
}
/* -------------------------------------------------------------------------- */
DumperIOHelper & Dumpable::getDumper(const std::string & dumper_name) {
auto it = this->dumpers.find(dumper_name);
auto end = this->dumpers.end();
if (it == end)
AKANTU_EXCEPTION("Dumper " << dumper_name
<< "has not been registered, yet.");
return *(it->second);
}
/* -------------------------------------------------------------------------- */
std::string Dumpable::getDefaultDumperName() const {
return this->default_dumper;
}
} // namespace akantu
#endif
diff --git a/src/io/dumper/dumpable_dummy.hh b/src/io/dumper/dumpable_dummy.hh
index f60256253..a1a3e2a5c 100644
--- a/src/io/dumper/dumpable_dummy.hh
+++ b/src/io/dumper/dumpable_dummy.hh
@@ -1,265 +1,265 @@
/**
* @file dumpable_dummy.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 26 2012
* @date last modification: Tue Feb 20 2018
*
* @brief Interface for object who wants to dump themselves
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DUMPABLE_DUMMY_HH__
#define __AKANTU_DUMPABLE_DUMMY_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused"
namespace dumper {
class Field;
}
class DumperIOHelper;
class Mesh;
/* -------------------------------------------------------------------------- */
class Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
Dumpable(){};
virtual ~Dumpable(){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
template <class T>
inline void registerDumper(const std::string & dumper_name,
const std::string & file_name = "",
const bool is_default = false) {}
- void registerExternalDumper(DumperIOHelper * dumper,
+ void registerExternalDumper(std::shared_ptr<DumperIOHelper> dumper,
const std::string & dumper_name,
const bool is_default = false) {}
void addDumpMesh(const Mesh & mesh, UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) {}
void addDumpMeshToDumper(const std::string & dumper_name, const Mesh & mesh,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) {
}
void addDumpFilteredMesh(const Mesh & mesh,
const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) {
}
void addDumpFilteredMeshToDumper(
const std::string & dumper_name, const Mesh & mesh,
const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) {}
virtual void addDumpField(const std::string & field_id) {
AKANTU_TO_IMPLEMENT();
}
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_TO_IMPLEMENT();
}
virtual void addDumpFieldExternal(const std::string & field_id,
std::shared_ptr<dumper::Field> field) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
virtual void
addDumpFieldExternalToDumper(const std::string & dumper_name,
const std::string & field_id,
std::shared_ptr<dumper::Field> field) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
template <typename T>
void addDumpFieldExternal(const std::string & field_id,
const Array<T> & field) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
template <typename T>
void addDumpFieldExternalToDumper(const std::string & dumper_name,
const std::string & field_id,
const Array<T> & field) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
template <typename T>
void
addDumpFieldExternal(const std::string & field_id,
const ElementTypeMapArray<T> & field,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
template <typename T>
void addDumpFieldExternalToDumper(
const std::string & dumper_name, const std::string & field_id,
const ElementTypeMapArray<T> & field,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void removeDumpField(const std::string & field_id) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void removeDumpFieldFromDumper(const std::string & dumper_name,
const std::string & field_id) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void setDirecory(const std::string & directory) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void setDirectoryToDumper(const std::string & dumper_name,
const std::string & directory) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void setBaseName(const std::string & basename) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void setBaseNameToDumper(const std::string & dumper_name,
const std::string & basename) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void setTextModeToDumper(const std::string & dumper_name) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void setTextModeToDumper() {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void dump() {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void dump(const std::string & dumper_name) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void dump(UInt step) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void dump(const std::string & dumper_name, UInt step) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void dump(Real current_time, UInt step) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
void dump(const std::string & dumper_name, Real current_time, UInt step) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
protected:
void internalAddDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id,
std::shared_ptr<dumper::Field> field) {
AKANTU_DEBUG_WARNING("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
protected:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
DumperIOHelper & getDumper() {
AKANTU_ERROR("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
DumperIOHelper & getDumper(const std::string & dumper_name) {
AKANTU_ERROR("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
template <class T> T & getDumper(const std::string & dumper_name) {
AKANTU_ERROR("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
std::string getDefaultDumperName() {
AKANTU_ERROR("No dumper activated at compilation, turn on "
"AKANTU_USE_IOHELPER in cmake.");
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
#pragma GCC diagnostic pop
} // namespace akantu
#endif /* __AKANTU_DUMPABLE_DUMMY_HH__ */
diff --git a/src/io/dumper/dumpable_inline_impl.hh b/src/io/dumper/dumpable_inline_impl.hh
index c20a969d5..4b57b3205 100644
--- a/src/io/dumper/dumpable_inline_impl.hh
+++ b/src/io/dumper/dumpable_inline_impl.hh
@@ -1,134 +1,134 @@
/**
* @file dumpable_inline_impl.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Wed Nov 08 2017
*
* @brief Implementation of the Dumpable class
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPABLE_INLINE_IMPL_HH__
#define __AKANTU_DUMPABLE_INLINE_IMPL_HH__
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
#include "dumper_elemental_field.hh"
#include "dumper_nodal_field.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class T>
inline void Dumpable::registerDumper(const std::string & dumper_name,
const std::string & file_name,
const bool is_default) {
if (this->dumpers.find(dumper_name) != this->dumpers.end()) {
AKANTU_DEBUG_INFO("Dumper " + dumper_name + "is already registered.");
}
std::string name = file_name;
if (name == "")
name = dumper_name;
- this->dumpers[dumper_name] = new T(name);
+ this->dumpers[dumper_name] = std::make_shared<T>(name);
if (is_default)
this->default_dumper = dumper_name;
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Dumpable::addDumpFieldExternal(const std::string & field_id,
const Array<T> & field) {
this->addDumpFieldExternalToDumper<T>(this->default_dumper, field_id, field);
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void
Dumpable::addDumpFieldExternalToDumper(const std::string & dumper_name,
const std::string & field_id,
const Array<T> & field) {
auto field_cont = std::make_shared<dumper::NodalField<T>>(field);
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.registerField(field_id, field_cont);
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Dumpable::addDumpFieldExternal(const std::string & field_id,
const ElementTypeMapArray<T> & field,
UInt spatial_dimension,
const GhostType & ghost_type,
const ElementKind & element_kind) {
this->addDumpFieldExternalToDumper(this->default_dumper, field_id, field,
spatial_dimension, ghost_type,
element_kind);
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Dumpable::addDumpFieldExternalToDumper(
const std::string & dumper_name, const std::string & field_id,
const ElementTypeMapArray<T> & field, UInt spatial_dimension,
const GhostType & ghost_type, const ElementKind & element_kind) {
std::shared_ptr<dumper::Field> field_cont;
#if defined(AKANTU_IGFEM)
if (element_kind == _ek_igfem) {
field_cont = std::make_shared<dumper::IGFEMElementalField<T>>(
field, spatial_dimension, ghost_type, element_kind);
} else
#endif
field_cont = std::make_shared<dumper::ElementalField<T>>(
field, spatial_dimension, ghost_type, element_kind);
DumperIOHelper & dumper = this->getDumper(dumper_name);
dumper.registerField(field_id, field_cont);
}
/* -------------------------------------------------------------------------- */
template <class T>
inline T & Dumpable::getDumper(const std::string & dumper_name) {
DumperIOHelper & dumper = this->getDumper(dumper_name);
try {
auto & templated_dumper = aka::as_type<T>(dumper);
return templated_dumper;
} catch (std::bad_cast &) {
AKANTU_EXCEPTION("Dumper " << dumper_name << " is not of type: "
<< debug::demangle(typeid(T).name()));
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
#endif
#endif /* __AKANTU_DUMPABLE_INLINE_IMPL_HH__ */
diff --git a/src/io/dumper/dumpable_iohelper.hh b/src/io/dumper/dumpable_iohelper.hh
index 5a5995951..b5e90ced2 100644
--- a/src/io/dumper/dumpable_iohelper.hh
+++ b/src/io/dumper/dumpable_iohelper.hh
@@ -1,193 +1,193 @@
/**
* @file dumpable_iohelper.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jan 06 2015
* @date last modification: Sun Dec 03 2017
*
* @brief Interface for object who wants to dump themselves
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_iohelper.hh"
/* -------------------------------------------------------------------------- */
#include <set>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DUMPABLE_IOHELPER_HH__
#define __AKANTU_DUMPABLE_IOHELPER_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
class Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
Dumpable();
virtual ~Dumpable();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// create a new dumper (of templated type T) and register it under
/// dumper_name. file_name is used for construction of T. is default states if
/// this dumper is the default dumper.
template <class T>
inline void registerDumper(const std::string & dumper_name,
const std::string & file_name = "",
const bool is_default = false);
/// register an externally created dumper
- void registerExternalDumper(DumperIOHelper & dumper,
+ void registerExternalDumper(std::shared_ptr<DumperIOHelper> dumper,
const std::string & dumper_name,
const bool is_default = false);
/// register a mesh to the default dumper
void addDumpMesh(const Mesh & mesh, UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
/// register a mesh to the default identified by its name
void addDumpMeshToDumper(const std::string & dumper_name, const Mesh & mesh,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
/// register a filtered mesh as the default dumper
void addDumpFilteredMesh(const Mesh & mesh,
const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
/// register a filtered mesh and provides a name
void addDumpFilteredMeshToDumper(
const std::string & dumper_name, const Mesh & mesh,
const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
/// to implement
virtual void addDumpField(const std::string & field_id);
/// to implement
virtual void addDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id);
/// add a field
virtual void addDumpFieldExternal(const std::string & field_id,
std::shared_ptr<dumper::Field> field);
virtual void
addDumpFieldExternalToDumper(const std::string & dumper_name,
const std::string & field_id,
std::shared_ptr<dumper::Field> field);
template <typename T>
inline void addDumpFieldExternal(const std::string & field_id,
const Array<T> & field);
template <typename T>
inline void addDumpFieldExternalToDumper(const std::string & dumper_name,
const std::string & field_id,
const Array<T> & field);
template <typename T>
inline void
addDumpFieldExternal(const std::string & field_id,
const ElementTypeMapArray<T> & field,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
template <typename T>
inline void addDumpFieldExternalToDumper(
const std::string & dumper_name, const std::string & field_id,
const ElementTypeMapArray<T> & field,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
void removeDumpField(const std::string & field_id);
void removeDumpFieldFromDumper(const std::string & dumper_name,
const std::string & field_id);
virtual void addDumpFieldVector(const std::string & field_id);
virtual void addDumpFieldVectorToDumper(const std::string & dumper_name,
const std::string & field_id);
virtual void addDumpFieldTensor(const std::string & field_id);
virtual void addDumpFieldTensorToDumper(const std::string & dumper_name,
const std::string & field_id);
void setDirectory(const std::string & directory);
void setDirectoryToDumper(const std::string & dumper_name,
const std::string & directory);
void setBaseName(const std::string & basename);
void setBaseNameToDumper(const std::string & dumper_name,
const std::string & basename);
void setTimeStepToDumper(Real time_step);
void setTimeStepToDumper(const std::string & dumper_name, Real time_step);
void setTextModeToDumper(const std::string & dumper_name);
void setTextModeToDumper();
virtual void dump();
virtual void dump(UInt step);
virtual void dump(Real time, UInt step);
virtual void dump(const std::string & dumper_name);
virtual void dump(const std::string & dumper_name, UInt step);
virtual void dump(const std::string & dumper_name, Real time, UInt step);
public:
void internalAddDumpFieldToDumper(const std::string & dumper_name,
const std::string & field_id,
std::shared_ptr<dumper::Field> field);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
DumperIOHelper & getDumper();
DumperIOHelper & getDumper(const std::string & dumper_name);
template <class T> T & getDumper(const std::string & dumper_name);
std::string getDefaultDumperName() const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
- using DumperMap = std::map<std::string, DumperIOHelper *>;
+ using DumperMap = std::map<std::string, std::shared_ptr<DumperIOHelper>>;
using DumperSet = std::set<std::string>;
DumperMap dumpers;
std::string default_dumper;
};
} // namespace akantu
#endif /* __AKANTU_DUMPABLE_IOHELPER_HH__ */
diff --git a/src/io/dumper/dumper_compute.hh b/src/io/dumper/dumper_compute.hh
index a73aef5f0..01d56351a 100644
--- a/src/io/dumper/dumper_compute.hh
+++ b/src/io/dumper/dumper_compute.hh
@@ -1,260 +1,262 @@
/**
* @file dumper_compute.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Sun Dec 03 2017
*
* @brief Field that map a function to another field
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_COMPUTE_HH__
#define __AKANTU_DUMPER_COMPUTE_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "dumper_field.hh"
#include "dumper_iohelper.hh"
#include "dumper_type_traits.hh"
#include <io_helper.hh>
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
class ComputeFunctorInterface {
public:
virtual ~ComputeFunctorInterface() = default;
virtual UInt getDim() = 0;
virtual UInt getNbComponent(UInt old_nb_comp) = 0;
};
/* -------------------------------------------------------------------------- */
template <typename return_type>
class ComputeFunctorOutput : public ComputeFunctorInterface {
public:
ComputeFunctorOutput() = default;
~ComputeFunctorOutput() override = default;
};
/* -------------------------------------------------------------------------- */
template <typename input_type, typename return_type>
class ComputeFunctor : public ComputeFunctorOutput<return_type> {
public:
ComputeFunctor() = default;
~ComputeFunctor() override = default;
virtual return_type func(const input_type & d, Element global_index) = 0;
};
/* -------------------------------------------------------------------------- */
template <typename SubFieldCompute, typename _return_type>
class FieldCompute : public Field {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
using sub_iterator = typename SubFieldCompute::iterator;
using sub_types = typename SubFieldCompute::types;
using sub_return_type = typename sub_types::return_type;
using return_type = _return_type;
using data_type = typename sub_types::data_type;
using types =
TypeTraits<data_type, return_type, ElementTypeMapArray<data_type>>;
class iterator {
public:
iterator(const sub_iterator & it,
ComputeFunctor<sub_return_type, return_type> & func)
: it(it), func(func) {}
bool operator!=(const iterator & it) const { return it.it != this->it; }
iterator operator++() {
++this->it;
return *this;
}
UInt currentGlobalIndex() { return this->it.currentGlobalIndex(); }
return_type operator*() { return func.func(*it, it.getCurrentElement()); }
Element getCurrentElement() { return this->it.getCurrentElement(); }
UInt element_type() { return this->it.element_type(); }
protected:
sub_iterator it;
ComputeFunctor<sub_return_type, return_type> & func;
};
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- FieldCompute(SubFieldCompute & cont, std::unique_ptr<ComputeFunctorInterface> func)
+ FieldCompute(SubFieldCompute & cont,
+ std::unique_ptr<ComputeFunctorInterface> func)
: sub_field(aka::as_type<SubFieldCompute>(cont.shared_from_this())),
- func(aka::as_type<ComputeFunctor<sub_return_type, return_type>>(func.release())) {
+ func(aka::as_type<ComputeFunctor<sub_return_type, return_type>>(
+ func.release())) {
this->checkHomogeneity();
};
~FieldCompute() override = default;
void registerToDumper(const std::string & id,
iohelper::Dumper & dumper) override {
dumper.addElemDataField(id, *this);
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public:
iterator begin() { return iterator(sub_field->begin(), *func); }
iterator end() { return iterator(sub_field->end(), *func); }
UInt getDim() { return func->getDim(); }
UInt size() {
throw;
// return Functor::size();
return 0;
}
void checkHomogeneity() override { this->homogeneous = true; };
iohelper::DataType getDataType() {
return iohelper::getDataType<data_type>();
}
/// get the number of components of the hosted field
ElementTypeMap<UInt>
getNbComponents(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_not_defined) override {
ElementTypeMap<UInt> nb_components;
const auto & old_nb_components =
this->sub_field->getNbComponents(dim, ghost_type, kind);
for (auto type : old_nb_components.elementTypes(dim, ghost_type, kind)) {
UInt nb_comp = old_nb_components(type, ghost_type);
nb_components(type, ghost_type) = func->getNbComponent(nb_comp);
}
return nb_components;
};
/// for connection to a FieldCompute
inline std::shared_ptr<Field> connect(FieldComputeProxy & proxy) override;
/// for connection to a FieldCompute
std::unique_ptr<ComputeFunctorInterface>
connect(HomogenizerProxy & proxy) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public:
std::shared_ptr<SubFieldCompute> sub_field;
std::unique_ptr<ComputeFunctor<sub_return_type, return_type>> func;
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class FieldComputeProxy {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
FieldComputeProxy(std::unique_ptr<ComputeFunctorInterface> func)
: func(std::move(func)){};
inline static std::shared_ptr<Field>
createFieldCompute(std::shared_ptr<Field> field,
std::unique_ptr<ComputeFunctorInterface> func) {
FieldComputeProxy compute_proxy(std::move(func));
return field->connect(compute_proxy);
}
template <typename T> std::shared_ptr<Field> connectToField(T * ptr) {
if (aka::is_of_type<ComputeFunctorOutput<Vector<Real>>>(func)) {
return this->connectToFunctor<Vector<Real>>(ptr);
} else if (aka::is_of_type<ComputeFunctorOutput<Vector<UInt>>>(func)) {
return this->connectToFunctor<Vector<UInt>>(ptr);
} else if (aka::is_of_type<ComputeFunctorOutput<Matrix<UInt>>>(func)) {
return this->connectToFunctor<Matrix<UInt>>(ptr);
} else if (aka::is_of_type<ComputeFunctorOutput<Matrix<Real>>>(func)) {
return this->connectToFunctor<Matrix<Real>>(ptr);
} else {
throw;
}
}
template <typename output, typename T>
std::shared_ptr<Field> connectToFunctor(T * ptr) {
return std::make_shared<FieldCompute<T, output>>(*ptr, std::move(func));
}
template <typename output, typename SubFieldCompute, typename return_type1,
typename return_type2>
std::shared_ptr<Field>
connectToFunctor(__attribute__((unused))
FieldCompute<FieldCompute<SubFieldCompute, return_type1>,
return_type2> * ptr) {
throw; // return new FieldCompute<T,output>(*ptr,func);
return nullptr;
}
template <typename output, typename SubFieldCompute, typename return_type1,
typename return_type2, typename return_type3, typename return_type4>
std::shared_ptr<Field> connectToFunctor(
__attribute__((unused)) FieldCompute<
FieldCompute<FieldCompute<FieldCompute<SubFieldCompute, return_type1>,
return_type2>,
return_type3>,
return_type4> * ptr) {
throw; // return new FieldCompute<T,output>(*ptr,func);
return nullptr;
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public:
std::unique_ptr<ComputeFunctorInterface> func;
};
/* -------------------------------------------------------------------------- */
/// for connection to a FieldCompute
template <typename SubFieldCompute, typename return_type>
inline std::shared_ptr<Field>
FieldCompute<SubFieldCompute, return_type>::connect(FieldComputeProxy & proxy) {
return proxy.connectToField(this);
}
/* -------------------------------------------------------------------------- */
__END_AKANTU_DUMPER__
} // namespace akantu
#endif /* __AKANTU_DUMPER_COMPUTE_HH__ */
diff --git a/src/io/dumper/dumper_element_iterator.hh b/src/io/dumper/dumper_element_iterator.hh
index 9710b7d7c..3d90b1103 100644
--- a/src/io/dumper/dumper_element_iterator.hh
+++ b/src/io/dumper/dumper_element_iterator.hh
@@ -1,178 +1,178 @@
/**
* @file dumper_element_iterator.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Sun Dec 03 2017
*
* @brief Iterators for elemental fields
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_ELEMENT_ITERATOR_HH__
#define __AKANTU_DUMPER_ELEMENT_ITERATOR_HH__
/* -------------------------------------------------------------------------- */
#include "element.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
template <class types, template <class> class final_iterator>
class element_iterator {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
using it_type = typename types::it_type;
using field_type = typename types::field_type;
using array_type = typename types::array_type;
using array_iterator = typename types::array_iterator;
using iterator = final_iterator<types>;
public:
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
element_iterator(const field_type & field,
const typename field_type::type_iterator & t_it,
const typename field_type::type_iterator & t_it_end,
const array_iterator & array_it,
const array_iterator & array_it_end,
const GhostType ghost_type = _not_ghost)
: field(field), tit(t_it), tit_end(t_it_end), array_it(array_it),
array_it_end(array_it_end), ghost_type(ghost_type) {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
bool operator!=(const iterator & it) const {
return (ghost_type != it.ghost_type) ||
(tit != it.tit || (array_it != it.array_it));
}
iterator & operator++() {
++array_it;
while (array_it == array_it_end && tit != tit_end) {
++tit;
if (tit != tit_end) {
const array_type & vect = field(*tit, ghost_type);
UInt _nb_data_per_elem = getNbDataPerElem(*tit);
UInt nb_component = vect.getNbComponent();
UInt size = (vect.size() * nb_component) / _nb_data_per_elem;
array_it = vect.begin_reinterpret(_nb_data_per_elem, size);
array_it_end = vect.end_reinterpret(_nb_data_per_elem, size);
}
}
return *(static_cast<iterator *>(this));
};
ElementType getType() { return *tit; }
UInt element_type() { return getIOHelperType(*tit); }
Element getCurrentElement() {
return Element{*tit, array_it.getCurrentIndex(), _not_ghost};
}
UInt getNbDataPerElem(const ElementType & type) const {
if (!nb_data_per_elem.exists(type, ghost_type))
return field(type, ghost_type).getNbComponent();
return nb_data_per_elem(type, ghost_type);
}
void setNbDataPerElem(const ElementTypeMap<UInt> & nb_data) {
this->nb_data_per_elem = nb_data;
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// the field to iterate on
const field_type & field;
/// field iterator
typename field_type::type_iterator tit;
/// field iterator end
typename field_type::type_iterator tit_end;
/// array iterator
array_iterator array_it;
/// internal iterator end
array_iterator array_it_end;
/// ghost type identification
const GhostType ghost_type;
/// number of data per element
ElementTypeMap<UInt> nb_data_per_elem;
};
/* -------------------------------------------------------------------------- */
template <typename types>
class elemental_field_iterator
: public element_iterator<types, elemental_field_iterator> {
public:
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
using parent =
element_iterator<types, ::akantu::dumper::elemental_field_iterator>;
using it_type = typename types::it_type;
using return_type = typename types::return_type;
using field_type = typename types::field_type;
using array_iterator = typename types::array_iterator;
public:
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
elemental_field_iterator(const field_type & field,
const typename field_type::type_iterator & t_it,
const typename field_type::type_iterator & t_it_end,
const array_iterator & array_it,
const array_iterator & array_it_end,
const GhostType ghost_type = _not_ghost)
: parent(field, t_it, t_it_end, array_it, array_it_end, ghost_type) {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
return_type operator*() { return *this->array_it; }
private:
};
/* -------------------------------------------------------------------------- */
__END_AKANTU_DUMPER__
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
#endif /* __AKANTU_DUMPER_ELEMENT_ITERATOR_HH__ */
diff --git a/src/io/dumper/dumper_element_partition.hh b/src/io/dumper/dumper_element_partition.hh
index 57bf314eb..f4db6ce9e 100644
--- a/src/io/dumper/dumper_element_partition.hh
+++ b/src/io/dumper/dumper_element_partition.hh
@@ -1,118 +1,137 @@
/**
* @file dumper_element_partition.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Sun Dec 03 2017
*
* @brief ElementPartition field
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
namespace akantu {
namespace dumper {
#ifdef AKANTU_IGFEM
#include "dumper_igfem_element_partition.hh"
#endif
-/* -------------------------------------------------------------------------- */
-template <class types>
-class element_partition_field_iterator
- : public element_iterator<types, element_partition_field_iterator> {
+ /* --------------------------------------------------------------------------
+ */
+ template <class types>
+ class element_partition_field_iterator
+ : public element_iterator<types, element_partition_field_iterator> {
- /* ------------------------------------------------------------------------ */
- /* Typedefs */
- /* ------------------------------------------------------------------------ */
-public:
- using parent =
- element_iterator<types, dumper::element_partition_field_iterator>;
- using return_type =
- typename SingleType<unsigned int, Vector, true>::return_type;
- using array_iterator = typename types::array_iterator;
- using field_type = typename types::field_type;
+ /* ------------------------------------------------------------------------
+ */
+ /* Typedefs */
+ /* ------------------------------------------------------------------------
+ */
+ public:
+ using parent =
+ element_iterator<types, dumper::element_partition_field_iterator>;
+ using return_type =
+ typename SingleType<unsigned int, Vector, true>::return_type;
+ using array_iterator = typename types::array_iterator;
+ using field_type = typename types::field_type;
- /* ------------------------------------------------------------------------ */
- /* Constructors/Destructors */
- /* ------------------------------------------------------------------------ */
-public:
- element_partition_field_iterator(
- const field_type & field, const typename field_type::type_iterator & t_it,
- const typename field_type::type_iterator & t_it_end,
- const array_iterator & array_it, const array_iterator & array_it_end,
- const GhostType ghost_type = _not_ghost)
- : parent(field, t_it, t_it_end, array_it, array_it_end, ghost_type) {
- prank = Communicator::getStaticCommunicator().whoAmI();
- }
+ /* ------------------------------------------------------------------------
+ */
+ /* Constructors/Destructors */
+ /* ------------------------------------------------------------------------
+ */
+ public:
+ element_partition_field_iterator(
+ const field_type & field,
+ const typename field_type::type_iterator & t_it,
+ const typename field_type::type_iterator & t_it_end,
+ const array_iterator & array_it, const array_iterator & array_it_end,
+ const GhostType ghost_type = _not_ghost)
+ : parent(field, t_it, t_it_end, array_it, array_it_end, ghost_type) {
+ prank = Communicator::getStaticCommunicator().whoAmI();
+ }
- /* ------------------------------------------------------------------------ */
- /* Methods */
- /* ------------------------------------------------------------------------ */
-public:
- return_type operator*() { return return_type(1, prank); }
+ /* ------------------------------------------------------------------------
+ */
+ /* Methods */
+ /* ------------------------------------------------------------------------
+ */
+ public:
+ return_type operator*() { return return_type(1, prank); }
- /* ------------------------------------------------------------------------ */
- /* Class Members */
- /* ------------------------------------------------------------------------ */
-protected:
- UInt prank;
-};
+ /* ------------------------------------------------------------------------
+ */
+ /* Class Members */
+ /* ------------------------------------------------------------------------
+ */
+ protected:
+ UInt prank;
+ };
-/* -------------------------------------------------------------------------- */
-template <bool filtered = false>
-class ElementPartitionField
- : public GenericElementalField<SingleType<UInt, Vector, filtered>,
- element_partition_field_iterator> {
-public:
- /* ------------------------------------------------------------------------ */
- /* Typedefs */
- /* ------------------------------------------------------------------------ */
+ /* --------------------------------------------------------------------------
+ */
+ template <bool filtered = false>
+ class ElementPartitionField
+ : public GenericElementalField<SingleType<UInt, Vector, filtered>,
+ element_partition_field_iterator> {
+ public:
+ /* ------------------------------------------------------------------------
+ */
+ /* Typedefs */
+ /* ------------------------------------------------------------------------
+ */
- using types = SingleType<UInt, Vector, filtered>;
- using iterator = element_partition_field_iterator<types>;
- using parent = GenericElementalField<types, element_partition_field_iterator>;
- using field_type = typename types::field_type;
+ using types = SingleType<UInt, Vector, filtered>;
+ using iterator = element_partition_field_iterator<types>;
+ using parent =
+ GenericElementalField<types, element_partition_field_iterator>;
+ using field_type = typename types::field_type;
-public:
- /* ------------------------------------------------------------------------ */
- /* Constructors/Destructors */
- /* ------------------------------------------------------------------------ */
+ public:
+ /* ------------------------------------------------------------------------
+ */
+ /* Constructors/Destructors */
+ /* ------------------------------------------------------------------------
+ */
- ElementPartitionField(const field_type & field,
- UInt spatial_dimension = _all_dimensions,
- GhostType ghost_type = _not_ghost,
- ElementKind element_kind = _ek_not_defined)
- : parent(field, spatial_dimension, ghost_type, element_kind) {
- this->homogeneous = true;
- }
+ ElementPartitionField(const field_type & field,
+ UInt spatial_dimension = _all_dimensions,
+ GhostType ghost_type = _not_ghost,
+ ElementKind element_kind = _ek_not_defined)
+ : parent(field, spatial_dimension, ghost_type, element_kind) {
+ this->homogeneous = true;
+ }
- /* ------------------------------------------------------------------------ */
- /* Methods */
- /* ------------------------------------------------------------------------ */
+ /* ------------------------------------------------------------------------
+ */
+ /* Methods */
+ /* ------------------------------------------------------------------------
+ */
- UInt getDim() override { return 1; }
-};
+ UInt getDim() override { return 1; }
+ };
-/* -------------------------------------------------------------------------- */
+ /* --------------------------------------------------------------------------
+ */
-} // dumper
-} // akantu
+} // namespace dumper
+} // namespace akantu
diff --git a/src/io/dumper/dumper_elemental_field.hh b/src/io/dumper/dumper_elemental_field.hh
index 3caf94b40..74c6d53d2 100644
--- a/src/io/dumper/dumper_elemental_field.hh
+++ b/src/io/dumper/dumper_elemental_field.hh
@@ -1,76 +1,76 @@
/**
* @file dumper_elemental_field.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief description of elemental fields
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_ELEMENTAL_FIELD_HH__
#define __AKANTU_DUMPER_ELEMENTAL_FIELD_HH__
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "dumper_field.hh"
#include "dumper_generic_elemental_field.hh"
#ifdef AKANTU_IGFEM
#include "dumper_igfem_elemental_field.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
template <typename T, template <class> class ret = Vector,
bool filtered = false>
class ElementalField
: public GenericElementalField<SingleType<T, ret, filtered>,
elemental_field_iterator> {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
using types = SingleType<T, ret, filtered>;
using field_type = typename types::field_type;
using iterator = elemental_field_iterator<types>;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ElementalField(const field_type & field,
UInt spatial_dimension = _all_dimensions,
GhostType ghost_type = _not_ghost,
ElementKind element_kind = _ek_not_defined)
: GenericElementalField<types, elemental_field_iterator>(
field, spatial_dimension, ghost_type, element_kind) {}
};
/* -------------------------------------------------------------------------- */
__END_AKANTU_DUMPER__
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DUMPER_ELEMENTAL_FIELD_HH__ */
diff --git a/src/io/dumper/dumper_filtered_connectivity.hh b/src/io/dumper/dumper_filtered_connectivity.hh
index bfda0e792..fe0f97ed9 100644
--- a/src/io/dumper/dumper_filtered_connectivity.hh
+++ b/src/io/dumper/dumper_filtered_connectivity.hh
@@ -1,152 +1,152 @@
/**
* @file dumper_filtered_connectivity.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Wed Nov 08 2017
*
* @brief FilteredConnectivities field
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "dumper_generic_elemental_field.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
template <class types>
class filtered_connectivity_field_iterator
: public element_iterator<types, filtered_connectivity_field_iterator> {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
typedef element_iterator<types, dumper::filtered_connectivity_field_iterator>
parent;
using return_type = typename types::return_type;
using field_type = typename types::field_type;
using array_iterator = typename types::array_iterator;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
filtered_connectivity_field_iterator(
const field_type & field, const typename field_type::type_iterator & t_it,
const typename field_type::type_iterator & t_it_end,
const array_iterator & array_it, const array_iterator & array_it_end,
const GhostType ghost_type = _not_ghost)
: parent(field, t_it, t_it_end, array_it, array_it_end, ghost_type) {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
return_type operator*() {
const Vector<UInt> & old_connect = *this->array_it;
Vector<UInt> new_connect(old_connect.size());
Array<UInt>::const_iterator<UInt> nodes_begin = nodal_filter->begin();
Array<UInt>::const_iterator<UInt> nodes_end = nodal_filter->end();
for (UInt i(0); i < old_connect.size(); ++i) {
Array<UInt>::const_iterator<UInt> new_id =
std::find(nodes_begin, nodes_end, old_connect(i));
if (new_id == nodes_end)
AKANTU_EXCEPTION("Node not found in the filter!");
new_connect(i) = new_id - nodes_begin;
}
return new_connect;
}
void setNodalFilter(const Array<UInt> & new_nodal_filter) {
nodal_filter = &new_nodal_filter;
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
const Array<UInt> * nodal_filter;
};
/* -------------------------------------------------------------------------- */
class FilteredConnectivityField
: public GenericElementalField<SingleType<UInt, Vector, true>,
filtered_connectivity_field_iterator> {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
typedef SingleType<UInt, Vector, true> types;
using iterator = filtered_connectivity_field_iterator<types>;
using field_type = types::field_type;
typedef GenericElementalField<types, filtered_connectivity_field_iterator>
parent;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
FilteredConnectivityField(const field_type & field,
const Array<UInt> & nodal_filter,
UInt spatial_dimension = _all_dimensions,
GhostType ghost_type = _not_ghost,
ElementKind element_kind = _ek_not_defined)
: parent(field, spatial_dimension, ghost_type, element_kind),
nodal_filter(nodal_filter) {}
~FilteredConnectivityField() override {
// since the field is created in registerFilteredMesh it is destroyed here
delete const_cast<field_type *>(&this->field);
}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
iterator begin() override {
iterator it = parent::begin();
it.setNodalFilter(nodal_filter);
return it;
}
iterator end() override {
iterator it = parent::end();
it.setNodalFilter(nodal_filter);
return it;
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
const Array<UInt> & nodal_filter;
};
/* -------------------------------------------------------------------------- */
__END_AKANTU_DUMPER__
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
diff --git a/src/io/dumper/dumper_internal_material_field.hh b/src/io/dumper/dumper_internal_material_field.hh
index c9410ace0..e3761aaaf 100644
--- a/src/io/dumper/dumper_internal_material_field.hh
+++ b/src/io/dumper/dumper_internal_material_field.hh
@@ -1,72 +1,72 @@
/**
* @file dumper_internal_material_field.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief description of material internal field
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_INTERNAL_MATERIAL_FIELD_HH__
#define __AKANTU_DUMPER_INTERNAL_MATERIAL_FIELD_HH__
/* -------------------------------------------------------------------------- */
#include "dumper_quadrature_point_iterator.hh"
#ifdef AKANTU_IGFEM
#include "dumper_igfem_material_internal_field.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
template <typename T, bool filtered = false>
class InternalMaterialField
: public GenericElementalField<SingleType<T, Vector, filtered>,
quadrature_point_iterator> {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
using types = SingleType<T, Vector, filtered>;
using parent = GenericElementalField<types, quadrature_point_iterator>;
using field_type = typename types::field_type;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
InternalMaterialField(const field_type & field,
UInt spatial_dimension = _all_dimensions,
GhostType ghost_type = _not_ghost,
ElementKind element_kind = _ek_not_defined)
: parent(field, spatial_dimension, ghost_type, element_kind) {}
};
__END_AKANTU_DUMPER__
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DUMPER_INTERNAL_MATERIAL_FIELD_HH__ */
diff --git a/src/io/dumper/dumper_iohelper.hh b/src/io/dumper/dumper_iohelper.hh
index 6125a253e..64e3f7958 100644
--- a/src/io/dumper/dumper_iohelper.hh
+++ b/src/io/dumper/dumper_iohelper.hh
@@ -1,160 +1,161 @@
/**
* @file dumper_iohelper.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 26 2012
* @date last modification: Sun Dec 03 2017
*
* @brief Define the akantu dumper interface for IOhelper dumpers
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
#include "aka_types.hh"
#include "element_type_map.hh"
-
+/* -------------------------------------------------------------------------- */
+#include <memory>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DUMPER_IOHELPER_HH__
#define __AKANTU_DUMPER_IOHELPER_HH__
/* -------------------------------------------------------------------------- */
namespace iohelper {
class Dumper;
}
namespace akantu {
UInt getIOHelperType(ElementType type);
namespace dumper {
class Field;
class VariableBase;
} // namespace dumper
class Mesh;
-class DumperIOHelper {
+class DumperIOHelper : public std::enable_shared_from_this<DumperIOHelper> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DumperIOHelper();
virtual ~DumperIOHelper();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// register a given Mesh for the current dumper
virtual void registerMesh(const Mesh & mesh,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
/// register a filtered Mesh (provided filter lists) for the current dumper
virtual void
registerFilteredMesh(const Mesh & mesh,
const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
/// register a Field object identified by name and provided by pointer
void registerField(const std::string & field_id,
std::shared_ptr<dumper::Field> field);
/// remove the Field identified by name from managed fields
void unRegisterField(const std::string & field_id);
/// register a VariableBase object identified by name and provided by pointer
void registerVariable(const std::string & variable_id,
std::shared_ptr<dumper::VariableBase> variable);
/// remove a VariableBase identified by name from managed fields
void unRegisterVariable(const std::string & variable_id);
/// request dump: this calls IOHelper dump routine
virtual void dump();
/// request dump: this first set the current step and then calls IOHelper dump
/// routine
virtual void dump(UInt step);
/// request dump: this first set the current step and current time and then
/// calls IOHelper dump routine
virtual void dump(Real current_time, UInt step);
/// set the parallel context for IOHeper
virtual void setParallelContext(bool is_parallel);
/// set the directory where to generate the dumped files
virtual void setDirectory(const std::string & directory);
/// set the base name (needed by most IOHelper dumpers)
virtual void setBaseName(const std::string & basename);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// direct access to the iohelper::Dumper object
AKANTU_GET_MACRO(Dumper, *dumper, iohelper::Dumper &)
/// set the timestep of the iohelper::Dumper
void setTimeStep(Real time_step);
public:
/* ------------------------------------------------------------------------ */
/* Variable wrapper */
template <typename T, bool is_scal = std::is_arithmetic<T>::value>
class Variable;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// internal iohelper::Dumper
std::unique_ptr<iohelper::Dumper> dumper;
using Fields = std::map<std::string, std::shared_ptr<dumper::Field>>;
using Variables =
std::map<std::string, std::shared_ptr<dumper::VariableBase>>;
/// list of registered fields to dump
Fields fields;
Variables variables;
/// dump counter
UInt count{0};
/// directory name
std::string directory;
/// filename prefix
std::string filename;
/// is time tracking activated in the dumper
bool time_activated{false};
};
} // namespace akantu
#endif /* __AKANTU_DUMPER_IOHELPER_HH__ */
diff --git a/src/io/dumper/dumper_iohelper_paraview.hh b/src/io/dumper/dumper_iohelper_paraview.hh
index 312045070..ef9a79f75 100644
--- a/src/io/dumper/dumper_iohelper_paraview.hh
+++ b/src/io/dumper/dumper_iohelper_paraview.hh
@@ -1,71 +1,71 @@
/**
* @file dumper_iohelper_paraview.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Mon Jan 22 2018
*
* @brief Dumper Paraview using IOHelper
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DUMPER_PARAVIEW_HH__
#define __AKANTU_DUMPER_PARAVIEW_HH__
#include "dumper_iohelper.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class DumperParaview : public DumperIOHelper {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DumperParaview(const std::string & filename,
const std::string & directory = "./paraview",
bool parallel = true);
~DumperParaview() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
// void dump();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
void setBaseName(const std::string & basename) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DUMPER_PARAVIEW_HH__ */
diff --git a/src/io/dumper/dumper_material_padders.hh b/src/io/dumper/dumper_material_padders.hh
index 5c5501f53..6950cee88 100644
--- a/src/io/dumper/dumper_material_padders.hh
+++ b/src/io/dumper/dumper_material_padders.hh
@@ -1,289 +1,289 @@
/**
* @file dumper_material_padders.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Wed Nov 29 2017
*
* @brief Material padders for plane stress/ plane strain
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_MATERIAL_PADDERS_HH__
#define __AKANTU_DUMPER_MATERIAL_PADDERS_HH__
/* -------------------------------------------------------------------------- */
#include "dumper_padding_helper.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
class MaterialFunctor {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialFunctor(const SolidMechanicsModel & model)
: model(model), material_index(model.getMaterialByElement()),
nb_data_per_element("nb_data_per_element", model.getID(),
model.getMemoryID()),
spatial_dimension(model.getSpatialDimension()) {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
/// return the material from the global element index
const Material & getMaterialFromGlobalIndex(Element global_index) {
UInt index = global_index.element;
UInt material_id = material_index(global_index.type)(index);
const Material & material = model.getMaterial(material_id);
return material;
}
/// return the type of the element from global index
ElementType getElementTypeFromGlobalIndex(Element global_index) {
return global_index.type;
}
protected:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
/// all material padders probably need access to solid mechanics model
const SolidMechanicsModel & model;
/// they also need an access to the map from global ids to material id and
/// local ids
const ElementTypeMapArray<UInt> & material_index;
/// the number of data per element
const ElementTypeMapArray<UInt> nb_data_per_element;
UInt spatial_dimension;
};
/* -------------------------------------------------------------------------- */
template <class T, class R>
class MaterialPadder : public MaterialFunctor,
public PadderGeneric<Vector<T>, R> {
public:
MaterialPadder(const SolidMechanicsModel & model) : MaterialFunctor(model) {}
};
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
class StressPadder : public MaterialPadder<Real, Matrix<Real>> {
public:
StressPadder(const SolidMechanicsModel & model)
: MaterialPadder<Real, Matrix<Real>>(model) {
this->setPadding(3, 3);
}
inline Matrix<Real> func(const Vector<Real> & in,
Element global_element_id) override {
UInt nrows = spatial_dimension;
UInt ncols = in.size() / nrows;
UInt nb_data = in.size() / (nrows * nrows);
Matrix<Real> stress = this->pad(in, nrows, ncols, nb_data);
const Material & material =
this->getMaterialFromGlobalIndex(global_element_id);
bool plane_strain = true;
if (spatial_dimension == 2)
plane_strain = !((bool)material.getParam("Plane_Stress"));
if (plane_strain) {
Real nu = material.getParam("nu");
for (UInt d = 0; d < nb_data; ++d) {
stress(2, 2 + 3 * d) =
nu * (stress(0, 0 + 3 * d) + stress(1, 1 + 3 * d));
}
}
return stress;
}
UInt getDim() override { return 9; };
UInt getNbComponent(UInt /*old_nb_comp*/) override { return this->getDim(); };
};
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
class StrainPadder : public MaterialFunctor,
public PadderGeneric<Matrix<Real>, Matrix<Real>> {
public:
StrainPadder(const SolidMechanicsModel & model) : MaterialFunctor(model) {
this->setPadding(3, 3);
}
inline Matrix<Real> func(const Matrix<Real> & in,
Element global_element_id) override {
UInt nrows = spatial_dimension;
UInt nb_data = in.size() / (nrows * nrows);
Matrix<Real> strain = this->pad(in, nb_data);
const Material & material =
this->getMaterialFromGlobalIndex(global_element_id);
bool plane_stress = material.getParam("Plane_Stress");
if (plane_stress) {
Real nu = material.getParam("nu");
for (UInt d = 0; d < nb_data; ++d) {
strain(2, 2 + 3 * d) =
nu / (nu - 1) * (strain(0, 0 + 3 * d) + strain(1, 1 + 3 * d));
}
}
return strain;
}
UInt getDim() override { return 9; };
UInt getNbComponent(UInt /*old_nb_comp*/) override { return this->getDim(); };
};
/* -------------------------------------------------------------------------- */
template <bool green_strain>
class ComputeStrain : public MaterialFunctor,
public ComputeFunctor<Vector<Real>, Matrix<Real>> {
public:
ComputeStrain(const SolidMechanicsModel & model) : MaterialFunctor(model) {}
inline Matrix<Real> func(const Vector<Real> & in,
Element /*global_element_id*/) override {
UInt nrows = spatial_dimension;
UInt ncols = in.size() / nrows;
UInt nb_data = in.size() / (nrows * nrows);
Matrix<Real> ret_all_strain(nrows, ncols);
Tensor3<Real> all_grad_u(in.storage(), nrows, nrows, nb_data);
Tensor3<Real> all_strain(ret_all_strain.storage(), nrows, nrows, nb_data);
for (UInt d = 0; d < nb_data; ++d) {
Matrix<Real> grad_u = all_grad_u(d);
Matrix<Real> strain = all_strain(d);
if (spatial_dimension == 2) {
if (green_strain)
Material::gradUToGreenStrain<2>(grad_u, strain);
else
Material::gradUToEpsilon<2>(grad_u, strain);
} else if (spatial_dimension == 3) {
if (green_strain)
Material::gradUToGreenStrain<3>(grad_u, strain);
else
Material::gradUToEpsilon<3>(grad_u, strain);
}
}
return ret_all_strain;
}
UInt getDim() override { return spatial_dimension * spatial_dimension; };
UInt getNbComponent(UInt /*old_nb_comp*/) override { return this->getDim(); };
};
/* -------------------------------------------------------------------------- */
template <bool green_strain>
class ComputePrincipalStrain
: public MaterialFunctor,
public ComputeFunctor<Vector<Real>, Matrix<Real>> {
public:
ComputePrincipalStrain(const SolidMechanicsModel & model)
: MaterialFunctor(model) {}
inline Matrix<Real> func(const Vector<Real> & in,
Element /*global_element_id*/) override {
UInt nrows = spatial_dimension;
UInt nb_data = in.size() / (nrows * nrows);
Matrix<Real> ret_all_strain(nrows, nb_data);
Tensor3<Real> all_grad_u(in.storage(), nrows, nrows, nb_data);
Matrix<Real> strain(nrows, nrows);
for (UInt d = 0; d < nb_data; ++d) {
Matrix<Real> grad_u = all_grad_u(d);
if (spatial_dimension == 2) {
if (green_strain)
Material::gradUToGreenStrain<2>(grad_u, strain);
else
Material::gradUToEpsilon<2>(grad_u, strain);
} else if (spatial_dimension == 3) {
if (green_strain)
Material::gradUToGreenStrain<3>(grad_u, strain);
else
Material::gradUToEpsilon<3>(grad_u, strain);
}
Vector<Real> principal_strain(ret_all_strain(d));
strain.eig(principal_strain);
}
return ret_all_strain;
}
UInt getDim() override { return spatial_dimension; };
UInt getNbComponent(UInt /*old_nb_comp*/) override { return this->getDim(); };
};
/* -------------------------------------------------------------------------- */
class ComputeVonMisesStress
: public MaterialFunctor,
public ComputeFunctor<Vector<Real>, Vector<Real>> {
public:
ComputeVonMisesStress(const SolidMechanicsModel & model)
: MaterialFunctor(model) {}
inline Vector<Real> func(const Vector<Real> & in,
Element /*global_element_id*/) override {
UInt nrows = spatial_dimension;
UInt nb_data = in.size() / (nrows * nrows);
Vector<Real> von_mises_stress(nb_data);
Matrix<Real> deviatoric_stress(3, 3);
for (UInt d = 0; d < nb_data; ++d) {
Matrix<Real> cauchy_stress(in.storage() + d * nrows * nrows, nrows,
nrows);
von_mises_stress(d) = Material::stressToVonMises(cauchy_stress);
}
return von_mises_stress;
}
UInt getDim() override { return 1; };
UInt getNbComponent(UInt /*old_nb_comp*/) override { return this->getDim(); };
};
/* -------------------------------------------------------------------------- */
__END_AKANTU_DUMPER__
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DUMPER_MATERIAL_PADDERS_HH__ */
diff --git a/src/io/dumper/dumper_nodal_field.hh b/src/io/dumper/dumper_nodal_field.hh
index adce3c5fa..6b5388702 100644
--- a/src/io/dumper/dumper_nodal_field.hh
+++ b/src/io/dumper/dumper_nodal_field.hh
@@ -1,242 +1,242 @@
/**
* @file dumper_nodal_field.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 26 2012
* @date last modification: Wed Nov 08 2017
*
* @brief Description of nodal fields
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_NODAL_FIELD_HH__
#define __AKANTU_DUMPER_NODAL_FIELD_HH__
#include "dumper_field.hh"
#include <io_helper.hh>
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
// This represents a iohelper compatible field
template <typename T, bool filtered = false, class Container = Array<T>,
class Filter = Array<UInt>>
class NodalField;
/* -------------------------------------------------------------------------- */
template <typename T, class Container, class Filter>
class NodalField<T, false, Container, Filter> : public dumper::Field {
public:
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
/// associated iterator with any nodal field (non filetered)
class iterator : public iohelper::iterator<T, iterator, Vector<T>> {
public:
iterator(T * vect, UInt offset, UInt n, UInt stride,
__attribute__((unused)) const UInt * filter = nullptr)
:
internal_it(vect), offset(offset), n(n), stride(stride) {}
bool operator!=(const iterator & it) const override {
return internal_it != it.internal_it;
}
iterator & operator++() override {
internal_it += offset;
return *this;
};
Vector<T> operator*() override {
return Vector<T>(internal_it + stride, n);
};
private:
T * internal_it;
UInt offset, n, stride;
};
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
NodalField(const Container & field, UInt n = 0, UInt stride = 0,
- [[gnu::unused]] const Filter * filter = nullptr) :
- field(field), n(n), stride(stride), padding(0) {
+ [[gnu::unused]] const Filter * filter = nullptr)
+ : field(field), n(n), stride(stride), padding(0) {
AKANTU_DEBUG_ASSERT(filter == nullptr,
"Filter passed to unfiltered NodalField!");
if (n == 0) {
this->n = field.getNbComponent() - stride;
}
}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
void registerToDumper(const std::string & id,
iohelper::Dumper & dumper) override {
dumper.addNodeDataField(id, *this);
}
inline iterator begin() {
return iterator(field.storage(), field.getNbComponent(), n, stride);
}
inline iterator end() {
return iterator(field.storage() + field.getNbComponent() * field.size(),
field.getNbComponent(), n, stride);
}
bool isHomogeneous() override { return true; }
void checkHomogeneity() override { this->homogeneous = true; }
virtual UInt getDim() {
if (this->padding)
return this->padding;
else
return n;
}
void setPadding(UInt padding) { this->padding = padding; }
UInt size() { return field.size(); }
iohelper::DataType getDataType() { return iohelper::getDataType<T>(); }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
const Container & field;
UInt n, stride;
UInt padding;
};
/* -------------------------------------------------------------------------- */
template <typename T, class Container, class Filter>
class NodalField<T, true, Container, Filter> : public dumper::Field {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
public:
class iterator : public iohelper::iterator<T, iterator, Vector<T>> {
public:
iterator(T * const vect, UInt _offset, UInt _n, UInt _stride,
const UInt * filter)
:
internal_it(vect), offset(_offset), n(_n), stride(_stride),
filter(filter) {}
bool operator!=(const iterator & it) const override {
return filter != it.filter;
}
iterator & operator++() override {
++filter;
return *this;
}
Vector<T> operator*() override {
return Vector<T>(internal_it + *(filter)*offset + stride, n);
}
private:
T * const internal_it;
UInt offset, n, stride;
const UInt * filter;
};
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
NodalField(const Container & _field, UInt _n = 0, UInt _stride = 0,
const Filter * filter = NULL)
: field(_field), n(_n), stride(_stride), filter(filter), padding(0) {
AKANTU_DEBUG_ASSERT(this->filter != nullptr,
"No filter passed to filtered NodalField!");
AKANTU_DEBUG_ASSERT(this->filter->getNbComponent() == 1,
"Multi-component filter given to NodalField ("
<< this->filter->getNbComponent()
<< " components detected, sould be 1");
if (n == 0) {
this->n = field.getNbComponent() - stride;
}
}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
void registerToDumper(const std::string & id,
iohelper::Dumper & dumper) override {
dumper.addNodeDataField(id, *this);
}
inline iterator begin() {
return iterator(field.storage(), field.getNbComponent(), n, stride,
filter->storage());
}
inline iterator end() {
return iterator(field.storage(), field.getNbComponent(), n, stride,
filter->storage() + filter->size());
}
bool isHomogeneous() override { return true; }
void checkHomogeneity() override { this->homogeneous = true; }
virtual UInt getDim() {
if (this->padding)
return this->padding;
else
return n;
}
void setPadding(UInt padding) { this->padding = padding; }
UInt size() { return filter->size(); }
iohelper::DataType getDataType() { return iohelper::getDataType<T>(); }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
const Container & field;
UInt n, stride;
const Filter * filter;
UInt padding;
};
__END_AKANTU_DUMPER__
} // namespace akantu
/* -------------------------------------------------------------------------- */
#endif /* __AKANTU_DUMPER_NODAL_FIELD_HH__ */
diff --git a/src/io/dumper/dumper_padding_helper.hh b/src/io/dumper/dumper_padding_helper.hh
index 5875ebe35..f76e69b63 100644
--- a/src/io/dumper/dumper_padding_helper.hh
+++ b/src/io/dumper/dumper_padding_helper.hh
@@ -1,132 +1,132 @@
/**
* @file dumper_padding_helper.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Mon Jun 19 2017
*
* @brief Padding helper for field iterators
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_PADDING_HELPER_HH__
#define __AKANTU_DUMPER_PADDING_HELPER_HH__
/* -------------------------------------------------------------------------- */
#include "dumper_compute.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
class PadderInterface {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
PadderInterface() {
padding_m = 0;
padding_n = 0;
}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void setPadding(UInt m, UInt n = 0) {
padding_m = m;
padding_n = n;
}
virtual UInt getPaddedDim(UInt nb_data) { return nb_data; }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public:
/// padding informations
UInt padding_n, padding_m;
};
/* -------------------------------------------------------------------------- */
template <class input_type, class output_type>
class PadderGeneric : public ComputeFunctor<input_type, output_type>,
public PadderInterface {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
PadderGeneric() : PadderInterface() {}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
inline output_type pad(const input_type & in,
__attribute__((unused)) UInt nb_data) {
return in; // trick due to the fact that IOHelper padds the vectors (avoid a
// copy of data)
}
};
/* -------------------------------------------------------------------------- */
template <class T>
class PadderGeneric<Vector<T>, Matrix<T>>
: public ComputeFunctor<Vector<T>, Matrix<T>>, public PadderInterface {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
inline Matrix<T> pad(const Vector<T> & _in, UInt nrows, UInt ncols,
UInt nb_data) {
Matrix<T> in(_in.storage(), nrows, ncols);
if (padding_m <= nrows && padding_n * nb_data <= ncols)
return in;
else {
Matrix<T> ret(padding_m, padding_n * nb_data);
UInt nb_cols_per_data = in.cols() / nb_data;
for (UInt d = 0; d < nb_data; ++d)
for (UInt i = 0; i < in.rows(); ++i)
for (UInt j = 0; j < nb_cols_per_data; ++j)
ret(i, j + d * padding_n) = in(i, j + d * nb_cols_per_data);
return ret;
}
}
};
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
__END_AKANTU_DUMPER__
#endif /* __AKANTU_DUMPER_PADDING_HELPER_HH__ */
diff --git a/src/io/dumper/dumper_text.hh b/src/io/dumper/dumper_text.hh
index e7d1ce990..ae20a210f 100644
--- a/src/io/dumper/dumper_text.hh
+++ b/src/io/dumper/dumper_text.hh
@@ -1,87 +1,87 @@
/**
* @file dumper_text.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief to dump into a text file
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_iohelper.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DUMPER_TEXT_HH__
#define __AKANTU_DUMPER_TEXT_HH__
/* -------------------------------------------------------------------------- */
#include <io_helper.hh>
/* -------------------------------------------------------------------------- */
namespace akantu {
class DumperText : public DumperIOHelper {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DumperText(const std::string & basename = "dumper_text",
iohelper::TextDumpMode mode = iohelper::_tdm_space,
bool parallel = true);
~DumperText() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void
registerMesh(const Mesh & mesh, UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) override;
void registerFilteredMesh(
const Mesh & mesh, const ElementTypeMapArray<UInt> & elements_filter,
const Array<UInt> & nodes_filter,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined) override;
void setBaseName(const std::string & basename) override;
private:
void registerNodeTypeField();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
void setPrecision(UInt prec);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DUMPER_TEXT_HH__ */
diff --git a/src/io/dumper/dumper_type_traits.hh b/src/io/dumper/dumper_type_traits.hh
index c7f688a8a..043190287 100644
--- a/src/io/dumper/dumper_type_traits.hh
+++ b/src/io/dumper/dumper_type_traits.hh
@@ -1,90 +1,90 @@
/**
* @file dumper_type_traits.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Wed Nov 08 2017
*
* @brief Type traits for field properties
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#ifndef __AKANTU_DUMPER_TYPE_TRAITS_HH__
#define __AKANTU_DUMPER_TYPE_TRAITS_HH__
/* -------------------------------------------------------------------------- */
#include "element_type_map.hh"
#include "element_type_map_filter.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
__BEGIN_AKANTU_DUMPER__
/* -------------------------------------------------------------------------- */
template <class data, class ret, class field> struct TypeTraits {
//! the stored data (real, int, uint, ...)
using data_type = data;
//! the type returned by the operator *
using return_type = ret;
//! the field type (ElementTypeMap or ElementTypeMapFilter)
using field_type = field;
//! the type over which we iterate
using it_type = typename field_type::type;
//! the type of array (Array<T> or ArrayFilter<T>)
using array_type = typename field_type::array_type;
//! the iterator over the array
using array_iterator = typename array_type::const_vector_iterator;
};
/* -------------------------------------------------------------------------- */
// specialization for the case in which input and output types are the same
template <class T, template <class> class ret, bool filtered>
struct SingleType : public TypeTraits<T, ret<T>, ElementTypeMapArray<T>> {};
/* -------------------------------------------------------------------------- */
// same as before but for filtered data
template <class T, template <class> class ret>
struct SingleType<T, ret, true>
: public TypeTraits<T, ret<T>, ElementTypeMapArrayFilter<T>> {};
/* -------------------------------------------------------------------------- */
// specialization for the case in which input and output types are different
template <class it_type, class data_type, template <class> class ret,
bool filtered>
struct DualType : public TypeTraits<data_type, ret<data_type>,
ElementTypeMapArray<it_type>> {};
/* -------------------------------------------------------------------------- */
// same as before but for filtered data
template <class it_type, class data_type, template <class> class ret>
struct DualType<it_type, data_type, ret, true>
: public TypeTraits<data_type, ret<data_type>,
ElementTypeMapArrayFilter<it_type>> {};
/* -------------------------------------------------------------------------- */
__END_AKANTU_DUMPER__
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
#endif /* __AKANTU_DUMPER_TYPE_TRAITS_HH__ */
diff --git a/src/io/mesh_io.cc b/src/io/mesh_io.cc
index ab1429c04..20bf9279a 100644
--- a/src/io/mesh_io.cc
+++ b/src/io/mesh_io.cc
@@ -1,139 +1,139 @@
/**
* @file mesh_io.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Thu Feb 01 2018
*
* @brief common part for all mesh io classes
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_io.hh"
#include "aka_common.hh"
#include "aka_iterators.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
MeshIO::MeshIO() {
canReadSurface = false;
canReadExtendedData = false;
}
/* -------------------------------------------------------------------------- */
MeshIO::~MeshIO() = default;
/* -------------------------------------------------------------------------- */
std::unique_ptr<MeshIO> MeshIO::getMeshIO(const std::string & filename,
const MeshIOType & type) {
MeshIOType t = type;
if (type == _miot_auto) {
std::string::size_type idx = filename.rfind('.');
std::string ext;
if (idx != std::string::npos) {
ext = filename.substr(idx + 1);
}
if (ext == "msh") {
t = _miot_gmsh;
} else if (ext == "diana") {
t = _miot_diana;
} else
AKANTU_EXCEPTION("Cannot guess the type of file of "
<< filename << " (ext " << ext << "). "
<< "Please provide the MeshIOType to the read function");
}
switch (t) {
case _miot_gmsh:
return std::make_unique<MeshIOMSH>();
#if defined(AKANTU_STRUCTURAL_MECHANICS)
case _miot_gmsh_struct:
return std::make_unique<MeshIOMSHStruct>();
#endif
case _miot_diana:
return std::make_unique<MeshIODiana>();
default:
return nullptr;
}
}
/* -------------------------------------------------------------------------- */
void MeshIO::read(const std::string & filename, Mesh & mesh,
const MeshIOType & type) {
std::unique_ptr<MeshIO> mesh_io = getMeshIO(filename, type);
mesh_io->read(filename, mesh);
}
/* -------------------------------------------------------------------------- */
void MeshIO::write(const std::string & filename, Mesh & mesh,
const MeshIOType & type) {
std::unique_ptr<MeshIO> mesh_io = getMeshIO(filename, type);
mesh_io->write(filename, mesh);
}
/* -------------------------------------------------------------------------- */
void MeshIO::constructPhysicalNames(const std::string & tag_name, Mesh & mesh) {
if (!physical_names.empty()) {
for (auto type : mesh.elementTypes()) {
auto & name_vec =
mesh.getDataPointer<std::string>("physical_names", type);
const auto & tags_vec = mesh.getData<UInt>(tag_name, type);
for (auto pair : zip(tags_vec, name_vec)) {
auto tag = std::get<0>(pair);
auto & name = std::get<1>(pair);
auto map_it = physical_names.find(tag);
if (map_it == physical_names.end()) {
std::stringstream sstm;
sstm << tag;
name = sstm.str();
} else {
name = map_it->second;
}
}
}
}
}
/* -------------------------------------------------------------------------- */
void MeshIO::printself(std::ostream & stream, int indent) const {
std::string space(AKANTU_INDENT, indent);
-
+
if (physical_names.size()) {
stream << space << "Physical map:" << std::endl;
for (auto & pair : physical_names) {
stream << space << pair.first << ": " << pair.second << std::endl;
}
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/io/mesh_io/mesh_io_diana.hh b/src/io/mesh_io/mesh_io_diana.hh
index fde134690..82a0ffa91 100644
--- a/src/io/mesh_io/mesh_io_diana.hh
+++ b/src/io/mesh_io/mesh_io_diana.hh
@@ -1,108 +1,108 @@
/**
* @file mesh_io_diana.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Alodie Schneuwly <alodie.schneuwly@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief diana mesh reader description
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_IO_DIANA_HH__
#define __AKANTU_MESH_IO_DIANA_HH__
/* -------------------------------------------------------------------------- */
#include "mesh_io.hh"
/* -------------------------------------------------------------------------- */
#include <vector>
/* -------------------------------------------------------------------------- */
namespace akantu {
class MeshIODiana : public MeshIO {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MeshIODiana();
~MeshIODiana() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// read a mesh from the file
void read(const std::string & filename, Mesh & mesh) override;
/// write a mesh to a file
void write(const std::string & filename, const Mesh & mesh) override;
private:
std::string readCoordinates(std::ifstream & infile, Mesh & mesh,
UInt & first_node_number);
std::string readElements(std::ifstream & infile, Mesh & mesh,
UInt first_node_number);
std::string readGroups(std::ifstream & infile, Mesh & mesh,
UInt first_node_number);
std::string readConnectivity(std::ifstream & infile, Mesh & mesh,
UInt first_node_number);
std::string readMaterialElement(std::ifstream & infile, Mesh & mesh);
std::string readMaterial(std::ifstream & infile,
const std::string & filename);
UInt readInterval(std::stringstream & line, std::set<UInt> & interval);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
std::map<std::string, ElementType> _diana_to_akantu_element_types;
std::map<std::string, std::string> _diana_to_akantu_mat_prop;
/// order in witch element as to be read, akantu_node_order =
/// _read_order[diana_node_order]
std::map<ElementType, UInt *> _read_order;
std::map<UInt, Element> diana_element_number_to_elements;
std::map<Element, UInt> akantu_number_to_diana_number;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_IO_DIANA_HH__ */
diff --git a/src/io/mesh_io/mesh_io_msh.cc b/src/io/mesh_io/mesh_io_msh.cc
index 79c8b0205..bb432fc7a 100644
--- a/src/io/mesh_io/mesh_io_msh.cc
+++ b/src/io/mesh_io/mesh_io_msh.cc
@@ -1,1100 +1,1100 @@
/**
* @file mesh_io_msh.cc
*
* @author Dana Christen <dana.christen@gmail.com>
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief Read/Write for MSH files generated by gmsh
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -----------------------------------------------------------------------------
Version (Legacy) 1.0
$NOD
number-of-nodes
node-number x-coord y-coord z-coord
...
$ENDNOD
$ELM
number-of-elements
elm-number elm-type reg-phys reg-elem number-of-nodes node-number-list
...
$ENDELM
-----------------------------------------------------------------------------
Version 2.1
$MeshFormat
version-number file-type data-size
$EndMeshFormat
$Nodes
number-of-nodes
node-number x-coord y-coord z-coord
...
$EndNodes
$Elements
number-of-elements
elm-number elm-type number-of-tags < tag > ... node-number-list
...
$EndElements
$PhysicalNames
number-of-names
physical-dimension physical-number "physical-name"
...
$EndPhysicalNames
$NodeData
number-of-string-tags
< "string-tag" >
...
number-of-real-tags
< real-tag >
...
number-of-integer-tags
< integer-tag >
...
node-number value ...
...
$EndNodeData
$ElementData
number-of-string-tags
< "string-tag" >
...
number-of-real-tags
< real-tag >
...
number-of-integer-tags
< integer-tag >
...
elm-number value ...
...
$EndElementData
$ElementNodeData
number-of-string-tags
< "string-tag" >
...
number-of-real-tags
< real-tag >
...
number-of-integer-tags
< integer-tag >
...
elm-number number-of-nodes-per-element value ...
...
$ElementEndNodeData
-----------------------------------------------------------------------------
elem-type
1: 2-node line.
2: 3-node triangle.
3: 4-node quadrangle.
4: 4-node tetrahedron.
5: 8-node hexahedron.
6: 6-node prism.
7: 5-node pyramid.
8: 3-node second order line
9: 6-node second order triangle
10: 9-node second order quadrangle
11: 10-node second order tetrahedron
12: 27-node second order hexahedron
13: 18-node second order prism
14: 14-node second order pyramid
15: 1-node point.
16: 8-node second order quadrangle
17: 20-node second order hexahedron
18: 15-node second order prism
19: 13-node second order pyramid
20: 9-node third order incomplete triangle
21: 10-node third order triangle
22: 12-node fourth order incomplete triangle
23: 15-node fourth order triangle
24: 15-node fifth order incomplete triangle
25: 21-node fifth order complete triangle
26: 4-node third order edge
27: 5-node fourth order edge
28: 6-node fifth order edge
29: 20-node third order tetrahedron
30: 35-node fourth order tetrahedron
31: 56-node fifth order tetrahedron
-------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "element_group.hh"
#include "mesh_io.hh"
#include "mesh_utils.hh"
#include "node_group.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Methods Implentations */
/* -------------------------------------------------------------------------- */
MeshIOMSH::MeshIOMSH() {
canReadSurface = true;
canReadExtendedData = true;
_msh_nodes_per_elem[_msh_not_defined] = 0;
_msh_nodes_per_elem[_msh_segment_2] = 2;
_msh_nodes_per_elem[_msh_triangle_3] = 3;
_msh_nodes_per_elem[_msh_quadrangle_4] = 4;
_msh_nodes_per_elem[_msh_tetrahedron_4] = 4;
_msh_nodes_per_elem[_msh_hexahedron_8] = 8;
_msh_nodes_per_elem[_msh_prism_1] = 6;
_msh_nodes_per_elem[_msh_pyramid_1] = 1;
_msh_nodes_per_elem[_msh_segment_3] = 3;
_msh_nodes_per_elem[_msh_triangle_6] = 6;
_msh_nodes_per_elem[_msh_quadrangle_9] = 9;
_msh_nodes_per_elem[_msh_tetrahedron_10] = 10;
_msh_nodes_per_elem[_msh_hexahedron_27] = 27;
_msh_nodes_per_elem[_msh_hexahedron_20] = 20;
_msh_nodes_per_elem[_msh_prism_18] = 18;
_msh_nodes_per_elem[_msh_prism_15] = 15;
_msh_nodes_per_elem[_msh_pyramid_14] = 14;
_msh_nodes_per_elem[_msh_point] = 1;
_msh_nodes_per_elem[_msh_quadrangle_8] = 8;
_msh_to_akantu_element_types[_msh_not_defined] = _not_defined;
_msh_to_akantu_element_types[_msh_segment_2] = _segment_2;
_msh_to_akantu_element_types[_msh_triangle_3] = _triangle_3;
_msh_to_akantu_element_types[_msh_quadrangle_4] = _quadrangle_4;
_msh_to_akantu_element_types[_msh_tetrahedron_4] = _tetrahedron_4;
_msh_to_akantu_element_types[_msh_hexahedron_8] = _hexahedron_8;
_msh_to_akantu_element_types[_msh_prism_1] = _pentahedron_6;
_msh_to_akantu_element_types[_msh_pyramid_1] = _not_defined;
_msh_to_akantu_element_types[_msh_segment_3] = _segment_3;
_msh_to_akantu_element_types[_msh_triangle_6] = _triangle_6;
_msh_to_akantu_element_types[_msh_quadrangle_9] = _not_defined;
_msh_to_akantu_element_types[_msh_tetrahedron_10] = _tetrahedron_10;
_msh_to_akantu_element_types[_msh_hexahedron_27] = _not_defined;
_msh_to_akantu_element_types[_msh_hexahedron_20] = _hexahedron_20;
_msh_to_akantu_element_types[_msh_prism_18] = _not_defined;
_msh_to_akantu_element_types[_msh_prism_15] = _pentahedron_15;
_msh_to_akantu_element_types[_msh_pyramid_14] = _not_defined;
_msh_to_akantu_element_types[_msh_point] = _point_1;
_msh_to_akantu_element_types[_msh_quadrangle_8] = _quadrangle_8;
_akantu_to_msh_element_types[_not_defined] = _msh_not_defined;
_akantu_to_msh_element_types[_segment_2] = _msh_segment_2;
_akantu_to_msh_element_types[_segment_3] = _msh_segment_3;
_akantu_to_msh_element_types[_triangle_3] = _msh_triangle_3;
_akantu_to_msh_element_types[_triangle_6] = _msh_triangle_6;
_akantu_to_msh_element_types[_tetrahedron_4] = _msh_tetrahedron_4;
_akantu_to_msh_element_types[_tetrahedron_10] = _msh_tetrahedron_10;
_akantu_to_msh_element_types[_quadrangle_4] = _msh_quadrangle_4;
_akantu_to_msh_element_types[_quadrangle_8] = _msh_quadrangle_8;
_akantu_to_msh_element_types[_hexahedron_8] = _msh_hexahedron_8;
_akantu_to_msh_element_types[_hexahedron_20] = _msh_hexahedron_20;
_akantu_to_msh_element_types[_pentahedron_6] = _msh_prism_1;
_akantu_to_msh_element_types[_pentahedron_15] = _msh_prism_15;
_akantu_to_msh_element_types[_point_1] = _msh_point;
#if defined(AKANTU_STRUCTURAL_MECHANICS)
_akantu_to_msh_element_types[_bernoulli_beam_2] = _msh_segment_2;
_akantu_to_msh_element_types[_bernoulli_beam_3] = _msh_segment_2;
_akantu_to_msh_element_types[_discrete_kirchhoff_triangle_18] =
_msh_triangle_3;
#endif
std::map<ElementType, MSHElementType>::iterator it;
for (it = _akantu_to_msh_element_types.begin();
it != _akantu_to_msh_element_types.end(); ++it) {
UInt nb_nodes = _msh_nodes_per_elem[it->second];
std::vector<UInt> tmp(nb_nodes);
for (UInt i = 0; i < nb_nodes; ++i) {
tmp[i] = i;
}
switch (it->first) {
case _tetrahedron_10:
tmp[8] = 9;
tmp[9] = 8;
break;
case _pentahedron_6:
tmp[0] = 2;
tmp[1] = 0;
tmp[2] = 1;
tmp[3] = 5;
tmp[4] = 3;
tmp[5] = 4;
break;
case _pentahedron_15:
tmp[0] = 2;
tmp[1] = 0;
tmp[2] = 1;
tmp[3] = 5;
tmp[4] = 3;
tmp[5] = 4;
tmp[6] = 8;
tmp[8] = 11;
tmp[9] = 6;
tmp[10] = 9;
tmp[11] = 10;
tmp[12] = 14;
tmp[14] = 12;
break;
case _hexahedron_20:
tmp[9] = 11;
tmp[10] = 12;
tmp[11] = 9;
tmp[12] = 13;
tmp[13] = 10;
tmp[17] = 19;
tmp[18] = 17;
tmp[19] = 18;
break;
default:
// nothing to change
break;
}
_read_order[it->first] = tmp;
}
}
/* -------------------------------------------------------------------------- */
MeshIOMSH::~MeshIOMSH() = default;
/* -------------------------------------------------------------------------- */
namespace {
struct File {
std::string filename;
std::ifstream infile;
std::string line;
size_t current_line{0};
size_t first_node_number{std::numeric_limits<UInt>::max()},
last_node_number{0};
bool has_physical_names{false};
std::unordered_map<size_t, size_t> node_tags;
std::unordered_map<size_t, Element> element_tags;
double version{0};
int size_of_size_t{0};
Mesh & mesh;
MeshAccessor mesh_accessor;
std::multimap<std::pair<int, int>, int> entity_tag_to_physical_tags;
File(const std::string & filename, Mesh & mesh)
: filename(filename), mesh(mesh), mesh_accessor(mesh) {
infile.open(filename.c_str());
if (not infile.good()) {
AKANTU_EXCEPTION("Cannot open file " << filename);
}
}
~File() { infile.close(); }
auto good() { return infile.good(); }
std::stringstream get_line() {
std::string tmp_str;
if (infile.eof()) {
AKANTU_EXCEPTION("Reached the end of the file " << filename);
}
std::getline(infile, tmp_str);
line = trim(tmp_str);
++current_line;
return std::stringstream(line);
}
template <typename... Ts> void read_line(Ts &&... ts) {
auto && sstr = get_line();
(void)std::initializer_list<int>{
(sstr >> std::forward<decltype(ts)>(ts), 0)...};
}
};
} // namespace
/* -------------------------------------------------------------------------- */
template <typename File, typename Readers>
void MeshIOMSH::populateReaders2(File & file, Readers & readers) {
readers["$NOD"] = readers["$Nodes"] = [&](const std::string &) {
UInt nb_nodes;
file.read_line(nb_nodes);
Array<Real> & nodes = file.mesh_accessor.getNodes();
nodes.resize(nb_nodes);
file.mesh_accessor.setNbGlobalNodes(nb_nodes);
size_t index;
Vector<double> coord(3);
/// for each node, read the coordinates
for (auto && data : enumerate(make_view(nodes, nodes.getNbComponent()))) {
file.read_line(index, coord(0), coord(1), coord(2));
if (index > std::numeric_limits<UInt>::max()) {
AKANTU_EXCEPTION(
"There are more nodes in this files than the index type of akantu "
"can handle, consider recompiling with a bigger index type");
}
file.first_node_number = std::min(file.first_node_number, index);
file.last_node_number = std::max(file.last_node_number, index);
for (auto && coord_data : zip(std::get<1>(data), coord)) {
std::get<0>(coord_data) = std::get<1>(coord_data);
}
file.node_tags[index] = std::get<0>(data);
}
};
readers["$ELM"] = readers["$Elements"] = [&](const std::string &) {
UInt nb_elements;
file.read_line(nb_elements);
Int index;
UInt msh_type;
ElementType akantu_type;
for (UInt i = 0; i < nb_elements; ++i) {
auto && sstr_elem = file.get_line();
sstr_elem >> index;
sstr_elem >> msh_type;
/// get the connectivity vector depending on the element type
akantu_type =
this->_msh_to_akantu_element_types[MSHElementType(msh_type)];
if (akantu_type == _not_defined) {
AKANTU_DEBUG_WARNING("Unsuported element kind "
<< msh_type << " at line " << file.current_line);
continue;
}
Element elem{akantu_type, 0, _not_ghost};
auto & connectivity = file.mesh_accessor.getConnectivity(akantu_type);
auto node_per_element = connectivity.getNbComponent();
auto & read_order = this->_read_order[akantu_type];
/// read tags informations
if (file.version < 2) {
Int tag0, tag1, nb_nodes; // reg-phys, reg-elem, number-of-nodes
sstr_elem >> tag0 >> tag1 >> nb_nodes;
auto & data0 =
file.mesh_accessor.template getData<UInt>("tag_0", akantu_type);
data0.push_back(tag0);
auto & data1 =
file.mesh_accessor.template getData<UInt>("tag_1", akantu_type);
data1.push_back(tag1);
} else if (file.version < 4) {
UInt nb_tags;
sstr_elem >> nb_tags;
for (UInt j = 0; j < nb_tags; ++j) {
Int tag;
sstr_elem >> tag;
auto & data = file.mesh_accessor.template getData<UInt>(
"tag_" + std::to_string(j), akantu_type);
data.push_back(tag);
}
}
Vector<UInt> local_connect(node_per_element);
for (UInt j = 0; j < node_per_element; ++j) {
UInt node_index;
sstr_elem >> node_index;
AKANTU_DEBUG_ASSERT(node_index <= file.last_node_number,
"Node number not in range : line "
<< file.current_line);
local_connect(read_order[j]) = file.node_tags[node_index];
}
connectivity.push_back(local_connect);
elem.element = connectivity.size() - 1;
file.element_tags[index] = elem;
}
};
readers["$Periodic"] = [&](const std::string &) {
UInt nb_periodic_entities;
file.read_line(nb_periodic_entities);
file.mesh_accessor.getNodesFlags().resize(file.mesh.getNbNodes(),
NodeFlag::_normal);
for (UInt p = 0; p < nb_periodic_entities; ++p) {
// dimension slave-tag master-tag
UInt dimension;
file.read_line(dimension);
// transformation
file.get_line();
// nb nodes
UInt nb_nodes;
file.read_line(nb_nodes);
for (UInt n = 0; n < nb_nodes; ++n) {
// slave master
auto && sstr = file.get_line();
// The info in the mesh seem inconsistent so they are ignored for now.
continue;
if (dimension == file.mesh.getSpatialDimension() - 1) {
UInt slave, master;
sstr >> slave;
sstr >> master;
file.mesh_accessor.addPeriodicSlave(file.node_tags[slave],
file.node_tags[master]);
}
}
}
// mesh_accessor.markMeshPeriodic();
};
}
/* -------------------------------------------------------------------------- */
template <typename File, typename Readers>
void MeshIOMSH::populateReaders4(File & file, Readers & readers) {
static std::map<int, std::string> entity_type{
{0, "points"},
{1, "curve"},
{2, "surface"},
{3, "volume"},
};
readers["$Entities"] = [&](const std::string &) {
size_t num_entity[4];
file.read_line(num_entity[0], num_entity[1], num_entity[2], num_entity[3]);
for (auto entity_dim : arange(4)) {
for (auto _ [[gnu::unused]] : arange(num_entity[entity_dim])) {
auto && sstr = file.get_line();
int tag;
double min_x, min_y, min_z, max_x, max_y, max_z;
size_t num_physical_tags;
sstr >> tag >> min_x >> min_y >> min_z;
if (entity_dim > 0 or file.version < 4.1) {
sstr >> max_x >> max_y >> max_z;
}
sstr >> num_physical_tags;
for (auto _ [[gnu::unused]] : arange(num_physical_tags)) {
int phys_tag;
sstr >> phys_tag;
std::string physical_name;
if (this->physical_names.find(phys_tag) ==
this->physical_names.end()) {
physical_name = "msh_block_" + std::to_string(phys_tag);
} else {
physical_name = this->physical_names[phys_tag];
}
if (not file.mesh.elementGroupExists(physical_name)) {
file.mesh.createElementGroup(physical_name, entity_dim);
} else {
file.mesh.getElementGroup(physical_name).addDimension(entity_dim);
}
file.entity_tag_to_physical_tags.insert(
std::make_pair(std::make_pair(tag, entity_dim), phys_tag));
}
}
}
};
readers["$Nodes"] = [&](const std::string &) {
size_t num_blocks, num_nodes;
if (file.version >= 4.1) {
file.read_line(num_blocks, num_nodes, file.first_node_number,
file.last_node_number);
} else {
file.read_line(num_blocks, num_nodes);
}
auto & nodes = file.mesh_accessor.getNodes();
nodes.reserve(num_nodes);
file.mesh_accessor.setNbGlobalNodes(num_nodes);
if (num_nodes > std::numeric_limits<UInt>::max()) {
AKANTU_EXCEPTION(
"There are more nodes in this files than the index type of akantu "
"can handle, consider recompiling with a bigger index type");
}
size_t node_id{0};
for (auto block [[gnu::unused]] : arange(num_blocks)) {
int entity_dim, entity_tag, parametric;
size_t num_nodes_in_block;
Vector<double> pos(3);
Vector<double> real_pos(nodes.getNbComponent());
if (file.version >= 4.1) {
file.read_line(entity_dim, entity_tag, parametric, num_nodes_in_block);
if (parametric) {
AKANTU_EXCEPTION(
"Akantu does not support parametric nodes in msh files");
}
for (auto _ [[gnu::unused]] : arange(num_nodes_in_block)) {
size_t tag;
file.read_line(tag);
file.node_tags[tag] = node_id;
++node_id;
}
-
+
for (auto _ [[gnu::unused]] : arange(num_nodes_in_block)) {
file.read_line(pos(_x), pos(_y), pos(_z));
for (auto && data : zip(real_pos, pos)) {
std::get<0>(data) = std::get<1>(data);
}
nodes.push_back(real_pos);
}
} else {
file.read_line(entity_tag, entity_dim, parametric, num_nodes_in_block);
for (auto _ [[gnu::unused]] : arange(num_nodes_in_block)) {
size_t tag;
file.read_line(tag, pos(_x), pos(_y), pos(_z));
if (file.version < 4.1) {
file.first_node_number = std::min(file.first_node_number, tag);
file.last_node_number = std::max(file.last_node_number, tag);
}
for (auto && data : zip(real_pos, pos)) {
std::get<0>(data) = std::get<1>(data);
}
nodes.push_back(real_pos);
file.node_tags[tag] = node_id;
++node_id;
}
}
}
};
readers["$Elements"] = [&](const std::string &) {
size_t num_blocks, num_elements;
file.read_line(num_blocks, num_elements);
for (auto block [[gnu::unused]] : arange(num_blocks)) {
int entity_dim, entity_tag, element_type;
size_t num_elements_in_block;
if (file.version >= 4.1) {
file.read_line(entity_dim, entity_tag, element_type,
num_elements_in_block);
} else {
file.read_line(entity_tag, entity_dim, element_type,
num_elements_in_block);
}
/// get the connectivity vector depending on the element type
auto && akantu_type =
this->_msh_to_akantu_element_types[(MSHElementType)element_type];
if (akantu_type == _not_defined) {
AKANTU_DEBUG_WARNING("Unsuported element kind " << element_type
<< " at line "
<< file.current_line);
continue;
}
Element elem{akantu_type, 0, _not_ghost};
auto & connectivity = file.mesh_accessor.getConnectivity(akantu_type);
Vector<UInt> local_connect(connectivity.getNbComponent());
auto && read_order = this->_read_order[akantu_type];
auto & data0 =
file.mesh_accessor.template getData<UInt>("tag_0", akantu_type);
data0.resize(data0.size() + num_elements_in_block, 0);
auto & physical_data = file.mesh_accessor.template getData<std::string>(
"physical_names", akantu_type);
physical_data.resize(physical_data.size() + num_elements_in_block, "");
for (auto _ [[gnu::unused]] : arange(num_elements_in_block)) {
auto && sstr_elem = file.get_line();
size_t elem_tag;
sstr_elem >> elem_tag;
for (auto && c : arange(connectivity.getNbComponent())) {
size_t node_tag;
sstr_elem >> node_tag;
AKANTU_DEBUG_ASSERT(node_tag <= file.last_node_number,
"Node number not in range : line "
<< file.current_line);
node_tag = file.node_tags[node_tag];
local_connect(read_order[c]) = node_tag;
}
connectivity.push_back(local_connect);
elem.element = connectivity.size() - 1;
file.element_tags[elem_tag] = elem;
auto range = file.entity_tag_to_physical_tags.equal_range(
std::make_pair(entity_tag, entity_dim));
bool first = true;
for (auto it = range.first; it != range.second; ++it) {
auto phys_it = this->physical_names.find(it->second);
if (first) {
data0(elem.element) =
it->second; // for compatibility with version 2
if (phys_it != this->physical_names.end())
physical_data(elem.element) = phys_it->second;
first = false;
}
if (phys_it != this->physical_names.end())
file.mesh.getElementGroup(phys_it->second).add(elem, true, false);
}
}
}
for (auto && element_group : file.mesh.iterateElementGroups()) {
element_group.getNodeGroup().optimize();
}
};
}
/* -------------------------------------------------------------------------- */
void MeshIOMSH::read(const std::string & filename, Mesh & mesh) {
File file(filename, mesh);
std::map<std::string, std::function<void(const std::string &)>> readers;
readers["$MeshFormat"] = [&](const std::string &) {
auto && sstr = file.get_line();
int format;
sstr >> file.version >> format;
if (format != 0)
AKANTU_ERROR("This reader can only read ASCII files.");
if (file.version > 2) {
sstr >> file.size_of_size_t;
if (file.size_of_size_t > int(sizeof(UInt))) {
AKANTU_DEBUG_INFO("The size of the indexes in akantu might be to small "
"to read this file (akantu "
<< sizeof(UInt) << " vs. msh file "
<< file.size_of_size_t << ")");
}
}
if (file.version < 4) {
this->populateReaders2(file, readers);
} else {
this->populateReaders4(file, readers);
}
};
auto && read_data = [&](auto && entity_tags, auto && get_data,
auto && read_data) {
auto read_data_tags = [&](auto x) {
UInt number_of_tags{0};
file.read_line(number_of_tags);
std::vector<decltype(x)> tags(number_of_tags);
for (auto && tag : tags) {
file.read_line(tag);
}
return tags;
};
auto && string_tags = read_data_tags(std::string{});
auto && real_tags [[gnu::unused]] = read_data_tags(double{});
auto && int_tags = read_data_tags(int{});
for (auto & s : string_tags) {
s = trim(s, '"');
}
auto id = string_tags[0];
auto size = int_tags[2];
auto nb_component = int_tags[1];
auto & data = get_data(id, size, nb_component);
for (auto n [[gnu::unused]] : arange(size)) {
auto && sstr = file.get_line();
size_t tag;
sstr >> tag;
const auto & entity = entity_tags[tag];
read_data(entity, sstr, data, nb_component);
}
};
readers["$NodeData"] = [&](const std::string &) {
/* $NodeData
numStringTags(ASCII int)
stringTag(string) ...
numRealTags(ASCII int)
realTag(ASCII double) ...
numIntegerTags(ASCII int)
integerTag(ASCII int) ...
nodeTag(size_t) value(double) ...
...
$EndNodeData */
read_data(file.node_tags,
[&](auto && id, auto && size [[gnu::unused]],
auto && nb_component [[gnu::unused]]) -> Array<double> & {
- auto & data = file.mesh.template getNodalData<double>(
- id, nb_component);
+ auto & data =
+ file.mesh.template getNodalData<double>(id, nb_component);
data.resize(size);
return data;
},
[&](auto && node, auto && sstr, auto && data,
auto && nb_component [[gnu::unused]]) {
for (auto c : arange(nb_component)) {
sstr >> data(node, c);
}
});
};
readers["$ElementData"] = [&](const std::string &) {
/* $ElementData
numStringTags(ASCII int)
stringTag(string) ...
numRealTags(ASCII int)
realTag(ASCII double) ...
numIntegerTags(ASCII int)
integerTag(ASCII int) ...
elementTag(size_t) value(double) ...
...
$EndElementData
*/
read_data(
file.element_tags,
[&](auto && id, auto && size [[gnu::unused]],
auto && nb_component
[[gnu::unused]]) -> ElementTypeMapArray<double> & {
file.mesh.template getElementalData<double>(id);
return file.mesh.template getElementalData<double>(id);
},
[&](auto && element, auto && sstr, auto && data, auto && nb_component) {
if (not data.exists(element.type)) {
data.alloc(mesh.getNbElement(element.type), nb_component,
element.type, element.ghost_type);
}
auto & data_array = data(element.type);
for (auto c : arange(nb_component)) {
sstr >> data_array(element.element, c);
}
});
};
readers["$ElementNodeData"] = [&](const std::string &) {
/* $ElementNodeData
numStringTags(ASCII int)
stringTag(string) ...
numRealTags(ASCII int)
realTag(ASCII double) ...
numIntegerTags(ASCII int)
integerTag(ASCII int) ...
elementTag(size_t) value(double) ...
...
$EndElementNodeData
*/
read_data(
file.element_tags,
[&](auto && id, auto && size [[gnu::unused]],
auto && nb_component
[[gnu::unused]]) -> ElementTypeMapArray<double> & {
file.mesh.template getElementalData<double>(id);
auto & data = file.mesh.template getElementalData<double>(id);
data.isNodal(true);
return data;
},
[&](auto && element, auto && sstr, auto && data, auto && nb_component) {
int nb_nodes_per_element;
sstr >> nb_nodes_per_element;
if (not data.exists(element.type)) {
data.alloc(mesh.getNbElement(element.type),
nb_component * nb_nodes_per_element, element.type,
element.ghost_type);
}
auto & data_array = data(element.type);
for (auto c : arange(nb_component)) {
sstr >> data_array(element.element, c);
}
});
};
readers["$PhysicalNames"] = [&](const std::string &) {
file.has_physical_names = true;
int num_of_phys_names;
file.read_line(num_of_phys_names); /// the format line
for (auto k [[gnu::unused]] : arange(num_of_phys_names)) {
int phys_name_id;
int phys_dim;
std::string phys_name;
file.read_line(phys_dim, phys_name_id, std::quoted(phys_name));
this->physical_names[phys_name_id] = phys_name;
}
};
readers["Unsupported"] = [&](const std::string & _block) {
std::string block = _block.substr(1);
AKANTU_DEBUG_WARNING("Unsupported block_kind " << block << " at line "
<< file.current_line);
auto && end_block = "$End" + block;
while (file.line != end_block) {
file.get_line();
}
};
while (file.good()) {
std::string block;
file.read_line(block);
auto && it = readers.find(block);
if (it != readers.end()) {
it->second(block);
std::string end_block;
file.read_line(end_block);
block = block.substr(1);
if (end_block != "$End" + block) {
AKANTU_EXCEPTION("The reader failed to properly read the block "
<< block << ". Expected a $End" << block << " at line "
<< file.current_line);
}
} else if (block.size() != 0) {
readers["Unsupported"](block);
}
}
// mesh.updateTypesOffsets(_not_ghost);
if (file.version < 4) {
this->constructPhysicalNames("tag_0", mesh);
if (file.has_physical_names)
mesh.createGroupsFromMeshData<std::string>("physical_names");
}
MeshUtils::fillElementToSubElementsData(mesh);
}
/* -------------------------------------------------------------------------- */
void MeshIOMSH::write(const std::string & filename, const Mesh & mesh) {
std::ofstream outfile;
const Array<Real> & nodes = mesh.getNodes();
outfile.open(filename.c_str());
outfile << "$MeshFormat"
<< "\n";
outfile << "2.2 0 8"
<< "\n";
outfile << "$EndMeshFormat"
<< "\n";
outfile << std::setprecision(std::numeric_limits<Real>::digits10);
outfile << "$Nodes"
<< "\n";
outfile << nodes.size() << "\n";
outfile << std::uppercase;
for (UInt i = 0; i < nodes.size(); ++i) {
Int offset = i * nodes.getNbComponent();
outfile << i + 1;
for (UInt j = 0; j < nodes.getNbComponent(); ++j) {
outfile << " " << nodes.storage()[offset + j];
}
for (UInt p = nodes.getNbComponent(); p < 3; ++p)
outfile << " " << 0.;
outfile << "\n";
;
}
outfile << std::nouppercase;
outfile << "$EndNodes"
<< "\n";
outfile << "$Elements"
<< "\n";
Int nb_elements = 0;
for (auto && type :
mesh.elementTypes(_all_dimensions, _not_ghost, _ek_not_defined)) {
const Array<UInt> & connectivity = mesh.getConnectivity(type, _not_ghost);
nb_elements += connectivity.size();
}
outfile << nb_elements << "\n";
std::map<Element, size_t> element_to_msh_element;
UInt element_idx = 1;
Element element;
for (auto && type :
mesh.elementTypes(_all_dimensions, _not_ghost, _ek_not_defined)) {
const auto & connectivity = mesh.getConnectivity(type, _not_ghost);
element.type = type;
UInt * tag[2] = {nullptr, nullptr};
if (mesh.hasData<UInt>("tag_0", type, _not_ghost)) {
const auto & data_tag_0 = mesh.getData<UInt>("tag_0", type, _not_ghost);
tag[0] = data_tag_0.storage();
}
if (mesh.hasData<UInt>("tag_1", type, _not_ghost)) {
const auto & data_tag_1 = mesh.getData<UInt>("tag_1", type, _not_ghost);
tag[1] = data_tag_1.storage();
}
for (auto && data :
enumerate(make_view(connectivity, connectivity.getNbComponent()))) {
element.element = std::get<0>(data);
const auto & conn = std::get<1>(data);
element_to_msh_element[element] = element_idx;
outfile << element_idx << " " << _akantu_to_msh_element_types[type]
<< " 2";
/// \todo write the real data in the file
for (UInt t = 0; t < 2; ++t)
if (tag[t])
outfile << " " << tag[t][element.element];
else
outfile << " 0";
for (auto && c : conn) {
outfile << " " << c + 1;
}
outfile << "\n";
element_idx++;
}
}
outfile << "$EndElements"
<< "\n";
if (mesh.hasData(MeshDataType::_nodal)) {
auto && tags = mesh.getTagNames();
for (auto && tag : tags) {
auto type = mesh.getTypeCode(tag, MeshDataType::_nodal);
if (type != MeshDataTypeCode::_real) {
AKANTU_DEBUG_WARNING(
"The field "
<< tag << " is ignored by the MSH writer, msh files do not support "
<< type << " data");
continue;
}
auto && data = mesh.getNodalData<double>(tag);
outfile << "$NodeData"
<< "\n";
outfile << "1"
<< "\n";
outfile << "\"" << tag << "\"\n";
outfile << "1\n0.0"
<< "\n";
outfile << "3\n0"
<< "\n";
outfile << data.getNbComponent() << "\n";
outfile << data.size() << "\n";
for (auto && d : enumerate(make_view(data, data.getNbComponent()))) {
outfile << std::get<0>(d) + 1;
for (auto && v : std::get<1>(d)) {
outfile << " " << v;
}
outfile << "\n";
}
outfile << "$EndNodeData"
<< "\n";
}
}
if (mesh.hasData(MeshDataType::_elemental)) {
auto && tags = mesh.getTagNames();
for (auto && tag : tags) {
auto && data = mesh.getElementalData<double>(tag);
auto type = mesh.getTypeCode(tag, MeshDataType::_elemental);
if (type != MeshDataTypeCode::_real) {
AKANTU_DEBUG_WARNING(
"The field "
<< tag << " is ignored by the MSH writer, msh files do not support "
<< type << " data");
continue;
}
if (data.isNodal())
continue;
auto size = data.size();
if (size == 0)
continue;
auto && nb_components = data.getNbComponents();
auto nb_component = nb_components(*(data.elementTypes().begin()));
outfile << "$ElementData"
<< "\n";
outfile << "1"
<< "\n";
outfile << "\"" << tag << "\"\n";
outfile << "1\n0.0"
<< "\n";
outfile << "3\n0"
<< "\n";
outfile << nb_component << "\n";
outfile << size << "\n";
Element element;
for (auto type : data.elementTypes()) {
element.type = type;
for (auto && _ :
enumerate(make_view(data(type), nb_components(type)))) {
element.element = std::get<0>(_);
outfile << element_to_msh_element[element];
for (auto && v : std::get<1>(_)) {
outfile << " " << v;
}
outfile << "\n";
}
}
outfile << "$EndElementData"
<< "\n";
}
}
outfile.close();
}
/* --------------------------------------------------------------------------
*/
} // namespace akantu
diff --git a/src/io/mesh_io/mesh_io_msh_struct.cc b/src/io/mesh_io/mesh_io_msh_struct.cc
index 55300ef69..41eac26da 100644
--- a/src/io/mesh_io/mesh_io_msh_struct.cc
+++ b/src/io/mesh_io/mesh_io_msh_struct.cc
@@ -1,80 +1,80 @@
/**
* @file mesh_io_msh_struct.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Fri Jan 26 2018
*
* @brief Read/Write for MSH files generated by gmsh
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_io_msh_struct.hh"
/* -------------------------------------------------------------------------- */
#include <numeric>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
MeshIOMSHStruct::MeshIOMSHStruct() : MeshIOMSH() {
canReadSurface = true;
canReadExtendedData = true;
_msh_to_akantu_element_types.clear();
_msh_to_akantu_element_types[_msh_not_defined] = _not_defined;
_msh_to_akantu_element_types[_msh_segment_2] = _bernoulli_beam_2;
_msh_to_akantu_element_types[_msh_triangle_3] =
_discrete_kirchhoff_triangle_18;
_akantu_to_msh_element_types.clear();
_akantu_to_msh_element_types[_not_defined] = _msh_not_defined;
_akantu_to_msh_element_types[_bernoulli_beam_2] = _msh_segment_2;
_akantu_to_msh_element_types[_bernoulli_beam_3] = _msh_segment_2;
_akantu_to_msh_element_types[_discrete_kirchhoff_triangle_18] =
_msh_triangle_3;
for (auto & kv_pair : _akantu_to_msh_element_types) {
UInt nb_nodes = _msh_nodes_per_elem[kv_pair.second];
std::vector<UInt> tmp(nb_nodes);
std::iota(tmp.begin(), tmp.end(), 0);
_read_order[kv_pair.first] = tmp;
}
}
/* -------------------------------------------------------------------------- */
void MeshIOMSHStruct::read(const std::string & filename, Mesh & mesh) {
if (mesh.getSpatialDimension() == 2) {
_msh_to_akantu_element_types[_msh_segment_2] = _bernoulli_beam_2;
} else if (mesh.getSpatialDimension() == 3) {
_msh_to_akantu_element_types[_msh_segment_2] = _bernoulli_beam_3;
AKANTU_DEBUG_WARNING("The MeshIOMSHStruct is reading bernoulli beam 3D be "
"sure to provide the missing normals with the element "
"data \"extra_normal\"");
}
MeshIOMSH::read(filename, mesh);
}
-} // akantu
+} // namespace akantu
diff --git a/src/io/mesh_io/mesh_io_msh_struct.hh b/src/io/mesh_io/mesh_io_msh_struct.hh
index 542d65743..bcc553f50 100644
--- a/src/io/mesh_io/mesh_io_msh_struct.hh
+++ b/src/io/mesh_io/mesh_io_msh_struct.hh
@@ -1,54 +1,54 @@
/**
* @file mesh_io_msh_struct.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Fri Jan 26 2018
*
* @brief Read/Write for MSH files
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_IO_MSH_STRUCT_HH__
#define __AKANTU_MESH_IO_MSH_STRUCT_HH__
/* -------------------------------------------------------------------------- */
#include "mesh_io.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class MeshIOMSHStruct : public MeshIOMSH {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MeshIOMSHStruct();
/// read a mesh from the file
void read(const std::string & filename, Mesh & mesh) override;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_IO_MSH_STRUCT_HH__ */
diff --git a/src/io/parser/algebraic_parser.hh b/src/io/parser/algebraic_parser.hh
index bfecaeb63..2f66e8509 100644
--- a/src/io/parser/algebraic_parser.hh
+++ b/src/io/parser/algebraic_parser.hh
@@ -1,512 +1,512 @@
/**
* @file algebraic_parser.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Wed Nov 08 2017
*
* @brief algebraic_parser definition of the grammar
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
// Boost
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <boost/spirit/include/qi.hpp>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ALGEBRAIC_PARSER_HH__
#define __AKANTU_ALGEBRAIC_PARSER_HH__
namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
namespace lbs = boost::spirit::qi::labels;
namespace ascii = boost::spirit::ascii;
namespace phx = boost::phoenix;
namespace akantu {
namespace parser {
struct algebraic_error_handler_ {
template <typename, typename, typename> struct result {
using type = void;
};
template <typename Iterator>
void operator()(qi::info const & what, Iterator err_pos,
Iterator last) const {
AKANTU_EXCEPTION(
"Error! Expecting "
<< what // what failed?
<< " here: \""
<< std::string(err_pos, last) // iterators to error-pos, end
<< "\"");
}
};
static Real my_min(Real a, Real b) { return std::min(a, b); }
static Real my_max(Real a, Real b) { return std::max(a, b); }
static Real my_pow(Real a, Real b) { return std::pow(a, b); }
static Real eval_param(const ID & a, const ParserSection & section) {
return section.getParameter(a, _ppsc_current_and_parent_scope);
}
static Real unary_func(Real (*func)(Real), Real a) { return func(a); }
static Real binary_func(Real (*func)(Real, Real), Real a, Real b) {
return func(a, b);
}
template <class Iterator, typename Skipper = spirit::unused_type>
struct AlgebraicGrammar : qi::grammar<Iterator, Real(), Skipper> {
AlgebraicGrammar(const ParserSection & section)
: AlgebraicGrammar::base_type(start, "algebraic_grammar"),
section(section) {
// phx::function<lazy_pow_> lazy_pow;
// phx::function<lazy_unary_func_> lazy_unary_func;
// phx::function<lazy_binary_func_> lazy_binary_func;
// phx::function<lazy_eval_param_> lazy_eval_param;
/* clang-format off */
start
= expr.alias()
;
expr
= term [ lbs::_val = lbs::_1 ]
>> *( ('+' > term [ lbs::_val += lbs::_1 ])
| ('-' > term [ lbs::_val -= lbs::_1 ])
)
;
term
= factor [ lbs::_val = lbs::_1 ]
>> *( ('*' > factor [ lbs::_val *= lbs::_1 ])
| ('/' > factor [ lbs::_val /= lbs::_1 ])
)
;
factor
= number [ lbs::_val = lbs::_1 ]
>> *("**" > number [ lbs::_val = phx::bind(&my_pow, lbs::_val, lbs::_1) ])
;
number
= real [ lbs::_val = lbs::_1 ]
| ('-' > number [ lbs::_val = -lbs::_1 ])
| ('+' > number [ lbs::_val = lbs::_1 ])
| constant [ lbs::_val = lbs::_1 ]
| function [ lbs::_val = lbs::_1 ]
| ('(' > expr > ')') [ lbs::_val = lbs::_1 ]
| variable [ lbs::_val = lbs::_1 ]
;
function
= (qi::no_case[unary_function]
> '('
> expr
> ')') [ lbs::_val = phx::bind(&unary_func, lbs::_1, lbs::_2) ]
| (qi::no_case[binary_function]
> '(' >> expr
> ',' >> expr
> ')') [ lbs::_val = phx::bind(&binary_func ,lbs::_1, lbs::_2, lbs::_3) ]
;
variable
= key [ lbs::_val = phx::bind(&eval_param, lbs::_1, section) ]
;
key
= qi::no_skip[qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9")] // coming from the InputFileGrammar
;
#ifndef M_PI
# define M_PI 3.14159265358979323846
#endif
#ifndef M_E
# define M_E 2.7182818284590452354
#endif
constant.add
("pi", M_PI)
("e", M_E);
unary_function.add
("abs" , &std::abs )
("acos" , &std::acos )
("asin" , &std::asin )
("atan" , &std::atan )
("ceil" , &std::ceil )
("cos" , &std::cos )
("cosh" , &std::cosh )
("exp" , &std::exp )
("floor" , &std::floor )
("log10" , &std::log10 )
("log" , &std::log )
("sin" , &std::sin )
("sinh" , &std::sinh )
("sqrt" , &std::sqrt )
("tan" , &std::tan )
("tanh" , &std::tanh )
("acosh" , &std::acosh )
("asinh" , &std::asinh )
("atanh" , &std::atanh )
("exp2" , &std::exp2 )
("expm1" , &std::expm1 )
("log1p" , &std::log1p )
("log2" , &std::log2 )
("erf" , &std::erf )
("erfc" , &std::erfc )
("lgamma", &std::lgamma)
("tgamma", &std::tgamma)
("trunc" , &std::trunc )
("round" , &std::round )
// ("crbt" , &std::crbt )
;
binary_function.add
("pow" , &std::pow )
("min" , &parser::my_min)
("max" , &parser::my_max)
("atan2", &std::atan2 )
("fmod" , &std::fmod )
("hypot", &std::hypot )
;
#if !defined(AKANTU_NDEBUG)
phx::function<algebraic_error_handler_> const error_handler = algebraic_error_handler_();
qi::on_error<qi::fail>(start, error_handler(lbs::_4, lbs::_3, lbs::_2));
#endif
expr .name("expression");
term .name("term");
factor .name("factor");
number .name("numerical-value");
variable.name("variable");
function.name("function");
constant.name("constants-list");
unary_function.name("unary-functions-list");
binary_function.name("binary-functions-list");
#if !defined AKANTU_NDEBUG
if(AKANTU_DEBUG_TEST(dblDebug)) {
qi::debug(expr);
qi::debug(term);
qi::debug(factor);
qi::debug(number);
qi::debug(variable);
qi::debug(function);
}
#endif
}
/* clang-format on */
private:
qi::rule<Iterator, Real(), Skipper> start;
qi::rule<Iterator, Real(), Skipper> expr;
qi::rule<Iterator, Real(), Skipper> term;
qi::rule<Iterator, Real(), Skipper> factor;
qi::rule<Iterator, Real(), Skipper> number;
qi::rule<Iterator, Real(), Skipper> variable;
qi::rule<Iterator, Real(), Skipper> function;
qi::rule<Iterator, std::string(), Skipper> key;
qi::real_parser<Real, qi::real_policies<Real>> real;
qi::symbols<char, Real> constant;
qi::symbols<char, Real (*)(Real)> unary_function;
qi::symbols<char, Real (*)(Real, Real)> binary_function;
const ParserSection & section;
};
/* ---------------------------------------------------------------------- */
/* Vector Parser */
/* ---------------------------------------------------------------------- */
struct parsable_vector {
operator Vector<Real>() {
Vector<Real> tmp(_cells.size());
auto it = _cells.begin();
for (UInt i = 0; it != _cells.end(); ++it, ++i)
tmp(i) = *it;
return tmp;
}
std::vector<Real> _cells;
};
inline std::ostream & operator<<(std::ostream & stream,
const parsable_vector & pv) {
stream << "pv[";
auto it = pv._cells.begin();
if (it != pv._cells.end()) {
stream << *it;
for (++it; it != pv._cells.end(); ++it)
stream << ", " << *it;
}
stream << "]";
return stream;
}
struct parsable_matrix {
operator Matrix<Real>() {
size_t cols = 0;
auto it_rows = _cells.begin();
for (; it_rows != _cells.end(); ++it_rows)
cols = std::max(cols, it_rows->_cells.size());
Matrix<Real> tmp(_cells.size(), _cells[0]._cells.size(), 0.);
it_rows = _cells.begin();
for (UInt i = 0; it_rows != _cells.end(); ++it_rows, ++i) {
auto it_cols = it_rows->_cells.begin();
for (UInt j = 0; it_cols != it_rows->_cells.end(); ++it_cols, ++j) {
tmp(i, j) = *it_cols;
}
}
return tmp;
}
std::vector<parsable_vector> _cells;
};
inline std::ostream & operator<<(std::ostream & stream,
const parsable_matrix & pm) {
stream << "pm[";
auto it = pm._cells.begin();
if (it != pm._cells.end()) {
stream << *it;
for (++it; it != pm._cells.end(); ++it)
stream << ", " << *it;
}
stream << "]";
return stream;
}
/* ---------------------------------------------------------------------- */
template <typename T1, typename T2>
static void cont_add(T1 & cont, T2 & value) {
cont._cells.push_back(value);
}
/* ---------------------------------------------------------------------- */
template <class Iterator, typename Skipper = spirit::unused_type>
struct VectorGrammar : qi::grammar<Iterator, parsable_vector(), Skipper> {
VectorGrammar(const ParserSection & section)
: VectorGrammar::base_type(start, "vector_algebraic_grammar"),
number(section) {
start = '[' > vector > ']';
vector =
(number[phx::bind(&cont_add<parsable_vector, Real>, lbs::_a,
lbs::_1)] >>
*(',' >> number[phx::bind(&cont_add<parsable_vector, Real>, lbs::_a,
lbs::_1)]))[lbs::_val = lbs::_a];
-#if !defined(AKANTU_NDEBUG) && defined(AKANTU_CORE_CXX_11)
+#if !defined(AKANTU_NDEBUG)
phx::function<algebraic_error_handler_> const error_handler =
algebraic_error_handler_();
qi::on_error<qi::fail>(start, error_handler(lbs::_4, lbs::_3, lbs::_2));
#endif
start.name("start");
vector.name("vector");
number.name("value");
#if !defined AKANTU_NDEBUG
if (AKANTU_DEBUG_TEST(dblDebug)) {
qi::debug(start);
qi::debug(vector);
}
#endif
}
private:
qi::rule<Iterator, parsable_vector(), Skipper> start;
qi::rule<Iterator, parsable_vector(), qi::locals<parsable_vector>, Skipper>
vector;
qi::rule<Iterator, Real(), Skipper> value;
AlgebraicGrammar<Iterator, Skipper> number;
};
/* ---------------------------------------------------------------------- */
static inline bool vector_eval(const ID & a, const ParserSection & section,
parsable_vector & result) {
std::string value = section.getParameter(a, _ppsc_current_and_parent_scope);
std::string::const_iterator b = value.begin();
std::string::const_iterator e = value.end();
parser::VectorGrammar<std::string::const_iterator, qi::space_type> grammar(
section);
return qi::phrase_parse(b, e, grammar, qi::space, result);
}
/* ---------------------------------------------------------------------- */
template <class Iterator, typename Skipper = spirit::unused_type>
struct MatrixGrammar : qi::grammar<Iterator, parsable_matrix(), Skipper> {
MatrixGrammar(const ParserSection & section)
: MatrixGrammar::base_type(start, "matrix_algebraic_grammar"),
vector(section) {
start = '[' >> matrix >> ']';
matrix =
(rows[phx::bind(&cont_add<parsable_matrix, parsable_vector>, lbs::_a,
lbs::_1)] >>
*(',' >> rows[phx::bind(&cont_add<parsable_matrix, parsable_vector>,
lbs::_a, lbs::_1)]))[lbs::_val = lbs::_a];
rows = eval_vector | vector;
eval_vector = (key[lbs::_pass = phx::bind(&vector_eval, lbs::_1, section,
lbs::_a)])[lbs::_val = lbs::_a];
key = qi::char_("a-zA-Z_") >>
*qi::char_("a-zA-Z_0-9") // coming from the InputFileGrammar
;
-#if !defined(AKANTU_NDEBUG) && defined(AKANTU_CORE_CXX_11)
+#if !defined(AKANTU_NDEBUG)
phx::function<algebraic_error_handler_> const error_handler =
algebraic_error_handler_();
qi::on_error<qi::fail>(start, error_handler(lbs::_4, lbs::_3, lbs::_2));
#endif
start.name("matrix");
matrix.name("all_rows");
rows.name("rows");
vector.name("vector");
eval_vector.name("eval_vector");
#ifndef AKANTU_NDEBUG
if (AKANTU_DEBUG_TEST(dblDebug)) {
qi::debug(start);
qi::debug(matrix);
qi::debug(rows);
qi::debug(eval_vector);
qi::debug(key);
}
#endif
}
private:
qi::rule<Iterator, parsable_matrix(), Skipper> start;
qi::rule<Iterator, parsable_matrix(), qi::locals<parsable_matrix>, Skipper>
matrix;
qi::rule<Iterator, parsable_vector(), Skipper> rows;
qi::rule<Iterator, parsable_vector(), qi::locals<parsable_vector>, Skipper>
eval_vector;
qi::rule<Iterator, std::string(), Skipper> key;
VectorGrammar<Iterator, Skipper> vector;
};
/* ---------------------------------------------------------------------- */
/* Randon Generator */
/* ---------------------------------------------------------------------- */
struct ParsableRandomGenerator {
ParsableRandomGenerator(
Real base = Real(),
const RandomDistributionType & type = _rdt_not_defined,
const parsable_vector & parameters = parsable_vector())
: base(base), type(type), parameters(parameters) {}
Real base;
RandomDistributionType type;
parsable_vector parameters;
};
inline std::ostream & operator<<(std::ostream & stream,
const ParsableRandomGenerator & prg) {
stream << "prg[" << prg.base << " " << UInt(prg.type) << " "
<< prg.parameters << "]";
return stream;
}
/* ---------------------------------------------------------------------- */
template <class Iterator, typename Skipper = spirit::unused_type>
struct RandomGeneratorGrammar
: qi::grammar<Iterator, ParsableRandomGenerator(), Skipper> {
RandomGeneratorGrammar(const ParserSection & section)
: RandomGeneratorGrammar::base_type(start, "random_generator_grammar"),
number(section) {
start = generator.alias();
generator =
qi::hold[distribution[lbs::_val = lbs::_1]] |
number[lbs::_val = phx::construct<ParsableRandomGenerator>(lbs::_1)];
distribution = (number >> generator_type >> '[' >> generator_params >>
']')[lbs::_val = phx::construct<ParsableRandomGenerator>(
lbs::_1, lbs::_2, lbs::_3)];
generator_params =
(number[phx::bind(&cont_add<parsable_vector, Real>, lbs::_a,
lbs::_1)] >>
*(',' > number[phx::bind(&cont_add<parsable_vector, Real>, lbs::_a,
lbs::_1)]))[lbs::_val = lbs::_a];
#define AKANTU_RANDOM_DISTRIBUTION_TYPE_ADD(r, data, elem) \
(BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 0, elem)), \
AKANTU_RANDOM_DISTRIBUTION_TYPES_PREFIX(BOOST_PP_TUPLE_ELEM(2, 0, elem)))
generator_type.add BOOST_PP_SEQ_FOR_EACH(
AKANTU_RANDOM_DISTRIBUTION_TYPE_ADD, _,
AKANTU_RANDOM_DISTRIBUTION_TYPES);
#undef AKANTU_RANDOM_DISTRIBUTION_TYPE_ADD
-#if !defined(AKANTU_NDEBUG) && defined(AKANTU_CORE_CXX_11)
+#if !defined(AKANTU_NDEBUG)
phx::function<algebraic_error_handler_> const error_handler =
algebraic_error_handler_();
qi::on_error<qi::fail>(start, error_handler(lbs::_4, lbs::_3, lbs::_2));
#endif
start.name("random-generator");
generator.name("random-generator");
distribution.name("random-distribution");
generator_type.name("generator-type");
generator_params.name("generator-parameters");
number.name("number");
#ifndef AKANTU_NDEBUG
if (AKANTU_DEBUG_TEST(dblDebug)) {
qi::debug(generator);
qi::debug(distribution);
qi::debug(generator_params);
}
#endif
}
private:
qi::rule<Iterator, ParsableRandomGenerator(), Skipper> start;
qi::rule<Iterator, ParsableRandomGenerator(), Skipper> generator;
qi::rule<Iterator, ParsableRandomGenerator(), Skipper> distribution;
qi::rule<Iterator, parsable_vector(), qi::locals<parsable_vector>, Skipper>
generator_params;
AlgebraicGrammar<Iterator, Skipper> number;
qi::symbols<char, RandomDistributionType> generator_type;
};
-}
-}
+} // namespace parser
+} // namespace akantu
#endif /* __AKANTU_ALGEBRAIC_PARSER_HH__ */
diff --git a/src/io/parser/cppargparse/cppargparse.cc b/src/io/parser/cppargparse/cppargparse.cc
index 301ae0290..36e475949 100644
--- a/src/io/parser/cppargparse/cppargparse.cc
+++ b/src/io/parser/cppargparse/cppargparse.cc
@@ -1,523 +1,523 @@
/**
* @file cppargparse.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Apr 03 2014
* @date last modification: Wed Nov 08 2017
*
* @brief implementation of the ArgumentParser
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "cppargparse.hh"
#include <cstdlib>
#include <cstring>
#include <libgen.h>
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <sstream>
#include <string>
#include <exception>
#include <stdexcept>
#include <string.h>
namespace cppargparse {
/* -------------------------------------------------------------------------- */
static inline std::string to_upper(const std::string & str) {
std::string lstr = str;
std::transform(lstr.begin(), lstr.end(), lstr.begin(),
(int (*)(int))std::toupper);
return lstr;
}
/* -------------------------------------------------------------------------- */
/* ArgumentParser */
/* -------------------------------------------------------------------------- */
ArgumentParser::ArgumentParser() {
this->addArgument("-h;--help", "show this help message and exit", 0, _boolean,
false, true);
}
/* -------------------------------------------------------------------------- */
ArgumentParser::~ArgumentParser() {
for (auto it = arguments.begin(); it != arguments.end(); ++it) {
delete it->second;
}
}
/* -------------------------------------------------------------------------- */
void ArgumentParser::setParallelContext(int prank, int psize) {
this->prank = prank;
this->psize = psize;
}
/* -------------------------------------------------------------------------- */
void ArgumentParser::_exit(const std::string & msg, int status) {
if (prank == 0) {
if (msg != "") {
std::cerr << msg << std::endl;
std::cerr << std::endl;
}
this->print_help(std::cerr);
}
if (external_exit)
(*external_exit)(status);
else {
exit(status);
}
}
/* -------------------------------------------------------------------------- */
const ArgumentParser::Argument & ArgumentParser::
operator[](const std::string & name) const {
auto it = success_parsed.find(name);
if (it != success_parsed.end()) {
return *(it->second);
} else {
throw std::range_error("No argument named \'" + name +
"\' was found in the parsed argument," +
" make sur to specify it \'required\'" +
" or to give it a default value");
}
}
/* -------------------------------------------------------------------------- */
bool ArgumentParser::has(const std::string & name) const {
return (success_parsed.find(name) != success_parsed.end());
}
/* -------------------------------------------------------------------------- */
void ArgumentParser::addArgument(const std::string & name_or_flag,
const std::string & help, int nargs,
ArgumentType type) {
_addArgument(name_or_flag, help, nargs, type);
}
/* -------------------------------------------------------------------------- */
ArgumentParser::_Argument &
ArgumentParser::_addArgument(const std::string & name, const std::string & help,
int nargs, ArgumentType type) {
_Argument * arg = nullptr;
switch (type) {
case _string: {
arg = new ArgumentStorage<std::string>();
break;
}
case _float: {
arg = new ArgumentStorage<double>();
break;
}
case _integer: {
arg = new ArgumentStorage<long int>();
break;
}
case _boolean: {
arg = new ArgumentStorage<bool>();
break;
}
}
arg->help = help;
arg->nargs = nargs;
arg->type = type;
std::stringstream sstr(name);
std::string item;
std::vector<std::string> tmp_keys;
while (std::getline(sstr, item, ';')) {
tmp_keys.push_back(item);
}
int long_key = -1;
int short_key = -1;
bool problem = (tmp_keys.size() > 2) || (name == "");
for (auto it = tmp_keys.begin(); it != tmp_keys.end(); ++it) {
if (it->find("--") == 0) {
problem |= (long_key != -1);
long_key = it - tmp_keys.begin();
} else if (it->find("-") == 0) {
problem |= (long_key != -1);
short_key = it - tmp_keys.begin();
}
}
problem |= ((tmp_keys.size() == 2) && (long_key == -1 || short_key == -1));
if (problem) {
delete arg;
throw std::invalid_argument("Synthax of name or flags is not correct. "
"Possible synthax are \'-f\', \'-f;--foo\', "
"\'--foo\', \'bar\'");
}
if (long_key != -1) {
arg->name = tmp_keys[long_key];
arg->name.erase(0, 2);
} else if (short_key != -1) {
arg->name = tmp_keys[short_key];
arg->name.erase(0, 1);
} else {
arg->name = tmp_keys[0];
pos_args.push_back(arg);
arg->required = (nargs != _one_if_possible);
arg->is_positional = true;
}
arguments[arg->name] = arg;
if (!arg->is_positional) {
if (short_key != -1) {
std::string key = tmp_keys[short_key];
key_args[key] = arg;
arg->keys.push_back(key);
}
if (long_key != -1) {
std::string key = tmp_keys[long_key];
key_args[key] = arg;
arg->keys.push_back(key);
}
}
return *arg;
}
#if not HAVE_STRDUP
static char * strdup(const char * str) {
size_t len = strlen(str);
auto * x = (char *)malloc(len + 1); /* 1 for the null terminator */
if (!x)
return nullptr; /* malloc could not allocate memory */
memcpy(x, str, len + 1); /* copy the string into the new buffer */
return x;
}
#endif
/* -------------------------------------------------------------------------- */
void ArgumentParser::parse(int & argc, char **& argv, int flags,
bool parse_help) {
bool stop_in_not_parsed = flags & _stop_on_not_parsed;
bool remove_parsed = flags & _remove_parsed;
std::vector<std::string> argvs;
argvs.reserve(argc);
for (int i = 0; i < argc; ++i) {
argvs.emplace_back(argv[i]);
}
unsigned int current_position = 0;
if (this->program_name == "" && argc > 0) {
std::string prog = argvs[current_position];
const char * c_prog = prog.c_str();
char * c_prog_tmp = strdup(c_prog);
std::string base_prog(basename(c_prog_tmp));
this->program_name = base_prog;
std::free(c_prog_tmp);
}
std::queue<_Argument *> positional_queue;
for (auto it = pos_args.begin(); it != pos_args.end(); ++it)
positional_queue.push(*it);
std::vector<int> argvs_to_remove;
++current_position; // consume argv[0]
while (current_position < argvs.size()) {
std::string arg = argvs[current_position];
++current_position;
auto key_it = key_args.find(arg);
bool is_positional = false;
_Argument * argument_ptr = nullptr;
if (key_it == key_args.end()) {
if (positional_queue.empty()) {
if (stop_in_not_parsed)
this->_exit("Argument " + arg + " not recognized", EXIT_FAILURE);
continue;
} else {
argument_ptr = positional_queue.front();
is_positional = true;
--current_position;
}
} else {
argument_ptr = key_it->second;
}
if (remove_parsed && !is_positional && argument_ptr->name != "help") {
argvs_to_remove.push_back(current_position - 1);
}
_Argument & argument = *argument_ptr;
unsigned int min_nb_val = 0, max_nb_val = 0;
switch (argument.nargs) {
case _one_if_possible:
max_nb_val = 1;
break; // "?"
case _at_least_one:
min_nb_val = 1; // "+"
/* FALLTHRU */
/* [[fallthrough]]; un-comment when compiler will get it*/
case _any:
max_nb_val = argc - current_position;
break; // "*"
default:
min_nb_val = max_nb_val = argument.nargs; // "N"
}
std::vector<std::string> values;
unsigned int arg_consumed = 0;
if (max_nb_val <= (argc - current_position)) {
for (; arg_consumed < max_nb_val; ++arg_consumed) {
std::string v = argvs[current_position];
++current_position;
bool is_key = key_args.find(v) != key_args.end();
bool is_good_type = checkType(argument.type, v);
if (!is_key && is_good_type) {
values.push_back(v);
if (remove_parsed)
argvs_to_remove.push_back(current_position - 1);
} else {
// unconsume not parsed argument for optional
if (!is_positional || is_key)
--current_position;
break;
}
}
}
if (arg_consumed < min_nb_val) {
if (!is_positional) {
this->_exit("Not enought values for the argument " + argument.name +
" where provided",
EXIT_FAILURE);
} else {
if (stop_in_not_parsed)
this->_exit("Argument " + arg + " not recognized", EXIT_FAILURE);
}
} else {
if (is_positional)
positional_queue.pop();
if (!argument.parsed) {
success_parsed[argument.name] = &argument;
argument.parsed = true;
if ((argument.nargs == _one_if_possible || argument.nargs == 0) &&
arg_consumed == 0) {
if (argument.has_const)
argument.setToConst();
else if (argument.has_default)
argument.setToDefault();
} else {
argument.setValues(values);
}
} else {
this->_exit("Argument " + argument.name +
" already present in the list of argument",
EXIT_FAILURE);
}
}
}
for (auto ait = arguments.begin(); ait != arguments.end(); ++ait) {
_Argument & argument = *(ait->second);
if (!argument.parsed) {
if (argument.has_default) {
argument.setToDefault();
success_parsed[argument.name] = &argument;
}
if (argument.required) {
this->_exit("Argument " + argument.name + " required but not given!",
EXIT_FAILURE);
}
}
}
// removing the parsed argument if remove_parsed is true
if (argvs_to_remove.size()) {
std::vector<int>::const_iterator next_to_remove = argvs_to_remove.begin();
for (int i = 0, c = 0; i < argc; ++i) {
if (next_to_remove == argvs_to_remove.end() || i != *next_to_remove) {
argv[c] = argv[i];
++c;
} else {
if (next_to_remove != argvs_to_remove.end())
++next_to_remove;
}
}
argc -= argvs_to_remove.size();
}
this->argc = &argc;
this->argv = &argv;
if (this->arguments["help"]->parsed && parse_help) {
this->_exit();
}
}
/* -------------------------------------------------------------------------- */
bool ArgumentParser::checkType(ArgumentType type,
const std::string & value) const {
std::stringstream sstr(value);
switch (type) {
case _string: {
std::string s;
sstr >> s;
break;
}
case _float: {
double d;
sstr >> d;
break;
}
case _integer: {
long int i;
sstr >> i;
break;
}
case _boolean: {
bool b;
sstr >> b;
break;
}
}
return (sstr.fail() == false);
}
/* -------------------------------------------------------------------------- */
void ArgumentParser::printself(std::ostream & stream) const {
for (auto it = success_parsed.begin(); it != success_parsed.end(); ++it) {
const Argument & argument = *(it->second);
argument.printself(stream);
stream << std::endl;
}
}
/* -------------------------------------------------------------------------- */
void ArgumentParser::print_usage(std::ostream & stream) const {
stream << "Usage: " << this->program_name;
// print shorten usage
for (auto it = arguments.begin(); it != arguments.end(); ++it) {
const _Argument & argument = *(it->second);
if (!argument.is_positional) {
if (!argument.required)
stream << " [";
stream << argument.keys[0];
this->print_usage_nargs(stream, argument);
if (!argument.required)
stream << "]";
}
}
for (auto it = pos_args.begin(); it != pos_args.end(); ++it) {
const _Argument & argument = **it;
this->print_usage_nargs(stream, argument);
}
stream << std::endl;
}
/* -------------------------------------------------------------------------- */
void ArgumentParser::print_usage_nargs(std::ostream & stream,
const _Argument & argument) const {
std::string u_name = to_upper(argument.name);
switch (argument.nargs) {
case _one_if_possible:
stream << " [" << u_name << "]";
break;
case _at_least_one:
stream << " " << u_name;
/* FALLTHRU */
/* [[fallthrough]]; un-comment when compiler will get it */
case _any:
stream << " [" << u_name << " ...]";
break;
default:
for (int i = 0; i < argument.nargs; ++i) {
stream << " " << u_name;
}
}
}
void ArgumentParser::print_help(std::ostream & stream) const {
this->print_usage(stream);
if (!pos_args.empty()) {
stream << std::endl;
stream << "positional arguments:" << std::endl;
for (auto it = pos_args.begin(); it != pos_args.end(); ++it) {
const _Argument & argument = **it;
this->print_help_argument(stream, argument);
}
}
if (!key_args.empty()) {
stream << std::endl;
stream << "optional arguments:" << std::endl;
for (auto it = arguments.begin(); it != arguments.end(); ++it) {
const _Argument & argument = *(it->second);
if (!argument.is_positional) {
this->print_help_argument(stream, argument);
}
}
}
}
void ArgumentParser::print_help_argument(std::ostream & stream,
const _Argument & argument) const {
std::string key("");
if (argument.is_positional)
key = argument.name;
else {
std::stringstream sstr;
for (unsigned int i = 0; i < argument.keys.size(); ++i) {
if (i != 0)
sstr << ", ";
sstr << argument.keys[i];
this->print_usage_nargs(sstr, argument);
}
key = sstr.str();
}
stream << " " << std::left << std::setw(15) << key << " " << argument.help;
argument.printDefault(stream);
stream << std::endl;
}
-}
+} // namespace cppargparse
diff --git a/src/io/parser/cppargparse/cppargparse_tmpl.hh b/src/io/parser/cppargparse/cppargparse_tmpl.hh
index 9dcad76df..b4ed79f87 100644
--- a/src/io/parser/cppargparse/cppargparse_tmpl.hh
+++ b/src/io/parser/cppargparse/cppargparse_tmpl.hh
@@ -1,240 +1,240 @@
/**
* @file cppargparse_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Apr 03 2014
* @date last modification: Wed Nov 08 2017
*
* @brief Implementation of the templated part of the commandline argument
* parser
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <sstream>
#include <stdexcept>
#ifndef __CPPARGPARSE_TMPL_HH__
#define __CPPARGPARSE_TMPL_HH__
namespace cppargparse {
/* -------------------------------------------------------------------------- */
/* Argument */
/* -------------------------------------------------------------------------- */
/// internal description of arguments
struct ArgumentParser::_Argument : public Argument {
_Argument() : Argument(), help(std::string()) {}
~_Argument() override = default;
void setValues(std::vector<std::string> & values) {
for (auto it = values.begin(); it != values.end(); ++it) {
this->addValue(*it);
}
}
virtual void addValue(std::string & value) = 0;
virtual void setToDefault() = 0;
virtual void setToConst() = 0;
std::ostream & printDefault(std::ostream & stream) const {
stream << std::boolalpha;
if (has_default) {
stream << " (default: ";
this->_printDefault(stream);
stream << ")";
}
if (has_const) {
stream << " (const: ";
this->_printConst(stream);
stream << ")";
}
return stream;
}
virtual std::ostream & _printDefault(std::ostream & stream) const = 0;
virtual std::ostream & _printConst(std::ostream & stream) const = 0;
std::string help;
int nargs{1};
ArgumentType type{_string};
bool required{false};
bool parsed{false};
bool has_default{false};
bool has_const{false};
std::vector<std::string> keys;
bool is_positional{false};
};
/* -------------------------------------------------------------------------- */
/// typed storage of the arguments
template <class T>
class ArgumentParser::ArgumentStorage : public ArgumentParser::_Argument {
public:
ArgumentStorage() : _default(T()), _const(T()), values(std::vector<T>()) {}
void addValue(std::string & value) override {
std::stringstream sstr(value);
T t;
sstr >> t;
values.push_back(t);
}
void setToDefault() override {
values.clear();
values.push_back(_default);
}
void setToConst() override {
values.clear();
values.push_back(_const);
}
void printself(std::ostream & stream) const override {
stream << this->name << " =";
stream << std::boolalpha; // for boolean
for (auto vit = this->values.begin(); vit != this->values.end(); ++vit) {
stream << " " << *vit;
}
}
std::ostream & _printDefault(std::ostream & stream) const override {
stream << _default;
return stream;
}
std::ostream & _printConst(std::ostream & stream) const override {
stream << _const;
return stream;
}
T _default;
T _const;
std::vector<T> values;
};
/* -------------------------------------------------------------------------- */
template <>
inline void
ArgumentParser::ArgumentStorage<std::string>::addValue(std::string & value) {
values.push_back(value);
}
template <class T> struct is_vector {
enum { value = false };
};
template <class T> struct is_vector<std::vector<T>> {
enum { value = true };
};
/* -------------------------------------------------------------------------- */
template <class T, bool is_vector = cppargparse::is_vector<T>::value>
struct cast_helper {
static T cast(const ArgumentParser::Argument & arg) {
const auto & _arg =
dynamic_cast<const ArgumentParser::ArgumentStorage<T> &>(arg);
if (_arg.values.size() == 1) {
return _arg.values[0];
} else {
throw std::length_error("Not enougth or too many argument where passed "
"for the command line argument: " +
arg.name);
}
}
};
template <class T> struct cast_helper<T, true> {
static T cast(const ArgumentParser::Argument & arg) {
const auto & _arg =
dynamic_cast<const ArgumentParser::ArgumentStorage<T> &>(arg);
return _arg.values;
}
};
/* -------------------------------------------------------------------------- */
template <class T> ArgumentParser::Argument::operator T() const {
return cast_helper<T>::cast(*this);
}
template <> inline ArgumentParser::Argument::operator const char *() const {
return cast_helper<std::string>::cast(*this).c_str();
}
template <> inline ArgumentParser::Argument::operator unsigned int() const {
return cast_helper<int>::cast(*this);
}
template <class T>
void ArgumentParser::addArgument(const std::string & name_or_flag,
const std::string & help, int nargs,
ArgumentType type, T def) {
_Argument & arg = _addArgument(name_or_flag, help, nargs, type);
dynamic_cast<ArgumentStorage<T> &>(arg)._default = def;
arg.has_default = true;
}
template <class T>
void ArgumentParser::addArgument(const std::string & name_or_flag,
const std::string & help, int nargs,
ArgumentType type, T def, T cons) {
_Argument & arg = _addArgument(name_or_flag, help, nargs, type);
dynamic_cast<ArgumentStorage<T> &>(arg)._default = def;
arg.has_default = true;
dynamic_cast<ArgumentStorage<T> &>(arg)._const = cons;
arg.has_const = true;
}
/* -------------------------------------------------------------------------- */
template <>
inline void
ArgumentParser::addArgument<const char *>(const std::string & name_or_flag,
const std::string & help, int nargs,
ArgumentType type, const char * def) {
this->addArgument<std::string>(name_or_flag, help, nargs, type, def);
}
template <>
inline void
ArgumentParser::addArgument<unsigned int>(const std::string & name_or_flag,
const std::string & help, int nargs,
ArgumentType type, unsigned int def) {
this->addArgument<int>(name_or_flag, help, nargs, type, def);
}
/* -------------------------------------------------------------------------- */
template <>
inline void ArgumentParser::addArgument<const char *>(
const std::string & name_or_flag, const std::string & help, int nargs,
ArgumentType type, const char * def, const char * cons) {
this->addArgument<std::string>(name_or_flag, help, nargs, type, def, cons);
}
template <>
inline void ArgumentParser::addArgument<unsigned int>(
const std::string & name_or_flag, const std::string & help, int nargs,
ArgumentType type, unsigned int def, unsigned int cons) {
this->addArgument<int>(name_or_flag, help, nargs, type, def, cons);
}
-}
+} // namespace cppargparse
#endif /* __AKANTU_CPPARGPARSE_TMPL_HH__ */
diff --git a/src/io/parser/input_file_parser.hh b/src/io/parser/input_file_parser.hh
index 8de5904c9..435d1a842 100644
--- a/src/io/parser/input_file_parser.hh
+++ b/src/io/parser/input_file_parser.hh
@@ -1,268 +1,268 @@
/**
* @file input_file_parser.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Mon Dec 18 2017
*
* @brief Grammar definition for the input files
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// Boost
/* -------------------------------------------------------------------------- */
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/phoenix_bind.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_fusion.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/variant/recursive_variant.hpp>
#ifndef __AKANTU_INPUT_FILE_PARSER_HH__
#define __AKANTU_INPUT_FILE_PARSER_HH__
namespace spirit = boost::spirit;
namespace qi = boost::spirit::qi;
namespace lbs = boost::spirit::qi::labels;
namespace ascii = boost::spirit::ascii;
namespace phx = boost::phoenix;
namespace akantu {
namespace parser {
struct error_handler_ {
template <typename, typename, typename, typename> struct result {
using type = void;
};
template <typename Iterator>
void operator()(qi::info const & what, Iterator err_pos, Iterator /*first*/,
Iterator /*last*/) const {
spirit::classic::file_position pos = err_pos.get_position();
AKANTU_EXCEPTION("Parse error [ "
<< "Expecting " << what << " instead of \"" << *err_pos
<< "\" ]"
<< " in file " << pos.file << " line " << pos.line
<< " column " << pos.column << std::endl
<< "'" << err_pos.get_currentline() << "'" << std::endl
<< std::setw(pos.column) << " "
<< "^- here");
}
private:
};
static ParserSection & create_subsection(
const ParserType & type, const boost::optional<std::string> & opt_name,
const boost::optional<std::string> & opt_option, ParserSection & sect) {
std::string option = "";
if (opt_option)
option = *opt_option;
static size_t id = 12;
std::string name = "anonymous_" + std::to_string(id++);
if (opt_name)
name = *opt_name;
ParserSection sect_tmp(name, type, option, sect);
return sect.addSubSection(sect_tmp);
}
template <typename Iter>
static bool create_parameter(boost::iterator_range<Iter> & rng,
std::string & value, ParserSection & sect) {
try {
std::string name(rng.begin(), rng.end());
name = trim(name);
spirit::classic::file_position pos = rng.begin().get_position();
ParserParameter param_tmp(name, value, sect);
param_tmp.setDebugInfo(pos.file, pos.line, pos.column);
sect.addParameter(param_tmp);
} catch (debug::Exception & e) {
return false;
}
return true;
}
static std::string concatenate(const std::string & t1,
const std::string & t2) {
return (t1 + t2);
}
/* ---------------------------------------------------------------------- */
/* Grammars definitions */
/* ---------------------------------------------------------------------- */
template <class Iterator>
struct InputFileGrammar
: qi::grammar<Iterator, void(), typename Skipper<Iterator>::type> {
InputFileGrammar(ParserSection * sect)
: InputFileGrammar::base_type(start, "input_file_grammar"),
parent_section(sect) {
/* clang-format off */
start
= mini_section(parent_section)
;
mini_section
= *(
entry (lbs::_r1)
| section(lbs::_r1)
)
;
entry
= (
qi::raw[key]
>> '='
> value
) [ lbs::_pass = phx::bind(&create_parameter<Iterator>,
lbs::_1,
lbs::_2,
*lbs::_r1) ]
;
section
= (
qi::no_case[section_type]
> qi::lexeme
[
-section_name
> -section_option
]
) [ lbs::_a = &phx::bind(&create_subsection,
lbs::_1,
phx::at_c<0>(lbs::_2),
phx::at_c<1>(lbs::_2),
*lbs::_r1) ]
> '['
> mini_section(lbs::_a)
> ']'
;
section_name
= qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9")
;
section_option
= (+ascii::space >> section_name) [ lbs::_val = lbs::_2 ]
;
key
= qi::char_("a-zA-Z_") >> *qi::char_("a-zA-Z_0-9")
;
value
= (
mono_line_value [ lbs::_a = phx::bind(&concatenate, lbs::_a, lbs::_1) ]
> *(
'\\' > mono_line_value [ lbs::_a = phx::bind(&concatenate, lbs::_a, lbs::_1) ]
)
) [ lbs::_val = lbs::_a ]
;
mono_line_value
= qi::lexeme
[
+(qi::char_ - (qi::char_('=') | spirit::eol | '#' | ';' | '\\'))
]
;
skipper
= ascii::space
| "#" >> *(qi::char_ - spirit::eol)
;
-/* clang-format on */
+ /* clang-format on */
#define AKANTU_SECTION_TYPE_ADD(r, data, elem) \
(BOOST_PP_STRINGIZE(elem), BOOST_PP_CAT(ParserType::_, elem))
section_type.add BOOST_PP_SEQ_FOR_EACH(AKANTU_SECTION_TYPE_ADD, _,
AKANTU_SECTION_TYPES);
#undef AKANTU_SECTION_TYPE_ADD
-#if !defined(AKANTU_NDEBUG) && defined(AKANTU_CORE_CXX_11)
+#if !defined(AKANTU_NDEBUG)
phx::function<error_handler_> const error_handler = error_handler_();
qi::on_error<qi::fail>(start,
error_handler(lbs::_4, lbs::_3, lbs::_1, lbs::_2));
#endif
section.name("section");
section_name.name("section-name");
section_option.name("section-option");
mini_section.name("section-content");
entry.name("parameter");
key.name("parameter-name");
value.name("parameter-value");
section_type.name("section-types-list");
mono_line_value.name("mono-line-value");
#if !defined AKANTU_NDEBUG
if (AKANTU_DEBUG_TEST(dblDebug)) {
// qi::debug(section);
qi::debug(section_name);
qi::debug(section_option);
// qi::debug(mini_section);
// qi::debug(entry);
qi::debug(key);
qi::debug(value);
qi::debug(mono_line_value);
}
#endif
}
const std::string & getErrorMessage() const { return error_message; };
using skipper_type = typename Skipper<Iterator>::type;
skipper_type skipper;
private:
std::string error_message;
qi::rule<Iterator, void(ParserSection *), skipper_type> mini_section;
qi::rule<Iterator, void(ParserSection *), qi::locals<ParserSection *>,
skipper_type>
section;
qi::rule<Iterator, void(), skipper_type> start;
qi::rule<Iterator, std::string()> section_name;
qi::rule<Iterator, std::string()> section_option;
qi::rule<Iterator, void(ParserSection *), skipper_type> entry;
qi::rule<Iterator, std::string(), skipper_type> key;
qi::rule<Iterator, std::string(), qi::locals<std::string>, skipper_type>
value;
qi::rule<Iterator, std::string(), skipper_type> mono_line_value;
qi::symbols<char, ParserType> section_type;
ParserSection * parent_section;
};
-}
+} // namespace parser
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_INPUT_FILE_PARSER_HH__ */
diff --git a/src/io/parser/parameter_registry.cc b/src/io/parser/parameter_registry.cc
index 070a8ce5d..edde8cfbc 100644
--- a/src/io/parser/parameter_registry.cc
+++ b/src/io/parser/parameter_registry.cc
@@ -1,152 +1,152 @@
/**
* @file parameter_registry.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed May 04 2016
* @date last modification: Thu Feb 01 2018
*
* @brief Parameter Registry and derived classes implementation
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <utility>
#include "parameter_registry.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
Parameter::Parameter() : name(""), description("") {}
/* -------------------------------------------------------------------------- */
Parameter::Parameter(std::string name, std::string description,
ParameterAccessType param_type)
: name(std::move(name)), description(std::move(description)),
param_type(param_type) {}
/* -------------------------------------------------------------------------- */
bool Parameter::isWritable() const { return param_type & _pat_writable; }
/* -------------------------------------------------------------------------- */
bool Parameter::isReadable() const { return param_type & _pat_readable; }
/* -------------------------------------------------------------------------- */
bool Parameter::isInternal() const { return param_type & _pat_internal; }
/* -------------------------------------------------------------------------- */
bool Parameter::isParsable() const { return param_type & _pat_parsable; }
/* -------------------------------------------------------------------------- */
void Parameter::setAccessType(ParameterAccessType ptype) {
this->param_type = ptype;
}
/* -------------------------------------------------------------------------- */
void Parameter::printself(std::ostream & stream) const {
stream << " ";
if (isInternal())
stream << "iii";
else {
if (isReadable())
stream << "r";
else
stream << "-";
if (isWritable())
stream << "w";
else
stream << "-";
if (isParsable())
stream << "p";
else
stream << "-";
}
stream << " ";
std::stringstream sstr;
sstr << name;
UInt width = std::max(int(10 - sstr.str().length()), 0);
sstr.width(width);
if (description != "") {
sstr << " [" << description << "]";
}
stream << sstr.str();
width = std::max(int(50 - sstr.str().length()), 0);
stream.width(width);
stream << " : ";
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
ParameterRegistry::ParameterRegistry() = default;
/* -------------------------------------------------------------------------- */
ParameterRegistry::~ParameterRegistry() {
std::map<std::string, Parameter *>::iterator it, end;
for (it = params.begin(); it != params.end(); ++it) {
delete it->second;
it->second = NULL;
}
this->params.clear();
}
/* -------------------------------------------------------------------------- */
void ParameterRegistry::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
Parameters::const_iterator it;
for (it = params.begin(); it != params.end(); ++it) {
stream << space;
it->second->printself(stream);
}
SubRegisteries::const_iterator sub_it;
for (sub_it = sub_registries.begin(); sub_it != sub_registries.end();
++sub_it) {
stream << space << "Registry [" << std::endl;
sub_it->second->printself(stream, indent + 1);
stream << space << "]";
}
}
/* -------------------------------------------------------------------------- */
void ParameterRegistry::registerSubRegistry(const ID & id,
ParameterRegistry & registry) {
sub_registries[id] = &registry;
}
/* -------------------------------------------------------------------------- */
void ParameterRegistry::setParameterAccessType(const std::string & name,
ParameterAccessType ptype) {
auto it = params.find(name);
if (it == params.end())
AKANTU_CUSTOM_EXCEPTION(debug::ParameterUnexistingException(name, *this));
Parameter & param = *(it->second);
param.setAccessType(ptype);
}
-} // akantu
+} // namespace akantu
diff --git a/src/io/parser/parameter_registry.hh b/src/io/parser/parameter_registry.hh
index fcd84a702..d76ce975b 100644
--- a/src/io/parser/parameter_registry.hh
+++ b/src/io/parser/parameter_registry.hh
@@ -1,224 +1,224 @@
/**
* @file parameter_registry.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Aug 09 2012
* @date last modification: Tue Jan 30 2018
*
* @brief Interface of the parameter registry
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "parser.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PARAMETER_REGISTRY_HH__
#define __AKANTU_PARAMETER_REGISTRY_HH__
namespace akantu {
class ParserParameter;
}
namespace akantu {
/* -------------------------------------------------------------------------- */
/// Defines the access modes of parsable parameters
enum ParameterAccessType {
_pat_internal = 0x0001,
_pat_writable = 0x0010,
_pat_readable = 0x0100,
_pat_modifiable = 0x0110, //<_pat_readable | _pat_writable,
_pat_parsable = 0x1000,
_pat_parsmod = 0x1110 //< _pat_parsable | _pat_modifiable
};
/// Bit-wise operator between access modes
inline ParameterAccessType operator|(const ParameterAccessType & a,
const ParameterAccessType & b) {
auto tmp = ParameterAccessType(UInt(a) | UInt(b));
return tmp;
}
/* -------------------------------------------------------------------------- */
template <typename T> class ParameterTyped;
/**
* Interface for the Parameter
*/
class Parameter {
public:
Parameter();
Parameter(std::string name, std::string description,
ParameterAccessType param_type);
virtual ~Parameter() = default;
/* ------------------------------------------------------------------------ */
bool isInternal() const;
bool isWritable() const;
bool isReadable() const;
bool isParsable() const;
void setAccessType(ParameterAccessType ptype);
/* ------------------------------------------------------------------------ */
template <typename T, typename V> void set(const V & value);
virtual void setAuto(const ParserParameter & param);
template <typename T> T & get();
template <typename T> const T & get() const;
virtual inline operator Real() const { throw std::bad_cast(); };
template <typename T> inline operator T() const;
/* ------------------------------------------------------------------------ */
virtual void printself(std::ostream & stream) const;
virtual const std::type_info & type() const = 0;
protected:
/// Returns const instance of templated sub-class ParameterTyped
template <typename T> const ParameterTyped<T> & getParameterTyped() const;
/// Returns instance of templated sub-class ParameterTyped
template <typename T> ParameterTyped<T> & getParameterTyped();
protected:
/// Name of parameter
std::string name;
private:
/// Description of parameter
std::string description;
/// Type of access
ParameterAccessType param_type{_pat_internal};
};
/* -------------------------------------------------------------------------- */
/* Typed Parameter */
/* -------------------------------------------------------------------------- */
/**
* Type parameter transfering a ParserParameter (string: string) to a typed
* parameter in the memory of the p
*/
template <typename T> class ParameterTyped : public Parameter {
public:
ParameterTyped(std::string name, std::string description,
ParameterAccessType param_type, T & param);
/* ------------------------------------------------------------------------ */
template <typename V> void setTyped(const V & value);
void setAuto(const ParserParameter & param) override;
T & getTyped();
const T & getTyped() const;
void printself(std::ostream & stream) const override;
inline operator Real() const override;
inline const std::type_info & type() const override { return typeid(T); }
private:
/// Value of parameter
T & param;
};
/* -------------------------------------------------------------------------- */
/* Parsable Interface */
/* -------------------------------------------------------------------------- */
/// Defines interface for classes to manipulate parsable parameters
class ParameterRegistry {
public:
ParameterRegistry();
virtual ~ParameterRegistry();
/* ------------------------------------------------------------------------ */
/// Add parameter to the params map
template <typename T>
void registerParam(std::string name, T & variable, ParameterAccessType type,
const std::string & description = "");
/// Add parameter to the params map (with default value)
template <typename T>
void registerParam(std::string name, T & variable, const T & default_value,
ParameterAccessType type,
const std::string & description = "");
/*------------------------------------------------------------------------- */
protected:
void registerSubRegistry(const ID & id, ParameterRegistry & registry);
/* ------------------------------------------------------------------------ */
public:
/// Set value to a parameter (with possible different type)
template <typename T, typename V>
void setMixed(const std::string & name, const V & value);
/// Set value to a parameter
template <typename T> void set(const std::string & name, const T & value);
/// Get value of a parameter
inline const Parameter & get(const std::string & name) const;
/// Get value of a parameter
inline Parameter & get(const std::string & name);
std::vector<ID> listParameters() const {
std::vector<ID> params;
for (auto & pair : this->params)
params.push_back(pair.first);
return params;
}
std::vector<ID> listSubRegisteries() const {
std::vector<ID> subs;
for (auto & pair : this->sub_registries)
subs.push_back(pair.first);
return subs;
}
protected:
template <typename T> T & get_(const std::string & name);
protected:
void setParameterAccessType(const std::string & name,
ParameterAccessType ptype);
/* ------------------------------------------------------------------------ */
virtual void printself(std::ostream & stream, int indent) const;
protected:
/// Parameters map
using Parameters = std::map<std::string, Parameter *>;
Parameters params;
/// list of sub-registries
using SubRegisteries = std::map<std::string, ParameterRegistry *>;
SubRegisteries sub_registries;
/// should accessor check in sub registries
bool consisder_sub{true};
};
-} // akantu
+} // namespace akantu
#include "parameter_registry_tmpl.hh"
#endif /* __AKANTU_PARAMETER_REGISTRY_HH__ */
diff --git a/src/io/parser/parsable.cc b/src/io/parser/parsable.cc
index c779bd11f..4d17df31b 100644
--- a/src/io/parser/parsable.cc
+++ b/src/io/parser/parsable.cc
@@ -1,110 +1,110 @@
/**
* @file parsable.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Thu Feb 08 2018
*
* @brief Parsable implementation
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "parsable.hh"
#include "aka_random_generator.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Parsable::Parsable(const ParserType & section_type, const ID & id)
: section_type(section_type), pid(id) {
this->consisder_sub = false;
}
/* -------------------------------------------------------------------------- */
Parsable::~Parsable() = default;
/* -------------------------------------------------------------------------- */
void Parsable::registerSubSection(const ParserType & type,
const std::string & name,
Parsable & sub_section) {
SubSectionKey key(type, name);
sub_sections[key] = &sub_section;
this->registerSubRegistry(name, sub_section);
}
/* -------------------------------------------------------------------------- */
void Parsable::parseParam(const ParserParameter & in_param) {
auto it = params.find(in_param.getName());
if (it == params.end()) {
if (Parser::isPermissive()) {
AKANTU_DEBUG_WARNING("No parameter named " << in_param.getName()
<< " registered in " << pid
<< ".");
return;
} else
AKANTU_EXCEPTION("No parameter named " << in_param.getName()
<< " registered in " << pid
<< ".");
}
Parameter & param = *(it->second);
param.setAuto(in_param);
}
/* -------------------------------------------------------------------------- */
void Parsable::parseSection(const ParserSection & section) {
if (section_type != section.getType())
AKANTU_EXCEPTION("The object "
<< pid << " is meant to parse section of type "
<< section_type << ", so it cannot parse section of type "
<< section.getType());
auto params = section.getParameters();
auto it = params.first;
for (; it != params.second; ++it) {
parseParam(*it);
}
auto sit = section.getSubSections().first;
for (; sit != section.getSubSections().second; ++sit) {
parseSubSection(*sit);
}
}
/* -------------------------------------------------------------------------- */
void Parsable::parseSubSection(const ParserSection & section) {
SubSectionKey key(section.getType(), section.getName());
auto it = sub_sections.find(key);
if (it != sub_sections.end()) {
it->second->parseSection(section);
} else if (!Parser::isPermissive()) {
AKANTU_EXCEPTION("No parsable defined for sub sections of type <"
<< key.first << "," << key.second << "> in " << pid);
} else {
AKANTU_DEBUG_WARNING("No parsable defined for sub sections of type <"
<< key.first << "," << key.second << "> in " << pid);
}
}
-} // akantu
+} // namespace akantu
diff --git a/src/io/parser/parser.cc b/src/io/parser/parser.cc
index 4fc82d9e4..c54e58af5 100644
--- a/src/io/parser/parser.cc
+++ b/src/io/parser/parser.cc
@@ -1,97 +1,97 @@
/**
* @file parser.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Thu Feb 01 2018
*
* @brief implementation of the parser
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
// STL
#include <fstream>
#include <iomanip>
#include <map>
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "parser.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
ParserSection::~ParserSection() { this->clean(); }
/* -------------------------------------------------------------------------- */
ParserParameter & ParserSection::addParameter(const ParserParameter & param) {
if (parameters.find(param.getName()) != parameters.end())
AKANTU_EXCEPTION("The parameter \"" + param.getName() +
"\" is already defined in this section");
return (parameters
.insert(std::pair<std::string, ParserParameter>(param.getName(),
param))
.first->second);
}
/* -------------------------------------------------------------------------- */
ParserSection & ParserSection::addSubSection(const ParserSection & section) {
return ((sub_sections_by_type.insert(std::pair<ParserType, ParserSection>(
section.getType(), section)))
->second);
}
/* -------------------------------------------------------------------------- */
std::string Parser::getLastParsedFile() const { return last_parsed_file; }
/* -------------------------------------------------------------------------- */
void ParserSection::printself(std::ostream & stream,
unsigned int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "Section(" << this->type << ") " << this->name
<< (option != "" ? (" " + option) : "") << " [" << std::endl;
if (!this->parameters.empty()) {
stream << space << " Parameters [" << std::endl;
auto pit = this->parameters.begin();
for (; pit != this->parameters.end(); ++pit) {
stream << space << " + ";
pit->second.printself(stream, indent);
stream << "\n";
}
stream << space << " ]" << std::endl;
}
if (!this->sub_sections_by_type.empty()) {
stream << space << " Subsections [" << std::endl;
auto sit = this->sub_sections_by_type.begin();
for (; sit != this->sub_sections_by_type.end(); ++sit)
sit->second.printself(stream, indent + 2);
stream << std::endl;
stream << space << " ]" << std::endl;
}
stream << space << "]" << std::endl;
}
-} // akantu
+} // namespace akantu
diff --git a/src/io/parser/parser.hh b/src/io/parser/parser.hh
index d03e9cacc..5f5c310c8 100644
--- a/src/io/parser/parser.hh
+++ b/src/io/parser/parser.hh
@@ -1,505 +1,506 @@
/**
* @file parser.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Fri Dec 08 2017
*
* @brief File parser interface
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_random_generator.hh"
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PARSER_HH__
#define __AKANTU_PARSER_HH__
namespace akantu {
// clang-format off
#define AKANTU_SECTION_TYPES \
(cohesive_inserter) \
(contact) \
(embedded_interface) \
(friction) \
(global) \
(heat) \
(integration_scheme) \
(material) \
(mesh) \
(model) \
(model_solver) \
(neighborhood) \
(neighborhoods) \
(non_linear_solver) \
(non_local) \
(rules) \
(solver) \
(time_step_solver) \
(user) \
(weight_function) \
(contact_detector) \
(contact_resolution) \
(not_defined)
// clang-format on
/// Defines the possible section types
AKANTU_CLASS_ENUM_DECLARE(ParserType, AKANTU_SECTION_TYPES)
AKANTU_CLASS_ENUM_OUTPUT_STREAM(ParserType, AKANTU_SECTION_TYPES)
AKANTU_CLASS_ENUM_INPUT_STREAM(ParserType, AKANTU_SECTION_TYPES)
/// Defines the possible search contexts/scopes (for parameter search)
enum ParserParameterSearchCxt {
_ppsc_current_scope = 0x1,
_ppsc_parent_scope = 0x2,
_ppsc_current_and_parent_scope = 0x3
};
/* ------------------------------------------------------------------------ */
/* Parameters Class */
/* ------------------------------------------------------------------------ */
class ParserSection;
/// @brief The ParserParameter objects represent the end of tree branches as
/// they
/// are the different informations contained in the input file.
class ParserParameter {
public:
ParserParameter()
: name(std::string()), value(std::string()), dbg_filename(std::string()) {
}
ParserParameter(const std::string & name, const std::string & value,
const ParserSection & parent_section)
: parent_section(&parent_section), name(name), value(value),
dbg_filename(std::string()) {}
ParserParameter(const ParserParameter & param) = default;
virtual ~ParserParameter() = default;
/// Get parameter name
const std::string & getName() const { return name; }
/// Get parameter value
const std::string & getValue() const { return value; }
/// Set info for debug output
void setDebugInfo(const std::string & filename, UInt line, UInt column) {
dbg_filename = filename;
dbg_line = line;
dbg_column = column;
}
template <typename T> inline operator T() const;
// template <typename T> inline operator Vector<T>() const;
// template <typename T> inline operator Matrix<T>() const;
/// Print parameter info in stream
void printself(std::ostream & stream,
__attribute__((unused)) unsigned int indent = 0) const {
stream << name << ": " << value << " (" << dbg_filename << ":" << dbg_line
<< ":" << dbg_column << ")";
}
private:
void setParent(const ParserSection & sect) { parent_section = &sect; }
friend class ParserSection;
private:
/// Pointer to the parent section
const ParserSection * parent_section{nullptr};
/// Name of the parameter
std::string name;
/// Value of the parameter
std::string value;
/// File for debug output
std::string dbg_filename;
/// Position of parameter in parsed file
UInt dbg_line, dbg_column;
};
/* ------------------------------------------------------------------------ */
/* Sections Class */
/* ------------------------------------------------------------------------ */
/// ParserSection represents a branch of the parsing tree.
class ParserSection {
public:
using SubSections = std::multimap<ParserType, ParserSection>;
using Parameters = std::map<std::string, ParserParameter>;
private:
using const_section_iterator_ = SubSections::const_iterator;
public:
/* ------------------------------------------------------------------------ */
/* SubSection iterator */
/* ------------------------------------------------------------------------ */
/// Iterator on sections
class const_section_iterator {
public:
using iterator_category = std::forward_iterator_tag;
using value_type = ParserSection;
using pointer = ParserSection *;
using reference = ParserSection &;
const_section_iterator() = default;
const_section_iterator(const const_section_iterator_ & it) : it(it) {}
const_section_iterator(const const_section_iterator & other) = default;
const_section_iterator &
operator=(const const_section_iterator & other) = default;
const ParserSection & operator*() const { return it->second; }
const ParserSection * operator->() const { return &(it->second); }
bool operator==(const const_section_iterator & other) const {
return it == other.it;
}
bool operator!=(const const_section_iterator & other) const {
return it != other.it;
}
const_section_iterator & operator++() {
++it;
return *this;
}
const_section_iterator operator++(int) {
const_section_iterator tmp = *this;
operator++();
return tmp;
}
private:
const_section_iterator_ it;
};
/* ------------------------------------------------------------------------ */
/* Parameters iterator */
/* ------------------------------------------------------------------------ */
/// Iterator on parameters
class const_parameter_iterator {
public:
const_parameter_iterator(const const_parameter_iterator & other) = default;
const_parameter_iterator(const Parameters::const_iterator & it) : it(it) {}
const_parameter_iterator &
operator=(const const_parameter_iterator & other) {
if (this != &other) {
it = other.it;
}
return *this;
}
const ParserParameter & operator*() const { return it->second; }
const ParserParameter * operator->() { return &(it->second); };
bool operator==(const const_parameter_iterator & other) const {
return it == other.it;
}
bool operator!=(const const_parameter_iterator & other) const {
return it != other.it;
}
const_parameter_iterator & operator++() {
++it;
return *this;
}
const_parameter_iterator operator++(int) {
const_parameter_iterator tmp = *this;
operator++();
return tmp;
}
private:
Parameters::const_iterator it;
};
/* ---------------------------------------------------------------------- */
ParserSection() : name(std::string()) {}
ParserSection(const std::string & name, ParserType type)
: parent_section(nullptr), name(name), type(type) {}
ParserSection(const std::string & name, ParserType type,
const std::string & option,
const ParserSection & parent_section)
: parent_section(&parent_section), name(name), type(type),
option(option) {}
ParserSection(const ParserSection & section)
: parent_section(section.parent_section), name(section.name),
type(section.type), option(section.option),
parameters(section.parameters),
sub_sections_by_type(section.sub_sections_by_type) {
setChldrenPointers();
}
ParserSection & operator=(const ParserSection & other) {
if (&other != this) {
parent_section = other.parent_section;
name = other.name;
type = other.type;
option = other.option;
parameters = other.parameters;
sub_sections_by_type = other.sub_sections_by_type;
setChldrenPointers();
}
return *this;
}
virtual ~ParserSection();
virtual void printself(std::ostream & stream, unsigned int indent = 0) const;
/* ---------------------------------------------------------------------- */
/* Creation functions */
/* ---------------------------------------------------------------------- */
public:
ParserParameter & addParameter(const ParserParameter & param);
ParserSection & addSubSection(const ParserSection & section);
protected:
/// Clean ParserSection content
void clean() {
parameters.clear();
sub_sections_by_type.clear();
}
private:
void setChldrenPointers() {
for (auto && param_pair : this->parameters)
param_pair.second.setParent(*this);
for (auto && sub_sect_pair : this->sub_sections_by_type)
sub_sect_pair.second.setParent(*this);
}
/* ---------------------------------------------------------------------- */
/* Accessors */
/* ---------------------------------------------------------------------- */
public:
class SubSectionsRange
: public std::pair<const_section_iterator, const_section_iterator> {
public:
SubSectionsRange(const const_section_iterator & first,
const const_section_iterator & second)
: std::pair<const_section_iterator, const_section_iterator>(first,
second) {}
auto begin() { return this->first; }
auto end() { return this->second; }
};
/// Get begin and end iterators on subsections of certain type
auto getSubSections(ParserType type = ParserType::_not_defined) const {
if (type != ParserType::_not_defined) {
auto range = sub_sections_by_type.equal_range(type);
return SubSectionsRange(range.first, range.second);
} else {
return SubSectionsRange(sub_sections_by_type.begin(),
sub_sections_by_type.end());
}
}
/// Get number of subsections of certain type
UInt getNbSubSections(ParserType type = ParserType::_not_defined) const {
if (type != ParserType::_not_defined) {
return this->sub_sections_by_type.count(type);
} else {
return this->sub_sections_by_type.size();
}
}
/// Get begin and end iterators on parameters
auto getParameters() const {
return std::pair<const_parameter_iterator, const_parameter_iterator>(
parameters.begin(), parameters.end());
}
/* ---------------------------------------------------------------------- */
/// Get parameter within specified context
const ParserParameter & getParameter(
const std::string & name,
ParserParameterSearchCxt search_ctx = _ppsc_current_scope) const {
Parameters::const_iterator it;
if (search_ctx & _ppsc_current_scope)
it = parameters.find(name);
if (it == parameters.end()) {
if ((search_ctx & _ppsc_parent_scope) && parent_section)
return parent_section->getParameter(name, search_ctx);
else {
AKANTU_SILENT_EXCEPTION(
"The parameter " << name
<< " has not been found in the specified context");
}
}
return it->second;
}
/* ------------------------------------------------------------------------ */
/// Get parameter within specified context, with a default value in case the
/// parameter does not exists
template <class T>
const T getParameter(
const std::string & name, const T & default_value,
ParserParameterSearchCxt search_ctx = _ppsc_current_scope) const {
try {
T tmp = this->getParameter(name, search_ctx);
return tmp;
} catch (debug::Exception &) {
return default_value;
}
}
/* ------------------------------------------------------------------------ */
/// Check if parameter exists within specified context
bool hasParameter(
const std::string & name,
ParserParameterSearchCxt search_ctx = _ppsc_current_scope) const {
Parameters::const_iterator it;
if (search_ctx & _ppsc_current_scope)
it = parameters.find(name);
if (it == parameters.end()) {
if ((search_ctx & _ppsc_parent_scope) && parent_section)
return parent_section->hasParameter(name, search_ctx);
else {
return false;
}
}
return true;
}
/* --------------------------------------------------------------------------
*/
/// Get value of given parameter in context
template <class T>
T getParameterValue(
const std::string & name,
ParserParameterSearchCxt search_ctx = _ppsc_current_scope) const {
const ParserParameter & tmp_param = getParameter(name, search_ctx);
T t = tmp_param;
return t;
}
/* --------------------------------------------------------------------------
*/
/// Get section name
const std::string getName() const { return name; }
/// Get section type
ParserType getType() const { return type; }
/// Get section option
const std::string getOption(const std::string & def = "") const {
return option != "" ? option : def;
}
protected:
void setParent(const ParserSection & sect) { parent_section = &sect; }
/* ---------------------------------------------------------------------- */
/* Members */
/* ---------------------------------------------------------------------- */
private:
/// Pointer to the parent section
const ParserSection * parent_section{nullptr};
/// Name of section
std::string name;
/// Type of section, see AKANTU_SECTION_TYPES
ParserType type{ParserType::_not_defined};
/// Section option
std::string option;
/// Map of parameters in section
Parameters parameters;
/// Multi-map of subsections
SubSections sub_sections_by_type;
};
/* ------------------------------------------------------------------------ */
/* Parser Class */
/* ------------------------------------------------------------------------ */
/// Root of parsing tree, represents the global ParserSection
class Parser : public ParserSection {
public:
Parser() : ParserSection("global", ParserType::_global) {}
void parse(const std::string & filename);
std::string getLastParsedFile() const;
static bool isPermissive() { return permissive_parser; }
public:
/// Parse real scalar
static Real parseReal(const std::string & value,
const ParserSection & section);
/// Parse real vector
static Vector<Real> parseVector(const std::string & value,
const ParserSection & section);
/// Parse real matrix
static Matrix<Real> parseMatrix(const std::string & value,
const ParserSection & section);
/// Parse real random parameter
static RandomParameter<Real>
parseRandomParameter(const std::string & value,
const ParserSection & section);
+
protected:
/// General parse function
template <class T, class Grammar>
static T parseType(const std::string & value, Grammar & grammar);
protected:
// friend class Parsable;
static bool permissive_parser;
std::string last_parsed_file;
};
inline std::ostream & operator<<(std::ostream & stream,
const ParserParameter & _this) {
_this.printself(stream);
return stream;
}
inline std::ostream & operator<<(std::ostream & stream,
const ParserSection & section) {
section.printself(stream);
return stream;
}
} // namespace akantu
namespace std {
template <> struct iterator_traits<::akantu::Parser::const_section_iterator> {
using iterator_category = input_iterator_tag;
using value_type = ::akantu::ParserParameter;
using difference_type = ptrdiff_t;
using pointer = const ::akantu::ParserParameter *;
using reference = const ::akantu::ParserParameter &;
};
} // namespace std
#include "parser_tmpl.hh"
#endif /* __AKANTU_PARSER_HH__ */
diff --git a/src/io/parser/parser_grammar_tmpl.hh b/src/io/parser/parser_grammar_tmpl.hh
index d957801b7..64edfbdfe 100644
--- a/src/io/parser/parser_grammar_tmpl.hh
+++ b/src/io/parser/parser_grammar_tmpl.hh
@@ -1,82 +1,82 @@
/**
* @file parser_grammar_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 11 2015
* @date last modification: Sun Dec 03 2017
*
* @brief implementation of the templated part of ParsableParam Parsable and
* ParsableParamTyped
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
//#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/classic_position_iterator.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_multi_pass.hpp>
/* -------------------------------------------------------------------------- */
#ifndef AKANTU_PARSER_GRAMMAR_TMPL_HH
#define AKANTU_PARSER_GRAMMAR_TMPL_HH
namespace akantu {
namespace qi = boost::spirit::qi;
/* -------------------------------------------------------------------------- */
template <class T, class Grammar>
T Parser::parseType(const std::string & value, Grammar & grammar) {
using boost::spirit::ascii::space;
std::string::const_iterator b = value.begin();
std::string::const_iterator e = value.end();
T resultat = T();
bool res = false;
try {
res = qi::phrase_parse(b, e, grammar, space, resultat);
} catch (debug::Exception & ex) {
AKANTU_EXCEPTION("Could not parse '"
<< value << "' as a " << debug::demangle(typeid(T).name())
<< ", an unknown error append '" << ex.what());
}
if (!res || (b != e)) {
AKANTU_EXCEPTION("Could not parse '"
<< value << "' as a " << debug::demangle(typeid(T).name())
<< ", an unknown error append '"
<< std::string(value.begin(), b) << "<HERE>"
<< std::string(b, e) << "'");
}
return resultat;
}
namespace parser {
template <class Iterator> struct Skipper {
using type = qi::rule<Iterator, void()>;
};
-}
+} // namespace parser
-} // akantu
+} // namespace akantu
#endif // AKANTU_PARSER_GRAMMAR_TMPL_HH
diff --git a/src/io/parser/parser_input_files.cc b/src/io/parser/parser_input_files.cc
index c3016a000..751655825 100644
--- a/src/io/parser/parser_input_files.cc
+++ b/src/io/parser/parser_input_files.cc
@@ -1,119 +1,119 @@
/**
* @file parser_input_files.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 11 2015
* @date last modification: Wed Nov 08 2017
*
* @brief implementation of the parser
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if defined(__INTEL_COMPILER)
//#pragma warning ( disable : 383 )
#elif defined(__clang__) // test clang to be sure that when we test for gnu it
// is only gnu
#elif (defined(__GNUC__) || defined(__GNUG__))
#define GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION > 40600
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
/* -------------------------------------------------------------------------- */
#include "parser.hh"
#include "parser_grammar_tmpl.hh"
/* -------------------------------------------------------------------------- */
#include "input_file_parser.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void Parser::parse(const std::string & filename) {
this->clean();
std::ifstream input(filename.c_str());
if (!input.good()) {
AKANTU_EXCEPTION("Could not open file " << filename << "!");
}
input.unsetf(std::ios::skipws);
// wrap istream into iterator
spirit::istream_iterator fwd_begin(input);
spirit::istream_iterator fwd_end;
// wrap forward iterator with position iterator, to record the position
using pos_iterator_type =
spirit::classic::position_iterator2<spirit::istream_iterator>;
pos_iterator_type position_begin(fwd_begin, fwd_end, filename);
pos_iterator_type position_end;
// parse
parser::InputFileGrammar<pos_iterator_type> ag(this);
bool result = qi::phrase_parse(position_begin, position_end, ag, ag.skipper);
if (!result || position_begin != position_end) {
spirit::classic::file_position pos = position_begin.get_position();
AKANTU_EXCEPTION("Parse error [ "
<< ag.getErrorMessage() << " ]"
<< " in file " << filename << " line " << pos.line
<< " column " << pos.column << std::endl
<< "'" << position_begin.get_currentline() << "'"
<< std::endl
<< std::setw(pos.column) << " "
<< "^- here");
}
try {
bool permissive = getParameter("permissive_parser", _ppsc_current_scope);
permissive_parser = permissive;
AKANTU_DEBUG_INFO("Parser switched permissive mode to "
<< std::boolalpha << permissive_parser);
} catch (debug::Exception & e) {
}
last_parsed_file = filename;
input.close();
}
-} // akantu
+} // namespace akantu
#if defined(__INTEL_COMPILER)
//#pragma warning ( disable : 383 )
#elif defined(__clang__) // test clang to be sure that when we test for gnu it
// is only gnu
#elif defined(__GNUG__)
#if GCC_VERSION > 40600
#pragma GCC diagnostic pop
#else
#pragma GCC diagnostic warning "-Wunused-local-typedefs"
#endif
#endif
diff --git a/src/io/parser/parser_real.cc b/src/io/parser/parser_real.cc
index 0c8471c13..d20722d79 100644
--- a/src/io/parser/parser_real.cc
+++ b/src/io/parser/parser_real.cc
@@ -1,63 +1,63 @@
/**
* @file parser_real.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Mon Jun 19 2017
*
* @brief implementation of the parser
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if defined(__INTEL_COMPILER)
//#pragma warning ( disable : 383 )
#elif defined(__clang__) // test clang to be sure that when we test for gnu it
// is only gnu
#elif (defined(__GNUC__) || defined(__GNUG__))
#define GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION > 40600
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
/* -------------------------------------------------------------------------- */
#include "parser.hh"
#include "parser_grammar_tmpl.hh"
/* -------------------------------------------------------------------------- */
#include "algebraic_parser.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Real Parser::parseReal(const std::string & value,
const ParserSection & section) {
using boost::spirit::ascii::space_type;
parser::AlgebraicGrammar<std::string::const_iterator, space_type> grammar(
section);
grammar.name("algebraic_grammar");
return Parser::parseType<Real>(value, grammar);
}
-} // akantu
+} // namespace akantu
diff --git a/src/io/parser/parser_tmpl.hh b/src/io/parser/parser_tmpl.hh
index f3ba422c9..83644f7a5 100644
--- a/src/io/parser/parser_tmpl.hh
+++ b/src/io/parser/parser_tmpl.hh
@@ -1,112 +1,112 @@
/**
* @file parser_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Mon Dec 18 2017
*
* @brief Implementation of the parser templated methods
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <regex>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T> inline ParserParameter::operator T() const {
T t;
std::stringstream sstr(value);
sstr >> t;
if (sstr.bad())
AKANTU_EXCEPTION("No known conversion of a ParserParameter \""
<< name << "\" to the type " << typeid(T).name());
return t;
}
/* -------------------------------------------------------------------------- */
template <> inline ParserParameter::operator const char *() const {
return value.c_str();
}
/* -------------------------------------------------------------------------- */
template <> inline ParserParameter::operator Real() const {
return Parser::parseReal(value, *parent_section);
}
/* --------------------------------------------------------- -----------------
*/
template <> inline ParserParameter::operator bool() const {
bool b;
std::stringstream sstr(value);
sstr >> std::boolalpha >> b;
if (sstr.fail()) {
sstr.clear();
sstr >> std::noboolalpha >> b;
}
return b;
}
/* -------------------------------------------------------------------------- */
template <> inline ParserParameter::operator std::vector<std::string>() const {
std::vector<std::string> tmp;
auto string =
std::regex_replace(value, std::regex("[[:space:]]|\\[|\\]"), "");
std::smatch sm;
while (std::regex_search(string, sm, std::regex("[^,]+"))) {
tmp.push_back(sm.str());
string = sm.suffix();
}
return tmp;
}
/* --------------------------------------------------------- -----------------
*/
template <> inline ParserParameter::operator Vector<Real>() const {
return Parser::parseVector(value, *parent_section);
}
/* --------------------------------------------------------- -----------------
*/
template <> inline ParserParameter::operator Vector<UInt>() const {
Vector<Real> tmp = Parser::parseVector(value, *parent_section);
Vector<UInt> tmp_uint(tmp.size());
for (UInt i = 0; i < tmp.size(); ++i) {
tmp_uint(i) = UInt(tmp(i));
}
return tmp_uint;
}
/* --------------------------------------------------------- -----------------
*/
template <> inline ParserParameter::operator Matrix<Real>() const {
return Parser::parseMatrix(value, *parent_section);
}
/* -------------------------------------------------------------------------- */
template <> inline ParserParameter::operator RandomParameter<Real>() const {
return Parser::parseRandomParameter(value, *parent_section);
}
-} // akantu
+} // namespace akantu
diff --git a/src/io/parser/parser_types.cc b/src/io/parser/parser_types.cc
index 2b60bfdbd..89517f1de 100644
--- a/src/io/parser/parser_types.cc
+++ b/src/io/parser/parser_types.cc
@@ -1,75 +1,75 @@
/**
* @file parser_types.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Mon Jun 19 2017
*
* @brief implementation of the parser
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#if defined(__INTEL_COMPILER)
//#pragma warning ( disable : 383 )
#elif defined(__clang__) // test clang to be sure that when we test for gnu it
// is only gnu
#elif (defined(__GNUC__) || defined(__GNUG__))
#define GCC_VERSION \
(__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
#if GCC_VERSION > 40600
#pragma GCC diagnostic push
#endif
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#endif
/* -------------------------------------------------------------------------- */
#include "parser.hh"
#include "parser_grammar_tmpl.hh"
/* -------------------------------------------------------------------------- */
#include "algebraic_parser.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Vector<Real> Parser::parseVector(const std::string & value,
const ParserSection & section) {
using boost::spirit::ascii::space_type;
parser::VectorGrammar<std::string::const_iterator, space_type> grammar(
section);
grammar.name("vector_grammar");
return Parser::parseType<parser::parsable_vector>(value, grammar);
}
/* -------------------------------------------------------------------------- */
Matrix<Real> Parser::parseMatrix(const std::string & value,
const ParserSection & section) {
using boost::spirit::ascii::space_type;
parser::MatrixGrammar<std::string::const_iterator, space_type> grammar(
section);
grammar.name("matrix_grammar");
return Parser::parseType<parser::parsable_matrix>(value, grammar);
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/mesh/element_type_map.hh b/src/mesh/element_type_map.hh
index ea30f8eaa..0c557a346 100644
--- a/src/mesh/element_type_map.hh
+++ b/src/mesh/element_type_map.hh
@@ -1,468 +1,468 @@
/**
* @file element_type_map.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 31 2011
* @date last modification: Tue Feb 20 2018
*
* @brief storage class by element type
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_memory.hh"
#include "aka_named_argument.hh"
#include "element.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_TYPE_MAP_HH__
#define __AKANTU_ELEMENT_TYPE_MAP_HH__
namespace akantu {
class FEEngine;
} // namespace akantu
namespace akantu {
namespace {
DECLARE_NAMED_ARGUMENT(all_ghost_types);
DECLARE_NAMED_ARGUMENT(default_value);
DECLARE_NAMED_ARGUMENT(element_kind);
DECLARE_NAMED_ARGUMENT(ghost_type);
DECLARE_NAMED_ARGUMENT(nb_component);
DECLARE_NAMED_ARGUMENT(nb_component_functor);
DECLARE_NAMED_ARGUMENT(with_nb_element);
DECLARE_NAMED_ARGUMENT(with_nb_nodes_per_element);
DECLARE_NAMED_ARGUMENT(spatial_dimension);
DECLARE_NAMED_ARGUMENT(do_not_default);
} // namespace
template <class Stored, typename SupportType = ElementType>
class ElementTypeMap;
/* -------------------------------------------------------------------------- */
/* ElementTypeMapBase */
/* -------------------------------------------------------------------------- */
/// Common non templated base class for the ElementTypeMap class
class ElementTypeMapBase {
public:
virtual ~ElementTypeMapBase() = default;
};
/* -------------------------------------------------------------------------- */
/* ElementTypeMap */
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
class ElementTypeMap : public ElementTypeMapBase {
public:
ElementTypeMap();
~ElementTypeMap() override;
inline static std::string printType(const SupportType & type,
const GhostType & ghost_type);
/*! Tests whether a type is present in the object
* @param type the type to check for
* @param ghost_type optional: by default, the data map for non-ghost
* elements is searched
* @return true if the type is present. */
inline bool exists(const SupportType & type,
const GhostType & ghost_type = _not_ghost) const;
/*! get the stored data corresponding to a type
* @param type the type to check for
* @param ghost_type optional: by default, the data map for non-ghost
* elements is searched
* @return stored data corresponding to type. */
inline const Stored &
operator()(const SupportType & type,
const GhostType & ghost_type = _not_ghost) const;
/*! get the stored data corresponding to a type
* @param type the type to check for
* @param ghost_type optional: by default, the data map for non-ghost
* elements is searched
* @return stored data corresponding to type. */
inline Stored & operator()(const SupportType & type,
const GhostType & ghost_type = _not_ghost);
/*! insert data of a new type (not yet present) into the map. THIS METHOD IS
* NOT ARRAY SAFE, when using ElementTypeMapArray, use setArray instead
* @param data to insert
* @param type type of data (if this type is already present in the map,
* an exception is thrown).
* @param ghost_type optional: by default, the data map for non-ghost
* elements is searched
* @return stored data corresponding to type. */
template <typename U>
inline Stored & operator()(U && insertee, const SupportType & type,
const GhostType & ghost_type = _not_ghost);
public:
/// print helper
virtual void printself(std::ostream & stream, int indent = 0) const;
/* ------------------------------------------------------------------------ */
/* Element type Iterator */
/* ------------------------------------------------------------------------ */
/*! iterator allows to iterate over type-data pairs of the map. The interface
* expects the SupportType to be ElementType. */
using DataMap = std::map<SupportType, Stored>;
/// helper class to use in range for constructions
class type_iterator
: private std::iterator<std::forward_iterator_tag, const SupportType> {
public:
using value_type = const SupportType;
using pointer = const SupportType *;
using reference = const SupportType &;
protected:
using DataMapIterator =
typename ElementTypeMap<Stored>::DataMap::const_iterator;
public:
type_iterator(DataMapIterator & list_begin, DataMapIterator & list_end,
UInt dim, ElementKind ek);
type_iterator(const type_iterator & it);
type_iterator() = default;
inline reference operator*();
inline reference operator*() const;
inline type_iterator & operator++();
type_iterator operator++(int);
inline bool operator==(const type_iterator & other) const;
inline bool operator!=(const type_iterator & other) const;
type_iterator & operator=(const type_iterator & other);
private:
DataMapIterator list_begin;
DataMapIterator list_end;
UInt dim;
ElementKind kind;
};
/// helper class to use in range for constructions
class ElementTypesIteratorHelper {
public:
using Container = ElementTypeMap<Stored, SupportType>;
using iterator = typename Container::type_iterator;
ElementTypesIteratorHelper(const Container & container, UInt dim,
GhostType ghost_type, ElementKind kind)
: container(std::cref(container)), dim(dim), ghost_type(ghost_type),
kind(kind) {}
template <typename... pack>
ElementTypesIteratorHelper(const Container & container, use_named_args_t,
pack &&... _pack)
: ElementTypesIteratorHelper(
container, OPTIONAL_NAMED_ARG(spatial_dimension, _all_dimensions),
OPTIONAL_NAMED_ARG(ghost_type, _not_ghost),
OPTIONAL_NAMED_ARG(element_kind, _ek_not_defined)) {}
ElementTypesIteratorHelper(const ElementTypesIteratorHelper &) = default;
ElementTypesIteratorHelper &
operator=(const ElementTypesIteratorHelper &) = default;
ElementTypesIteratorHelper &
operator=(ElementTypesIteratorHelper &&) = default;
iterator begin();
iterator end();
private:
std::reference_wrapper<const Container> container;
UInt dim;
GhostType ghost_type;
ElementKind kind;
};
private:
ElementTypesIteratorHelper
elementTypesImpl(UInt dim = _all_dimensions,
GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_not_defined) const;
template <typename... pack>
ElementTypesIteratorHelper
elementTypesImpl(const use_named_args_t & /*unused*/, pack &&... _pack) const;
public:
/*!
* \param _spatial_dimension optional: filter for elements of given spatial
* dimension
* \param _ghost_type optional: filter for a certain ghost_type
* \param _element_kind optional: filter for elements of given kind
*/
template <typename... pack>
std::enable_if_t<are_named_argument<pack...>::value,
ElementTypesIteratorHelper>
elementTypes(pack &&... _pack) const {
return elementTypesImpl(use_named_args,
std::forward<decltype(_pack)>(_pack)...);
}
template <typename... pack>
std::enable_if_t<not are_named_argument<pack...>::value,
ElementTypesIteratorHelper>
elementTypes(pack &&... _pack) const {
return elementTypesImpl(std::forward<decltype(_pack)>(_pack)...);
}
/*! Get an iterator to the beginning of a subset datamap. This method expects
* the SupportType to be ElementType.
* @param dim optional: iterate over data of dimension dim (e.g. when
* iterating over (surface) facets of a 3D mesh, dim would be 2).
* by default, all dimensions are considered.
* @param ghost_type optional: by default, the data map for non-ghost
* elements is iterated over.
* @param kind optional: the kind of element to search for (see
* aka_common.hh), by default all kinds are considered
* @return an iterator to the first stored data matching the filters
* or an iterator to the end of the map if none match*/
[[deprecated("Use elementTypes instead")]] inline type_iterator
firstType(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_not_defined) const;
/*! Get an iterator to the end of a subset datamap. This method expects
* the SupportType to be ElementType.
* @param dim optional: iterate over data of dimension dim (e.g. when
* iterating over (surface) facets of a 3D mesh, dim would be 2).
* by default, all dimensions are considered.
* @param ghost_type optional: by default, the data map for non-ghost
* elements is iterated over.
* @param kind optional: the kind of element to search for (see
* aka_common.hh), by default all kinds are considered
* @return an iterator to the last stored data matching the filters
* or an iterator to the end of the map if none match */
[[deprecated("Use elementTypes instead")]] inline type_iterator
lastType(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_not_defined) const;
/*! Direct access to the underlying data map. for internal use by daughter
* classes only
* @param ghost_type whether to return the data map or the ghost_data map
* @return the raw map */
inline DataMap & getData(GhostType ghost_type);
/*! Direct access to the underlying data map. for internal use by daughter
* classes only
* @param ghost_type whether to return the data map or the ghost_data map
* @return the raw map */
inline const DataMap & getData(GhostType ghost_type) const;
/* ------------------------------------------------------------------------ */
protected:
DataMap data;
DataMap ghost_data;
};
/* -------------------------------------------------------------------------- */
/* Some typedefs */
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
class ElementTypeMapArray : public ElementTypeMap<Array<T> *, SupportType>,
public Memory {
public:
using type = T;
using array_type = Array<T>;
protected:
using parent = ElementTypeMap<Array<T> *, SupportType>;
using DataMap = typename parent::DataMap;
public:
using type_iterator = typename parent::type_iterator;
/// standard assigment (copy) operator
void operator=(const ElementTypeMapArray &) = delete;
ElementTypeMapArray(const ElementTypeMapArray &);
/// explicit copy
void copy(const ElementTypeMapArray & other);
/*! Constructor
* @param id optional: identifier (string)
* @param parent_id optional: parent identifier. for organizational purposes
* only
* @param memory_id optional: choose a specific memory, defaults to memory 0
*/
ElementTypeMapArray(const ID & id = "by_element_type_array",
const ID & parent_id = "no_parent",
const MemoryID & memory_id = 0)
: parent(), Memory(parent_id + ":" + id, memory_id), name(id){};
/*! allocate memory for a new array
* @param size number of tuples of the new array
* @param nb_component tuple size
* @param type the type under which the array is indexed in the map
* @param ghost_type whether to add the field to the data map or the
* ghost_data map
* @return a reference to the allocated array */
inline Array<T> & alloc(UInt size, UInt nb_component,
const SupportType & type,
const GhostType & ghost_type,
const T & default_value = T());
/*! allocate memory for a new array in both the data and the ghost_data map
* @param size number of tuples of the new array
* @param nb_component tuple size
* @param type the type under which the array is indexed in the map*/
inline void alloc(UInt size, UInt nb_component, const SupportType & type,
const T & default_value = T());
/* get a reference to the array of certain type
* @param type data filed under type is returned
* @param ghost_type optional: by default the non-ghost map is searched
* @return a reference to the array */
inline const Array<T> &
operator()(const SupportType & type,
const GhostType & ghost_type = _not_ghost) const;
/// access the data of an element, this combine the map and array accessor
inline const T & operator()(const Element & element,
UInt component = 0) const;
/// access the data of an element, this combine the map and array accessor
inline T & operator()(const Element & element, UInt component = 0);
/* get a reference to the array of certain type
* @param type data filed under type is returned
* @param ghost_type optional: by default the non-ghost map is searched
* @return a const reference to the array */
inline Array<T> & operator()(const SupportType & type,
const GhostType & ghost_type = _not_ghost);
/*! insert data of a new type (not yet present) into the map.
* @param type type of data (if this type is already present in the map,
* an exception is thrown).
* @param ghost_type optional: by default, the data map for non-ghost
* elements is searched
* @param vect the vector to include into the map
* @return stored data corresponding to type. */
inline void setArray(const SupportType & type, const GhostType & ghost_type,
const Array<T> & vect);
/*! frees all memory related to the data*/
inline void free();
/*! set all values in the ElementTypeMap to zero*/
inline void clear();
/*! set all values in the ElementTypeMap to value */
template <typename ST> inline void set(const ST & value);
/*! deletes and reorders entries in the stored arrays
* @param new_numbering a ElementTypeMapArray of new indices. UInt(-1)
* indicates
* deleted entries. */
inline void
onElementsRemoved(const ElementTypeMapArray<UInt> & new_numbering);
/// text output helper
void printself(std::ostream & stream, int indent = 0) const override;
/*! set the id
* @param id the new name
*/
inline void setID(const ID & id) { this->id = id; }
ElementTypeMap<UInt>
getNbComponents(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_not_defined) const {
ElementTypeMap<UInt> nb_components;
for (auto & type : this->elementTypes(dim, ghost_type, kind)) {
UInt nb_comp = (*this)(type, ghost_type).getNbComponent();
nb_components(type, ghost_type) = nb_comp;
}
return nb_components;
}
/* ------------------------------------------------------------------------ */
/* more evolved allocators */
/* ------------------------------------------------------------------------ */
public:
/// initialize the arrays in accordance to a functor
template <class Func>
void initialize(const Func & f, const T & default_value, bool do_not_default);
/// initialize with sizes and number of components in accordance of a mesh
/// content
template <typename... pack>
void initialize(const Mesh & mesh, pack &&... _pack);
/// initialize with sizes and number of components in accordance of a fe
/// engine content (aka integration points)
template <typename... pack>
void initialize(const FEEngine & fe_engine, pack &&... _pack);
/* ------------------------------------------------------------------------ */
/* Accesssors */
/* ------------------------------------------------------------------------ */
public:
/// get the name of the internal field
AKANTU_GET_MACRO(Name, name, ID);
/**
* get the size of the ElementTypeMapArray<T>
* @param[in] _spatial_dimension the dimension to consider (default:
* _all_dimensions)
* @param[in] _ghost_type (default: _not_ghost)
* @param[in] _element_kind (default: _ek_not_defined)
* @param[in] _all_ghost_types (default: false)
**/
- template <typename... pack>
- UInt size(pack &&... _pack) const;
-
+ template <typename... pack> UInt size(pack &&... _pack) const;
+
bool isNodal() const { return is_nodal; }
void isNodal(bool is_nodal) { this->is_nodal = is_nodal; }
private:
- UInt sizeImpl(UInt spatial_dimension, const GhostType & ghost_type, const ElementKind & kind) const;
-
+ UInt sizeImpl(UInt spatial_dimension, const GhostType & ghost_type,
+ const ElementKind & kind) const;
+
protected:
/// name of the element type map: e.g. connectivity, grad_u
ID name;
/// Is the data stored by node of the element
bool is_nodal{false};
};
/// to store data Array<Real> by element type
using ElementTypeMapReal = ElementTypeMapArray<Real>;
/// to store data Array<Int> by element type
using ElementTypeMapInt = ElementTypeMapArray<Int>;
/// to store data Array<UInt> by element type
using ElementTypeMapUInt = ElementTypeMapArray<UInt, ElementType>;
/// Map of data of type UInt stored in a mesh
using UIntDataMap = std::map<std::string, Array<UInt> *>;
using ElementTypeMapUIntDataMap = ElementTypeMap<UIntDataMap, ElementType>;
} // namespace akantu
#endif /* __AKANTU_ELEMENT_TYPE_MAP_HH__ */
diff --git a/src/mesh/element_type_map_tmpl.hh b/src/mesh/element_type_map_tmpl.hh
index 53cd06a62..48ec707a0 100644
--- a/src/mesh/element_type_map_tmpl.hh
+++ b/src/mesh/element_type_map_tmpl.hh
@@ -1,790 +1,791 @@
/**
* @file element_type_map_tmpl.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 31 2011
* @date last modification: Tue Feb 20 2018
*
* @brief implementation of template functions of the ElementTypeMap and
* ElementTypeMapArray classes
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_static_if.hh"
#include "element_type_map.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#include "element_type_conversion.hh"
/* -------------------------------------------------------------------------- */
#include <functional>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_TYPE_MAP_TMPL_HH__
#define __AKANTU_ELEMENT_TYPE_MAP_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* ElementTypeMap */
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline std::string
ElementTypeMap<Stored, SupportType>::printType(const SupportType & type,
const GhostType & ghost_type) {
std::stringstream sstr;
sstr << "(" << ghost_type << ":" << type << ")";
return sstr.str();
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline bool ElementTypeMap<Stored, SupportType>::exists(
const SupportType & type, const GhostType & ghost_type) const {
return this->getData(ghost_type).find(type) !=
this->getData(ghost_type).end();
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline const Stored & ElementTypeMap<Stored, SupportType>::
operator()(const SupportType & type, const GhostType & ghost_type) const {
auto it = this->getData(ghost_type).find(type);
if (it == this->getData(ghost_type).end())
AKANTU_SILENT_EXCEPTION("No element of type "
<< ElementTypeMap::printType(type, ghost_type)
<< " in this ElementTypeMap<"
<< debug::demangle(typeid(Stored).name())
<< "> class");
return it->second;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline Stored & ElementTypeMap<Stored, SupportType>::
operator()(const SupportType & type, const GhostType & ghost_type) {
return this->getData(ghost_type)[type];
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
template <typename U>
inline Stored & ElementTypeMap<Stored, SupportType>::
operator()(U && insertee, const SupportType & type,
const GhostType & ghost_type) {
auto it = this->getData(ghost_type).find(type);
if (it != this->getData(ghost_type).end()) {
AKANTU_SILENT_EXCEPTION("Element of type "
<< ElementTypeMap::printType(type, ghost_type)
<< " already in this ElementTypeMap<"
<< debug::demangle(typeid(Stored).name())
<< "> class");
} else {
auto & data = this->getData(ghost_type);
const auto & res =
data.insert(std::make_pair(type, std::forward<U>(insertee)));
it = res.first;
}
return it->second;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline typename ElementTypeMap<Stored, SupportType>::DataMap &
ElementTypeMap<Stored, SupportType>::getData(GhostType ghost_type) {
if (ghost_type == _not_ghost)
return data;
return ghost_data;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline const typename ElementTypeMap<Stored, SupportType>::DataMap &
ElementTypeMap<Stored, SupportType>::getData(GhostType ghost_type) const {
if (ghost_type == _not_ghost)
return data;
return ghost_data;
}
/* -------------------------------------------------------------------------- */
/// Works only if stored is a pointer to a class with a printself method
template <class Stored, typename SupportType>
void ElementTypeMap<Stored, SupportType>::printself(std::ostream & stream,
int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "ElementTypeMap<" << debug::demangle(typeid(Stored).name())
<< "> [" << std::endl;
for (auto gt : ghost_types) {
const DataMap & data = getData(gt);
for (auto & pair : data) {
stream << space << space << ElementTypeMap::printType(pair.first, gt)
<< std::endl;
}
}
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
ElementTypeMap<Stored, SupportType>::ElementTypeMap() = default;
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
ElementTypeMap<Stored, SupportType>::~ElementTypeMap() = default;
/* -------------------------------------------------------------------------- */
/* ElementTypeMapArray */
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
void ElementTypeMapArray<T, SupportType>::copy(
const ElementTypeMapArray & other) {
for (auto ghost_type : ghost_types) {
for (auto type :
this->elementTypes(_all_dimensions, ghost_type, _ek_not_defined)) {
const auto & array_to_copy = other(type, ghost_type);
auto & array =
this->alloc(0, array_to_copy.getNbComponent(), type, ghost_type);
array.copy(array_to_copy);
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
ElementTypeMapArray<T, SupportType>::ElementTypeMapArray(
const ElementTypeMapArray & other)
- : parent(), Memory(other.id + "_copy", other.memory_id), name(other.name + "_copy") {
+ : parent(), Memory(other.id + "_copy", other.memory_id),
+ name(other.name + "_copy") {
this->copy(other);
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline Array<T> & ElementTypeMapArray<T, SupportType>::alloc(
UInt size, UInt nb_component, const SupportType & type,
const GhostType & ghost_type, const T & default_value) {
std::string ghost_id = "";
if (ghost_type == _ghost)
ghost_id = ":ghost";
Array<T> * tmp;
auto it = this->getData(ghost_type).find(type);
if (it == this->getData(ghost_type).end()) {
auto id = this->id + ":" + std::to_string(type) + ghost_id;
tmp = &(Memory::alloc<T>(id, size, nb_component, default_value));
this->getData(ghost_type)[type] = tmp;
} else {
AKANTU_DEBUG_INFO(
"The vector "
<< this->id << this->printType(type, ghost_type)
<< " already exists, it is resized instead of allocated.");
tmp = it->second;
it->second->resize(size);
}
return *tmp;
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline void
ElementTypeMapArray<T, SupportType>::alloc(UInt size, UInt nb_component,
const SupportType & type,
const T & default_value) {
this->alloc(size, nb_component, type, _not_ghost, default_value);
this->alloc(size, nb_component, type, _ghost, default_value);
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline void ElementTypeMapArray<T, SupportType>::free() {
AKANTU_DEBUG_IN();
for (auto gt : ghost_types) {
auto & data = this->getData(gt);
for (auto & pair : data) {
dealloc(pair.second->getID());
}
data.clear();
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline void ElementTypeMapArray<T, SupportType>::clear() {
for (auto gt : ghost_types) {
auto & data = this->getData(gt);
for (auto & vect : data) {
vect.second->clear();
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
template <typename ST>
inline void ElementTypeMapArray<T, SupportType>::set(const ST & value) {
for (auto gt : ghost_types) {
auto & data = this->getData(gt);
for (auto & vect : data) {
vect.second->set(value);
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline const Array<T> & ElementTypeMapArray<T, SupportType>::
operator()(const SupportType & type, const GhostType & ghost_type) const {
auto it = this->getData(ghost_type).find(type);
if (it == this->getData(ghost_type).end())
AKANTU_SILENT_EXCEPTION("No element of type "
<< ElementTypeMapArray::printType(type, ghost_type)
<< " in this const ElementTypeMapArray<"
<< debug::demangle(typeid(T).name()) << "> class(\""
<< this->id << "\")");
return *(it->second);
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline Array<T> & ElementTypeMapArray<T, SupportType>::
operator()(const SupportType & type, const GhostType & ghost_type) {
auto it = this->getData(ghost_type).find(type);
if (it == this->getData(ghost_type).end())
AKANTU_SILENT_EXCEPTION("No element of type "
<< ElementTypeMapArray::printType(type, ghost_type)
<< " in this ElementTypeMapArray<"
<< debug::demangle(typeid(T).name())
<< "> class (\"" << this->id << "\")");
return *(it->second);
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline void
ElementTypeMapArray<T, SupportType>::setArray(const SupportType & type,
const GhostType & ghost_type,
const Array<T> & vect) {
auto it = this->getData(ghost_type).find(type);
if (AKANTU_DEBUG_TEST(dblWarning) && it != this->getData(ghost_type).end() &&
it->second != &vect) {
AKANTU_DEBUG_WARNING(
"The Array "
<< this->printType(type, ghost_type)
<< " is already registred, this call can lead to a memory leak.");
}
this->getData(ghost_type)[type] = &(const_cast<Array<T> &>(vect));
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
inline void ElementTypeMapArray<T, SupportType>::onElementsRemoved(
const ElementTypeMapArray<UInt> & new_numbering) {
for (auto gt : ghost_types) {
for (auto & type :
new_numbering.elementTypes(_all_dimensions, gt, _ek_not_defined)) {
auto support_type = convertType<ElementType, SupportType>(type);
if (this->exists(support_type, gt)) {
const auto & renumbering = new_numbering(type, gt);
if (renumbering.size() == 0)
continue;
auto & vect = this->operator()(support_type, gt);
auto nb_component = vect.getNbComponent();
Array<T> tmp(renumbering.size(), nb_component);
UInt new_size = 0;
for (UInt i = 0; i < vect.size(); ++i) {
UInt new_i = renumbering(i);
if (new_i != UInt(-1)) {
memcpy(tmp.storage() + new_i * nb_component,
vect.storage() + i * nb_component, nb_component * sizeof(T));
++new_size;
}
}
tmp.resize(new_size);
vect.copy(tmp);
}
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
void ElementTypeMapArray<T, SupportType>::printself(std::ostream & stream,
int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "ElementTypeMapArray<" << debug::demangle(typeid(T).name())
<< "> [" << std::endl;
for (UInt g = _not_ghost; g <= _ghost; ++g) {
auto gt = (GhostType)g;
const DataMap & data = this->getData(gt);
typename DataMap::const_iterator it;
for (it = data.begin(); it != data.end(); ++it) {
stream << space << space << ElementTypeMapArray::printType(it->first, gt)
<< " [" << std::endl;
it->second->printself(stream, indent + 3);
stream << space << space << " ]" << std::endl;
}
}
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
/* SupportType Iterator */
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
ElementTypeMap<Stored, SupportType>::type_iterator::type_iterator(
DataMapIterator & list_begin, DataMapIterator & list_end, UInt dim,
ElementKind ek)
: list_begin(list_begin), list_end(list_end), dim(dim), kind(ek) {}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
ElementTypeMap<Stored, SupportType>::type_iterator::type_iterator(
const type_iterator & it)
: list_begin(it.list_begin), list_end(it.list_end), dim(it.dim),
kind(it.kind) {}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
typename ElementTypeMap<Stored, SupportType>::type_iterator &
ElementTypeMap<Stored, SupportType>::type_iterator::
operator=(const type_iterator & it) {
if (this != &it) {
list_begin = it.list_begin;
list_end = it.list_end;
dim = it.dim;
kind = it.kind;
}
return *this;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline typename ElementTypeMap<Stored, SupportType>::type_iterator::reference
ElementTypeMap<Stored, SupportType>::type_iterator::operator*() {
return list_begin->first;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline typename ElementTypeMap<Stored, SupportType>::type_iterator::reference
ElementTypeMap<Stored, SupportType>::type_iterator::operator*() const {
return list_begin->first;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline typename ElementTypeMap<Stored, SupportType>::type_iterator &
ElementTypeMap<Stored, SupportType>::type_iterator::operator++() {
++list_begin;
while ((list_begin != list_end) &&
(((dim != _all_dimensions) &&
(dim != Mesh::getSpatialDimension(list_begin->first))) ||
((kind != _ek_not_defined) &&
(kind != Mesh::getKind(list_begin->first)))))
++list_begin;
return *this;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
typename ElementTypeMap<Stored, SupportType>::type_iterator
ElementTypeMap<Stored, SupportType>::type_iterator::operator++(int) {
type_iterator tmp(*this);
operator++();
return tmp;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline bool ElementTypeMap<Stored, SupportType>::type_iterator::
operator==(const type_iterator & other) const {
return this->list_begin == other.list_begin;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline bool ElementTypeMap<Stored, SupportType>::type_iterator::
operator!=(const type_iterator & other) const {
return this->list_begin != other.list_begin;
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
auto ElementTypeMap<Stored, SupportType>::ElementTypesIteratorHelper::begin()
-> iterator {
auto b = container.get().getData(ghost_type).begin();
auto e = container.get().getData(ghost_type).end();
// loop until the first valid type
while ((b != e) &&
(((dim != _all_dimensions) &&
(dim != Mesh::getSpatialDimension(b->first))) ||
((kind != _ek_not_defined) && (kind != Mesh::getKind(b->first)))))
++b;
return iterator(b, e, dim, kind);
}
template <class Stored, typename SupportType>
auto ElementTypeMap<Stored, SupportType>::ElementTypesIteratorHelper::end()
-> iterator {
auto e = container.get().getData(ghost_type).end();
return iterator(e, e, dim, kind);
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
auto ElementTypeMap<Stored, SupportType>::elementTypesImpl(
UInt dim, GhostType ghost_type, ElementKind kind) const
-> ElementTypesIteratorHelper {
return ElementTypesIteratorHelper(*this, dim, ghost_type, kind);
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
template <typename... pack>
auto ElementTypeMap<Stored, SupportType>::elementTypesImpl(
const use_named_args_t & unused, pack &&... _pack) const
-> ElementTypesIteratorHelper {
return ElementTypesIteratorHelper(*this, unused, _pack...);
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline auto ElementTypeMap<Stored, SupportType>::firstType(
UInt dim, GhostType ghost_type, ElementKind kind) const -> type_iterator {
return elementTypes(dim, ghost_type, kind).begin();
}
/* -------------------------------------------------------------------------- */
template <class Stored, typename SupportType>
inline auto ElementTypeMap<Stored, SupportType>::lastType(
UInt dim, GhostType ghost_type, ElementKind kind) const -> type_iterator {
typename DataMap::const_iterator e;
e = getData(ghost_type).end();
return typename ElementTypeMap<Stored, SupportType>::type_iterator(e, e, dim,
kind);
}
/* -------------------------------------------------------------------------- */
/// standard output stream operator
template <class Stored, typename SupportType>
inline std::ostream &
operator<<(std::ostream & stream,
const ElementTypeMap<Stored, SupportType> & _this) {
_this.printself(stream);
return stream;
}
/* -------------------------------------------------------------------------- */
class ElementTypeMapArrayInitializer {
protected:
using CompFunc = std::function<UInt(const ElementType &, const GhostType &)>;
public:
ElementTypeMapArrayInitializer(
const CompFunc & comp_func, UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined)
: comp_func(comp_func), spatial_dimension(spatial_dimension),
ghost_type(ghost_type), element_kind(element_kind) {}
const GhostType & ghostType() const { return ghost_type; }
virtual UInt nbComponent(const ElementType & type) const {
return comp_func(type, ghostType());
}
virtual bool isNodal() const { return false; }
protected:
CompFunc comp_func;
UInt spatial_dimension;
GhostType ghost_type;
ElementKind element_kind;
};
/* -------------------------------------------------------------------------- */
class MeshElementTypeMapArrayInitializer
: public ElementTypeMapArrayInitializer {
using CompFunc = ElementTypeMapArrayInitializer::CompFunc;
public:
MeshElementTypeMapArrayInitializer(
const Mesh & mesh, UInt nb_component = 1,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined,
bool with_nb_element = false, bool with_nb_nodes_per_element = false)
: MeshElementTypeMapArrayInitializer(
mesh,
[nb_component](const ElementType &, const GhostType &) -> UInt {
return nb_component;
},
spatial_dimension, ghost_type, element_kind, with_nb_element,
with_nb_nodes_per_element) {}
MeshElementTypeMapArrayInitializer(
const Mesh & mesh, const CompFunc & comp_func,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined,
bool with_nb_element = false, bool with_nb_nodes_per_element = false)
: ElementTypeMapArrayInitializer(comp_func, spatial_dimension, ghost_type,
element_kind),
mesh(mesh), with_nb_element(with_nb_element),
with_nb_nodes_per_element(with_nb_nodes_per_element) {}
decltype(auto) elementTypes() const {
return mesh.elementTypes(this->spatial_dimension, this->ghost_type,
this->element_kind);
}
virtual UInt size(const ElementType & type) const {
if (with_nb_element)
return mesh.getNbElement(type, this->ghost_type);
return 0;
}
UInt nbComponent(const ElementType & type) const override {
UInt res = ElementTypeMapArrayInitializer::nbComponent(type);
if (with_nb_nodes_per_element)
return (res * mesh.getNbNodesPerElement(type));
return res;
}
bool isNodal() const override { return with_nb_nodes_per_element; }
protected:
const Mesh & mesh;
bool with_nb_element;
bool with_nb_nodes_per_element;
};
/* -------------------------------------------------------------------------- */
class FEEngineElementTypeMapArrayInitializer
: public MeshElementTypeMapArrayInitializer {
public:
FEEngineElementTypeMapArrayInitializer(
const FEEngine & fe_engine, UInt nb_component = 1,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
FEEngineElementTypeMapArrayInitializer(
const FEEngine & fe_engine,
const ElementTypeMapArrayInitializer::CompFunc & nb_component,
UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & element_kind = _ek_not_defined);
UInt size(const ElementType & type) const override;
using ElementTypesIteratorHelper =
ElementTypeMapArray<Real, ElementType>::ElementTypesIteratorHelper;
ElementTypesIteratorHelper elementTypes() const;
protected:
const FEEngine & fe_engine;
};
/* -------------------------------------------------------------------------- */
template <typename T, typename SupportType>
template <class Func>
void ElementTypeMapArray<T, SupportType>::initialize(const Func & f,
const T & default_value,
bool do_not_default) {
this->is_nodal = f.isNodal();
auto ghost_type = f.ghostType();
for (auto & type : f.elementTypes()) {
if (not this->exists(type, ghost_type))
if (do_not_default) {
auto & array = this->alloc(0, f.nbComponent(type), type, ghost_type);
array.resize(f.size(type));
} else {
this->alloc(f.size(type), f.nbComponent(type), type, ghost_type,
default_value);
}
else {
auto & array = this->operator()(type, ghost_type);
if (not do_not_default)
array.resize(f.size(type), default_value);
else
array.resize(f.size(type));
}
}
}
/* -------------------------------------------------------------------------- */
/**
* All parameters are named optionals
* \param _nb_component a functor giving the number of components per
* (ElementType, GhostType) pair or a scalar giving a unique number of
* components
* regardless of type
* \param _spatial_dimension a filter for the elements of a specific dimension
* \param _element_kind filter with element kind (_ek_regular, _ek_structural,
* ...)
* \param _with_nb_element allocate the arrays with the number of elements for
* each
* type in the mesh
* \param _with_nb_nodes_per_element multiply the number of components by the
* number of nodes per element
* \param _default_value default inital value
* \param _do_not_default do not initialize the allocated arrays
* \param _ghost_type filter a type of ghost
*/
template <typename T, typename SupportType>
template <typename... pack>
void ElementTypeMapArray<T, SupportType>::initialize(const Mesh & mesh,
pack &&... _pack) {
GhostType requested_ghost_type = OPTIONAL_NAMED_ARG(ghost_type, _casper);
bool all_ghost_types = requested_ghost_type == _casper;
for (auto ghost_type : ghost_types) {
if ((not(ghost_type == requested_ghost_type)) and (not all_ghost_types))
continue;
auto functor = MeshElementTypeMapArrayInitializer(
mesh, OPTIONAL_NAMED_ARG(nb_component, 1),
OPTIONAL_NAMED_ARG(spatial_dimension, mesh.getSpatialDimension()),
ghost_type, OPTIONAL_NAMED_ARG(element_kind, _ek_not_defined),
OPTIONAL_NAMED_ARG(with_nb_element, false),
OPTIONAL_NAMED_ARG(with_nb_nodes_per_element, false));
this->initialize(functor, OPTIONAL_NAMED_ARG(default_value, T()),
OPTIONAL_NAMED_ARG(do_not_default, false));
}
}
/* -------------------------------------------------------------------------- */
/**
* All parameters are named optionals
* \param _nb_component a functor giving the number of components per
* (ElementType, GhostType) pair or a scalar giving a unique number of
* components
* regardless of type
* \param _spatial_dimension a filter for the elements of a specific dimension
* \param _element_kind filter with element kind (_ek_regular, _ek_structural,
* ...)
* \param _default_value default inital value
* \param _do_not_default do not initialize the allocated arrays
* \param _ghost_type filter a specific ghost type
* \param _all_ghost_types get all ghost types
*/
template <typename T, typename SupportType>
template <typename... pack>
void ElementTypeMapArray<T, SupportType>::initialize(const FEEngine & fe_engine,
pack &&... _pack) {
bool all_ghost_types = OPTIONAL_NAMED_ARG(all_ghost_types, true);
GhostType requested_ghost_type = OPTIONAL_NAMED_ARG(ghost_type, _not_ghost);
for (auto ghost_type : ghost_types) {
if ((not(ghost_type == requested_ghost_type)) and (not all_ghost_types))
continue;
auto functor = FEEngineElementTypeMapArrayInitializer(
fe_engine, OPTIONAL_NAMED_ARG(nb_component, 1),
OPTIONAL_NAMED_ARG(spatial_dimension, UInt(-2)), ghost_type,
OPTIONAL_NAMED_ARG(element_kind, _ek_not_defined));
this->initialize(functor, OPTIONAL_NAMED_ARG(default_value, T()),
OPTIONAL_NAMED_ARG(do_not_default, false));
}
}
/* -------------------------------------------------------------------------- */
template <class T, typename SupportType>
inline T & ElementTypeMapArray<T, SupportType>::
operator()(const Element & element, UInt component) {
return this->operator()(element.type, element.ghost_type)(element.element,
component);
}
/* -------------------------------------------------------------------------- */
template <class T, typename SupportType>
inline const T & ElementTypeMapArray<T, SupportType>::
operator()(const Element & element, UInt component) const {
return this->operator()(element.type, element.ghost_type)(element.element,
component);
}
/* -------------------------------------------------------------------------- */
template <class T, typename SupportType>
UInt ElementTypeMapArray<T, SupportType>::sizeImpl(
UInt spatial_dimension, const GhostType & ghost_type,
const ElementKind & kind) const {
UInt size = 0;
for (auto && type : this->elementTypes(spatial_dimension, ghost_type, kind)) {
size += this->operator()(type, ghost_type).size();
}
return size;
}
/* -------------------------------------------------------------------------- */
template <class T, typename SupportType>
template <typename... pack>
UInt ElementTypeMapArray<T, SupportType>::size(pack &&... _pack) const {
UInt size = 0;
bool all_ghost_types = OPTIONAL_NAMED_ARG(all_ghost_types, true);
GhostType requested_ghost_type = OPTIONAL_NAMED_ARG(ghost_type, _not_ghost);
for (auto ghost_type : ghost_types) {
if ((not(ghost_type == requested_ghost_type)) and (not all_ghost_types))
continue;
size +=
sizeImpl(OPTIONAL_NAMED_ARG(spatial_dimension, _all_dimensions),
ghost_type, OPTIONAL_NAMED_ARG(element_kind, _ek_not_defined));
}
return size;
}
} // namespace akantu
#endif /* __AKANTU_ELEMENT_TYPE_MAP_TMPL_HH__ */
diff --git a/src/mesh/group_manager.cc b/src/mesh/group_manager.cc
index 64b079d14..ff639a5cf 100644
--- a/src/mesh/group_manager.cc
+++ b/src/mesh/group_manager.cc
@@ -1,1039 +1,1039 @@
/**
* @file group_manager.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@gmail.com>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Tue Feb 20 2018
*
* @brief Stores information about ElementGroup and NodeGroup
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "group_manager.hh"
#include "aka_csr.hh"
#include "data_accessor.hh"
#include "element_group.hh"
#include "element_synchronizer.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
#include "mesh_utils.hh"
#include "node_group.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <iterator>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <utility>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
GroupManager::GroupManager(const Mesh & mesh, const ID & id,
const MemoryID & mem_id)
: id(id), memory_id(mem_id), mesh(mesh) {
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
GroupManager::~GroupManager() = default;
/* -------------------------------------------------------------------------- */
NodeGroup & GroupManager::createNodeGroup(const std::string & group_name,
bool replace_group) {
AKANTU_DEBUG_IN();
auto it = node_groups.find(group_name);
if (it != node_groups.end()) {
if (replace_group) {
it->second.reset();
} else {
AKANTU_EXCEPTION(
"Trying to create a node group that already exists:" << group_name);
}
}
std::stringstream sstr;
sstr << this->id << ":" << group_name << "_node_group";
auto && ptr =
std::make_unique<NodeGroup>(group_name, mesh, sstr.str(), memory_id);
auto & node_group = *ptr;
// \todo insert_or_assign in c++17
if (it != node_groups.end()) {
it->second = std::move(ptr);
} else {
node_groups[group_name] = std::move(ptr);
}
AKANTU_DEBUG_OUT();
return node_group;
}
/* -------------------------------------------------------------------------- */
template <typename T>
NodeGroup &
GroupManager::createFilteredNodeGroup(const std::string & group_name,
const NodeGroup & source_node_group,
T & filter) {
AKANTU_DEBUG_IN();
NodeGroup & node_group = this->createNodeGroup(group_name);
node_group.append(source_node_group);
if (T::type == FilterFunctor::_node_filter_functor) {
node_group.applyNodeFilter(filter);
} else {
AKANTU_ERROR("ElementFilter cannot be applied to NodeGroup yet."
<< " Needs to be implemented.");
}
AKANTU_DEBUG_OUT();
return node_group;
}
/* -------------------------------------------------------------------------- */
ElementGroup & GroupManager::createElementGroup(const std::string & group_name,
UInt dimension,
bool replace_group) {
AKANTU_DEBUG_IN();
auto it = element_groups.find(group_name);
if (it != element_groups.end()) {
if (replace_group) {
it->second.reset();
} else {
AKANTU_EXCEPTION("Trying to create a element group that already exists:"
<< group_name);
}
}
NodeGroup & new_node_group =
createNodeGroup(group_name + "_nodes", replace_group);
auto && ptr = std::make_unique<ElementGroup>(
group_name, mesh, new_node_group, dimension,
this->id + ":" + group_name + "_element_group", memory_id);
auto & element_group = *ptr;
if (it != element_groups.end()) {
it->second = std::move(ptr);
} else {
element_groups[group_name] = std::move(ptr);
}
AKANTU_DEBUG_OUT();
return element_group;
}
/* -------------------------------------------------------------------------- */
void GroupManager::destroyElementGroup(const std::string & group_name,
bool destroy_node_group) {
AKANTU_DEBUG_IN();
auto eit = element_groups.find(group_name);
if (eit != element_groups.end()) {
if (destroy_node_group)
destroyNodeGroup(eit->second->getNodeGroup().getName());
element_groups.erase(eit);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void GroupManager::destroyNodeGroup(const std::string & group_name) {
AKANTU_DEBUG_IN();
auto nit = node_groups.find(group_name);
if (nit != node_groups.end()) {
node_groups.erase(nit);
}
AKANTU_DEBUG_OUT();
}
-// /* -------------------------------------------------------------------------- */
-// void GroupManager::destroyAllElementGroups(bool destroy_node_groups) {
+// /* --------------------------------------------------------------------------
+// */ void GroupManager::destroyAllElementGroups(bool destroy_node_groups) {
// AKANTU_DEBUG_IN();
// if (destroy_node_groups)
// for (auto && data : element_groups) {
// destroyNodeGroup(std::get<1>(data)->getNodeGroup().getName());
// }
// element_groups.clear();
// AKANTU_DEBUG_OUT();
// }
/* -------------------------------------------------------------------------- */
ElementGroup & GroupManager::createElementGroup(const std::string & group_name,
UInt dimension,
NodeGroup & node_group) {
AKANTU_DEBUG_IN();
if (element_groups.find(group_name) != element_groups.end())
AKANTU_EXCEPTION(
"Trying to create a element group that already exists:" << group_name);
auto && ptr = std::make_unique<ElementGroup>(
group_name, mesh, node_group, dimension,
id + ":" + group_name + "_element_group", memory_id);
auto & element_group = *ptr;
element_groups[group_name] = std::move(ptr);
AKANTU_DEBUG_OUT();
return element_group;
}
/* -------------------------------------------------------------------------- */
template <typename T>
ElementGroup & GroupManager::createFilteredElementGroup(
const std::string & group_name, UInt dimension,
const NodeGroup & node_group, T & filter) {
AKANTU_DEBUG_IN();
if (T::type == FilterFunctor::_node_filter_functor) {
auto & filtered_node_group = this->createFilteredNodeGroup(
group_name + "_nodes", node_group, filter);
AKANTU_DEBUG_OUT();
return this->createElementGroup(group_name, dimension, filtered_node_group);
} else if (T::type == FilterFunctor::_element_filter_functor) {
AKANTU_ERROR(
"Cannot handle an ElementFilter yet. Needs to be implemented.");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
class ClusterSynchronizer : public DataAccessor<Element> {
using DistantIDs = std::set<std::pair<UInt, UInt>>;
public:
ClusterSynchronizer(GroupManager & group_manager, UInt element_dimension,
std::string cluster_name_prefix,
ElementTypeMapArray<UInt> & element_to_fragment,
const ElementSynchronizer & element_synchronizer,
UInt nb_cluster)
: group_manager(group_manager), element_dimension(element_dimension),
cluster_name_prefix(std::move(cluster_name_prefix)),
element_to_fragment(element_to_fragment),
element_synchronizer(element_synchronizer), nb_cluster(nb_cluster) {}
UInt synchronize() {
Communicator & comm = Communicator::getStaticCommunicator();
UInt rank = comm.whoAmI();
UInt nb_proc = comm.getNbProc();
/// find starting index to renumber local clusters
Array<UInt> nb_cluster_per_proc(nb_proc);
nb_cluster_per_proc(rank) = nb_cluster;
comm.allGather(nb_cluster_per_proc);
starting_index = std::accumulate(nb_cluster_per_proc.begin(),
nb_cluster_per_proc.begin() + rank, 0);
UInt global_nb_fragment =
std::accumulate(nb_cluster_per_proc.begin() + rank,
nb_cluster_per_proc.end(), starting_index);
/// create the local to distant cluster pairs with neighbors
element_synchronizer.synchronizeOnce(*this,
SynchronizationTag::_gm_clusters);
/// count total number of pairs
Array<int> nb_pairs(nb_proc); // This is potentially a bug for more than
// 2**31 pairs, but due to a all gatherv after
// it must be int to match MPI interfaces
nb_pairs(rank) = distant_ids.size();
comm.allGather(nb_pairs);
UInt total_nb_pairs = std::accumulate(nb_pairs.begin(), nb_pairs.end(), 0);
/// generate pairs global array
UInt local_pair_index =
std::accumulate(nb_pairs.storage(), nb_pairs.storage() + rank, 0);
Array<UInt> total_pairs(total_nb_pairs, 2);
for (auto & ids : distant_ids) {
total_pairs(local_pair_index, 0) = ids.first;
total_pairs(local_pair_index, 1) = ids.second;
++local_pair_index;
}
/// communicate pairs to all processors
nb_pairs *= 2;
comm.allGatherV(total_pairs, nb_pairs);
/// renumber clusters
/// generate fragment list
std::vector<std::set<UInt>> global_clusters;
UInt total_nb_cluster = 0;
Array<bool> is_fragment_in_cluster(global_nb_fragment, 1, false);
std::queue<UInt> fragment_check_list;
while (total_pairs.size() != 0) {
/// create a new cluster
++total_nb_cluster;
global_clusters.resize(total_nb_cluster);
std::set<UInt> & current_cluster = global_clusters[total_nb_cluster - 1];
UInt first_fragment = total_pairs(0, 0);
UInt second_fragment = total_pairs(0, 1);
total_pairs.erase(0);
fragment_check_list.push(first_fragment);
fragment_check_list.push(second_fragment);
while (!fragment_check_list.empty()) {
UInt current_fragment = fragment_check_list.front();
UInt * total_pairs_end = total_pairs.storage() + total_pairs.size() * 2;
UInt * fragment_found =
std::find(total_pairs.storage(), total_pairs_end, current_fragment);
if (fragment_found != total_pairs_end) {
UInt position = fragment_found - total_pairs.storage();
UInt pair = position / 2;
UInt other_index = (position + 1) % 2;
fragment_check_list.push(total_pairs(pair, other_index));
total_pairs.erase(pair);
} else {
fragment_check_list.pop();
current_cluster.insert(current_fragment);
is_fragment_in_cluster(current_fragment) = true;
}
}
}
/// add to FragmentToCluster all local fragments
for (UInt c = 0; c < global_nb_fragment; ++c) {
if (!is_fragment_in_cluster(c)) {
++total_nb_cluster;
global_clusters.resize(total_nb_cluster);
std::set<UInt> & current_cluster =
global_clusters[total_nb_cluster - 1];
current_cluster.insert(c);
}
}
/// reorganize element groups to match global clusters
for (UInt c = 0; c < global_clusters.size(); ++c) {
/// create new element group corresponding to current cluster
std::stringstream sstr;
sstr << cluster_name_prefix << "_" << c;
ElementGroup & cluster =
group_manager.createElementGroup(sstr.str(), element_dimension, true);
auto it = global_clusters[c].begin();
auto end = global_clusters[c].end();
/// append to current element group all fragments that belong to
/// the same cluster if they exist
for (; it != end; ++it) {
Int local_index = *it - starting_index;
if (local_index < 0 || local_index >= Int(nb_cluster))
continue;
std::stringstream tmp_sstr;
tmp_sstr << "tmp_" << cluster_name_prefix << "_" << local_index;
AKANTU_DEBUG_ASSERT(group_manager.elementGroupExists(tmp_sstr.str()),
"Temporary fragment \"" << tmp_sstr.str()
<< "\" not found");
cluster.append(group_manager.getElementGroup(tmp_sstr.str()));
group_manager.destroyElementGroup(tmp_sstr.str(), true);
}
}
return total_nb_cluster;
}
private:
/// functions for parallel communications
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override {
if (tag == SynchronizationTag::_gm_clusters)
return elements.size() * sizeof(UInt);
return 0;
}
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override {
if (tag != SynchronizationTag::_gm_clusters)
return;
Array<Element>::const_iterator<> el_it = elements.begin();
Array<Element>::const_iterator<> el_end = elements.end();
for (; el_it != el_end; ++el_it) {
const Element & el = *el_it;
/// for each element pack its global cluster index
buffer << element_to_fragment(el.type, el.ghost_type)(el.element) +
starting_index;
}
}
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override {
if (tag != SynchronizationTag::_gm_clusters)
return;
Array<Element>::const_iterator<> el_it = elements.begin();
Array<Element>::const_iterator<> el_end = elements.end();
for (; el_it != el_end; ++el_it) {
UInt distant_cluster;
buffer >> distant_cluster;
const Element & el = *el_it;
UInt local_cluster =
element_to_fragment(el.type, el.ghost_type)(el.element) +
starting_index;
distant_ids.insert(std::make_pair(local_cluster, distant_cluster));
}
}
private:
GroupManager & group_manager;
UInt element_dimension;
std::string cluster_name_prefix;
ElementTypeMapArray<UInt> & element_to_fragment;
const ElementSynchronizer & element_synchronizer;
UInt nb_cluster;
DistantIDs distant_ids;
UInt starting_index;
};
/* -------------------------------------------------------------------------- */
/// \todo this function doesn't work in 1D
UInt GroupManager::createBoundaryGroupFromGeometry() {
UInt spatial_dimension = mesh.getSpatialDimension();
return createClusters(spatial_dimension - 1, "boundary");
}
/* -------------------------------------------------------------------------- */
UInt GroupManager::createClusters(
UInt element_dimension, Mesh & mesh_facets, std::string cluster_name_prefix,
const GroupManager::ClusteringFilter & filter) {
return createClusters(element_dimension, std::move(cluster_name_prefix),
filter, mesh_facets);
}
/* -------------------------------------------------------------------------- */
UInt GroupManager::createClusters(
UInt element_dimension, std::string cluster_name_prefix,
const GroupManager::ClusteringFilter & filter) {
std::unique_ptr<Mesh> mesh_facets;
if (!mesh_facets && element_dimension > 0) {
MeshAccessor mesh_accessor(const_cast<Mesh &>(mesh));
mesh_facets = std::make_unique<Mesh>(mesh.getSpatialDimension(),
mesh_accessor.getNodesSharedPtr(),
"mesh_facets_for_clusters");
mesh_facets->defineMeshParent(mesh);
MeshUtils::buildAllFacets(mesh, *mesh_facets, element_dimension,
element_dimension - 1);
}
return createClusters(element_dimension, std::move(cluster_name_prefix),
filter, *mesh_facets);
}
/* -------------------------------------------------------------------------- */
//// \todo if needed element list construction can be optimized by
//// templating the filter class
UInt GroupManager::createClusters(UInt element_dimension,
const std::string & cluster_name_prefix,
const GroupManager::ClusteringFilter & filter,
Mesh & mesh_facets) {
AKANTU_DEBUG_IN();
UInt nb_proc = mesh.getCommunicator().getNbProc();
std::string tmp_cluster_name_prefix = cluster_name_prefix;
ElementTypeMapArray<UInt> * element_to_fragment = nullptr;
if (nb_proc > 1 && mesh.isDistributed()) {
element_to_fragment =
new ElementTypeMapArray<UInt>("element_to_fragment", id, memory_id);
element_to_fragment->initialize(
mesh, _nb_component = 1, _spatial_dimension = element_dimension,
_element_kind = _ek_not_defined, _with_nb_element = true);
// mesh.initElementTypeMapArray(*element_to_fragment, 1, element_dimension,
// false, _ek_not_defined, true);
tmp_cluster_name_prefix = "tmp_" + tmp_cluster_name_prefix;
}
ElementTypeMapArray<bool> seen_elements("seen_elements", id, memory_id);
seen_elements.initialize(mesh, _spatial_dimension = element_dimension,
_element_kind = _ek_not_defined,
_with_nb_element = true);
// mesh.initElementTypeMapArray(seen_elements, 1, element_dimension, false,
// _ek_not_defined, true);
for (auto ghost_type : ghost_types) {
Element el;
el.ghost_type = ghost_type;
for (auto type :
mesh.elementTypes(_spatial_dimension = element_dimension,
_ghost_type = ghost_type, _element_kind = _ek_not_defined)) {
el.type = type;
UInt nb_element = mesh.getNbElement(type, ghost_type);
Array<bool> & seen_elements_array = seen_elements(type, ghost_type);
for (UInt e = 0; e < nb_element; ++e) {
el.element = e;
if (!filter(el))
seen_elements_array(e) = true;
}
}
}
Array<bool> checked_node(mesh.getNbNodes(), 1, false);
UInt nb_cluster = 0;
for (auto ghost_type : ghost_types) {
Element uns_el;
uns_el.ghost_type = ghost_type;
for (auto type :
mesh.elementTypes(_spatial_dimension = element_dimension,
_ghost_type = ghost_type, _element_kind = _ek_not_defined)) {
uns_el.type = type;
Array<bool> & seen_elements_vec =
seen_elements(uns_el.type, uns_el.ghost_type);
for (UInt e = 0; e < seen_elements_vec.size(); ++e) {
// skip elements that have been already seen
if (seen_elements_vec(e) == true)
continue;
// set current element
uns_el.element = e;
seen_elements_vec(e) = true;
/// create a new cluster
std::stringstream sstr;
sstr << tmp_cluster_name_prefix << "_" << nb_cluster;
ElementGroup & cluster =
createElementGroup(sstr.str(), element_dimension, true);
++nb_cluster;
// point element are cluster by themself
if (element_dimension == 0) {
cluster.add(uns_el);
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(uns_el.type);
Vector<UInt> connect =
mesh.getConnectivity(uns_el.type, uns_el.ghost_type)
.begin(nb_nodes_per_element)[uns_el.element];
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
/// add element's nodes to the cluster
UInt node = connect[n];
if (!checked_node(node)) {
cluster.addNode(node);
checked_node(node) = true;
}
}
continue;
}
std::queue<Element> element_to_add;
element_to_add.push(uns_el);
/// keep looping until current cluster is complete (no more
/// connected elements)
while (!element_to_add.empty()) {
/// take first element and erase it in the queue
Element el = element_to_add.front();
element_to_add.pop();
/// if parallel, store cluster index per element
if (nb_proc > 1 && mesh.isDistributed())
(*element_to_fragment)(el.type, el.ghost_type)(el.element) =
nb_cluster - 1;
/// add current element to the cluster
cluster.add(el);
const Array<Element> & element_to_facet =
mesh_facets.getSubelementToElement(el.type, el.ghost_type);
UInt nb_facet_per_element = element_to_facet.getNbComponent();
for (UInt f = 0; f < nb_facet_per_element; ++f) {
const Element & facet = element_to_facet(el.element, f);
if (facet == ElementNull)
continue;
const std::vector<Element> & connected_elements =
mesh_facets.getElementToSubelement(
facet.type, facet.ghost_type)(facet.element);
for (UInt elem = 0; elem < connected_elements.size(); ++elem) {
const Element & check_el = connected_elements[elem];
// check if this element has to be skipped
if (check_el == ElementNull || check_el == el)
continue;
Array<bool> & seen_elements_vec_current =
seen_elements(check_el.type, check_el.ghost_type);
if (seen_elements_vec_current(check_el.element) == false) {
seen_elements_vec_current(check_el.element) = true;
element_to_add.push(check_el);
}
}
}
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(el.type);
Vector<UInt> connect = mesh.getConnectivity(el.type, el.ghost_type)
.begin(nb_nodes_per_element)[el.element];
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
/// add element's nodes to the cluster
UInt node = connect[n];
if (!checked_node(node)) {
cluster.addNode(node, false);
checked_node(node) = true;
}
}
}
}
}
}
if (nb_proc > 1 && mesh.isDistributed()) {
ClusterSynchronizer cluster_synchronizer(
*this, element_dimension, cluster_name_prefix, *element_to_fragment,
this->mesh.getElementSynchronizer(), nb_cluster);
nb_cluster = cluster_synchronizer.synchronize();
delete element_to_fragment;
}
if (mesh.isDistributed())
this->synchronizeGroupNames();
AKANTU_DEBUG_OUT();
return nb_cluster;
}
/* -------------------------------------------------------------------------- */
template <typename T>
void GroupManager::createGroupsFromMeshData(const std::string & dataset_name) {
std::set<std::string> group_names;
const auto & datas = mesh.getData<T>(dataset_name);
std::map<std::string, UInt> group_dim;
for (auto ghost_type : ghost_types) {
for (auto type : datas.elementTypes(_ghost_type = ghost_type)) {
const Array<T> & dataset = datas(type, ghost_type);
UInt nb_element = mesh.getNbElement(type, ghost_type);
AKANTU_DEBUG_ASSERT(dataset.size() == nb_element,
"Not the same number of elements ("
<< type << ":" << ghost_type
<< ") in the map from MeshData ("
<< dataset.size() << ") " << dataset_name
<< " and in the mesh (" << nb_element << ")!");
for (UInt e(0); e < nb_element; ++e) {
std::stringstream sstr;
sstr << dataset(e);
std::string gname = sstr.str();
group_names.insert(gname);
auto it = group_dim.find(gname);
if (it == group_dim.end()) {
group_dim[gname] = mesh.getSpatialDimension(type);
} else {
it->second = std::max(it->second, mesh.getSpatialDimension(type));
}
}
}
}
auto git = group_names.begin();
auto gend = group_names.end();
for (; git != gend; ++git)
createElementGroup(*git, group_dim[*git]);
if (mesh.isDistributed())
this->synchronizeGroupNames();
Element el;
for (auto ghost_type : ghost_types) {
el.ghost_type = ghost_type;
for (auto type : datas.elementTypes(_ghost_type = ghost_type)) {
el.type = type;
const Array<T> & dataset = datas(type, ghost_type);
UInt nb_element = mesh.getNbElement(type, ghost_type);
AKANTU_DEBUG_ASSERT(dataset.size() == nb_element,
"Not the same number of elements in the map from "
"MeshData and in the mesh!");
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(el.type);
Array<UInt>::const_iterator<Vector<UInt>> cit =
mesh.getConnectivity(type, ghost_type).begin(nb_nodes_per_element);
for (UInt e(0); e < nb_element; ++e, ++cit) {
el.element = e;
std::stringstream sstr;
sstr << dataset(e);
ElementGroup & group = getElementGroup(sstr.str());
group.add(el, false, false);
const Vector<UInt> & connect = *cit;
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
UInt node = connect[n];
group.addNode(node, false);
}
}
}
}
git = group_names.begin();
for (; git != gend; ++git) {
getElementGroup(*git).optimize();
}
}
template void GroupManager::createGroupsFromMeshData<std::string>(
const std::string & dataset_name);
template void
GroupManager::createGroupsFromMeshData<UInt>(const std::string & dataset_name);
/* -------------------------------------------------------------------------- */
void GroupManager::createElementGroupFromNodeGroup(
const std::string & name, const std::string & node_group_name,
UInt dimension) {
NodeGroup & node_group = getNodeGroup(node_group_name);
ElementGroup & group = createElementGroup(name, dimension, node_group);
group.fillFromNodeGroup();
}
/* -------------------------------------------------------------------------- */
void GroupManager::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "GroupManager [" << std::endl;
std::set<std::string> node_group_seen;
for (auto & group : iterateElementGroups()) {
group.printself(stream, indent + 1);
node_group_seen.insert(group.getNodeGroup().getName());
}
- for (auto &group : iterateNodeGroups()) {
+ for (auto & group : iterateNodeGroups()) {
if (node_group_seen.find(group.getName()) == node_group_seen.end())
group.printself(stream, indent + 1);
}
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
UInt GroupManager::getNbElementGroups(UInt dimension) const {
if (dimension == _all_dimensions)
return element_groups.size();
auto it = element_groups.begin();
auto end = element_groups.end();
UInt count = 0;
for (; it != end; ++it)
count += (it->second->getDimension() == dimension);
return count;
}
/* -------------------------------------------------------------------------- */
void GroupManager::checkAndAddGroups(DynamicCommunicationBuffer & buffer) {
AKANTU_DEBUG_IN();
UInt nb_node_group;
buffer >> nb_node_group;
AKANTU_DEBUG_INFO("Received " << nb_node_group << " node group names");
for (UInt ng = 0; ng < nb_node_group; ++ng) {
std::string node_group_name;
buffer >> node_group_name;
if (node_groups.find(node_group_name) == node_groups.end()) {
this->createNodeGroup(node_group_name);
}
AKANTU_DEBUG_INFO("Received node goup name: " << node_group_name);
}
UInt nb_element_group;
buffer >> nb_element_group;
AKANTU_DEBUG_INFO("Received " << nb_element_group << " element group names");
for (UInt eg = 0; eg < nb_element_group; ++eg) {
std::string element_group_name;
buffer >> element_group_name;
std::string node_group_name;
buffer >> node_group_name;
UInt dim;
buffer >> dim;
AKANTU_DEBUG_INFO("Received element group name: "
<< element_group_name << " corresponding to a "
<< Int(dim) << "D group with node group "
<< node_group_name);
NodeGroup & node_group = *node_groups[node_group_name];
if (element_groups.find(element_group_name) == element_groups.end()) {
this->createElementGroup(element_group_name, dim, node_group);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void GroupManager::fillBufferWithGroupNames(
DynamicCommunicationBuffer & comm_buffer) const {
AKANTU_DEBUG_IN();
// packing node group names;
UInt nb_groups = this->node_groups.size();
comm_buffer << nb_groups;
AKANTU_DEBUG_INFO("Sending " << nb_groups << " node group names");
auto nnames_it = node_groups.begin();
auto nnames_end = node_groups.end();
for (; nnames_it != nnames_end; ++nnames_it) {
std::string node_group_name = nnames_it->first;
comm_buffer << node_group_name;
AKANTU_DEBUG_INFO("Sending node goupe name: " << node_group_name);
}
// packing element group names with there associated node group name
nb_groups = this->element_groups.size();
comm_buffer << nb_groups;
AKANTU_DEBUG_INFO("Sending " << nb_groups << " element group names");
auto gnames_it = this->element_groups.begin();
auto gnames_end = this->element_groups.end();
for (; gnames_it != gnames_end; ++gnames_it) {
ElementGroup & element_group = *(gnames_it->second);
std::string element_group_name = gnames_it->first;
std::string node_group_name = element_group.getNodeGroup().getName();
UInt dim = element_group.getDimension();
comm_buffer << element_group_name;
comm_buffer << node_group_name;
comm_buffer << dim;
AKANTU_DEBUG_INFO("Sending element group name: "
<< element_group_name << " corresponding to a "
<< Int(dim) << "D group with the node group "
<< node_group_name);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void GroupManager::synchronizeGroupNames() {
AKANTU_DEBUG_IN();
const Communicator & comm = mesh.getCommunicator();
Int nb_proc = comm.getNbProc();
Int my_rank = comm.whoAmI();
if (nb_proc == 1)
return;
if (my_rank == 0) {
for (Int p = 1; p < nb_proc; ++p) {
DynamicCommunicationBuffer recv_buffer;
auto tag = Tag::genTag(p, 0, Tag::_ELEMENT_GROUP);
comm.receive(recv_buffer, p, tag);
AKANTU_DEBUG_INFO("Got " << printMemorySize<char>(recv_buffer.size())
<< " from proc " << p << " " << tag);
this->checkAndAddGroups(recv_buffer);
}
DynamicCommunicationBuffer comm_buffer;
this->fillBufferWithGroupNames(comm_buffer);
AKANTU_DEBUG_INFO("Initiating broadcast with "
<< printMemorySize<char>(comm_buffer.size()));
comm.broadcast(comm_buffer);
} else {
DynamicCommunicationBuffer comm_buffer;
this->fillBufferWithGroupNames(comm_buffer);
auto tag = Tag::genTag(my_rank, 0, Tag::_ELEMENT_GROUP);
AKANTU_DEBUG_INFO("Sending " << printMemorySize<char>(comm_buffer.size())
<< " to proc " << 0 << " " << tag);
comm.send(comm_buffer, 0, tag);
DynamicCommunicationBuffer recv_buffer;
comm.broadcast(recv_buffer);
AKANTU_DEBUG_INFO("Receiving broadcast with "
<< printMemorySize<char>(recv_buffer.size()));
this->checkAndAddGroups(recv_buffer);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
const ElementGroup &
GroupManager::getElementGroup(const std::string & name) const {
auto it = element_groups.find(name);
if (it == element_groups.end()) {
AKANTU_EXCEPTION("There are no element groups named "
<< name << " associated to the group manager: " << id);
}
return *(it->second);
}
/* -------------------------------------------------------------------------- */
ElementGroup & GroupManager::getElementGroup(const std::string & name) {
auto it = element_groups.find(name);
if (it == element_groups.end()) {
AKANTU_EXCEPTION("There are no element groups named "
<< name << " associated to the group manager: " << id);
}
return *(it->second);
}
/* -------------------------------------------------------------------------- */
const NodeGroup & GroupManager::getNodeGroup(const std::string & name) const {
auto it = node_groups.find(name);
if (it == node_groups.end()) {
AKANTU_EXCEPTION("There are no node groups named "
<< name << " associated to the group manager: " << id);
}
return *(it->second);
}
/* -------------------------------------------------------------------------- */
NodeGroup & GroupManager::getNodeGroup(const std::string & name) {
auto it = node_groups.find(name);
if (it == node_groups.end()) {
AKANTU_EXCEPTION("There are no node groups named "
<< name << " associated to the group manager: " << id);
}
return *(it->second);
}
/* -------------------------------------------------------------------------- */
template <typename GroupsType>
void GroupManager::renameGroup(GroupsType & groups, const std::string & name,
const std::string & new_name) {
auto it = groups.find(name);
if (it == groups.end()) {
AKANTU_EXCEPTION("There are no group named "
<< name << " associated to the group manager: " << id);
}
auto && group_ptr = std::move(it->second);
group_ptr->name = new_name;
groups.erase(it);
groups[new_name] = std::move(group_ptr);
}
/* -------------------------------------------------------------------------- */
void GroupManager::renameElementGroup(const std::string & name,
const std::string & new_name) {
renameGroup(element_groups, name, new_name);
}
/* -------------------------------------------------------------------------- */
void GroupManager::renameNodeGroup(const std::string & name,
const std::string & new_name) {
renameGroup(node_groups, name, new_name);
}
/* -------------------------------------------------------------------------- */
void GroupManager::copyElementGroup(const std::string & name,
const std::string & new_name) {
const auto & grp = getElementGroup(name);
auto & new_grp = createElementGroup(new_name, grp.getDimension());
new_grp.getElements().copy(grp.getElements());
}
/* -------------------------------------------------------------------------- */
void GroupManager::copyNodeGroup(const std::string & name,
const std::string & new_name) {
const auto & grp = getNodeGroup(name);
auto & new_grp = createNodeGroup(new_name);
new_grp.getNodes().copy(grp.getNodes());
}
} // namespace akantu
diff --git a/src/mesh/group_manager.hh b/src/mesh/group_manager.hh
index 0cb1cb0dc..ea0f219e8 100644
--- a/src/mesh/group_manager.hh
+++ b/src/mesh/group_manager.hh
@@ -1,350 +1,352 @@
/**
* @file group_manager.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@gmail.com>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Wed Feb 07 2018
*
* @brief Stores information relevent to the notion of element and nodes
* groups.
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_GROUP_MANAGER_HH__
#define __AKANTU_GROUP_MANAGER_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_iterators.hh"
#include "element_type_map.hh"
/* -------------------------------------------------------------------------- */
#include <set>
/* -------------------------------------------------------------------------- */
namespace akantu {
class ElementGroup;
class NodeGroup;
class Mesh;
class Element;
class ElementSynchronizer;
template <bool> class CommunicationBufferTemplated;
namespace dumper {
class Field;
}
} // namespace akantu
namespace akantu {
/* -------------------------------------------------------------------------- */
class GroupManager {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
private:
using ElementGroups = std::map<std::string, std::unique_ptr<ElementGroup>>;
using NodeGroups = std::map<std::string, std::unique_ptr<NodeGroup>>;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
GroupManager(const Mesh & mesh, const ID & id = "group_manager",
const MemoryID & memory_id = 0);
virtual ~GroupManager();
/* ------------------------------------------------------------------------ */
/* Groups iterators */
/* ------------------------------------------------------------------------ */
public:
using node_group_iterator = NodeGroups::iterator;
using element_group_iterator = ElementGroups::iterator;
using const_node_group_iterator = NodeGroups::const_iterator;
using const_element_group_iterator = ElementGroups::const_iterator;
-#define AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION(group_type, function, \
- param_in, param_out) \
+#define AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION(group_type, function, \
+ param_in, param_out) \
[[deprecated( \
"use iterate(Element|Node)Groups or " \
- "(element|node)GroupExists")]] inline BOOST_PP_CAT(BOOST_PP_CAT(const_, group_type), _iterator) \
- BOOST_PP_CAT(BOOST_PP_CAT(group_type, _), function)(param_in) const { \
- return BOOST_PP_CAT(group_type, s).function(param_out); \
- }; \
- \
- [[deprecated( \
- "use iterate(Element|Node)Groups or " \
- "(element|node)GroupExists")]] inline BOOST_PP_CAT(group_type, _iterator) \
- BOOST_PP_CAT(BOOST_PP_CAT(group_type, _), function)(param_in) { \
- return BOOST_PP_CAT(group_type, s).function(param_out); \
+ "(element|node)GroupExists")]] inline BOOST_PP_CAT(BOOST_PP_CAT(const_, \
+ group_type), \
+ _iterator) \
+ BOOST_PP_CAT(BOOST_PP_CAT(group_type, _), function)(param_in) const { \
+ return BOOST_PP_CAT(group_type, s).function(param_out); \
+ }; \
+ \
+ [[deprecated("use iterate(Element|Node)Groups or " \
+ "(element|node)GroupExists")]] inline BOOST_PP_CAT(group_type, \
+ _iterator) \
+ BOOST_PP_CAT(BOOST_PP_CAT(group_type, _), function)(param_in) { \
+ return BOOST_PP_CAT(group_type, s).function(param_out); \
}
#define AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION_NP(group_type, function) \
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION( \
group_type, function, BOOST_PP_EMPTY(), BOOST_PP_EMPTY())
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION_NP(node_group, begin);
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION_NP(node_group, end);
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION_NP(element_group, begin);
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION_NP(element_group, end);
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION(element_group, find,
const std::string & name, name);
AKANTU_GROUP_MANAGER_DEFINE_ITERATOR_FUNCTION(node_group, find,
const std::string & name, name);
public:
decltype(auto) iterateNodeGroups() {
return make_dereference_adaptor(make_values_adaptor(node_groups));
}
decltype(auto) iterateNodeGroups() const {
return make_dereference_adaptor(make_values_adaptor(node_groups));
}
decltype(auto) iterateElementGroups() {
return make_dereference_adaptor(make_values_adaptor(element_groups));
}
decltype(auto) iterateElementGroups() const {
return make_dereference_adaptor(make_values_adaptor(element_groups));
}
/* ------------------------------------------------------------------------ */
/* Clustering filter */
/* ------------------------------------------------------------------------ */
public:
class ClusteringFilter {
public:
virtual bool operator()(const Element &) const { return true; }
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// create an empty node group
NodeGroup & createNodeGroup(const std::string & group_name,
bool replace_group = false);
/// create an element group and the associated node group
ElementGroup & createElementGroup(const std::string & group_name,
UInt dimension = _all_dimensions,
bool replace_group = false);
/* ------------------------------------------------------------------------ */
/// renames an element group
void renameElementGroup(const std::string & name,
const std::string & new_name);
/// renames a node group
void renameNodeGroup(const std::string & name, const std::string & new_name);
/// copy an existing element group
void copyElementGroup(const std::string & name, const std::string & new_name);
/// copy an existing node group
void copyNodeGroup(const std::string & name, const std::string & new_name);
/* ------------------------------------------------------------------------ */
/// create a node group from another node group but filtered
template <typename T>
NodeGroup & createFilteredNodeGroup(const std::string & group_name,
const NodeGroup & node_group, T & filter);
/// create an element group from another element group but filtered
template <typename T>
ElementGroup &
createFilteredElementGroup(const std::string & group_name, UInt dimension,
const NodeGroup & node_group, T & filter);
/// destroy a node group
void destroyNodeGroup(const std::string & group_name);
/// destroy an element group and the associated node group
void destroyElementGroup(const std::string & group_name,
bool destroy_node_group = false);
// /// destroy all element groups and the associated node groups
// void destroyAllElementGroups(bool destroy_node_groups = false);
/// create a element group using an existing node group
ElementGroup & createElementGroup(const std::string & group_name,
UInt dimension, NodeGroup & node_group);
/// create groups based on values stored in a given mesh data
template <typename T>
void createGroupsFromMeshData(const std::string & dataset_name);
/// create boundaries group by a clustering algorithm \todo extend to parallel
UInt createBoundaryGroupFromGeometry();
/// create element clusters for a given dimension
UInt createClusters(UInt element_dimension, Mesh & mesh_facets,
std::string cluster_name_prefix = "cluster",
const ClusteringFilter & filter = ClusteringFilter());
/// create element clusters for a given dimension
UInt createClusters(UInt element_dimension,
std::string cluster_name_prefix = "cluster",
const ClusteringFilter & filter = ClusteringFilter());
private:
/// create element clusters for a given dimension
UInt createClusters(UInt element_dimension,
const std::string & cluster_name_prefix,
const ClusteringFilter & filter, Mesh & mesh_facets);
public:
/// Create an ElementGroup based on a NodeGroup
void createElementGroupFromNodeGroup(const std::string & name,
const std::string & node_group,
UInt dimension = _all_dimensions);
virtual void printself(std::ostream & stream, int indent = 0) const;
/// this function insure that the group names are present on all processors
/// /!\ it is a SMP call
void synchronizeGroupNames();
/// register an elemental field to the given group name (overloading for
/// ElementalPartionField)
template <typename T, template <bool> class dump_type>
std::shared_ptr<dumper::Field> createElementalField(
const ElementTypeMapArray<T> & field, const std::string & group_name,
UInt spatial_dimension, const ElementKind & kind,
ElementTypeMap<UInt> nb_data_per_elem = ElementTypeMap<UInt>());
/// register an elemental field to the given group name (overloading for
/// ElementalField)
template <typename T, template <class> class ret_type,
template <class, template <class> class, bool> class dump_type>
std::shared_ptr<dumper::Field> createElementalField(
const ElementTypeMapArray<T> & field, const std::string & group_name,
UInt spatial_dimension, const ElementKind & kind,
ElementTypeMap<UInt> nb_data_per_elem = ElementTypeMap<UInt>());
/// register an elemental field to the given group name (overloading for
/// MaterialInternalField)
template <typename T,
/// type of InternalMaterialField
template <typename, bool filtered> class dump_type>
std::shared_ptr<dumper::Field>
createElementalField(const ElementTypeMapArray<T> & field,
const std::string & group_name, UInt spatial_dimension,
const ElementKind & kind,
ElementTypeMap<UInt> nb_data_per_elem);
template <typename type, bool flag, template <class, bool> class ftype>
std::shared_ptr<dumper::Field>
createNodalField(const ftype<type, flag> * field,
const std::string & group_name, UInt padding_size = 0);
template <typename type, bool flag, template <class, bool> class ftype>
std::shared_ptr<dumper::Field>
createStridedNodalField(const ftype<type, flag> * field,
const std::string & group_name, UInt size,
UInt stride, UInt padding_size);
protected:
/// fill a buffer with all the group names
void fillBufferWithGroupNames(
CommunicationBufferTemplated<false> & comm_buffer) const;
/// take a buffer and create the missing groups localy
void checkAndAddGroups(CommunicationBufferTemplated<false> & buffer);
/// register an elemental field to the given group name
template <class dump_type, typename field_type>
inline std::shared_ptr<dumper::Field>
createElementalField(const field_type & field, const std::string & group_name,
UInt spatial_dimension, const ElementKind & kind,
const ElementTypeMap<UInt> & nb_data_per_elem);
/// register an elemental field to the given group name
template <class dump_type, typename field_type>
inline std::shared_ptr<dumper::Field>
createElementalFilteredField(const field_type & field,
const std::string & group_name,
UInt spatial_dimension, const ElementKind & kind,
ElementTypeMap<UInt> nb_data_per_elem);
/* ------------------------------------------------------------------------ */
/* Accessor */
/* ------------------------------------------------------------------------ */
public:
// AKANTU_GET_MACRO(ElementGroups, element_groups, const ElementGroups &);
const ElementGroup & getElementGroup(const std::string & name) const;
const NodeGroup & getNodeGroup(const std::string & name) const;
ElementGroup & getElementGroup(const std::string & name);
NodeGroup & getNodeGroup(const std::string & name);
UInt getNbElementGroups(UInt dimension = _all_dimensions) const;
UInt getNbNodeGroups() { return node_groups.size(); };
bool elementGroupExists(const std::string & name) {
return element_groups.find(name) != element_groups.end();
}
bool nodeGroupExists(const std::string & name) {
return node_groups.find(name) != node_groups.end();
}
private:
template <typename GroupsType>
void renameGroup(GroupsType & groups, const std::string & name,
const std::string & new_name);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// id to create element and node groups
ID id;
/// memory_id to create element and node groups
MemoryID memory_id;
/// list of the node groups managed
NodeGroups node_groups;
/// list of the element groups managed
ElementGroups element_groups;
/// Mesh to which the element belongs
const Mesh & mesh;
};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const GroupManager & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AKANTU_GROUP_MANAGER_HH__ */
diff --git a/src/mesh/mesh.cc b/src/mesh/mesh.cc
index 7695b64b2..7e4ca8671 100644
--- a/src/mesh/mesh.cc
+++ b/src/mesh/mesh.cc
@@ -1,579 +1,577 @@
/**
* @file mesh.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief class handling meshes
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_config.hh"
/* -------------------------------------------------------------------------- */
#include "element_class.hh"
#include "group_manager_inline_impl.cc"
#include "mesh.hh"
#include "mesh_global_data_updater.hh"
#include "mesh_io.hh"
#include "mesh_iterators.hh"
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "element_synchronizer.hh"
#include "facet_synchronizer.hh"
#include "mesh_utils_distribution.hh"
#include "node_synchronizer.hh"
#include "periodic_node_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
#include "dumper_field.hh"
#include "dumper_internal_material_field.hh"
#endif
/* -------------------------------------------------------------------------- */
#include <limits>
#include <sstream>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Mesh::Mesh(UInt spatial_dimension, const ID & id, const MemoryID & memory_id,
Communicator & communicator)
: Memory(id, memory_id),
GroupManager(*this, id + ":group_manager", memory_id),
MeshData("mesh_data", id, memory_id),
connectivities("connectivities", id, memory_id),
ghosts_counters("ghosts_counters", id, memory_id),
normals("normals", id, memory_id), spatial_dimension(spatial_dimension),
size(spatial_dimension, 0.), bbox(spatial_dimension),
bbox_local(spatial_dimension), communicator(&communicator) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Mesh::Mesh(UInt spatial_dimension, Communicator & communicator, const ID & id,
const MemoryID & memory_id)
: Mesh(spatial_dimension, id, memory_id, communicator) {
AKANTU_DEBUG_IN();
this->nodes =
std::make_shared<Array<Real>>(0, spatial_dimension, id + ":coordinates");
this->nodes_flags = std::make_shared<Array<NodeFlag>>(0, 1, NodeFlag::_normal,
id + ":nodes_flags");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Mesh::Mesh(UInt spatial_dimension, const ID & id, const MemoryID & memory_id)
: Mesh(spatial_dimension, Communicator::getStaticCommunicator(), id,
memory_id) {}
/* -------------------------------------------------------------------------- */
Mesh::Mesh(UInt spatial_dimension, const std::shared_ptr<Array<Real>> & nodes,
const ID & id, const MemoryID & memory_id)
: Mesh(spatial_dimension, id, memory_id,
Communicator::getStaticCommunicator()) {
this->nodes = nodes;
this->nb_global_nodes = this->nodes->size();
this->nodes_to_elements.resize(nodes->size());
for (auto & node_set : nodes_to_elements) {
node_set = std::make_unique<std::set<Element>>();
}
this->computeBoundingBox();
}
/* -------------------------------------------------------------------------- */
void Mesh::getBarycenters(Array<Real> & barycenter, const ElementType & type,
const GhostType & ghost_type) const {
barycenter.resize(getNbElement(type, ghost_type));
for (auto && data : enumerate(make_view(barycenter, spatial_dimension))) {
getBarycenter(Element{type, UInt(std::get<0>(data)), ghost_type},
std::get<1>(data));
}
}
/* -------------------------------------------------------------------------- */
Mesh & Mesh::initMeshFacets(const ID & id) {
AKANTU_DEBUG_IN();
if (mesh_facets) {
AKANTU_DEBUG_OUT();
return *mesh_facets;
}
mesh_facets = std::make_unique<Mesh>(spatial_dimension, this->nodes,
getID() + ":" + id, getMemoryID());
mesh_facets->mesh_parent = this;
mesh_facets->is_mesh_facets = true;
mesh_facets->nodes_flags = this->nodes_flags;
mesh_facets->nodes_global_ids = this->nodes_global_ids;
MeshUtils::buildAllFacets(*this, *mesh_facets, 0);
if (mesh.isDistributed()) {
mesh_facets->is_distributed = true;
mesh_facets->element_synchronizer = std::make_unique<FacetSynchronizer>(
*mesh_facets, mesh.getElementSynchronizer());
}
/// transfers the the mesh physical names to the mesh facets
if (not this->hasData("physical_names")) {
AKANTU_DEBUG_OUT();
return *mesh_facets;
}
auto & mesh_phys_data = this->getData<std::string>("physical_names");
auto & phys_data = mesh_facets->getData<std::string>("physical_names");
phys_data.initialize(*mesh_facets, _spatial_dimension = spatial_dimension - 1,
_with_nb_element = true);
ElementTypeMapArray<Real> barycenters(getID(), "temporary_barycenters");
barycenters.initialize(*mesh_facets, _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension - 1,
_with_nb_element = true);
for (auto && ghost_type : ghost_types) {
for (auto && type :
barycenters.elementTypes(spatial_dimension - 1, ghost_type)) {
mesh_facets->getBarycenters(barycenters(type, ghost_type), type,
ghost_type);
}
}
for_each_element(
mesh,
[&](auto && element) {
Vector<Real> barycenter(spatial_dimension);
mesh.getBarycenter(element, barycenter);
auto norm_barycenter = barycenter.norm();
auto tolerance = Math::getTolerance();
if (norm_barycenter > tolerance)
tolerance *= norm_barycenter;
// const auto & element_to_facet = mesh_facets->getElementToSubelement(
// element.type, element.ghost_type);
Vector<Real> barycenter_facet(spatial_dimension);
auto range = enumerate(make_view(
barycenters(element.type, element.ghost_type), spatial_dimension));
#ifndef AKANTU_NDEBUG
auto min_dist = std::numeric_limits<Real>::max();
#endif
// this is a spacial search coded the most inefficient way.
auto facet =
std::find_if(range.begin(), range.end(), [&](auto && data) {
// auto facet = std::get<0>(data);
// if (element_to_facet(facet)[1] == ElementNull)
// return false;
auto norm_distance = barycenter.distance(std::get<1>(data));
#ifndef AKANTU_NDEBUG
min_dist = std::min(min_dist, norm_distance);
#endif
return (norm_distance < tolerance);
});
if (facet == range.end()) {
AKANTU_DEBUG_INFO("The element "
<< element
<< " did not find its associated facet in the "
"mesh_facets! Try to decrease math tolerance. "
"The closest element was at a distance of "
<< min_dist);
return;
}
// set physical name
phys_data(Element{element.type, UInt(std::get<0>(*facet)),
element.ghost_type}) = mesh_phys_data(element);
},
_spatial_dimension = spatial_dimension - 1);
mesh_facets->createGroupsFromMeshData<std::string>("physical_names");
AKANTU_DEBUG_OUT();
return *mesh_facets;
}
/* -------------------------------------------------------------------------- */
void Mesh::defineMeshParent(const Mesh & mesh) {
AKANTU_DEBUG_IN();
this->mesh_parent = &mesh;
this->is_mesh_facets = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Mesh::~Mesh() = default;
/* -------------------------------------------------------------------------- */
void Mesh::read(const std::string & filename, const MeshIOType & mesh_io_type) {
AKANTU_DEBUG_ASSERT(not is_distributed,
"You cannot read a mesh that is already distributed");
MeshIO mesh_io;
mesh_io.read(filename, *this, mesh_io_type);
auto types =
this->elementTypes(spatial_dimension, _not_ghost, _ek_not_defined);
auto it = types.begin();
auto last = types.end();
if (it == last)
AKANTU_DEBUG_WARNING(
"The mesh contained in the file "
<< filename << " does not seem to be of the good dimension."
<< " No element of dimension " << spatial_dimension << " where read.");
this->makeReady();
}
/* -------------------------------------------------------------------------- */
void Mesh::write(const std::string & filename,
const MeshIOType & mesh_io_type) {
MeshIO mesh_io;
mesh_io.write(filename, *this, mesh_io_type);
}
/* -------------------------------------------------------------------------- */
void Mesh::makeReady() {
this->nb_global_nodes = this->nodes->size();
this->computeBoundingBox();
this->nodes_flags->resize(nodes->size(), NodeFlag::_normal);
this->nodes_to_elements.resize(nodes->size());
for (auto & node_set : nodes_to_elements) {
node_set = std::make_unique<std::set<Element>>();
}
}
/* -------------------------------------------------------------------------- */
void Mesh::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "Mesh [" << std::endl;
stream << space << " + id : " << getID() << std::endl;
stream << space << " + spatial dimension : " << this->spatial_dimension
<< std::endl;
stream << space << " + nodes [" << std::endl;
nodes->printself(stream, indent + 2);
stream << space << " + connectivities [" << std::endl;
connectivities.printself(stream, indent + 2);
stream << space << " ]" << std::endl;
GroupManager::printself(stream, indent + 1);
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
void Mesh::computeBoundingBox() {
AKANTU_DEBUG_IN();
bbox_local.reset();
for (auto & pos : make_view(*nodes, spatial_dimension)) {
// if(!isPureGhostNode(i))
bbox_local += pos;
}
if (this->is_distributed) {
bbox = bbox_local.allSum(*communicator);
} else {
bbox = bbox_local;
}
size = bbox.size();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Mesh::initNormals() {
normals.initialize(*this, _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension,
_element_kind = _ek_not_defined);
}
/* -------------------------------------------------------------------------- */
void Mesh::getGlobalConnectivity(
ElementTypeMapArray<UInt> & global_connectivity) {
AKANTU_DEBUG_IN();
for (auto && ghost_type : ghost_types) {
for (auto type :
global_connectivity.elementTypes(_spatial_dimension = _all_dimensions,
_element_kind = _ek_not_defined, _ghost_type = ghost_type)) {
if (not connectivities.exists(type, ghost_type))
continue;
auto & local_conn = connectivities(type, ghost_type);
auto & g_connectivity = global_connectivity(type, ghost_type);
UInt nb_nodes = local_conn.size() * local_conn.getNbComponent();
std::transform(local_conn.begin_reinterpret(nb_nodes),
local_conn.end_reinterpret(nb_nodes),
g_connectivity.begin_reinterpret(nb_nodes),
[&](UInt l) -> UInt { return this->getNodeGlobalId(l); });
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
DumperIOHelper & Mesh::getGroupDumper(const std::string & dumper_name,
const std::string & group_name) {
if (group_name == "all")
return this->getDumper(dumper_name);
else
return element_groups[group_name]->getDumper(dumper_name);
}
/* -------------------------------------------------------------------------- */
template <typename T>
-ElementTypeMap<UInt> Mesh::getNbDataPerElem(ElementTypeMapArray<T> & arrays,
- const ElementKind & element_kind) {
+ElementTypeMap<UInt> Mesh::getNbDataPerElem(ElementTypeMapArray<T> & arrays) {
ElementTypeMap<UInt> nb_data_per_elem;
- for (auto type : elementTypes(spatial_dimension, _not_ghost, element_kind)) {
+ for (auto type : arrays.elementTypes()) {
UInt nb_elements = this->getNbElement(type);
auto & array = arrays(type);
nb_data_per_elem(type) = array.getNbComponent() * array.size();
nb_data_per_elem(type) /= nb_elements;
}
return nb_data_per_elem;
}
/* -------------------------------------------------------------------------- */
template ElementTypeMap<UInt>
-Mesh::getNbDataPerElem(ElementTypeMapArray<Real> & array,
- const ElementKind & element_kind);
+Mesh::getNbDataPerElem(ElementTypeMapArray<Real> & array);
template ElementTypeMap<UInt>
-Mesh::getNbDataPerElem(ElementTypeMapArray<UInt> & array,
- const ElementKind & element_kind);
+Mesh::getNbDataPerElem(ElementTypeMapArray<UInt> & array);
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
template <typename T>
std::shared_ptr<dumper::Field>
Mesh::createFieldFromAttachedData(const std::string & field_id,
const std::string & group_name,
const ElementKind & element_kind) {
std::shared_ptr<dumper::Field> field;
ElementTypeMapArray<T> * internal = nullptr;
try {
internal = &(this->getData<T>(field_id));
} catch (...) {
return nullptr;
}
- ElementTypeMap<UInt> nb_data_per_elem =
- this->getNbDataPerElem(*internal, element_kind);
+ ElementTypeMap<UInt> nb_data_per_elem = this->getNbDataPerElem(*internal);
field = this->createElementalField<T, dumper::InternalMaterialField>(
*internal, group_name, this->spatial_dimension, element_kind,
nb_data_per_elem);
return field;
}
template std::shared_ptr<dumper::Field>
Mesh::createFieldFromAttachedData<Real>(const std::string & field_id,
const std::string & group_name,
const ElementKind & element_kind);
template std::shared_ptr<dumper::Field>
Mesh::createFieldFromAttachedData<UInt>(const std::string & field_id,
const std::string & group_name,
const ElementKind & element_kind);
#endif
/* -------------------------------------------------------------------------- */
void Mesh::distributeImpl(
Communicator & communicator,
- std::function<Int(const Element &, const Element &)> edge_weight_function [[gnu::unused]],
- std::function<Int(const Element &)> vertex_weight_function [[gnu::unused]]) {
+ std::function<Int(const Element &, const Element &)> edge_weight_function
+ [[gnu::unused]],
+ std::function<Int(const Element &)> vertex_weight_function
+ [[gnu::unused]]) {
AKANTU_DEBUG_ASSERT(is_distributed == false,
"This mesh is already distribute");
this->communicator = &communicator;
this->element_synchronizer = std::make_unique<ElementSynchronizer>(
*this, this->getID() + ":element_synchronizer", this->getMemoryID(),
true);
this->node_synchronizer = std::make_unique<NodeSynchronizer>(
*this, this->getID() + ":node_synchronizer", this->getMemoryID(), true);
Int psize = this->communicator->getNbProc();
if (psize > 1) {
#ifdef AKANTU_USE_SCOTCH
Int prank = this->communicator->whoAmI();
if (prank == 0) {
MeshPartitionScotch partition(*this, spatial_dimension);
partition.partitionate(psize, edge_weight_function,
vertex_weight_function);
MeshUtilsDistribution::distributeMeshCentralized(*this, 0, partition);
} else {
MeshUtilsDistribution::distributeMeshCentralized(*this, 0);
}
#else
if (psize > 1) {
AKANTU_ERROR("Cannot distribute a mesh without a partitioning tool");
}
#endif
}
// if (psize > 1)
this->is_distributed = true;
this->computeBoundingBox();
}
/* -------------------------------------------------------------------------- */
void Mesh::getAssociatedElements(const Array<UInt> & node_list,
Array<Element> & elements) {
for (const auto & node : node_list)
for (const auto & element : *nodes_to_elements[node])
elements.push_back(element);
}
/* -------------------------------------------------------------------------- */
void Mesh::getAssociatedElements(const UInt & node,
Array<Element> & elements) {
for (const auto & element : *nodes_to_elements[node])
elements.push_back(element);
}
/* -------------------------------------------------------------------------- */
void Mesh::fillNodesToElements(UInt dimension) {
Element e;
UInt nb_nodes = nodes->size();
this->nodes_to_elements.resize(nodes->size());
for (UInt n = 0; n < nb_nodes; ++n) {
if (this->nodes_to_elements[n])
this->nodes_to_elements[n]->clear();
else
this->nodes_to_elements[n] = std::make_unique<std::set<Element>>();
}
for (auto ghost_type : ghost_types) {
e.ghost_type = ghost_type;
for (const auto & type :
elementTypes(dimension, ghost_type, _ek_not_defined)) {
e.type = type;
UInt nb_element = this->getNbElement(type, ghost_type);
Array<UInt>::const_iterator<Vector<UInt>> conn_it =
connectivities(type, ghost_type)
.begin(Mesh::getNbNodesPerElement(type));
for (UInt el = 0; el < nb_element; ++el, ++conn_it) {
e.element = el;
const Vector<UInt> & conn = *conn_it;
for (UInt n = 0; n < conn.size(); ++n)
nodes_to_elements[conn(n)]->insert(e);
}
}
}
}
/* -------------------------------------------------------------------------- */
std::tuple<UInt, UInt>
Mesh::updateGlobalData(NewNodesEvent & nodes_event,
NewElementsEvent & elements_event) {
if (global_data_updater)
return this->global_data_updater->updateData(nodes_event, elements_event);
else {
return std::make_tuple(nodes_event.getList().size(),
elements_event.getList().size());
}
}
/* -------------------------------------------------------------------------- */
void Mesh::registerGlobalDataUpdater(
std::unique_ptr<MeshGlobalDataUpdater> && global_data_updater) {
this->global_data_updater = std::move(global_data_updater);
}
/* -------------------------------------------------------------------------- */
void Mesh::eraseElements(const Array<Element> & elements) {
ElementTypeMap<UInt> last_element;
RemovedElementsEvent event(*this);
auto & remove_list = event.getList();
auto & new_numbering = event.getNewNumbering();
for (auto && el : elements) {
if (el.ghost_type != _not_ghost) {
auto & count = ghosts_counters(el);
--count;
if (count > 0)
continue;
}
remove_list.push_back(el);
if (not last_element.exists(el.type, el.ghost_type)) {
UInt nb_element = mesh.getNbElement(el.type, el.ghost_type);
last_element(nb_element - 1, el.type, el.ghost_type);
auto & numbering =
new_numbering.alloc(nb_element, 1, el.type, el.ghost_type);
for (auto && pair : enumerate(numbering)) {
std::get<1>(pair) = std::get<0>(pair);
}
}
UInt & pos = last_element(el.type, el.ghost_type);
auto & numbering = new_numbering(el.type, el.ghost_type);
numbering(el.element) = UInt(-1);
numbering(pos) = el.element;
--pos;
}
this->sendEvent(event);
}
} // namespace akantu
diff --git a/src/mesh/mesh.hh b/src/mesh/mesh.hh
index 522337572..7b4c38b66 100644
--- a/src/mesh/mesh.hh
+++ b/src/mesh/mesh.hh
@@ -1,704 +1,703 @@
/**
* @file mesh.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Mon Feb 19 2018
*
* @brief the class representing the meshes
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_HH__
#define __AKANTU_MESH_HH__
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_bbox.hh"
#include "aka_event_handler_manager.hh"
#include "aka_memory.hh"
#include "communicator.hh"
#include "dumpable.hh"
#include "element.hh"
#include "element_class.hh"
#include "element_type_map.hh"
#include "group_manager.hh"
#include "mesh_data.hh"
#include "mesh_events.hh"
/* -------------------------------------------------------------------------- */
#include <functional>
#include <set>
#include <unordered_map>
/* -------------------------------------------------------------------------- */
namespace akantu {
class ElementSynchronizer;
class NodeSynchronizer;
class PeriodicNodeSynchronizer;
class MeshGlobalDataUpdater;
} // namespace akantu
namespace akantu {
namespace {
DECLARE_NAMED_ARGUMENT(communicator);
DECLARE_NAMED_ARGUMENT(edge_weight_function);
DECLARE_NAMED_ARGUMENT(vertex_weight_function);
} // namespace
/* -------------------------------------------------------------------------- */
/* Mesh */
/* -------------------------------------------------------------------------- */
/**
* @class Mesh this contain the coordinates of the nodes in the Mesh.nodes
* Array, and the connectivity. The connectivity are stored in by element
* types.
*
* In order to loop on all element you have to loop on all types like this :
* @code{.cpp}
for(auto & type : mesh.elementTypes()) {
UInt nb_element = mesh.getNbElement(type);
const Array<UInt> & conn = mesh.getConnectivity(type);
for(UInt e = 0; e < nb_element; ++e) {
...
}
}
or
for_each_element(mesh, [](Element & element) {
std::cout << element << std::endl
});
@endcode
*/
class Mesh : protected Memory,
public EventHandlerManager<MeshEventHandler>,
public GroupManager,
public MeshData,
public Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
private:
/// default constructor used for chaining, the last parameter is just to
/// differentiate constructors
Mesh(UInt spatial_dimension, const ID & id, const MemoryID & memory_id,
Communicator & communicator);
public:
/// constructor that create nodes coordinates array
Mesh(UInt spatial_dimension, const ID & id = "mesh",
const MemoryID & memory_id = 0);
/// mesh not distributed and not using the default communicator
Mesh(UInt spatial_dimension, Communicator & communicator,
const ID & id = "mesh", const MemoryID & memory_id = 0);
/**
* constructor that use an existing nodes coordinates
* array, by getting the vector of coordinates
*/
Mesh(UInt spatial_dimension, const std::shared_ptr<Array<Real>> & nodes,
const ID & id = "mesh", const MemoryID & memory_id = 0);
~Mesh() override;
/// read the mesh from a file
void read(const std::string & filename,
const MeshIOType & mesh_io_type = _miot_auto);
/// write the mesh to a file
void write(const std::string & filename,
const MeshIOType & mesh_io_type = _miot_auto);
protected:
void makeReady();
private:
/// initialize the connectivity to NULL and other stuff
void init();
/// function that computes the bounding box (fills xmin, xmax)
void computeBoundingBox();
/* ------------------------------------------------------------------------ */
/* Distributed memory methods and accessors */
/* ------------------------------------------------------------------------ */
public:
protected:
/// patitionate the mesh among the processors involved in their computation
virtual void distributeImpl(
Communicator & communicator,
std::function<Int(const Element &, const Element &)> edge_weight_function,
std::function<Int(const Element &)> vertex_weight_function);
public:
/// with the arguments to pass to the partitionner
template <typename... pack>
std::enable_if_t<are_named_argument<pack...>::value>
distribute(pack &&... _pack) {
distributeImpl(
OPTIONAL_NAMED_ARG(communicator, Communicator::getStaticCommunicator()),
OPTIONAL_NAMED_ARG(edge_weight_function,
[](auto &&, auto &&) { return 1; }),
OPTIONAL_NAMED_ARG(vertex_weight_function, [](auto &&) { return 1; }));
}
/// defines is the mesh is distributed or not
inline bool isDistributed() const { return this->is_distributed; }
/* ------------------------------------------------------------------------ */
/* Periodicity methods and accessors */
/* ------------------------------------------------------------------------ */
public:
/// set the periodicity in a given direction
void makePeriodic(const SpatialDirection & direction);
void makePeriodic(const SpatialDirection & direction, const ID & list_1,
const ID & list_2);
protected:
void makePeriodic(const SpatialDirection & direction,
const Array<UInt> & list_1, const Array<UInt> & list_2);
/// Removes the face that the mesh is periodic
void wipePeriodicInfo();
inline void addPeriodicSlave(UInt slave, UInt master);
template <typename T>
void synchronizePeriodicSlaveDataWithMaster(Array<T> & data);
// update the periodic synchronizer (creates it if it does not exists)
void updatePeriodicSynchronizer();
public:
/// defines if the mesh is periodic or not
inline bool isPeriodic() const { return (this->is_periodic != 0); }
inline bool isPeriodic(const SpatialDirection & direction) const {
return ((this->is_periodic & (1 << direction)) != 0);
}
class PeriodicSlaves;
/// get the master node for a given slave nodes, except if node not a slave
inline UInt getPeriodicMaster(UInt slave) const;
/// get an iterable list of slaves for a given master node
inline decltype(auto) getPeriodicSlaves(UInt master) const;
/* ------------------------------------------------------------------------ */
/* General Methods */
/* ------------------------------------------------------------------------ */
public:
/// function to print the containt of the class
void printself(std::ostream & stream, int indent = 0) const override;
/// extract coordinates of nodes from an element
template <typename T>
inline void extractNodalValuesFromElement(const Array<T> & nodal_values,
T * elemental_values,
UInt * connectivity, UInt n_nodes,
UInt nb_degree_of_freedom) const;
// /// extract coordinates of nodes from a reversed element
// inline void extractNodalCoordinatesFromPBCElement(Real * local_coords,
// UInt * connectivity,
// UInt n_nodes);
/// add a Array of connectivity for the type <type>.
inline void addConnectivityType(const ElementType & type,
const GhostType & ghost_type = _not_ghost);
/* ------------------------------------------------------------------------ */
template <class Event> inline void sendEvent(Event & event) {
// if(event.getList().size() != 0)
EventHandlerManager<MeshEventHandler>::sendEvent<Event>(event);
}
/// prepare the event to remove the elements listed
void eraseElements(const Array<Element> & elements);
/* ------------------------------------------------------------------------ */
template <typename T>
inline void removeNodesFromArray(Array<T> & vect,
const Array<UInt> & new_numbering);
/// initialize normals
void initNormals();
/// init facets' mesh
Mesh & initMeshFacets(const ID & id = "mesh_facets");
/// define parent mesh
void defineMeshParent(const Mesh & mesh);
/// get global connectivity array
void getGlobalConnectivity(ElementTypeMapArray<UInt> & global_connectivity);
public:
void getAssociatedElements(const Array<UInt> & node_list,
Array<Element> & elements);
void getAssociatedElements(const UInt & node,
Array<Element> & elements);
public:
/// fills the nodes_to_elements for given dimension elements
void fillNodesToElements(UInt dimension = _all_dimensions);
private:
/// update the global ids, nodes type, ...
std::tuple<UInt, UInt> updateGlobalData(NewNodesEvent & nodes_event,
NewElementsEvent & elements_event);
void registerGlobalDataUpdater(
std::unique_ptr<MeshGlobalDataUpdater> && global_data_updater);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get the id of the mesh
AKANTU_GET_MACRO(ID, Memory::id, const ID &);
/// get the id of the mesh
AKANTU_GET_MACRO(MemoryID, Memory::memory_id, const MemoryID &);
/// get the spatial dimension of the mesh = number of component of the
/// coordinates
AKANTU_GET_MACRO(SpatialDimension, spatial_dimension, UInt);
/// get the nodes Array aka coordinates
AKANTU_GET_MACRO(Nodes, *nodes, const Array<Real> &);
AKANTU_GET_MACRO_NOT_CONST(Nodes, *nodes, Array<Real> &);
/// get the normals for the elements
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(Normals, normals, Real);
/// get the number of nodes
AKANTU_GET_MACRO(NbNodes, nodes->size(), UInt);
/// get the Array of global ids of the nodes (only used in parallel)
AKANTU_GET_MACRO(GlobalNodesIds, *nodes_global_ids, const Array<UInt> &);
// AKANTU_GET_MACRO_NOT_CONST(GlobalNodesIds, *nodes_global_ids, Array<UInt>
// &);
/// get the global id of a node
inline UInt getNodeGlobalId(UInt local_id) const;
/// get the global id of a node
inline UInt getNodeLocalId(UInt global_id) const;
/// get the global number of nodes
inline UInt getNbGlobalNodes() const;
/// get the nodes type Array
AKANTU_GET_MACRO(NodesFlags, *nodes_flags, const Array<NodeFlag> &);
protected:
AKANTU_GET_MACRO_NOT_CONST(NodesFlags, *nodes_flags, Array<NodeFlag> &);
public:
inline NodeFlag getNodeFlag(UInt local_id) const;
inline Int getNodePrank(UInt local_id) const;
/// say if a node is a pure ghost node
inline bool isPureGhostNode(UInt n) const;
/// say if a node is pur local or master node
inline bool isLocalOrMasterNode(UInt n) const;
inline bool isLocalNode(UInt n) const;
inline bool isMasterNode(UInt n) const;
inline bool isSlaveNode(UInt n) const;
inline bool isPeriodicSlave(UInt n) const;
inline bool isPeriodicMaster(UInt n) const;
const Vector<Real> & getLowerBounds() const { return bbox.getLowerBounds(); }
const Vector<Real> & getUpperBounds() const { return bbox.getUpperBounds(); }
AKANTU_GET_MACRO(BBox, bbox, const BBox &);
const Vector<Real> & getLocalLowerBounds() const {
return bbox_local.getLowerBounds();
}
const Vector<Real> & getLocalUpperBounds() const {
return bbox_local.getUpperBounds();
}
AKANTU_GET_MACRO(LocalBBox, bbox_local, const BBox &);
/// get the connectivity Array for a given type
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Connectivity, connectivities, UInt);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(Connectivity, connectivities, UInt);
AKANTU_GET_MACRO(Connectivities, connectivities,
const ElementTypeMapArray<UInt> &);
/// get the number of element of a type in the mesh
inline UInt getNbElement(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const;
/// get the number of element for a given ghost_type and a given dimension
inline UInt getNbElement(const UInt spatial_dimension = _all_dimensions,
const GhostType & ghost_type = _not_ghost,
const ElementKind & kind = _ek_not_defined) const;
/// compute the barycenter of a given element
inline void getBarycenter(const Element & element,
Vector<Real> & barycenter) const;
void getBarycenters(Array<Real> & barycenter, const ElementType & type,
const GhostType & ghost_type) const;
/// get the element connected to a subelement (element of lower dimension)
const auto & getElementToSubelement() const;
/// get the element connected to a subelement
const auto &
getElementToSubelement(const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
/// get the element connected to a subelement
auto & getElementToSubelement(const ElementType & el_type,
const GhostType & ghost_type = _not_ghost);
/// get the elements connected to a subelement
const auto & getElementToSubelement(const Element & element) const;
/// get the subelement (element of lower dimension) connected to a element
const auto & getSubelementToElement() const;
/// get the subelement connected to an element
const auto &
getSubelementToElement(const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
/// get the subelement connected to an element
auto & getSubelementToElement(const ElementType & el_type,
const GhostType & ghost_type = _not_ghost);
/// get the subelement (element of lower dimension) connected to a element
VectorProxy<Element> getSubelementToElement(const Element & element) const;
/// get connectivity of a given element
inline VectorProxy<UInt> getConnectivity(const Element & element) const;
inline Vector<UInt>
getConnectivityWithPeriodicity(const Element & element) const;
protected:
inline auto & getElementToSubelement(const Element & element);
inline VectorProxy<Element> getSubelementToElement(const Element & element);
inline VectorProxy<UInt> getConnectivity(const Element & element);
public:
/// get a name field associated to the mesh
template <typename T>
inline const Array<T> &
getData(const ID & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
/// get a name field associated to the mesh
template <typename T>
inline Array<T> & getData(const ID & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost);
/// get a name field associated to the mesh
template <typename T>
inline const ElementTypeMapArray<T> & getData(const ID & data_name) const;
/// get a name field associated to the mesh
template <typename T>
inline ElementTypeMapArray<T> & getData(const ID & data_name);
template <typename T>
- ElementTypeMap<UInt> getNbDataPerElem(ElementTypeMapArray<T> & array,
- const ElementKind & element_kind);
+ ElementTypeMap<UInt> getNbDataPerElem(ElementTypeMapArray<T> & array);
template <typename T>
std::shared_ptr<dumper::Field>
createFieldFromAttachedData(const std::string & field_id,
const std::string & group_name,
const ElementKind & element_kind);
/// templated getter returning the pointer to data in MeshData (modifiable)
template <typename T>
inline Array<T> &
getDataPointer(const std::string & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost,
UInt nb_component = 1, bool size_to_nb_element = true,
bool resize_with_parent = false);
template <typename T>
inline Array<T> & getDataPointer(const ID & data_name,
const ElementType & el_type,
const GhostType & ghost_type,
UInt nb_component, bool size_to_nb_element,
bool resize_with_parent, const T & defaul_);
/// Facets mesh accessor
inline const Mesh & getMeshFacets() const;
inline Mesh & getMeshFacets();
/// Parent mesh accessor
inline const Mesh & getMeshParent() const;
inline bool isMeshFacets() const { return this->is_mesh_facets; }
/// return the dumper from a group and and a dumper name
DumperIOHelper & getGroupDumper(const std::string & dumper_name,
const std::string & group_name);
/* ------------------------------------------------------------------------ */
/* Wrappers on ElementClass functions */
/* ------------------------------------------------------------------------ */
public:
/// get the number of nodes per element for a given element type
static inline UInt getNbNodesPerElement(const ElementType & type);
/// get the number of nodes per element for a given element type considered as
/// a first order element
static inline ElementType getP1ElementType(const ElementType & type);
/// get the kind of the element type
static inline ElementKind getKind(const ElementType & type);
/// get spatial dimension of a type of element
static inline UInt getSpatialDimension(const ElementType & type);
/// get the natural space dimension of a type of element
static inline UInt getNaturalSpaceDimension(const ElementType & type);
/// get number of facets of a given element type
static inline UInt getNbFacetsPerElement(const ElementType & type);
/// get number of facets of a given element type
static inline UInt getNbFacetsPerElement(const ElementType & type, UInt t);
/// get local connectivity of a facet for a given facet type
static inline auto getFacetLocalConnectivity(const ElementType & type,
UInt t = 0);
/// get connectivity of facets for a given element
inline auto getFacetConnectivity(const Element & element, UInt t = 0) const;
/// get the number of type of the surface element associated to a given
/// element type
static inline UInt getNbFacetTypes(const ElementType & type, UInt t = 0);
/// get the type of the surface element associated to a given element
static inline constexpr auto getFacetType(const ElementType & type,
UInt t = 0);
/// get all the type of the surface element associated to a given element
static inline constexpr auto getAllFacetTypes(const ElementType & type);
/// get the number of nodes in the given element list
static inline UInt getNbNodesPerElementList(const Array<Element> & elements);
/* ------------------------------------------------------------------------ */
/* Element type Iterator */
/* ------------------------------------------------------------------------ */
using type_iterator [[deprecated]] =
ElementTypeMapArray<UInt, ElementType>::type_iterator;
using ElementTypesIteratorHelper =
ElementTypeMapArray<UInt, ElementType>::ElementTypesIteratorHelper;
template <typename... pack>
ElementTypesIteratorHelper elementTypes(pack &&... _pack) const;
[[deprecated("Use elementTypes instead")]] inline decltype(auto)
firstType(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_regular) const {
return connectivities.elementTypes(dim, ghost_type, kind).begin();
}
[[deprecated("Use elementTypes instead")]] inline decltype(auto)
lastType(UInt dim = _all_dimensions, GhostType ghost_type = _not_ghost,
ElementKind kind = _ek_regular) const {
return connectivities.elementTypes(dim, ghost_type, kind).end();
}
AKANTU_GET_MACRO(ElementSynchronizer, *element_synchronizer,
const ElementSynchronizer &);
AKANTU_GET_MACRO_NOT_CONST(ElementSynchronizer, *element_synchronizer,
ElementSynchronizer &);
AKANTU_GET_MACRO(NodeSynchronizer, *node_synchronizer,
const NodeSynchronizer &);
AKANTU_GET_MACRO_NOT_CONST(NodeSynchronizer, *node_synchronizer,
NodeSynchronizer &);
AKANTU_GET_MACRO(PeriodicNodeSynchronizer, *periodic_node_synchronizer,
const PeriodicNodeSynchronizer &);
AKANTU_GET_MACRO_NOT_CONST(PeriodicNodeSynchronizer,
*periodic_node_synchronizer,
PeriodicNodeSynchronizer &);
// AKANTU_GET_MACRO_NOT_CONST(Communicator, *communicator, StaticCommunicator
// &);
AKANTU_GET_MACRO(Communicator, *communicator, const auto &);
AKANTU_GET_MACRO_NOT_CONST(Communicator, *communicator, auto &);
AKANTU_GET_MACRO(PeriodicMasterSlaves, periodic_master_slave, const auto &);
/* ------------------------------------------------------------------------ */
/* Private methods for friends */
/* ------------------------------------------------------------------------ */
private:
friend class MeshAccessor;
friend class MeshUtils;
AKANTU_GET_MACRO(NodesPointer, *nodes, Array<Real> &);
/// get a pointer to the nodes_global_ids Array<UInt> and create it if
/// necessary
inline Array<UInt> & getNodesGlobalIdsPointer();
/// get a pointer to the nodes_type Array<Int> and create it if necessary
inline Array<NodeFlag> & getNodesFlagsPointer();
/// get a pointer to the connectivity Array for the given type and create it
/// if necessary
inline Array<UInt> &
getConnectivityPointer(const ElementType & type,
const GhostType & ghost_type = _not_ghost);
/// get the ghost element counter
inline Array<UInt> &
getGhostsCounters(const ElementType & type,
const GhostType & ghost_type = _ghost) {
AKANTU_DEBUG_ASSERT(ghost_type != _not_ghost,
"No ghost counter for _not_ghost elements");
return ghosts_counters(type, ghost_type);
}
/// get a pointer to the element_to_subelement Array for the given type and
/// create it if necessary
inline Array<std::vector<Element>> &
getElementToSubelementPointer(const ElementType & type,
const GhostType & ghost_type = _not_ghost);
/// get a pointer to the subelement_to_element Array for the given type and
/// create it if necessary
inline Array<Element> &
getSubelementToElementPointer(const ElementType & type,
const GhostType & ghost_type = _not_ghost);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// array of the nodes coordinates
std::shared_ptr<Array<Real>> nodes;
/// global node ids
std::shared_ptr<Array<UInt>> nodes_global_ids;
/// node flags (shared/periodic/...)
std::shared_ptr<Array<NodeFlag>> nodes_flags;
/// processor handling the node when not local or master
std::unordered_map<UInt, Int> nodes_prank;
/// global number of nodes;
UInt nb_global_nodes{0};
/// all class of elements present in this mesh (for heterogenous meshes)
ElementTypeMapArray<UInt> connectivities;
/// count the references on ghost elements
ElementTypeMapArray<UInt> ghosts_counters;
/// map to normals for all class of elements present in this mesh
ElementTypeMapArray<Real> normals;
/// the spatial dimension of this mesh
UInt spatial_dimension{0};
/// size covered by the mesh on each direction
Vector<Real> size;
/// global bounding box
BBox bbox;
/// local bounding box
BBox bbox_local;
/// Extra data loaded from the mesh file
// MeshData mesh_data;
/// facets' mesh
std::unique_ptr<Mesh> mesh_facets;
/// parent mesh (this is set for mesh_facets meshes)
const Mesh * mesh_parent{nullptr};
/// defines if current mesh is mesh_facets or not
bool is_mesh_facets{false};
/// defines if the mesh is centralized or distributed
bool is_distributed{false};
/// defines if the mesh is periodic
bool is_periodic{false};
/// Communicator on which mesh is distributed
Communicator * communicator;
/// Element synchronizer
std::unique_ptr<ElementSynchronizer> element_synchronizer;
/// Node synchronizer
std::unique_ptr<NodeSynchronizer> node_synchronizer;
/// Node synchronizer for periodic nodes
std::unique_ptr<PeriodicNodeSynchronizer> periodic_node_synchronizer;
using NodesToElements = std::vector<std::unique_ptr<std::set<Element>>>;
/// class to update global data using external knowledge
std::unique_ptr<MeshGlobalDataUpdater> global_data_updater;
/// This info is stored to simplify the dynamic changes
NodesToElements nodes_to_elements;
/// periodicity local info
std::unordered_map<UInt, UInt> periodic_slave_master;
std::unordered_multimap<UInt, UInt> periodic_master_slave;
};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream, const Mesh & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* Inline functions */
/* -------------------------------------------------------------------------- */
#include "element_type_map_tmpl.hh"
#include "mesh_inline_impl.cc"
#endif /* __AKANTU_MESH_HH__ */
diff --git a/src/mesh/mesh_accessor.hh b/src/mesh/mesh_accessor.hh
index 7b818876f..ca673ff8e 100644
--- a/src/mesh/mesh_accessor.hh
+++ b/src/mesh/mesh_accessor.hh
@@ -1,171 +1,169 @@
/**
* @file mesh_accessor.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jun 30 2015
* @date last modification: Tue Sep 19 2017
*
* @brief this class allow to access some private member of mesh it is used for
* IO for examples
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_ACCESSOR_HH__
#define __AKANTU_MESH_ACCESSOR_HH__
namespace akantu {
class NodeSynchronizer;
class ElementSynchronizer;
class MeshGlobalDataUpdater;
} // namespace akantu
namespace akantu {
class MeshAccessor {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
explicit MeshAccessor(Mesh & mesh) : _mesh(mesh) {}
virtual ~MeshAccessor() = default;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get the global number of nodes
inline UInt getNbGlobalNodes() const { return this->_mesh.nb_global_nodes; }
/// set the global number of nodes
inline void setNbGlobalNodes(UInt nb_global_nodes) {
this->_mesh.nb_global_nodes = nb_global_nodes;
}
/// set the mesh as being distributed
inline void setDistributed() { this->_mesh.is_distributed = true; }
/// get a pointer to the nodes_global_ids Array<UInt> and create it if
/// necessary
inline auto & getNodesGlobalIds() {
return this->_mesh.getNodesGlobalIdsPointer();
}
/// get a pointer to the nodes_type Array<Int> and create it if necessary
inline auto & getNodesFlags() { return this->_mesh.getNodesFlags(); }
/// get a pointer to the nodes_type Array<Int> and create it if necessary
- inline void setNodePrank(UInt node, Int prank) { this->_mesh.nodes_prank[node] = prank; }
+ inline void setNodePrank(UInt node, Int prank) {
+ this->_mesh.nodes_prank[node] = prank;
+ }
/// get a pointer to the coordinates Array
inline auto & getNodes() { return this->_mesh.getNodesPointer(); }
/// get a pointer to the coordinates Array
inline auto getNodesSharedPtr() { return this->_mesh.nodes; }
/// get a pointer to the connectivity Array for the given type and create it
/// if necessary
inline auto & getConnectivity(const ElementType & type,
const GhostType & ghost_type = _not_ghost) {
return this->_mesh.getConnectivityPointer(type, ghost_type);
}
/// get the ghost element counter
inline auto & getGhostsCounters(const ElementType & type,
const GhostType & ghost_type = _ghost) {
return this->_mesh.getGhostsCounters(type, ghost_type);
}
/// get a pointer to the element_to_subelement Array for the given type and
/// create it if necessary
inline auto &
getElementToSubelement(const ElementType & type,
const GhostType & ghost_type = _not_ghost) {
return this->_mesh.getElementToSubelementPointer(type, ghost_type);
}
/// get a pointer to the subelement_to_element Array for the given type and
/// create it if necessary
inline auto &
getSubelementToElement(const ElementType & type,
const GhostType & ghost_type = _not_ghost) {
return this->_mesh.getSubelementToElementPointer(type, ghost_type);
}
template <typename T>
inline auto &
getData(const std::string & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost, UInt nb_component = 1,
bool size_to_nb_element = true, bool resize_with_parent = false) {
return this->_mesh.getDataPointer<T>(data_name, el_type, ghost_type,
nb_component, size_to_nb_element,
resize_with_parent);
}
/// get the node synchonizer
auto & getNodeSynchronizer() { return *this->_mesh.node_synchronizer; }
/// get the element synchonizer
auto & getElementSynchronizer() { return *this->_mesh.element_synchronizer; }
decltype(auto) updateGlobalData(NewNodesEvent & nodes_event,
NewElementsEvent & elements_event) {
return this->_mesh.updateGlobalData(nodes_event, elements_event);
}
void registerGlobalDataUpdater(
std::unique_ptr<MeshGlobalDataUpdater> && global_data_updater) {
this->_mesh.registerGlobalDataUpdater(
std::forward<std::unique_ptr<MeshGlobalDataUpdater>>(
global_data_updater));
}
/* ------------------------------------------------------------------------ */
- void makeReady() {
- this->_mesh.makeReady();
- }
+ void makeReady() { this->_mesh.makeReady(); }
/* ------------------------------------------------------------------------ */
void addPeriodicSlave(UInt slave, UInt master) {
this->_mesh.addPeriodicSlave(slave, master);
}
void markMeshPeriodic() {
for (UInt s : arange(this->_mesh.spatial_dimension)) {
this->_mesh.is_periodic |= 1 << s;
}
}
- void wipePeriodicInfo() {
- this->_mesh.wipePeriodicInfo();
- }
+ void wipePeriodicInfo() { this->_mesh.wipePeriodicInfo(); }
private:
Mesh & _mesh;
};
} // namespace akantu
#endif /* __AKANTU_MESH_ACCESSOR_HH__ */
diff --git a/src/mesh/mesh_data.hh b/src/mesh/mesh_data.hh
index 278ba34e7..f3258e579 100644
--- a/src/mesh/mesh_data.hh
+++ b/src/mesh/mesh_data.hh
@@ -1,193 +1,193 @@
/**
* @file mesh_data.hh
*
* @author Dana Christen <dana.christen@gmail.com>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri May 03 2013
* @date last modification: Mon Dec 18 2017
*
* @brief Stores generic data loaded from the mesh file
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_DATA_HH__
#define __AKANTU_MESH_DATA_HH__
/* -------------------------------------------------------------------------- */
#include "aka_memory.hh"
#include "element_type_map.hh"
#include <map>
#include <string>
/* -------------------------------------------------------------------------- */
namespace akantu {
#define AKANTU_MESH_DATA_TYPES \
((_int, Int))((_uint, UInt))((_real, Real))((_bool, bool))( \
(_element, Element))((_std_string, std::string))( \
(_std_vector_element, std::vector<Element>))
#define AKANTU_MESH_DATA_TUPLE_FIRST_ELEM(s, data, elem) \
BOOST_PP_TUPLE_ELEM(2, 0, elem)
enum class MeshDataTypeCode : int {
BOOST_PP_SEQ_ENUM(BOOST_PP_SEQ_TRANSFORM(AKANTU_MESH_DATA_TUPLE_FIRST_ELEM, ,
AKANTU_MESH_DATA_TYPES)),
_unknown
};
enum class MeshDataType {
_nodal,
_elemental,
};
class MeshData {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
private:
using TypeCode = MeshDataTypeCode;
using ElementalDataMap =
std::map<std::string, std::unique_ptr<ElementTypeMapBase>>;
using NodalDataMap = std::map<std::string, std::unique_ptr<ArrayBase>>;
using TypeCodeMap = std::map<std::string, TypeCode>;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MeshData(const ID & id = "mesh_data", const ID & parent_id = "",
const MemoryID & memory_id = 0);
/* ------------------------------------------------------------------------ */
/* Methods and accessors */
/* ------------------------------------------------------------------------ */
public:
/// tells if the given array exists
template <typename T>
bool hasData(const ID & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
/// tells if the given data exists
bool hasData(const ID & data_name,
MeshDataType type = MeshDataType::_elemental) const;
bool hasData(MeshDataType type = MeshDataType::_elemental) const;
/// get the names of the data stored in elemental_data
inline auto getTagNames(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const;
/// get the names of the data stored in elemental_data
inline auto getTagNames() const;
- /// get the type of the data stored in elemental_data
+ /// get the type of the data stored in elemental_data
template <typename T> TypeCode getTypeCode() const;
inline TypeCode
getTypeCode(const ID & name,
MeshDataType type = MeshDataType::_elemental) const;
/// Get an existing elemental data array
template <typename T>
const Array<T> &
getElementalDataArray(const ID & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
template <typename T>
Array<T> & getElementalDataArray(const ID & data_name,
const ElementType & el_type,
const GhostType & ghost_type = _not_ghost);
/// Get an elemental data array, if it does not exist: allocate it
template <typename T>
Array<T> &
getElementalDataArrayAlloc(const ID & data_name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost,
UInt nb_component = 1);
template <typename T>
inline UInt getNbComponentTemplated(const ID & name,
const ElementType & el_type,
const GhostType & ghost_type) const;
inline UInt getNbComponent(const ID & name, const ElementType & el_type,
const GhostType & ghost_type = _not_ghost) const;
inline UInt getNbComponent(const ID & name) const;
/// Get an existing elemental data
template <typename T>
const ElementTypeMapArray<T> & getElementalData(const ID & name) const;
template <typename T>
ElementTypeMapArray<T> & getElementalData(const ID & name);
template <typename T>
Array<T> & getNodalData(const ID & name, UInt nb_components = 1);
template <typename T> const Array<T> & getNodalData(const ID & name) const;
private:
/// Register new elemental data (and alloc data) with check if the name is
/// new
template <typename T>
ElementTypeMapArray<T> & registerElementalData(const ID & name);
inline void registerElementalData(const ID & name, TypeCode type);
/// Register new nodal data (and alloc data) with check if the name is
/// new
template <typename T>
Array<T> & registerNodalData(const ID & name, UInt nb_components = 1);
inline void registerNodalData(const ID & name, UInt nb_components,
TypeCode type);
/// Register new elemental data (add alloc data)
template <typename T>
ElementTypeMapArray<T> & allocElementalData(const ID & name);
/// Register new nodal data (add alloc data)
template <typename T>
Array<T> & allocNodalData(const ID & name, UInt nb_components);
friend class SlaveNodeInfoPerProc;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
ID _id;
UInt _memory_id{0};
/// Map when elemental data is stored as ElementTypeMap
ElementalDataMap elemental_data;
/// Map when elemental data is stored as ElementTypeMap
NodalDataMap nodal_data;
/// Map when elementalType of the data stored in elemental_data
std::map<MeshDataType, TypeCodeMap> typecode_map{
{MeshDataType::_elemental, {}}, {MeshDataType::_nodal, {}}};
};
} // namespace akantu
#include "mesh_data_tmpl.hh"
#undef AKANTU_MESH_DATA_TUPLE_FIRST_ELEM
#endif /* __AKANTU_MESH_DATA_HH__ */
diff --git a/src/mesh/mesh_data_tmpl.hh b/src/mesh/mesh_data_tmpl.hh
index 04da221cf..242f42478 100644
--- a/src/mesh/mesh_data_tmpl.hh
+++ b/src/mesh/mesh_data_tmpl.hh
@@ -1,410 +1,410 @@
/**
* @file mesh_data_tmpl.hh
*
* @author Dana Christen <dana.christen@gmail.com>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri May 03 2013
* @date last modification: Tue Feb 20 2018
*
* @brief Stores generic data loaded from the mesh file
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_data.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_DATA_TMPL_HH__
#define __AKANTU_MESH_DATA_TMPL_HH__
namespace akantu {
#define AKANTU_MESH_DATA_OSTREAM(r, name, elem) \
case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
stream << BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, elem)); \
break; \
}
inline std::ostream & operator<<(std::ostream & stream,
const MeshDataTypeCode & type_code) {
switch (type_code) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_MESH_DATA_OSTREAM, name,
AKANTU_MESH_DATA_TYPES)
default:
stream << "(unknown type)";
}
return stream;
}
#undef AKANTU_MESH_DATA_OSTREAM
#define MESH_DATA_GET_TYPE(r, data, type) \
template <> \
inline MeshDataTypeCode \
MeshData::getTypeCode<BOOST_PP_TUPLE_ELEM(2, 1, type)>() const { \
return MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, type); \
}
/* -------------------------------------------------------------------------- */
// get the type of the data stored in elemental_data
template <typename T> inline MeshDataTypeCode MeshData::getTypeCode() const {
AKANTU_ERROR("Type " << debug::demangle(typeid(T).name())
<< " not implemented by MeshData.");
}
/* -------------------------------------------------------------------------- */
BOOST_PP_SEQ_FOR_EACH(MESH_DATA_GET_TYPE, void, AKANTU_MESH_DATA_TYPES)
#undef MESH_DATA_GET_TYPE
inline MeshDataTypeCode MeshData::getTypeCode(const ID & name,
MeshDataType type) const {
auto it = typecode_map.at(type).find(name);
if (it == typecode_map.at(type).end())
AKANTU_EXCEPTION("No dataset named " << name << " found.");
return it->second;
}
/* -------------------------------------------------------------------------- */
// Register new elemental data templated (and alloc data) with check if the
// name is new
template <typename T>
ElementTypeMapArray<T> & MeshData::registerElementalData(const ID & name) {
auto it = elemental_data.find(name);
if (it == elemental_data.end()) {
return allocElementalData<T>(name);
} else {
AKANTU_DEBUG_INFO("Data named " << name << " already registered.");
return getElementalData<T>(name);
}
}
/* -------------------------------------------------------------------------- */
// Register new elemental data of a given MeshDataTypeCode with check if the
// name is new
#define AKANTU_MESH_DATA_CASE_MACRO(r, name, elem) \
case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
registerElementalData<BOOST_PP_TUPLE_ELEM(2, 1, elem)>(name); \
break; \
}
inline void MeshData::registerElementalData(const ID & name,
MeshDataTypeCode type) {
switch (type) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_MESH_DATA_CASE_MACRO, name,
AKANTU_MESH_DATA_TYPES)
default:
AKANTU_ERROR("Type " << type << "not implemented by MeshData.");
}
}
#undef AKANTU_MESH_DATA_CASE_MACRO
/* -------------------------------------------------------------------------- */
/// Register new elemental data (and alloc data)
template <typename T>
ElementTypeMapArray<T> & MeshData::allocElementalData(const ID & name) {
auto dataset =
std::make_unique<ElementTypeMapArray<T>>(name, _id, _memory_id);
auto * dataset_typed = dataset.get();
elemental_data[name] = std::move(dataset);
typecode_map[MeshDataType::_elemental][name] = getTypeCode<T>();
return *dataset_typed;
}
/* -------------------------------------------------------------------------- */
// Register new nodal data templated (and alloc data) with check if the
// name is new
template <typename T>
Array<T> & MeshData::registerNodalData(const ID & name, UInt nb_components) {
auto it = nodal_data.find(name);
if (it == nodal_data.end()) {
return allocNodalData<T>(name, nb_components);
} else {
AKANTU_DEBUG_INFO("Data named " << name << " already registered.");
return getNodalData<T>(name);
}
}
/* -------------------------------------------------------------------------- */
// Register new elemental data of a given MeshDataTypeCode with check if the
// name is new
#define AKANTU_MESH_NODAL_DATA_CASE_MACRO(r, name, elem) \
case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
registerNodalData<BOOST_PP_TUPLE_ELEM(2, 1, elem)>(name, nb_components); \
break; \
}
inline void MeshData::registerNodalData(const ID & name, UInt nb_components,
MeshDataTypeCode type) {
switch (type) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_MESH_NODAL_DATA_CASE_MACRO, name,
AKANTU_MESH_DATA_TYPES)
default:
AKANTU_ERROR("Type " << type << "not implemented by MeshData.");
}
}
#undef AKANTU_MESH_NODAL_DATA_CASE_MACRO
/* -------------------------------------------------------------------------- */
/// Register new elemental data (and alloc data)
template <typename T>
Array<T> & MeshData::allocNodalData(const ID & name, UInt nb_components) {
auto dataset =
std::make_unique<Array<T>>(0, nb_components, T(), _id + ":" + name);
auto * dataset_typed = dataset.get();
nodal_data[name] = std::move(dataset);
typecode_map[MeshDataType::_nodal][name] = getTypeCode<T>();
return *dataset_typed;
}
/* -------------------------------------------------------------------------- */
template <typename T>
const Array<T> & MeshData::getNodalData(const ID & name) const {
auto it = nodal_data.find(name);
if (it == nodal_data.end())
AKANTU_EXCEPTION("No nodal dataset named " << name << " found.");
return aka::as_type<Array<T>>(*(it->second.get()));
}
/* -------------------------------------------------------------------------- */
// Get an existing elemental data
template <typename T>
Array<T> & MeshData::getNodalData(const ID & name, UInt nb_components) {
auto it = nodal_data.find(name);
if (it == nodal_data.end())
return allocNodalData<T>(name, nb_components);
return aka::as_type<Array<T>>(*(it->second.get()));
}
/* -------------------------------------------------------------------------- */
template <typename T>
const ElementTypeMapArray<T> &
MeshData::getElementalData(const ID & name) const {
auto it = elemental_data.find(name);
if (it == elemental_data.end())
AKANTU_EXCEPTION("No dataset named " << name << " found.");
return aka::as_type<ElementTypeMapArray<T>>(*(it->second.get()));
}
/* -------------------------------------------------------------------------- */
// Get an existing elemental data
template <typename T>
ElementTypeMapArray<T> & MeshData::getElementalData(const ID & name) {
auto it = elemental_data.find(name);
if (it == elemental_data.end()) {
return allocElementalData<T>(name);
}
return aka::as_type<ElementTypeMapArray<T>>(*(it->second.get()));
}
/* -------------------------------------------------------------------------- */
template <typename T>
bool MeshData::hasData(const ID & name, const ElementType & elem_type,
const GhostType & ghost_type) const {
auto it = elemental_data.find(name);
if (it == elemental_data.end())
return false;
auto & elem_map = aka::as_type<ElementTypeMapArray<T>>(*(it->second));
return elem_map.exists(elem_type, ghost_type);
}
/* -------------------------------------------------------------------------- */
inline bool MeshData::hasData(const ID & name, MeshDataType type) const {
if (type == MeshDataType::_elemental) {
auto it = elemental_data.find(name);
return (it != elemental_data.end());
}
if (type == MeshDataType::_nodal) {
auto it = nodal_data.find(name);
return (it != nodal_data.end());
}
return false;
}
/* -------------------------------------------------------------------------- */
inline bool MeshData::hasData(MeshDataType type) const {
switch (type) {
case MeshDataType::_elemental:
return (not elemental_data.empty());
case MeshDataType::_nodal:
return (not nodal_data.empty());
}
return false;
}
/* -------------------------------------------------------------------------- */
template <typename T>
const Array<T> &
MeshData::getElementalDataArray(const ID & name, const ElementType & elem_type,
const GhostType & ghost_type) const {
auto it = elemental_data.find(name);
if (it == elemental_data.end()) {
AKANTU_EXCEPTION("Data named " << name
<< " not registered for type: " << elem_type
<< " - ghost_type:" << ghost_type << "!");
}
- return aka::as_type<ElementTypeMapArray<T>>(*(it->second))(
- elem_type, ghost_type);
+ return aka::as_type<ElementTypeMapArray<T>>(*(it->second))(elem_type,
+ ghost_type);
}
template <typename T>
Array<T> & MeshData::getElementalDataArray(const ID & name,
const ElementType & elem_type,
const GhostType & ghost_type) {
auto it = elemental_data.find(name);
if (it == elemental_data.end()) {
AKANTU_EXCEPTION("Data named " << name
<< " not registered for type: " << elem_type
<< " - ghost_type:" << ghost_type << "!");
}
- return aka::as_type<ElementTypeMapArray<T>>(*(it->second.get()))(
- elem_type, ghost_type);
+ return aka::as_type<ElementTypeMapArray<T>>(*(it->second.get()))(elem_type,
+ ghost_type);
}
/* -------------------------------------------------------------------------- */
// Get an elemental data array, if it does not exist: allocate it
template <typename T>
Array<T> & MeshData::getElementalDataArrayAlloc(const ID & name,
const ElementType & elem_type,
const GhostType & ghost_type,
UInt nb_component) {
auto it = elemental_data.find(name);
ElementTypeMapArray<T> * dataset;
if (it == elemental_data.end()) {
dataset = &allocElementalData<T>(name);
} else {
dataset = dynamic_cast<ElementTypeMapArray<T> *>(it->second.get());
}
AKANTU_DEBUG_ASSERT(
getTypeCode<T>() ==
typecode_map.at(MeshDataType::_elemental).find(name)->second,
"Function getElementalDataArrayAlloc called with the wrong type!");
if (!(dataset->exists(elem_type, ghost_type))) {
dataset->alloc(0, nb_component, elem_type, ghost_type);
}
return (*dataset)(elem_type, ghost_type);
}
/* -------------------------------------------------------------------------- */
#define AKANTU_MESH_DATA_CASE_MACRO(r, name, elem) \
case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
nb_comp = getNbComponentTemplated<BOOST_PP_TUPLE_ELEM(2, 1, elem)>( \
name, el_type, ghost_type); \
break; \
}
inline UInt MeshData::getNbComponent(const ID & name,
const ElementType & el_type,
const GhostType & ghost_type) const {
auto it = typecode_map.at(MeshDataType::_elemental).find(name);
UInt nb_comp(0);
if (it == typecode_map.at(MeshDataType::_elemental).end()) {
AKANTU_EXCEPTION("Could not determine the type held in dataset "
<< name << " for type: " << el_type
<< " - ghost_type:" << ghost_type << ".");
}
MeshDataTypeCode type = it->second;
switch (type) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_MESH_DATA_CASE_MACRO, name,
AKANTU_MESH_DATA_TYPES)
default:
AKANTU_ERROR(
"Could not call the correct instance of getNbComponentTemplated.");
break;
}
return nb_comp;
}
#undef AKANTU_MESH_DATA_CASE_MACRO
/* -------------------------------------------------------------------------- */
template <typename T>
inline UInt
MeshData::getNbComponentTemplated(const ID & name, const ElementType & el_type,
const GhostType & ghost_type) const {
return getElementalDataArray<T>(name, el_type, ghost_type).getNbComponent();
}
/* -------------------------------------------------------------------------- */
inline UInt MeshData::getNbComponent(const ID & name) const {
auto it = nodal_data.find(name);
if (it == nodal_data.end()) {
AKANTU_EXCEPTION("No nodal dataset registered with the name" << name
<< ".");
}
return it->second->getNbComponent();
}
/* -------------------------------------------------------------------------- */
// get the names of the data stored in elemental_data
#define AKANTU_MESH_DATA_CASE_MACRO(r, name, elem) \
case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
ElementTypeMapArray<BOOST_PP_TUPLE_ELEM(2, 1, elem)> * dataset; \
dataset = \
dynamic_cast<ElementTypeMapArray<BOOST_PP_TUPLE_ELEM(2, 1, elem)> *>( \
it->second.get()); \
exists = dataset->exists(el_type, ghost_type); \
break; \
}
inline auto MeshData::getTagNames(const ElementType & el_type,
const GhostType & ghost_type) const {
std::vector<std::string> tags;
bool exists(false);
auto it = elemental_data.begin();
auto it_end = elemental_data.end();
for (; it != it_end; ++it) {
MeshDataTypeCode type = getTypeCode(it->first);
switch (type) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_MESH_DATA_CASE_MACRO, ,
AKANTU_MESH_DATA_TYPES)
default:
AKANTU_ERROR("Could not determine the proper type to (dynamic-)cast.");
break;
}
if (exists) {
tags.push_back(it->first);
}
}
return tags;
}
#undef AKANTU_MESH_DATA_CASE_MACRO
/* -------------------------------------------------------------------------- */
inline auto MeshData::getTagNames() const {
std::vector<std::string> tags;
for (auto && data : nodal_data) {
tags.push_back(std::get<0>(data));
}
return tags;
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
#endif /* __AKANTU_MESH_DATA_TMPL_HH__ */
diff --git a/src/mesh/mesh_events.hh b/src/mesh/mesh_events.hh
index d0ff72068..0e2a8ea04 100644
--- a/src/mesh/mesh_events.hh
+++ b/src/mesh/mesh_events.hh
@@ -1,188 +1,188 @@
/**
* @file mesh_events.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Feb 20 2015
* @date last modification: Tue Feb 20 2018
*
* @brief Classes corresponding to mesh events type
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <utility>
#include "aka_array.hh"
#include "element.hh"
#include "element_type_map.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_EVENTS_HH__
#define __AKANTU_MESH_EVENTS_HH__
namespace akantu {
/// akantu::MeshEvent is the base event for meshes
template <class Entity> class MeshEvent {
public:
virtual ~MeshEvent() = default;
/// Get the list of entity modified by the event nodes or elements
const Array<Entity> & getList() const { return list; }
/// Get the list of entity modified by the event nodes or elements
Array<Entity> & getList() { return list; }
protected:
Array<Entity> list;
};
class Mesh;
/// akantu::MeshEvent related to new nodes in the mesh
class NewNodesEvent : public MeshEvent<UInt> {
public:
~NewNodesEvent() override = default;
};
/// akantu::MeshEvent related to nodes removed from the mesh
class RemovedNodesEvent : public MeshEvent<UInt> {
public:
~RemovedNodesEvent() override = default;
inline RemovedNodesEvent(const Mesh & mesh);
/// Get the new numbering following suppression of nodes from nodes arrays
AKANTU_GET_MACRO_NOT_CONST(NewNumbering, new_numbering, Array<UInt> &);
/// Get the new numbering following suppression of nodes from nodes arrays
AKANTU_GET_MACRO(NewNumbering, new_numbering, const Array<UInt> &);
private:
Array<UInt> new_numbering;
};
/// akantu::MeshEvent related to new elements in the mesh
class NewElementsEvent : public MeshEvent<Element> {
public:
~NewElementsEvent() override = default;
};
/// akantu::MeshEvent related to elements removed from the mesh
class RemovedElementsEvent : public MeshEvent<Element> {
public:
~RemovedElementsEvent() override = default;
inline RemovedElementsEvent(const Mesh & mesh,
const ID & new_numbering_id = "new_numbering");
/// Get the new numbering following suppression of elements from elements
/// arrays
AKANTU_GET_MACRO(NewNumbering, new_numbering,
const ElementTypeMapArray<UInt> &);
/// Get the new numbering following suppression of elements from elements
/// arrays
AKANTU_GET_MACRO_NOT_CONST(NewNumbering, new_numbering,
ElementTypeMapArray<UInt> &);
/// Get the new numbering following suppression of elements from elements
/// arrays
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(NewNumbering, new_numbering, UInt);
/// Get the new numbering following suppression of elements from elements
/// arrays
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(NewNumbering, new_numbering, UInt);
protected:
ElementTypeMapArray<UInt> new_numbering;
};
/// akantu::MeshEvent for element that changed in some sort, can be seen as a
/// combination of removed and added elements
class ChangedElementsEvent : public RemovedElementsEvent {
public:
~ChangedElementsEvent() override = default;
inline ChangedElementsEvent(
const Mesh & mesh, ID new_numbering_id = "changed_event:new_numbering")
: RemovedElementsEvent(mesh, std::move(new_numbering_id)){};
AKANTU_GET_MACRO(ListOld, list, const Array<Element> &);
AKANTU_GET_MACRO_NOT_CONST(ListOld, list, Array<Element> &);
AKANTU_GET_MACRO(ListNew, new_list, const Array<Element> &);
AKANTU_GET_MACRO_NOT_CONST(ListNew, new_list, Array<Element> &);
protected:
Array<Element> new_list;
};
/* -------------------------------------------------------------------------- */
class MeshEventHandler {
public:
virtual ~MeshEventHandler() = default;
/* ------------------------------------------------------------------------ */
/* Internal code */
/* ------------------------------------------------------------------------ */
private:
/// send a akantu::NewNodesEvent
inline void sendEvent(const NewNodesEvent & event) {
onNodesAdded(event.getList(), event);
}
/// send a akantu::RemovedNodesEvent
inline void sendEvent(const RemovedNodesEvent & event) {
onNodesRemoved(event.getList(), event.getNewNumbering(), event);
}
/// send a akantu::NewElementsEvent
inline void sendEvent(const NewElementsEvent & event) {
onElementsAdded(event.getList(), event);
}
/// send a akantu::RemovedElementsEvent
inline void sendEvent(const RemovedElementsEvent & event) {
onElementsRemoved(event.getList(), event.getNewNumbering(), event);
}
/// send a akantu::ChangedElementsEvent
inline void sendEvent(const ChangedElementsEvent & event) {
onElementsChanged(event.getListOld(), event.getListNew(),
event.getNewNumbering(), event);
}
template <class EventHandler> friend class EventHandlerManager;
/* ------------------------------------------------------------------------ */
/* Interface */
/* ------------------------------------------------------------------------ */
public:
/// function to implement to react on akantu::NewNodesEvent
virtual void onNodesAdded(const Array<UInt> & /*nodes_list*/,
const NewNodesEvent & /*event*/) {}
/// function to implement to react on akantu::RemovedNodesEvent
virtual void onNodesRemoved(const Array<UInt> & /*nodes_list*/,
const Array<UInt> & /*new_numbering*/,
const RemovedNodesEvent & /*event*/) {}
/// function to implement to react on akantu::NewElementsEvent
virtual void onElementsAdded(const Array<Element> & /*elements_list*/,
const NewElementsEvent & /*event*/) {}
/// function to implement to react on akantu::RemovedElementsEvent
virtual void
onElementsRemoved(const Array<Element> & /*elements_list*/,
const ElementTypeMapArray<UInt> & /*new_numbering*/,
const RemovedElementsEvent & /*event*/) {}
/// function to implement to react on akantu::ChangedElementsEvent
virtual void
onElementsChanged(const Array<Element> & /*old_elements_list*/,
const Array<Element> & /*new_elements_list*/,
const ElementTypeMapArray<UInt> & /*new_numbering*/,
const ChangedElementsEvent & /*event*/) {}
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_EVENTS_HH__ */
diff --git a/src/mesh/mesh_filter.hh b/src/mesh/mesh_filter.hh
index 3607f549d..13fc29ec4 100644
--- a/src/mesh/mesh_filter.hh
+++ b/src/mesh/mesh_filter.hh
@@ -1,72 +1,72 @@
/**
* @file mesh_filter.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief the class representing the meshes
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_FILTER_HH__
#define __AKANTU_MESH_FILTER_HH__
/* -------------------------------------------------------------------------- */
#include "element.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Filter Functors */
/* -------------------------------------------------------------------------- */
/// struct for the possible filter functors
struct FilterFunctor {
enum Type { _node_filter_functor, _element_filter_functor };
};
/// class (functor) for the node filter
class NodeFilterFunctor : public FilterFunctor {
public:
bool operator()(__attribute__((unused)) UInt node) { AKANTU_TO_IMPLEMENT(); }
public:
static const Type type = _node_filter_functor;
};
/// class (functor) for the element filter
class ElementFilterFunctor : public FilterFunctor {
public:
bool operator()(__attribute__((unused)) const Element & element) {
AKANTU_TO_IMPLEMENT();
}
public:
static const Type type = _element_filter_functor;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_FILTER_HH__ */
diff --git a/src/mesh/mesh_global_data_updater.hh b/src/mesh/mesh_global_data_updater.hh
index 5a8822e62..fbb72611f 100644
--- a/src/mesh/mesh_global_data_updater.hh
+++ b/src/mesh/mesh_global_data_updater.hh
@@ -1,49 +1,51 @@
/**
* @file mesh_global_data_updater.hh
*
* @author Nicolas Richart
*
* @date creation Sat Mar 03 2018
*
* @brief interface for the global data updater
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_GLOBAL_DATA_UPDATER_HH__
#define __AKANTU_MESH_GLOBAL_DATA_UPDATER_HH__
namespace akantu {
class NewNodesEvent;
class NewElementsEvent;
class MeshGlobalDataUpdater {
public:
virtual ~MeshGlobalDataUpdater() = default;
virtual std::tuple<UInt, UInt>
updateData(NewNodesEvent & /*nodes_event*/,
- NewElementsEvent & /*elements_event*/) { return std::make_tuple(0,0); }
+ NewElementsEvent & /*elements_event*/) {
+ return std::make_tuple(0, 0);
+ }
};
} // namespace akantu
#endif /* __AKANTU_MESH_GLOBAL_DATA_UPDATER_HH__ */
diff --git a/src/mesh/mesh_iterators.hh b/src/mesh/mesh_iterators.hh
index 1d1dd7968..5dccf4566 100644
--- a/src/mesh/mesh_iterators.hh
+++ b/src/mesh/mesh_iterators.hh
@@ -1,229 +1,228 @@
/**
* @file mesh_iterators.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Jul 16 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Set of helper classes to have fun with range based for
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_named_argument.hh"
#include "aka_static_if.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_ITERATORS_HH__
#define __AKANTU_MESH_ITERATORS_HH__
namespace akantu {
class MeshElementsByTypes {
using elements_iterator = Array<Element>::scalar_iterator;
public:
explicit MeshElementsByTypes(const Array<Element> & elements) {
this->elements.copy(elements);
std::sort(this->elements.begin(), this->elements.end());
}
/* ------------------------------------------------------------------------ */
class MeshElementsRange {
public:
MeshElementsRange() = default;
MeshElementsRange(const elements_iterator & begin,
const elements_iterator & end)
: type((*begin).type), ghost_type((*begin).ghost_type), begin(begin),
end(end) {}
AKANTU_GET_MACRO(Type, type, const ElementType &);
AKANTU_GET_MACRO(GhostType, ghost_type, const GhostType &);
const Array<UInt> & getElements() {
elements.resize(end - begin);
auto el_it = elements.begin();
for (auto it = begin; it != end; ++it, ++el_it) {
*el_it = it->element;
}
return elements;
}
private:
ElementType type{_not_defined};
GhostType ghost_type{_casper};
elements_iterator begin;
elements_iterator end;
Array<UInt> elements;
};
/* ------------------------------------------------------------------------ */
class iterator {
struct element_comparator {
bool operator()(const Element & lhs, const Element & rhs) const {
- return ((rhs == ElementNull) ||
- std::tie(lhs.ghost_type, lhs.type) <
- std::tie(rhs.ghost_type, rhs.type));
+ return ((rhs == ElementNull) || std::tie(lhs.ghost_type, lhs.type) <
+ std::tie(rhs.ghost_type, rhs.type));
}
};
public:
iterator(const iterator &) = default;
iterator(const elements_iterator & first, const elements_iterator & last)
: range(std::equal_range(first, last, *first, element_comparator())),
first(first), last(last) {}
decltype(auto) operator*() const {
return MeshElementsRange(range.first, range.second);
}
iterator operator++() {
first = range.second;
range = std::equal_range(first, last, *first, element_comparator());
return *this;
}
bool operator==(const iterator & other) const {
return (first == other.first and last == other.last);
}
bool operator!=(const iterator & other) const {
return (not operator==(other));
}
private:
std::pair<elements_iterator, elements_iterator> range;
elements_iterator first;
elements_iterator last;
};
iterator begin() { return iterator(elements.begin(), elements.end()); }
iterator end() { return iterator(elements.end(), elements.end()); }
private:
Array<Element> elements;
};
/* -------------------------------------------------------------------------- */
namespace mesh_iterators {
namespace details {
template <class internal_iterator> class delegated_iterator {
public:
using value_type = std::remove_pointer_t<
typename internal_iterator::value_type::second_type>;
using difference_type = std::ptrdiff_t;
using pointer = value_type *;
using reference = value_type &;
using iterator_category = std::input_iterator_tag;
explicit delegated_iterator(internal_iterator it) : it(std::move(it)) {}
decltype(auto) operator*() {
return std::forward<decltype(*(it->second))>(*(it->second));
}
delegated_iterator operator++() {
++it;
return *this;
}
bool operator==(const delegated_iterator & other) const {
return other.it == it;
}
bool operator!=(const delegated_iterator & other) const {
return other.it != it;
}
private:
internal_iterator it;
};
} // namespace details
} // namespace mesh_iterators
/* -------------------------------------------------------------------------- */
template <class Func>
void for_each_element(UInt nb_elements, const Array<UInt> & filter_elements,
Func && function) {
if (filter_elements != empty_filter) {
std::for_each(filter_elements.begin(), filter_elements.end(),
std::forward<Func>(function));
} else {
auto && range = arange(nb_elements);
std::for_each(range.begin(), range.end(), std::forward<Func>(function));
}
}
namespace {
DECLARE_NAMED_ARGUMENT(element_filter);
}
/* -------------------------------------------------------------------------- */
template <class Func, typename... pack>
void for_each_element(const Mesh & mesh, Func && function, pack &&... _pack) {
auto requested_ghost_type = OPTIONAL_NAMED_ARG(ghost_type, _casper);
const ElementTypeMapArray<UInt> * filter =
OPTIONAL_NAMED_ARG(element_filter, nullptr);
bool all_ghost_types = requested_ghost_type == _casper;
auto spatial_dimension =
OPTIONAL_NAMED_ARG(spatial_dimension, mesh.getSpatialDimension());
auto element_kind = OPTIONAL_NAMED_ARG(element_kind, _ek_not_defined);
for (auto ghost_type : ghost_types) {
if ((not(ghost_type == requested_ghost_type)) and (not all_ghost_types))
continue;
auto element_types =
mesh.elementTypes(spatial_dimension, ghost_type, element_kind);
if (filter) {
element_types =
filter->elementTypes(spatial_dimension, ghost_type, element_kind);
}
for (auto type : element_types) {
const Array<UInt> * filter_array;
if (filter) {
filter_array = &((*filter)(type, ghost_type));
} else {
filter_array = &empty_filter;
}
auto nb_elements = mesh.getNbElement(type, ghost_type);
for_each_element(nb_elements, *filter_array, [&](auto && el) {
auto element = Element{type, el, ghost_type};
std::forward<Func>(function)(element);
});
}
}
}
} // namespace akantu
#endif /* __AKANTU_MESH_ITERATORS_HH__ */
diff --git a/src/mesh/mesh_periodic.cc b/src/mesh/mesh_periodic.cc
index 7d3ced92e..e017e93c7 100644
--- a/src/mesh/mesh_periodic.cc
+++ b/src/mesh/mesh_periodic.cc
@@ -1,455 +1,454 @@
/**
* @file mesh_pbc.cc
*
* @author Nicolas Richart
*
* @date creation Sat Feb 10 2018
*
* @brief Implementation of the perdiodicity capabilities in the mesh
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communication_tag.hh"
#include "communicator.hh"
#include "element_group.hh"
#include "mesh.hh"
#include "periodic_node_synchronizer.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void Mesh::makePeriodic(const SpatialDirection & direction) {
Array<UInt> list_1;
Array<UInt> list_2;
Real tolerance = 1e-10;
auto lower_bound = this->getLowerBounds();
auto upper_bound = this->getUpperBounds();
auto length = upper_bound(direction) - lower_bound(direction);
const auto & positions = *nodes;
for (auto && data : enumerate(make_view(positions, spatial_dimension))) {
UInt node = std::get<0>(data);
const auto & pos = std::get<1>(data);
if (std::abs((pos(direction) - lower_bound(direction)) / length) <
tolerance) {
list_1.push_back(node);
}
if (std::abs((pos(direction) - upper_bound(direction)) / length) <
tolerance) {
list_2.push_back(node);
}
}
this->makePeriodic(direction, list_1, list_2);
}
/* -------------------------------------------------------------------------- */
void Mesh::makePeriodic(const SpatialDirection & direction, const ID & list_1,
const ID & list_2) {
const auto & list_nodes_1 =
mesh.getElementGroup(list_1).getNodeGroup().getNodes();
const auto & list_nodes_2 =
mesh.getElementGroup(list_2).getNodeGroup().getNodes();
this->makePeriodic(direction, list_nodes_1, list_nodes_2);
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
namespace {
struct NodeInfo {
NodeInfo() {}
NodeInfo(UInt spatial_dimension) : position(spatial_dimension) {}
NodeInfo(UInt node, const Vector<Real> & position,
const SpatialDirection & direction)
: node(node), position(position) {
this->direction_position = position(direction);
this->position(direction) = 0.;
}
NodeInfo(const NodeInfo & other)
: node(other.node), position(other.position),
direction_position(other.direction_position) {}
UInt node{0};
Vector<Real> position;
Real direction_position{0.};
};
-}
+} // namespace
/* -------------------------------------------------------------------------- */
// left is for lower values on direction and right for highest values
void Mesh::makePeriodic(const SpatialDirection & direction,
const Array<UInt> & list_left,
const Array<UInt> & list_right) {
Real tolerance = 1e-10;
const auto & positions = *nodes;
auto lower_bound = this->getLowerBounds();
auto upper_bound = this->getUpperBounds();
auto length = upper_bound(direction) - lower_bound(direction);
lower_bound(direction) = 0;
upper_bound(direction) = 0;
auto prank = communicator->whoAmI();
std::vector<NodeInfo> nodes_left(list_left.size());
std::vector<NodeInfo> nodes_right(list_right.size());
BBox bbox(spatial_dimension);
auto to_position = [&](UInt node) {
Vector<Real> pos(spatial_dimension);
for (UInt s : arange(spatial_dimension)) {
pos(s) = positions(node, s);
}
auto && info = NodeInfo(node, pos, direction);
bbox += info.position;
return info;
};
std::transform(list_left.begin(), list_left.end(), nodes_left.begin(),
to_position);
BBox bbox_left = bbox;
bbox.reset();
std::transform(list_right.begin(), list_right.end(), nodes_right.begin(),
to_position);
BBox bbox_right = bbox;
std::vector<UInt> new_nodes;
if (is_distributed) {
NewNodesEvent event;
/* ---------------------------------------------------------------------- */
// function to send nodes in bboxes intersections
auto extract_and_send_nodes = [&](const auto & bbox, const auto & node_list,
auto & buffers, auto proc, auto cnt) {
-
buffers.resize(buffers.size() + 1);
auto & buffer = buffers.back();
// std::cout << "Sending to " << proc << std::endl;
for (auto & info : node_list) {
if (bbox.contains(info.position) and isLocalOrMasterNode(info.node)) {
Vector<Real> pos = info.position;
pos(direction) = info.direction_position;
NodeFlag flag = (*nodes_flags)(info.node) & NodeFlag::_periodic_mask;
UInt gnode = getNodeGlobalId(info.node);
buffer << gnode;
buffer << pos;
buffer << flag;
// std::cout << " - node " << getNodeGlobalId(info.node);
// if is slave sends master info
if (flag == NodeFlag::_periodic_slave) {
UInt master = getNodeGlobalId(periodic_slave_master[info.node]);
// std::cout << " slave of " << master << std::endl;
buffer << master;
}
// if is master sends list of slaves
if (flag == NodeFlag::_periodic_master) {
UInt nb_slaves = periodic_master_slave.count(info.node);
buffer << nb_slaves;
// std::cout << " master of " << nb_slaves << " nodes : [";
auto slaves = periodic_master_slave.equal_range(info.node);
for (auto it = slaves.first; it != slaves.second; ++it) {
UInt gslave = getNodeGlobalId(it->second);
// std::cout << (it == slaves.first ? "" : ", ") << gslave;
buffer << gslave;
}
// std::cout << "]";
}
// std::cout << std::endl;
}
}
auto tag = Tag::genTag(prank, 10 * direction + cnt, Tag::_PERIODIC_NODES);
- // std::cout << "SBuffer size " << buffer.size() << " " << tag << std::endl;
+ // std::cout << "SBuffer size " << buffer.size() << " " << tag <<
+ // std::endl;
return communicator->asyncSend(buffer, proc, tag);
};
/* ---------------------------------------------------------------------- */
// function to receive nodes in bboxes intersections
auto recv_and_extract_nodes = [&](auto & node_list, const auto proc,
auto cnt) {
DynamicCommunicationBuffer buffer;
auto tag = Tag::genTag(proc, 10 * direction + cnt, Tag::_PERIODIC_NODES);
communicator->receive(buffer, proc, tag);
- // std::cout << "RBuffer size " << buffer.size() << " " << tag << std::endl;
- // std::cout << "Receiving from " << proc << std::endl;
+ // std::cout << "RBuffer size " << buffer.size() << " " << tag <<
+ // std::endl; std::cout << "Receiving from " << proc << std::endl;
while (not buffer.empty()) {
Vector<Real> pos(spatial_dimension);
UInt global_node;
NodeFlag flag;
buffer >> global_node;
buffer >> pos;
buffer >> flag;
// std::cout << " - node " << global_node;
auto local_node = getNodeLocalId(global_node);
// get the master info of is slave
if (flag == NodeFlag::_periodic_slave) {
UInt master_node;
buffer >> master_node;
// std::cout << " slave of " << master_node << std::endl;
// auto local_master_node = getNodeLocalId(master_node);
// AKANTU_DEBUG_ASSERT(local_master_node != UInt(-1),
//"Should I know the master node " << master_node);
}
// get the list of slaves if is master
if ((flag & NodeFlag::_periodic_mask) == NodeFlag::_periodic_master) {
UInt nb_slaves;
buffer >> nb_slaves;
// std::cout << " master of " << nb_slaves << " nodes : [";
- for (auto ns[[gnu::unused]] : arange(nb_slaves)) {
+ for (auto ns [[gnu::unused]] : arange(nb_slaves)) {
UInt gslave_node;
buffer >> gslave_node;
// std::cout << (ns == 0 ? "" : ", ") << gslave_node;
// auto lslave_node = getNodeLocalId(gslave_node);
// AKANTU_DEBUG_ASSERT(lslave_node != UInt(-1),
// "Should I know the slave node " <<
// gslave_node);
}
// std::cout << "]";
}
// std::cout << std::endl;
if (local_node != UInt(-1))
continue;
local_node = nodes->size();
NodeInfo info(local_node, pos, direction);
nodes->push_back(pos);
nodes_global_ids->push_back(global_node);
nodes_flags->push_back(flag | NodeFlag::_pure_ghost);
new_nodes.push_back(info.node);
node_list.push_back(info);
nodes_prank[info.node] = proc;
event.getList().push_back(local_node);
}
};
/* ---------------------------------------------------------------------- */
auto && intersections_with_right =
bbox_left.intersection(bbox_right, *communicator);
auto && intersections_with_left =
bbox_right.intersection(bbox_left, *communicator);
std::vector<CommunicationRequest> send_requests;
std::vector<DynamicCommunicationBuffer> send_buffers;
// sending nodes in the common zones
auto send_intersections = [&](auto & intersections, auto send_count) {
for (auto && data : intersections) {
auto proc = std::get<0>(data);
// Send local nodes if intersects with remote
const auto & intersection_with_proc = std::get<1>(data);
if (intersection_with_proc) {
send_requests.push_back(
extract_and_send_nodes(intersection_with_proc, nodes_right,
send_buffers, proc, send_count));
}
send_count += 2;
}
};
auto recv_intersections = [&](auto & intersections, auto recv_count) {
for (auto && data : intersections) {
auto proc = std::get<0>(data);
// receive remote nodes if intersects with local
const auto & intersection_with_proc = std::get<1>(data);
if (intersection_with_proc) {
recv_and_extract_nodes(nodes_right, proc, recv_count);
}
recv_count += 2;
}
};
-
send_intersections(intersections_with_left, 0);
send_intersections(intersections_with_right, 1);
recv_intersections(intersections_with_right, 0);
recv_intersections(intersections_with_right, 1);
communicator->waitAll(send_requests);
communicator->freeCommunicationRequest(send_requests);
this->sendEvent(event);
} // end distributed work
auto to_sort = [&](auto && info1, auto && info2) -> bool {
return info1.position < info2.position;
};
// sort nodes based on their distance to lower corner
std::sort(nodes_left.begin(), nodes_left.end(), to_sort);
std::sort(nodes_right.begin(), nodes_right.end(), to_sort);
// function to change the master of nodes
auto updating_master = [&](auto & old_master, auto & new_master) {
if (old_master == new_master)
return;
auto slaves = periodic_master_slave.equal_range(old_master);
AKANTU_DEBUG_ASSERT(
isPeriodicMaster(
old_master), // slaves.first != periodic_master_slave.end(),
"Cannot update master " << old_master << ", its not a master node!");
decltype(periodic_master_slave) tmp_master_slave;
for (auto it = slaves.first; it != slaves.second; ++it) {
auto slave = it->second;
tmp_master_slave.insert(std::make_pair(new_master, slave));
periodic_slave_master[slave] = new_master;
}
periodic_master_slave.erase(old_master);
(*nodes_flags)[old_master] &= ~NodeFlag::_periodic_master;
addPeriodicSlave(old_master, new_master);
for (auto && data : tmp_master_slave) {
addPeriodicSlave(data.second, data.first);
}
};
// handling 2 nodes that are periodic
auto match_found = [&](auto & info1, auto & info2) {
const auto & node1 = info1.node;
const auto & node2 = info2.node;
auto master = node1;
bool node1_side_master = false;
if (isPeriodicMaster(node1)) {
node1_side_master = true;
} else if (isPeriodicSlave(node1)) {
node1_side_master = true;
master = periodic_slave_master[node1];
}
auto node2_master = node2;
if (isPeriodicSlave(node2)) {
node2_master = periodic_slave_master[node2];
}
if (node1_side_master) {
if (isPeriodicSlave(node2)) {
updating_master(node2_master, master);
return;
}
if (isPeriodicMaster(node2)) {
updating_master(node2, master);
return;
}
addPeriodicSlave(node2, master);
} else {
if (isPeriodicSlave(node2)) {
addPeriodicSlave(node1, node2_master);
return;
}
if (isPeriodicMaster(node2)) {
addPeriodicSlave(node1, node2);
return;
}
addPeriodicSlave(node2, node1);
}
};
// matching the nodes from 2 lists
auto match_pairs = [&](auto & nodes_1, auto & nodes_2) {
auto it = nodes_2.begin();
// for every nodes in 1st list
for (auto && info1 : nodes_1) {
auto & pos1 = info1.position;
auto it_cur = it;
// try to find a match in 2nd list
for (; it_cur != nodes_2.end(); ++it_cur) {
auto & info2 = *it_cur;
auto & pos2 = info2.position;
auto dist = pos1.distance(pos2) / length;
if (dist < tolerance) {
// handles the found matches
match_found(info1, info2);
it = it_cur;
break;
}
}
}
};
match_pairs(nodes_left, nodes_right);
// match_pairs(nodes_right, nodes_left);
this->updatePeriodicSynchronizer();
this->is_periodic = true;
}
/* -------------------------------------------------------------------------- */
void Mesh::wipePeriodicInfo() {
this->is_periodic = false;
this->periodic_slave_master.clear();
this->periodic_master_slave.clear();
for (auto && flags : *nodes_flags) {
flags &= ~NodeFlag::_periodic_mask;
}
}
/* -------------------------------------------------------------------------- */
void Mesh::updatePeriodicSynchronizer() {
if (not this->periodic_node_synchronizer) {
this->periodic_node_synchronizer =
std::make_unique<PeriodicNodeSynchronizer>(
*this, this->getID() + ":periodic_synchronizer",
this->getMemoryID(), false);
}
this->periodic_node_synchronizer->update();
}
-} // akantu
+} // namespace akantu
diff --git a/src/mesh/node_group.hh b/src/mesh/node_group.hh
index 8fc2633bb..7dba12c59 100644
--- a/src/mesh/node_group.hh
+++ b/src/mesh/node_group.hh
@@ -1,131 +1,131 @@
/**
* @file node_group.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Node group definition
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
#include "aka_memory.hh"
#include "dumpable.hh"
#include "mesh_filter.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NODE_GROUP_HH__
#define __AKANTU_NODE_GROUP_HH__
namespace akantu {
class NodeGroup : public Memory, public Dumpable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NodeGroup(const std::string & name, const Mesh & mesh,
const std::string & id = "node_group",
const MemoryID & memory_id = 0);
~NodeGroup() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
using const_node_iterator = Array<UInt>::const_iterator<UInt>;
/// empty the node group
void empty();
/// iterator to the beginning of the node group
inline const_node_iterator begin() const;
/// iterator to the end of the node group
inline const_node_iterator end() const;
/// add a node and give the local position through an iterator
inline const_node_iterator add(UInt node, bool check_for_duplicate = true);
/// remove a node
inline void remove(UInt node);
inline decltype(auto) find(UInt node) const { return node_group.find(node); }
/// remove duplicated nodes
void optimize();
/// append a group to current one
void append(const NodeGroup & other_group);
/// apply a filter on current node group
template <typename T> void applyNodeFilter(T & filter);
/// function to print the contain of the class
virtual void printself(std::ostream & stream, int indent = 0) const;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO_NOT_CONST(Nodes, node_group, Array<UInt> &);
AKANTU_GET_MACRO(Nodes, node_group, const Array<UInt> &);
AKANTU_GET_MACRO(Name, name, const std::string &);
/// give the number of nodes in the current group
inline UInt size() const;
- //UInt * storage() { return node_group.storage(); };
+ // UInt * storage() { return node_group.storage(); };
friend class GroupManager;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// name of the group
std::string name;
/// list of nodes in the group
Array<UInt> & node_group;
/// reference to the mesh in question
// const Mesh & mesh;
};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const NodeGroup & _this) {
_this.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "node_group_inline_impl.cc"
#endif /* __AKANTU_NODE_GROUP_HH__ */
diff --git a/src/mesh/node_group_inline_impl.cc b/src/mesh/node_group_inline_impl.cc
index 49665377d..8be3de719 100644
--- a/src/mesh/node_group_inline_impl.cc
+++ b/src/mesh/node_group_inline_impl.cc
@@ -1,98 +1,98 @@
/**
* @file node_group_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Aug 13 2017
*
* @brief Node group inline function definitions
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
inline NodeGroup::const_node_iterator NodeGroup::begin() const {
return node_group.begin();
}
/* -------------------------------------------------------------------------- */
inline NodeGroup::const_node_iterator NodeGroup::end() const {
return node_group.end();
}
/* -------------------------------------------------------------------------- */
inline NodeGroup::const_node_iterator NodeGroup::add(UInt node,
bool check_for_duplicate) {
if (check_for_duplicate) {
const_node_iterator it = std::find(begin(), end(), node);
if (it == node_group.end()) {
node_group.push_back(node);
return (node_group.end() - 1);
}
return it;
} else {
node_group.push_back(node);
return (node_group.end() - 1);
}
}
/* -------------------------------------------------------------------------- */
inline void NodeGroup::remove(UInt node) {
Array<UInt>::iterator<> it = this->node_group.begin();
Array<UInt>::iterator<> end = this->node_group.end();
AKANTU_DEBUG_ASSERT(it != end, "The node group is empty!!");
for (; it != node_group.end(); ++it) {
if (*it == node) {
it = node_group.erase(it);
}
}
AKANTU_DEBUG_ASSERT(it != end, "The node was not found!");
}
/* -------------------------------------------------------------------------- */
inline UInt NodeGroup::size() const { return node_group.size(); }
/* -------------------------------------------------------------------------- */
struct FilterFunctor;
template <typename T> void NodeGroup::applyNodeFilter(T & filter) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(T::type == FilterFunctor::_node_filter_functor,
"NodeFilter can only apply node filter functor");
Array<UInt>::iterator<> it = this->node_group.begin();
for (; it != node_group.end(); ++it) {
/// filter == true -> keep node
if (!filter(*it)) {
it = node_group.erase(it);
}
}
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
diff --git a/src/mesh_utils/cohesive_element_inserter.cc b/src/mesh_utils/cohesive_element_inserter.cc
index 37a00514b..5f2a9396a 100644
--- a/src/mesh_utils/cohesive_element_inserter.cc
+++ b/src/mesh_utils/cohesive_element_inserter.cc
@@ -1,274 +1,281 @@
/**
* @file cohesive_element_inserter.cc
*
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Dec 04 2013
* @date last modification: Mon Feb 19 2018
*
* @brief Cohesive element inserter functions
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "cohesive_element_inserter.hh"
#include "communicator.hh"
#include "element_group.hh"
+#include "element_synchronizer.hh"
#include "global_ids_updater.hh"
#include "mesh_accessor.hh"
#include "mesh_iterators.hh"
-#include "element_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <limits>
/* -------------------------------------------------------------------------- */
namespace akantu {
CohesiveElementInserter::CohesiveElementInserter(Mesh & mesh, const ID & id)
: Parsable(ParserType::_cohesive_inserter), id(id), mesh(mesh),
mesh_facets(mesh.initMeshFacets()),
insertion_facets("insertion_facets", id),
insertion_limits(mesh.getSpatialDimension(), 2),
check_facets("check_facets", id) {
this->registerParam("cohesive_surfaces", physical_groups, _pat_parsable,
"List of groups to consider for insertion");
this->registerParam("bounding_box", insertion_limits, _pat_parsable,
"Global limit for insertion");
UInt spatial_dimension = mesh.getSpatialDimension();
MeshUtils::resetFacetToDouble(mesh_facets);
/// init insertion limits
for (UInt dim = 0; dim < spatial_dimension; ++dim) {
insertion_limits(dim, 0) = std::numeric_limits<Real>::max() * Real(-1.);
insertion_limits(dim, 1) = std::numeric_limits<Real>::max();
}
insertion_facets.initialize(mesh_facets,
_spatial_dimension = spatial_dimension - 1,
_with_nb_element = true, _default_value = false);
}
/* -------------------------------------------------------------------------- */
CohesiveElementInserter::~CohesiveElementInserter() = default;
/* -------------------------------------------------------------------------- */
void CohesiveElementInserter::parseSection(const ParserSection & section) {
Parsable::parseSection(section);
if (is_extrinsic)
limitCheckFacets(this->check_facets);
}
/* -------------------------------------------------------------------------- */
void CohesiveElementInserter::limitCheckFacets() {
limitCheckFacets(this->check_facets);
}
/* -------------------------------------------------------------------------- */
void CohesiveElementInserter::setLimit(SpatialDirection axis, Real first_limit,
Real second_limit) {
AKANTU_DEBUG_ASSERT(
axis < mesh.getSpatialDimension(),
"You are trying to limit insertion in a direction that doesn't exist");
insertion_limits(axis, 0) = std::min(first_limit, second_limit);
insertion_limits(axis, 1) = std::max(first_limit, second_limit);
}
/* -------------------------------------------------------------------------- */
UInt CohesiveElementInserter::insertIntrinsicElements() {
limitCheckFacets(insertion_facets);
return insertElements();
}
/* -------------------------------------------------------------------------- */
void CohesiveElementInserter::limitCheckFacets(
ElementTypeMapArray<bool> & check_facets) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
check_facets.initialize(mesh_facets,
_spatial_dimension = spatial_dimension - 1,
_with_nb_element = true, _default_value = true);
check_facets.set(true);
// remove the pure ghost elements
for_each_element(
mesh_facets,
[&](auto && facet) {
const auto & element_to_facet = mesh_facets.getElementToSubelement(
facet.type, facet.ghost_type)(facet.element);
auto & left = element_to_facet[0];
auto & right = element_to_facet[1];
if (right == ElementNull ||
(left.ghost_type == _ghost && right.ghost_type == _ghost)) {
check_facets(facet) = false;
return;
}
+#ifndef AKANTU_NDEBUG
+ if (left == ElementNull) {
+ AKANTU_DEBUG_WARNING("By convention element should not have "
+ "ElementNull on there first side: "
+ << facet);
+ }
+#endif
if (left.kind() == _ek_cohesive or right.kind() == _ek_cohesive) {
check_facets(facet) = false;
}
},
_spatial_dimension = spatial_dimension - 1);
auto tolerance = Math::getTolerance();
Vector<Real> bary_facet(spatial_dimension);
// set the limits to the bounding box
for_each_element(
mesh_facets,
[&](auto && facet) {
auto & need_check = check_facets(facet);
if (not need_check)
return;
mesh_facets.getBarycenter(facet, bary_facet);
UInt coord_in_limit = 0;
while (coord_in_limit < spatial_dimension and
bary_facet(coord_in_limit) >
(insertion_limits(coord_in_limit, 0) - tolerance) and
bary_facet(coord_in_limit) <
(insertion_limits(coord_in_limit, 1) + tolerance))
++coord_in_limit;
if (coord_in_limit != spatial_dimension)
need_check = false;
},
_spatial_dimension = spatial_dimension - 1);
if (physical_groups.size() == 0) {
AKANTU_DEBUG_OUT();
return;
}
if (not mesh_facets.hasData("physical_names")) {
AKANTU_DEBUG_ASSERT(
physical_groups.size() == 0,
"No physical names in the mesh but insertion limited to a group");
AKANTU_DEBUG_OUT();
return;
}
const auto & physical_ids =
mesh_facets.getData<std::string>("physical_names");
// set the limits to the physical surfaces
for_each_element(mesh_facets,
[&](auto && facet) {
auto & need_check = check_facets(facet);
if (not need_check)
return;
const auto & physical_id = physical_ids(facet);
auto it = find(physical_groups.begin(),
physical_groups.end(), physical_id);
need_check = (it != physical_groups.end());
},
_spatial_dimension = spatial_dimension - 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
UInt CohesiveElementInserter::insertElements(bool only_double_facets) {
CohesiveNewNodesEvent node_event;
NewElementsEvent element_event;
Array<UInt> new_pairs(0, 2);
if (mesh_facets.isDistributed()) {
mesh_facets.getElementSynchronizer().synchronizeOnce(
*this, SynchronizationTag::_ce_groups);
}
UInt nb_new_elements = MeshUtils::insertCohesiveElements(
mesh, mesh_facets, insertion_facets, new_pairs, element_event.getList(),
only_double_facets);
UInt nb_new_nodes = new_pairs.size();
node_event.getList().reserve(nb_new_nodes);
node_event.getOldNodesList().reserve(nb_new_nodes);
for (UInt n = 0; n < nb_new_nodes; ++n) {
node_event.getList().push_back(new_pairs(n, 1));
node_event.getOldNodesList().push_back(new_pairs(n, 0));
}
if (nb_new_elements > 0) {
updateInsertionFacets();
}
MeshAccessor mesh_accessor(mesh);
std::tie(nb_new_nodes, nb_new_elements) =
mesh_accessor.updateGlobalData(node_event, element_event);
return nb_new_elements;
}
/* -------------------------------------------------------------------------- */
void CohesiveElementInserter::updateInsertionFacets() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
for (auto && facet_gt : ghost_types) {
for (auto && facet_type :
mesh_facets.elementTypes(spatial_dimension - 1, facet_gt)) {
auto & ins_facets = insertion_facets(facet_type, facet_gt);
// this is the intrinsic case
if (not is_extrinsic)
continue;
auto & f_check = check_facets(facet_type, facet_gt);
for (auto && pair : zip(ins_facets, f_check)) {
bool & ins = std::get<0>(pair);
bool & check = std::get<1>(pair);
if (ins)
ins = check = false;
}
}
}
// resize for the newly added facets
insertion_facets.initialize(mesh_facets,
_spatial_dimension = spatial_dimension - 1,
_with_nb_element = true, _default_value = false);
// resize for the newly added facets
if (is_extrinsic) {
check_facets.initialize(mesh_facets,
_spatial_dimension = spatial_dimension - 1,
_with_nb_element = true, _default_value = false);
} else {
insertion_facets.set(false);
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/mesh_utils/cohesive_element_inserter.hh b/src/mesh_utils/cohesive_element_inserter.hh
index 4bcac768f..935030a95 100644
--- a/src/mesh_utils/cohesive_element_inserter.hh
+++ b/src/mesh_utils/cohesive_element_inserter.hh
@@ -1,171 +1,171 @@
/**
* @file cohesive_element_inserter.hh
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Dec 04 2013
* @date last modification: Sun Feb 04 2018
*
* @brief Cohesive element inserter
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "data_accessor.hh"
#include "mesh_utils.hh"
#include "parsable.hh"
/* -------------------------------------------------------------------------- */
#include <numeric>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COHESIVE_ELEMENT_INSERTER_HH__
#define __AKANTU_COHESIVE_ELEMENT_INSERTER_HH__
namespace akantu {
class GlobalIdsUpdater;
class FacetSynchronizer;
-} // akantu
+} // namespace akantu
namespace akantu {
class CohesiveElementInserter : public DataAccessor<Element>, public Parsable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
CohesiveElementInserter(Mesh & mesh,
const ID & id = "cohesive_element_inserter");
~CohesiveElementInserter() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// set range limitation for intrinsic cohesive element insertion
void setLimit(SpatialDirection axis, Real first_limit, Real second_limit);
/// insert intrinsic cohesive elements in a predefined range
UInt insertIntrinsicElements();
/// insert extrinsic cohesive elements (returns the number of new
/// cohesive elements)
UInt insertElements(bool only_double_facets = false);
/// limit check facets to match given insertion limits
void limitCheckFacets();
protected:
void parseSection(const ParserSection & section) override;
protected:
/// internal version of limitCheckFacets
void limitCheckFacets(ElementTypeMapArray<bool> & check_facets);
/// update facet insertion arrays after facets doubling
void updateInsertionFacets();
/// functions for parallel communications
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO_NOT_CONST(InsertionFacetsByElement, insertion_facets,
ElementTypeMapArray<bool> &);
AKANTU_GET_MACRO(InsertionFacetsByElement, insertion_facets,
const ElementTypeMapArray<bool> &);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(InsertionFacets, insertion_facets, bool);
AKANTU_GET_MACRO(CheckFacets, check_facets,
const ElementTypeMapArray<bool> &);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(CheckFacets, check_facets, bool);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(CheckFacets, check_facets, bool);
AKANTU_GET_MACRO(MeshFacets, mesh_facets, const Mesh &);
AKANTU_GET_MACRO_NOT_CONST(MeshFacets, mesh_facets, Mesh &);
AKANTU_SET_MACRO(IsExtrinsic, is_extrinsic, bool);
public:
friend class SolidMechanicsModelCohesive;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// object id
ID id;
/// main mesh where to insert cohesive elements
Mesh & mesh;
/// mesh containing facets
Mesh & mesh_facets;
/// list of facets where to insert elements
ElementTypeMapArray<bool> insertion_facets;
/// limits for element insertion
Matrix<Real> insertion_limits;
/// list of groups to consider for insertion, ignored if empty
std::vector<ID> physical_groups;
/// vector containing facets in which extrinsic cohesive elements can be
/// inserted
ElementTypeMapArray<bool> check_facets;
/// global connectivity ids updater
std::unique_ptr<GlobalIdsUpdater> global_ids_updater;
/// is this inserter used in extrinsic
bool is_extrinsic{false};
};
class CohesiveNewNodesEvent : public NewNodesEvent {
public:
CohesiveNewNodesEvent() = default;
~CohesiveNewNodesEvent() override = default;
AKANTU_GET_MACRO_NOT_CONST(OldNodesList, old_nodes, Array<UInt> &);
AKANTU_GET_MACRO(OldNodesList, old_nodes, const Array<UInt> &);
private:
Array<UInt> old_nodes;
};
-} // akantu
+} // namespace akantu
#include "cohesive_element_inserter_inline_impl.cc"
#endif /* __AKANTU_COHESIVE_ELEMENT_INSERTER_HH__ */
diff --git a/src/mesh_utils/cohesive_element_inserter_parallel.cc b/src/mesh_utils/cohesive_element_inserter_parallel.cc
index 5e8028dec..fc07e6a0e 100644
--- a/src/mesh_utils/cohesive_element_inserter_parallel.cc
+++ b/src/mesh_utils/cohesive_element_inserter_parallel.cc
@@ -1,40 +1,38 @@
/**
* @file cohesive_element_inserter_parallel.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Nov 05 2014
* @date last modification: Fri Dec 08 2017
*
* @brief Parallel functions for the cohesive element inserter
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "cohesive_element_inserter.hh"
#include "global_ids_updater.hh"
#include "mesh_accessor.hh"
/* -------------------------------------------------------------------------- */
-namespace akantu {
-
-} // namespace akantu
+namespace akantu {} // namespace akantu
diff --git a/src/mesh_utils/global_ids_updater.cc b/src/mesh_utils/global_ids_updater.cc
index fc485b7a9..834f272f8 100644
--- a/src/mesh_utils/global_ids_updater.cc
+++ b/src/mesh_utils/global_ids_updater.cc
@@ -1,133 +1,134 @@
/**
* @file global_ids_updater.cc
*
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Apr 13 2012
* @date last modification: Fri Dec 08 2017
*
* @brief Functions of the GlobalIdsUpdater
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "global_ids_updater.hh"
#include "element_synchronizer.hh"
#include "mesh_accessor.hh"
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
#include <numeric>
/* -------------------------------------------------------------------------- */
namespace akantu {
UInt GlobalIdsUpdater::updateGlobalIDs(UInt local_nb_new_nodes) {
if (mesh.getCommunicator().getNbProc() == 1)
return local_nb_new_nodes;
UInt total_nb_new_nodes = this->updateGlobalIDsLocally(local_nb_new_nodes);
if (mesh.isDistributed()) {
this->synchronizeGlobalIDs();
}
return total_nb_new_nodes;
}
UInt GlobalIdsUpdater::updateGlobalIDsLocally(UInt local_nb_new_nodes) {
const auto & comm = mesh.getCommunicator();
Int nb_proc = comm.getNbProc();
if (nb_proc == 1)
return local_nb_new_nodes;
/// resize global ids array
MeshAccessor mesh_accessor(mesh);
auto && nodes_global_ids = mesh_accessor.getNodesGlobalIds();
UInt old_nb_nodes = mesh.getNbNodes() - local_nb_new_nodes;
nodes_global_ids.resize(mesh.getNbNodes(), -1);
/// compute the number of global nodes based on the number of old nodes
Vector<UInt> local_master_nodes(2, 0);
for (UInt n = 0; n < old_nb_nodes; ++n)
if (mesh.isLocalOrMasterNode(n))
++local_master_nodes(0);
/// compute amount of local or master doubled nodes
for (UInt n = old_nb_nodes; n < mesh.getNbNodes(); ++n)
if (mesh.isLocalOrMasterNode(n))
++local_master_nodes(1);
-
auto starting_index = local_master_nodes(1);
comm.allReduce(local_master_nodes);
UInt old_global_nodes = local_master_nodes(0);
UInt total_nb_new_nodes = local_master_nodes(1);
if (total_nb_new_nodes == 0)
return 0;
/// set global ids of local and master nodes
comm.exclusiveScan(starting_index);
starting_index += old_global_nodes;
for (UInt n = old_nb_nodes; n < mesh.getNbNodes(); ++n) {
if (mesh.isLocalOrMasterNode(n)) {
nodes_global_ids(n) = starting_index;
++starting_index;
} else {
nodes_global_ids(n) = -1;
}
}
mesh_accessor.setNbGlobalNodes(old_global_nodes + total_nb_new_nodes);
return total_nb_new_nodes;
}
void GlobalIdsUpdater::synchronizeGlobalIDs() {
this->reduce = true;
- this->synchronizer.slaveReductionOnce(*this, SynchronizationTag::_giu_global_conn);
+ this->synchronizer.slaveReductionOnce(*this,
+ SynchronizationTag::_giu_global_conn);
#ifndef AKANTU_NDEBUG
for (auto node : nodes_flags) {
auto node_flag = mesh.getNodeFlag(node.first);
if (node_flag != NodeFlag::_pure_ghost)
continue;
auto n = 0u;
for (auto & pair : node.second) {
if (std::get<1>(pair) == NodeFlag::_pure_ghost)
++n;
}
if (n == node.second.size()) {
AKANTU_DEBUG_WARNING(
"The node " << n << "is ghost on all the neighboring processors");
}
}
#endif
this->reduce = false;
- this->synchronizer.synchronizeOnce(*this, SynchronizationTag::_giu_global_conn);
+ this->synchronizer.synchronizeOnce(*this,
+ SynchronizationTag::_giu_global_conn);
}
-} // akantu
+} // namespace akantu
diff --git a/src/mesh_utils/global_ids_updater.hh b/src/mesh_utils/global_ids_updater.hh
index 229397424..aea93d4f5 100644
--- a/src/mesh_utils/global_ids_updater.hh
+++ b/src/mesh_utils/global_ids_updater.hh
@@ -1,107 +1,107 @@
/**
* @file global_ids_updater.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Oct 02 2015
* @date last modification: Fri Dec 08 2017
*
* @brief Class that updates the global ids of new nodes that are
* inserted in the mesh. The functions in this class must be called
* after updating the node types
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_GLOBAL_IDS_UPDATER_HH__
#define __AKANTU_GLOBAL_IDS_UPDATER_HH__
/* -------------------------------------------------------------------------- */
#include "data_accessor.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class ElementSynchronizer;
-} // akantu
+} // namespace akantu
namespace akantu {
class GlobalIdsUpdater : public DataAccessor<Element> {
public:
GlobalIdsUpdater(Mesh & mesh, ElementSynchronizer & synchronizer)
: mesh(mesh), synchronizer(synchronizer) {}
/// function to update and synchronize the global connectivity of
/// new inserted nodes. It must be called after updating the node
/// types. (It calls in sequence the functions
/// updateGlobalIDsLocally and synchronizeGlobalIDs)
UInt updateGlobalIDs(UInt local_nb_new_nodes);
/// function to update the global connectivity (only locally) of new
/// inserted nodes. It must be called after updating the node types.
UInt updateGlobalIDsLocally(UInt local_nb_new_nodes);
/// function to synchronize the global connectivity of new inserted
/// nodes among the processors. It must be called after updating the
/// node types.
void synchronizeGlobalIDs();
/* ------------------------------------------------------------------------ */
/* Data Accessor inherited members */
/* ------------------------------------------------------------------------ */
public:
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
template <bool pack_mode>
inline void
packUnpackGlobalConnectivity(CommunicationBuffer & buffer,
const Array<Element> & elements) const;
/* ------------------------------------------------------------------------ */
/* Members */
/* ------------------------------------------------------------------------ */
private:
/// Reference to the mesh to update
Mesh & mesh;
/// distributed synchronizer to communicate the connectivity
ElementSynchronizer & synchronizer;
/// Tells if a reduction is taking place or not
bool reduce{false};
std::unordered_map<UInt, std::vector<std::pair<UInt, NodeFlag>>> nodes_flags;
};
-} // akantu
+} // namespace akantu
#include "global_ids_updater_inline_impl.cc"
#endif /* __AKANTU_GLOBAL_IDS_UPDATER_HH__ */
diff --git a/src/mesh_utils/mesh_partition.cc b/src/mesh_utils/mesh_partition.cc
index 146c45b2a..63c660153 100644
--- a/src/mesh_utils/mesh_partition.cc
+++ b/src/mesh_utils/mesh_partition.cc
@@ -1,444 +1,447 @@
/**
* @file mesh_partition.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Aug 17 2010
* @date last modification: Wed Jan 24 2018
*
* @brief implementation of common part of all partitioner
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_partition.hh"
#include "aka_iterators.hh"
#include "aka_types.hh"
#include "mesh_accessor.hh"
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <numeric>
#include <unordered_map>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
MeshPartition::MeshPartition(const Mesh & mesh, UInt spatial_dimension,
const ID & id, const MemoryID & memory_id)
: Memory(id, memory_id), mesh(mesh), spatial_dimension(spatial_dimension),
partitions("partition", id, memory_id),
ghost_partitions("ghost_partition", id, memory_id),
ghost_partitions_offset("ghost_partition_offset", id, memory_id),
saved_connectivity("saved_connectivity", id, memory_id) {
AKANTU_DEBUG_IN();
UInt nb_total_element = 0;
for (auto && type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_not_defined)) {
linearized_offsets.push_back(std::make_pair(type, nb_total_element));
nb_total_element += mesh.getConnectivity(type).size();
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
MeshPartition::~MeshPartition() = default;
/* -------------------------------------------------------------------------- */
UInt MeshPartition::linearized(const Element & element) {
auto it =
std::find_if(linearized_offsets.begin(), linearized_offsets.end(),
[&element](auto & a) { return a.first == element.type; });
AKANTU_DEBUG_ASSERT(it != linearized_offsets.end(),
"A bug might be crawling around this corner...");
return (it->second + element.element);
}
/* -------------------------------------------------------------------------- */
Element MeshPartition::unlinearized(UInt lin_element) {
ElementType type{_not_defined};
UInt offset{0};
for (auto & pair : linearized_offsets) {
if (lin_element < pair.second)
continue;
std::tie(type, offset) = pair;
}
return Element{type, lin_element - offset, _not_ghost};
}
/* -------------------------------------------------------------------------- */
/**
* TODO this function should most probably be rewritten in a more modern way
* conversion in c++ of the GENDUALMETIS (mesh.c) function wrote by George in
* Metis (University of Minnesota)
*/
void MeshPartition::buildDualGraph(
Array<Int> & dxadj, Array<Int> & dadjncy, Array<Int> & edge_loads,
std::function<Int(const Element &, const Element &)> edge_load_func,
Array<Int> & vertex_loads,
std::function<Int(const Element &)> vertex_load_func) {
AKANTU_DEBUG_IN();
std::map<ElementType, std::tuple<const Array<UInt> *, UInt, UInt>>
connectivities;
UInt spatial_dimension = mesh.getSpatialDimension();
UInt nb_total_element{0};
for (auto & type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_not_defined)) {
auto type_p1 = mesh.getP1ElementType(type);
auto nb_nodes_per_element_p1 = mesh.getNbNodesPerElement(type_p1);
const auto & conn = mesh.getConnectivity(type, _not_ghost);
for (auto n : arange(mesh.getNbFacetTypes(type_p1))) {
auto magic_number =
mesh.getNbNodesPerElement(mesh.getFacetType(type_p1, n));
connectivities[type] =
std::make_tuple(&conn, nb_nodes_per_element_p1, magic_number);
}
nb_total_element += conn.size();
}
CSR<Element> node_to_elem;
MeshUtils::buildNode2Elements(mesh, node_to_elem);
dxadj.resize(nb_total_element + 1);
/// initialize the dxadj array
auto dxadj_it = dxadj.begin();
for (auto & pair : connectivities) {
const auto & connectivity = *std::get<0>(pair.second);
auto nb_nodes_per_element_p1 = std::get<1>(pair.second);
std::fill_n(dxadj_it, connectivity.size(), nb_nodes_per_element_p1);
dxadj_it += connectivity.size();
}
/// convert the dxadj_val array in a csr one
for (UInt i = 1; i < nb_total_element; ++i)
dxadj(i) += dxadj(i - 1);
for (UInt i = nb_total_element; i > 0; --i)
dxadj(i) = dxadj(i - 1);
dxadj(0) = 0;
dadjncy.resize(2 * dxadj(nb_total_element));
/// weight map to determine adjacency
std::unordered_map<UInt, UInt> weight_map;
for (auto & pair : connectivities) {
auto type = pair.first;
const auto & connectivity = *std::get<0>(pair.second);
auto nb_nodes_per_element = std::get<1>(pair.second);
auto magic_number = std::get<2>(pair.second);
Element element{type, 0, _not_ghost};
for (const auto & conn :
make_view(connectivity, connectivity.getNbComponent())) {
auto linearized_el = linearized(element);
/// fill the weight map
for (UInt n : arange(nb_nodes_per_element)) {
auto && node = conn(n);
for (auto k = node_to_elem.rbegin(node); k != node_to_elem.rend(node);
--k) {
auto & current_element = *k;
auto current_el = linearized(current_element);
AKANTU_DEBUG_ASSERT(current_el != UInt(-1),
"Linearized element not found");
if (current_el <= linearized_el)
break;
auto weight_map_insert =
weight_map.insert(std::make_pair(current_el, 1));
if (not weight_map_insert.second)
(weight_map_insert.first->second)++;
}
}
/// each element with a weight of the size of a facet are adjacent
for (auto & weight_pair : weight_map) {
auto & adjacent_el = weight_pair.first;
auto magic = weight_pair.second;
if (magic != magic_number)
continue;
#if defined(AKANTU_COHESIVE_ELEMENT)
/// Patch in order to prevent neighboring cohesive elements
/// from detecting each other
auto adjacent_element = unlinearized(adjacent_el);
auto el_kind = element.kind();
auto adjacent_el_kind = adjacent_element.kind();
if (el_kind == adjacent_el_kind && el_kind == _ek_cohesive)
continue;
#endif
UInt index_adj = dxadj(adjacent_el)++;
UInt index_lin = dxadj(linearized_el)++;
dadjncy(index_lin) = adjacent_el;
dadjncy(index_adj) = linearized_el;
}
element.element++;
weight_map.clear();
}
}
Int k_start = 0, linerized_el = 0, j = 0;
for (auto & pair : connectivities) {
const auto & connectivity = *std::get<0>(pair.second);
auto nb_nodes_per_element_p1 = std::get<1>(pair.second);
auto nb_element = connectivity.size();
for (UInt el = 0; el < nb_element; ++el, ++linerized_el) {
for (Int k = k_start; k < dxadj(linerized_el); ++k, ++j)
dadjncy(j) = dadjncy(k);
dxadj(linerized_el) = j;
k_start += nb_nodes_per_element_p1;
}
}
for (UInt i = nb_total_element; i > 0; --i)
dxadj(i) = dxadj(i - 1);
dxadj(0) = 0;
-
vertex_loads.resize(dxadj.size() - 1);
edge_loads.resize(dadjncy.size());
UInt adj = 0;
for (UInt i = 0; i < nb_total_element; ++i) {
auto el = unlinearized(i);
vertex_loads(i) = vertex_load_func(el);
- UInt nb_adj = dxadj(i + 1) - dxadj(i);
+ UInt nb_adj = dxadj(i + 1) - dxadj(i);
for (UInt j = 0; j < nb_adj; ++j, ++adj) {
auto el_adj_id = dadjncy(dxadj(i) + j);
auto el_adj = unlinearized(el_adj_id);
Int load = edge_load_func(el, el_adj);
edge_loads(adj) = load;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshPartition::fillPartitionInformation(
const Mesh & mesh, const Int * linearized_partitions) {
AKANTU_DEBUG_IN();
CSR<Element> node_to_elem;
MeshUtils::buildNode2Elements(mesh, node_to_elem);
UInt linearized_el = 0;
for (auto & type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_not_defined)) {
UInt nb_element = mesh.getNbElement(type);
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
auto & partition = partitions.alloc(nb_element, 1, type, _not_ghost);
auto & ghost_part_csr = ghost_partitions_csr(type, _not_ghost);
ghost_part_csr.resizeRows(nb_element);
auto & ghost_partition_offset =
ghost_partitions_offset.alloc(nb_element + 1, 1, type, _ghost);
auto & ghost_partition = ghost_partitions.alloc(0, 1, type, _ghost);
const auto & connectivity = mesh.getConnectivity(type, _not_ghost);
auto conn_it = connectivity.begin(connectivity.getNbComponent());
for (UInt el = 0; el < nb_element; ++el, ++linearized_el) {
UInt part = linearized_partitions[linearized_el];
partition(el) = part;
std::list<UInt> list_adj_part;
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
auto conn = Vector<UInt>(*(conn_it + el));
UInt node = conn(n);
for (const auto & adj_element : node_to_elem.getRow(node)) {
UInt adj_el = linearized(adj_element);
UInt adj_part = linearized_partitions[adj_el];
if (part != adj_part) {
list_adj_part.push_back(adj_part);
}
}
}
list_adj_part.sort();
list_adj_part.unique();
for (auto & adj_part : list_adj_part) {
ghost_part_csr.getRows().push_back(adj_part);
ghost_part_csr.rowOffset(el)++;
ghost_partition.push_back(adj_part);
ghost_partition_offset(el)++;
}
}
ghost_part_csr.countToCSR();
/// convert the ghost_partitions_offset array in an offset array
auto & ghost_partitions_offset_ptr = ghost_partitions_offset(type, _ghost);
for (UInt i = 1; i < nb_element; ++i)
ghost_partitions_offset_ptr(i) += ghost_partitions_offset_ptr(i - 1);
for (UInt i = nb_element; i > 0; --i)
ghost_partitions_offset_ptr(i) = ghost_partitions_offset_ptr(i - 1);
ghost_partitions_offset_ptr(0) = 0;
}
// All Facets
for (Int sp = spatial_dimension - 1; sp >= 0; --sp) {
for (auto & type : mesh.elementTypes(sp, _not_ghost, _ek_not_defined)) {
UInt nb_element = mesh.getNbElement(type);
auto & partition = partitions.alloc(nb_element, 1, type, _not_ghost);
AKANTU_DEBUG_INFO("Allocating partitions for " << type);
auto & ghost_part_csr = ghost_partitions_csr(type, _not_ghost);
ghost_part_csr.resizeRows(nb_element);
auto & ghost_partition_offset =
ghost_partitions_offset.alloc(nb_element + 1, 1, type, _ghost);
auto & ghost_partition = ghost_partitions.alloc(0, 1, type, _ghost);
AKANTU_DEBUG_INFO("Allocating ghost_partitions for " << type);
const Array<std::vector<Element>> & elem_to_subelem =
mesh.getElementToSubelement(type, _not_ghost);
// Facet loop
for (UInt i(0); i < mesh.getNbElement(type, _not_ghost); ++i) {
const auto & adjacent_elems = elem_to_subelem(i);
if (not adjacent_elems.empty()) {
Element min_elem{_max_element_type, std::numeric_limits<UInt>::max(),
*ghost_type_t::end()};
UInt min_part(std::numeric_limits<UInt>::max());
std::set<UInt> adjacent_parts;
for (UInt j(0); j < adjacent_elems.size(); ++j) {
auto adjacent_elem_id = adjacent_elems[j].element;
auto adjacent_elem_part =
partitions(adjacent_elems[j].type,
adjacent_elems[j].ghost_type)(adjacent_elem_id);
if (adjacent_elem_part < min_part) {
min_part = adjacent_elem_part;
min_elem = adjacent_elems[j];
}
adjacent_parts.insert(adjacent_elem_part);
}
partition(i) = min_part;
auto git = ghost_partitions_csr(min_elem.type, _not_ghost)
.begin(min_elem.element);
auto gend = ghost_partitions_csr(min_elem.type, _not_ghost)
.end(min_elem.element);
for (; git != gend; ++git) {
adjacent_parts.insert(*git);
}
adjacent_parts.erase(min_part);
for (auto & part : adjacent_parts) {
ghost_part_csr.getRows().push_back(part);
ghost_part_csr.rowOffset(i)++;
ghost_partition.push_back(part);
}
ghost_partition_offset(i + 1) =
ghost_partition_offset(i + 1) + adjacent_elems.size();
} else {
partition(i) = 0;
}
}
ghost_part_csr.countToCSR();
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshPartition::tweakConnectivity() {
AKANTU_DEBUG_IN();
MeshAccessor mesh_accessor(const_cast<Mesh &>(mesh));
for (auto && type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_not_defined)) {
auto & connectivity = mesh_accessor.getConnectivity(type, _not_ghost);
auto & saved_conn = saved_connectivity.alloc(
connectivity.size(), connectivity.getNbComponent(), type, _not_ghost);
saved_conn.copy(connectivity);
for (auto && conn :
make_view(connectivity, connectivity.getNbComponent())) {
for (auto && node : conn) {
if (mesh.isPeriodicSlave(node)) {
node = mesh.getPeriodicMaster(node);
}
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshPartition::restoreConnectivity() {
AKANTU_DEBUG_IN();
MeshAccessor mesh_accessor(const_cast<Mesh &>(mesh));
for (auto && type : saved_connectivity.elementTypes(
spatial_dimension, _not_ghost, _ek_not_defined)) {
auto & conn = mesh_accessor.getConnectivity(type, _not_ghost);
auto & saved_conn = saved_connectivity(type, _not_ghost);
conn.copy(saved_conn);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
bool MeshPartition::hasPartitions(const ElementType & type,
const GhostType & ghost_type) {
return partitions.exists(type, ghost_type);
}
/* -------------------------------------------------------------------------- */
void MeshPartition::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
- stream << space << "MeshPartition [" << "\n";
+ stream << space << "MeshPartition ["
+ << "\n";
stream << space << " + id : " << id << "\n";
stream << space << " + nb partitions: " << nb_partitions << "\n";
- stream << space << " + partitions [ " << "\n";
+ stream << space << " + partitions [ "
+ << "\n";
partitions.printself(stream, indent + 2);
- stream << space << " ]" << "\n";
- stream << space << "]" << "\n";
+ stream << space << " ]"
+ << "\n";
+ stream << space << "]"
+ << "\n";
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/mesh_utils/mesh_partition.hh b/src/mesh_utils/mesh_partition.hh
index c01c25821..80b12bfc9 100644
--- a/src/mesh_utils/mesh_partition.hh
+++ b/src/mesh_utils/mesh_partition.hh
@@ -1,152 +1,153 @@
/**
* @file mesh_partition.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Jan 23 2018
*
* @brief tools to partitionate a mesh
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_PARTITION_HH__
#define __AKANTU_MESH_PARTITION_HH__
/* -------------------------------------------------------------------------- */
#include "aka_csr.hh"
#include "aka_memory.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class MeshPartition : protected Memory {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MeshPartition(const Mesh & mesh, UInt spatial_dimension,
const ID & id = "MeshPartitioner",
const MemoryID & memory_id = 0);
~MeshPartition() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// define a partition of the mesh
virtual void partitionate(
UInt nb_part,
std::function<Int(const Element &, const Element &)> edge_load_func =
[](auto &&, auto &&) { return 1; },
std::function<Int(const Element &)> vertex_load_func =
[](auto &&) { return 1; }) = 0;
/// reorder the nodes to reduce the filling during the factorization of a
/// matrix that has a profil based on the connectivity of the mesh
virtual void reorder() = 0;
/// fill the partitions array with a given linearized partition information
void fillPartitionInformation(const Mesh & mesh,
const Int * linearized_partitions);
virtual void printself(std::ostream & stream, int indent = 0) const;
-
+
protected:
/// build the dual graph of the mesh, for all element of spatial_dimension
void buildDualGraph(
Array<Int> & dxadj, Array<Int> & dadjncy, Array<Int> & edge_loads,
std::function<Int(const Element &, const Element &)> edge_load_func,
Array<Int> & vertex_loads,
std::function<Int(const Element &)> vertex_load_func);
/// tweak the mesh to handle the PBC pairs
void tweakConnectivity();
/// restore the mesh that has been tweaked
void restoreConnectivity();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
bool hasPartitions(const ElementType & type, const GhostType & ghost_type);
AKANTU_GET_MACRO(Partitions, partitions, const ElementTypeMapArray<UInt> &);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Partition, partitions, UInt);
AKANTU_GET_MACRO(GhostPartitionCSR, ghost_partitions_csr,
const ElementTypeMap<CSR<UInt>> &);
AKANTU_GET_MACRO(NbPartition, nb_partitions, UInt);
AKANTU_SET_MACRO(NbPartition, nb_partitions, UInt);
protected:
UInt linearized(const Element & element);
Element unlinearized(UInt lin_element);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// id
std::string id;
/// the mesh to partition
const Mesh & mesh;
/// dimension of the elements to consider in the mesh
UInt spatial_dimension;
/// number of partitions
UInt nb_partitions;
/// partition numbers
ElementTypeMapArray<UInt> partitions;
ElementTypeMap<CSR<UInt>> ghost_partitions_csr;
ElementTypeMapArray<UInt> ghost_partitions;
ElementTypeMapArray<UInt> ghost_partitions_offset;
Array<UInt> * permutation;
ElementTypeMapArray<UInt> saved_connectivity;
// vector of pair to ensure the iteration order
std::vector<std::pair<ElementType, UInt>> linearized_offsets;
};
/// standard output stream operator
-inline std::ostream & operator<<(std::ostream & stream, const MeshPartition & _this) {
+inline std::ostream & operator<<(std::ostream & stream,
+ const MeshPartition & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#ifdef AKANTU_USE_SCOTCH
#include "mesh_partition_scotch.hh"
#endif
#endif /* __AKANTU_MESH_PARTITION_HH__ */
diff --git a/src/mesh_utils/mesh_partition/mesh_partition_mesh_data.hh b/src/mesh_utils/mesh_partition/mesh_partition_mesh_data.hh
index 68c6f1744..f3aa58541 100644
--- a/src/mesh_utils/mesh_partition/mesh_partition_mesh_data.hh
+++ b/src/mesh_utils/mesh_partition/mesh_partition_mesh_data.hh
@@ -1,95 +1,95 @@
/**
* @file mesh_partition_mesh_data.hh
*
* @author Dana Christen <dana.christen@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief mesh partitioning based on data provided in the mesh
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_PARTITION_MESH_DATA_HH__
#define __AKANTU_MESH_PARTITION_MESH_DATA_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "mesh_partition.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class MeshPartitionMeshData : public MeshPartition {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MeshPartitionMeshData(const Mesh & mesh, UInt spatial_dimension,
const ID & id = "MeshPartitionerMeshData",
const MemoryID & memory_id = 0);
MeshPartitionMeshData(const Mesh & mesh,
const ElementTypeMapArray<UInt> & mapping,
UInt spatial_dimension,
const ID & id = "MeshPartitionerMeshData",
const MemoryID & memory_id = 0);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void partitionate(
UInt nb_part,
std::function<Int(const Element &, const Element &)> edge_load_func =
[](auto &&, auto &&) { return 1; },
std::function<Int(const Element &)> vertex_load_func =
- [](auto &&) { return 1; }) override;
+ [](auto &&) { return 1; }) override;
void reorder() override;
void setPartitionMapping(const ElementTypeMapArray<UInt> & mapping);
void setPartitionMappingFromMeshData(const std::string & data_name);
private:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
const ElementTypeMapArray<UInt> * partition_mapping;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_PARTITION_MESH_DATA_HH__ */
diff --git a/src/mesh_utils/mesh_partition/mesh_partition_scotch.hh b/src/mesh_utils/mesh_partition/mesh_partition_scotch.hh
index 9a63c39ca..a7bd3f064 100644
--- a/src/mesh_utils/mesh_partition/mesh_partition_scotch.hh
+++ b/src/mesh_utils/mesh_partition/mesh_partition_scotch.hh
@@ -1,79 +1,79 @@
/**
* @file mesh_partition_scotch.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief mesh partitioning based on libScotch
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_PARTITION_SCOTCH_HH__
#define __AKANTU_MESH_PARTITION_SCOTCH_HH__
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "mesh_partition.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class MeshPartitionScotch : public MeshPartition {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MeshPartitionScotch(const Mesh & mesh, UInt spatial_dimension,
const ID & id = "mesh_partition_scotch",
const MemoryID & memory_id = 0);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
- virtual void partitionate(
+ virtual void partitionate(
UInt nb_part,
std::function<Int(const Element &, const Element &)> edge_load_func =
[](auto &&, auto &&) { return 1; },
std::function<Int(const Element &)> vertex_load_func =
[](auto &&) { return 1; }) override;
void reorder() override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_PARTITION_SCOTCH_HH__ */
diff --git a/src/mesh_utils/mesh_utils.cc b/src/mesh_utils/mesh_utils.cc
index f30b07edb..83e09943e 100644
--- a/src/mesh_utils/mesh_utils.cc
+++ b/src/mesh_utils/mesh_utils.cc
@@ -1,1847 +1,1834 @@
/**
* @file mesh_utils.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Leonardo Snozzi <leonardo.snozzi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Aug 20 2010
* @date last modification: Wed Feb 21 2018
*
* @brief All mesh utils necessary for various tasks
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_utils.hh"
#include "element_synchronizer.hh"
#include "fe_engine.hh"
#include "mesh_accessor.hh"
#include "mesh_iterators.hh"
/* -------------------------------------------------------------------------- */
#include <limits>
#include <numeric>
#include <queue>
#include <set>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
void MeshUtils::buildNode2Elements(const Mesh & mesh,
CSR<Element> & node_to_elem,
UInt spatial_dimension) {
AKANTU_DEBUG_IN();
if (spatial_dimension == _all_dimensions)
spatial_dimension = mesh.getSpatialDimension();
/// count number of occurrence of each node
UInt nb_nodes = mesh.getNbNodes();
/// array for the node-element list
node_to_elem.resizeRows(nb_nodes);
node_to_elem.clearRows();
for_each_element(mesh,
[&](auto && element) {
Vector<UInt> conn = mesh.getConnectivity(element);
for (auto && node : conn) {
++node_to_elem.rowOffset(node);
}
},
_spatial_dimension = spatial_dimension,
_element_kind = _ek_not_defined);
node_to_elem.countToCSR();
node_to_elem.resizeCols();
/// rearrange element to get the node-element list
// Element e;
node_to_elem.beginInsertions();
for_each_element(mesh,
[&](auto && element) {
Vector<UInt> conn = mesh.getConnectivity(element);
for (auto && node : conn) {
node_to_elem.insertInRow(node, element);
}
},
_spatial_dimension = spatial_dimension,
_element_kind = _ek_not_defined);
node_to_elem.endInsertions();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::buildNode2ElementsElementTypeMap(const Mesh & mesh,
CSR<UInt> & node_to_elem,
const ElementType & type,
const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
UInt nb_nodes = mesh.getNbNodes();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_elements = mesh.getConnectivity(type, ghost_type).size();
UInt * conn_val = mesh.getConnectivity(type, ghost_type).storage();
/// array for the node-element list
node_to_elem.resizeRows(nb_nodes);
node_to_elem.clearRows();
/// count number of occurrence of each node
for (UInt el = 0; el < nb_elements; ++el) {
UInt el_offset = el * nb_nodes_per_element;
for (UInt n = 0; n < nb_nodes_per_element; ++n)
++node_to_elem.rowOffset(conn_val[el_offset + n]);
}
/// convert the occurrence array in a csr one
node_to_elem.countToCSR();
node_to_elem.resizeCols();
node_to_elem.beginInsertions();
/// save the element index in the node-element list
for (UInt el = 0; el < nb_elements; ++el) {
UInt el_offset = el * nb_nodes_per_element;
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
node_to_elem.insertInRow(conn_val[el_offset + n], el);
}
}
node_to_elem.endInsertions();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::buildFacets(Mesh & mesh) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
for (auto ghost_type : ghost_types) {
for (auto & type : mesh.elementTypes(spatial_dimension - 1, ghost_type)) {
mesh.getConnectivity(type, ghost_type).resize(0);
// \todo inform the mesh event handler
}
}
buildFacetsDimension(mesh, mesh, true, spatial_dimension);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::buildAllFacets(const Mesh & mesh, Mesh & mesh_facets,
UInt to_dimension) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
buildAllFacets(mesh, mesh_facets, spatial_dimension, to_dimension);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::buildAllFacets(const Mesh & mesh, Mesh & mesh_facets,
UInt from_dimension, UInt to_dimension) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(
mesh_facets.isMeshFacets(),
"The mesh_facets should be initialized with initMeshFacets");
/// generate facets
buildFacetsDimension(mesh, mesh_facets, false, from_dimension);
/// sort facets and generate sub-facets
for (UInt i = from_dimension - 1; i > to_dimension; --i) {
buildFacetsDimension(mesh_facets, mesh_facets, false, i);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::buildFacetsDimension(const Mesh & mesh, Mesh & mesh_facets,
bool boundary_only, UInt dimension) {
AKANTU_DEBUG_IN();
// save the current parent of mesh_facets and set it temporarly to mesh since
// mesh is the one containing the elements for which mesh_facets has the
// sub-elements
// example: if the function is called with mesh = mesh_facets
const Mesh * mesh_facets_parent = nullptr;
try {
mesh_facets_parent = &mesh_facets.getMeshParent();
} catch (...) {
}
mesh_facets.defineMeshParent(mesh);
MeshAccessor mesh_accessor(mesh_facets);
UInt spatial_dimension = mesh.getSpatialDimension();
const Array<Real> & mesh_facets_nodes = mesh_facets.getNodes();
const auto mesh_facets_nodes_it = mesh_facets_nodes.begin(spatial_dimension);
CSR<Element> node_to_elem;
buildNode2Elements(mesh, node_to_elem, dimension);
Array<UInt> counter;
std::vector<Element> connected_elements;
// init the SubelementToElement data to improve performance
for (auto && ghost_type : ghost_types) {
for (auto && type : mesh.elementTypes(dimension, ghost_type)) {
mesh_accessor.getSubelementToElement(type, ghost_type);
auto facet_types = mesh.getAllFacetTypes(type);
for (auto && ft : arange(facet_types.size())) {
auto facet_type = facet_types(ft);
mesh_accessor.getElementToSubelement(facet_type, ghost_type);
mesh_accessor.getConnectivity(facet_type, ghost_type);
}
}
}
const ElementSynchronizer * synchronizer = nullptr;
if (mesh.isDistributed()) {
synchronizer = &(mesh.getElementSynchronizer());
}
Element current_element;
for (auto && ghost_type : ghost_types) {
GhostType facet_ghost_type = ghost_type;
current_element.ghost_type = ghost_type;
for (auto && type : mesh.elementTypes(dimension, ghost_type)) {
auto facet_types = mesh.getAllFacetTypes(type);
current_element.type = type;
for (auto && ft : arange(facet_types.size())) {
auto facet_type = facet_types(ft);
auto nb_element = mesh.getNbElement(type, ghost_type);
auto element_to_subelement =
&mesh_facets.getElementToSubelement(facet_type, ghost_type);
auto connectivity_facets =
&mesh_facets.getConnectivity(facet_type, ghost_type);
- auto nb_facet_per_element = mesh.getNbFacetsPerElement(type, ft);
- const auto & element_connectivity =
- mesh.getConnectivity(type, ghost_type);
- Matrix<const UInt> facet_local_connectivity(
- mesh.getFacetLocalConnectivity(type, ft));
-
auto nb_nodes_per_facet = connectivity_facets->getNbComponent();
- Vector<UInt> facet(nb_nodes_per_facet);
+ // Vector<UInt> facet(nb_nodes_per_facet);
for (UInt el = 0; el < nb_element; ++el) {
current_element.element = el;
- for (UInt f = 0; f < nb_facet_per_element; ++f) {
- for (UInt n = 0; n < nb_nodes_per_facet; ++n)
- facet(n) =
- element_connectivity(el, facet_local_connectivity(f, n));
+ auto && facets =
+ mesh.getFacetConnectivity(current_element, ft).transpose();
+
+ for (auto facet : facets) {
+ // facet = facets(f);
UInt first_node_nb_elements = node_to_elem.getNbCols(facet(0));
counter.resize(first_node_nb_elements);
counter.clear();
// loop over the other nodes to search intersecting elements,
// which are the elements that share another node with the
// starting element after first_node
- UInt local_el = 0;
- auto first_node_elements = node_to_elem.begin(facet(0));
- auto first_node_elements_end = node_to_elem.end(facet(0));
- for (; first_node_elements != first_node_elements_end;
- ++first_node_elements, ++local_el) {
- for (UInt n = 1; n < nb_nodes_per_facet; ++n) {
- auto node_elements_begin = node_to_elem.begin(facet(n));
- auto node_elements_end = node_to_elem.end(facet(n));
- counter(local_el) +=
- std::count(node_elements_begin, node_elements_end,
- *first_node_elements);
+ for (auto && data : enumerate(node_to_elem.getRow(facet(0)))) {
+ auto && local_el = std::get<0>(data);
+ auto && first_node = std::get<1>(data);
+ for (auto n : arange(1, nb_nodes_per_facet)) {
+ auto && node_elements = node_to_elem.getRow(facet(n));
+ counter(local_el) += std::count(
+ node_elements.begin(), node_elements.end(), first_node);
}
}
// counting the number of elements connected to the facets and
// taking the minimum element number, because the facet should
// be inserted just once
UInt nb_element_connected_to_facet = 0;
Element minimum_el = ElementNull;
connected_elements.clear();
- for (UInt el_f = 0; el_f < first_node_nb_elements; el_f++) {
- Element real_el = node_to_elem(facet(0), el_f);
- if (not(counter(el_f) == nb_nodes_per_facet - 1))
+ for (auto && data : enumerate(node_to_elem.getRow(facet(0)))) {
+
+ if (not(counter(std::get<0>(data)) == nb_nodes_per_facet - 1))
continue;
+ auto && real_el = std::get<1>(data);
+
++nb_element_connected_to_facet;
minimum_el = std::min(minimum_el, real_el);
connected_elements.push_back(real_el);
}
if (minimum_el != current_element)
continue;
bool full_ghost_facet = false;
UInt n = 0;
- while (n < nb_nodes_per_facet && mesh.isPureGhostNode(facet(n)))
+ while (n < nb_nodes_per_facet && mesh.isPureGhostNode(facet(n))) {
++n;
+ }
if (n == nb_nodes_per_facet)
full_ghost_facet = true;
if (full_ghost_facet)
continue;
if (boundary_only and nb_element_connected_to_facet != 1)
continue;
std::vector<Element> elements;
// build elements_on_facets: linearized_el must come first
// in order to store the facet in the correct direction
// and avoid to invert the sign in the normal computation
- elements.push_back(current_element);
+ for (auto && connected_element : connected_elements) {
+ elements.push_back(connected_element);
+ }
if (nb_element_connected_to_facet == 1) { /// boundary facet
elements.push_back(ElementNull);
} else if (nb_element_connected_to_facet == 2) { /// internal facet
- elements.push_back(connected_elements[1]);
-
/// check if facet is in between ghost and normal
/// elements: if it's the case, the facet is either
/// ghost or not ghost. The criterion to decide this
/// is arbitrary. It was chosen to check the processor
/// id (prank) of the two neighboring elements. If
/// prank of the ghost element is lower than prank of
/// the normal one, the facet is not ghost, otherwise
/// it's ghost
GhostType gt[2] = {_not_ghost, _not_ghost};
for (UInt el = 0; el < connected_elements.size(); ++el)
gt[el] = connected_elements[el].ghost_type;
if ((gt[0] == _not_ghost) xor (gt[1] == _not_ghost)) {
UInt prank[2];
for (UInt el = 0; el < 2; ++el) {
prank[el] = synchronizer->getRank(connected_elements[el]);
}
// ugly trick from Marco detected :P
bool ghost_one = (gt[0] != _ghost);
if (prank[ghost_one] > prank[!ghost_one])
facet_ghost_type = _not_ghost;
else
facet_ghost_type = _ghost;
connectivity_facets =
&mesh_facets.getConnectivity(facet_type, facet_ghost_type);
element_to_subelement = &mesh_facets.getElementToSubelement(
facet_type, facet_ghost_type);
}
- } else { /// facet of facet
- for (UInt i = 1; i < nb_element_connected_to_facet; ++i) {
- elements.push_back(connected_elements[i]);
- }
}
element_to_subelement->push_back(elements);
connectivity_facets->push_back(facet);
/// current facet index
UInt current_facet = connectivity_facets->size() - 1;
+ Element facet_element{facet_type, current_facet, facet_ghost_type};
/// loop on every element connected to current facet and
/// insert current facet in the first free spot of the
/// subelement_to_element vector
- for (UInt elem = 0; elem < elements.size(); ++elem) {
- Element loc_el = elements[elem];
-
- if (loc_el.type == _not_defined)
+ for (auto & loc_el : elements) {
+ if (loc_el == ElementNull)
continue;
- Array<Element> & subelement_to_element =
- mesh_facets.getSubelementToElement(loc_el.type,
- loc_el.ghost_type);
+ auto & subelement_to_element = mesh_facets.getSubelementToElement(
+ loc_el.type, loc_el.ghost_type);
- UInt nb_facet_per_loc_element =
- subelement_to_element.getNbComponent();
+ auto && subelements = Vector<Element>(
+ make_view(subelement_to_element,
+ subelement_to_element.getNbComponent())
+ .begin()[loc_el.element]);
- for (UInt f_in = 0; f_in < nb_facet_per_loc_element; ++f_in) {
- auto & el = subelement_to_element(loc_el.element, f_in);
- if (el.type != _not_defined)
+ for (auto & el : subelements) {
+ if (el != ElementNull)
continue;
- el.type = facet_type;
- el.element = current_facet;
- el.ghost_type = facet_ghost_type;
+ el = facet_element;
break;
}
}
/// reset connectivity in case a facet was found in
/// between ghost and normal elements
if (facet_ghost_type != ghost_type) {
facet_ghost_type = ghost_type;
connectivity_facets =
&mesh_accessor.getConnectivity(facet_type, facet_ghost_type);
element_to_subelement = &mesh_accessor.getElementToSubelement(
facet_type, facet_ghost_type);
}
}
}
}
}
}
// restore the parent of mesh_facet
if (mesh_facets_parent)
mesh_facets.defineMeshParent(*mesh_facets_parent);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::renumberMeshNodes(Mesh & mesh,
Array<UInt> & local_connectivities,
UInt nb_local_element, UInt nb_ghost_element,
ElementType type,
Array<UInt> & old_nodes_numbers) {
AKANTU_DEBUG_IN();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
std::map<UInt, UInt> renumbering_map;
for (UInt i = 0; i < old_nodes_numbers.size(); ++i) {
renumbering_map[old_nodes_numbers(i)] = i;
}
/// renumber the nodes
renumberNodesInConnectivity(local_connectivities,
(nb_local_element + nb_ghost_element) *
nb_nodes_per_element,
renumbering_map);
old_nodes_numbers.resize(renumbering_map.size());
for (auto & renumber_pair : renumbering_map) {
old_nodes_numbers(renumber_pair.second) = renumber_pair.first;
}
renumbering_map.clear();
MeshAccessor mesh_accessor(mesh);
/// copy the renumbered connectivity to the right place
auto & local_conn = mesh_accessor.getConnectivity(type);
local_conn.resize(nb_local_element);
if (nb_local_element > 0) {
memcpy(local_conn.storage(), local_connectivities.storage(),
nb_local_element * nb_nodes_per_element * sizeof(UInt));
}
auto & ghost_conn = mesh_accessor.getConnectivity(type, _ghost);
ghost_conn.resize(nb_ghost_element);
if (nb_ghost_element > 0) {
std::memcpy(ghost_conn.storage(),
local_connectivities.storage() +
nb_local_element * nb_nodes_per_element,
nb_ghost_element * nb_nodes_per_element * sizeof(UInt));
}
auto & ghost_counter = mesh_accessor.getGhostsCounters(type, _ghost);
ghost_counter.resize(nb_ghost_element, 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::renumberNodesInConnectivity(
Array<UInt> & list_nodes, UInt nb_nodes,
std::map<UInt, UInt> & renumbering_map) {
AKANTU_DEBUG_IN();
UInt * connectivity = list_nodes.storage();
UInt new_node_num = renumbering_map.size();
for (UInt n = 0; n < nb_nodes; ++n, ++connectivity) {
UInt & node = *connectivity;
auto it = renumbering_map.find(node);
if (it == renumbering_map.end()) {
UInt old_node = node;
renumbering_map[old_node] = new_node_num;
node = new_node_num;
++new_node_num;
} else {
node = it->second;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::purifyMesh(Mesh & mesh) {
AKANTU_DEBUG_IN();
std::map<UInt, UInt> renumbering_map;
RemovedNodesEvent remove_nodes(mesh);
Array<UInt> & nodes_removed = remove_nodes.getList();
for (auto ghost_type : ghost_types) {
for (auto type :
mesh.elementTypes(_all_dimensions, ghost_type, _ek_not_defined)) {
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
Array<UInt> & connectivity = mesh.getConnectivity(type, ghost_type);
UInt nb_element(connectivity.size());
renumberNodesInConnectivity(
connectivity, nb_element * nb_nodes_per_element, renumbering_map);
}
}
Array<UInt> & new_numbering = remove_nodes.getNewNumbering();
std::fill(new_numbering.begin(), new_numbering.end(), UInt(-1));
for (auto && pair : renumbering_map) {
new_numbering(std::get<0>(pair)) = std::get<1>(pair);
}
for (UInt i = 0; i < new_numbering.size(); ++i) {
if (new_numbering(i) == UInt(-1))
nodes_removed.push_back(i);
}
mesh.sendEvent(remove_nodes);
AKANTU_DEBUG_OUT();
}
#if defined(AKANTU_COHESIVE_ELEMENT)
/* -------------------------------------------------------------------------- */
UInt MeshUtils::insertCohesiveElements(
Mesh & mesh, Mesh & mesh_facets,
const ElementTypeMapArray<bool> & facet_insertion,
Array<UInt> & doubled_nodes, Array<Element> & new_elements,
bool only_double_facets) {
UInt spatial_dimension = mesh.getSpatialDimension();
UInt elements_to_insert = updateFacetToDouble(mesh_facets, facet_insertion);
if (elements_to_insert > 0) {
if (spatial_dimension == 1) {
doublePointFacet(mesh, mesh_facets, doubled_nodes);
} else {
doubleFacet(mesh, mesh_facets, spatial_dimension - 1, doubled_nodes,
true);
findSubfacetToDouble<false>(mesh_facets);
if (spatial_dimension == 2) {
doubleSubfacet<2>(mesh, mesh_facets, doubled_nodes);
} else if (spatial_dimension == 3) {
doubleFacet(mesh, mesh_facets, 1, doubled_nodes, false);
findSubfacetToDouble<true>(mesh_facets);
doubleSubfacet<3>(mesh, mesh_facets, doubled_nodes);
}
}
if (!only_double_facets)
updateCohesiveData(mesh, mesh_facets, new_elements);
}
return elements_to_insert;
}
#endif
/* -------------------------------------------------------------------------- */
void MeshUtils::doubleNodes(Mesh & mesh, const std::vector<UInt> & old_nodes,
Array<UInt> & doubled_nodes) {
AKANTU_DEBUG_IN();
Array<Real> & position = mesh.getNodes();
UInt spatial_dimension = mesh.getSpatialDimension();
UInt old_nb_nodes = position.size();
UInt new_nb_nodes = old_nb_nodes + old_nodes.size();
UInt old_nb_doubled_nodes = doubled_nodes.size();
UInt new_nb_doubled_nodes = old_nb_doubled_nodes + old_nodes.size();
position.resize(new_nb_nodes);
doubled_nodes.resize(new_nb_doubled_nodes);
Array<Real>::iterator<Vector<Real>> position_begin =
position.begin(spatial_dimension);
for (UInt n = 0; n < old_nodes.size(); ++n) {
UInt new_node = old_nb_nodes + n;
/// store doubled nodes
doubled_nodes(old_nb_doubled_nodes + n, 0) = old_nodes[n];
doubled_nodes(old_nb_doubled_nodes + n, 1) = new_node;
/// update position
std::copy(position_begin + old_nodes[n], position_begin + old_nodes[n] + 1,
position_begin + new_node);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::doubleFacet(Mesh & mesh, Mesh & mesh_facets,
UInt facet_dimension, Array<UInt> & doubled_nodes,
bool facet_mode) {
AKANTU_DEBUG_IN();
NewElementsEvent event;
for (auto gt_facet : ghost_types) {
for (auto && type_facet :
mesh_facets.elementTypes(facet_dimension, gt_facet)) {
auto & facets_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_facet, gt_facet);
auto nb_facet_to_double = facets_to_double.size();
if (nb_facet_to_double == 0)
continue;
// this while fail if multiple facet types
// \TODO handle multiple sub-facet types
auto nb_subfacet_per_facet = Mesh::getNbFacetsPerElement(type_facet);
auto & conn_facet = mesh_facets.getConnectivity(type_facet, gt_facet);
auto nb_nodes_per_facet = conn_facet.getNbComponent();
auto old_nb_facet = conn_facet.size();
auto new_nb_facet = old_nb_facet + nb_facet_to_double;
#ifndef AKANTU_NDEBUG
// memory initialization are slow but help debug
conn_facet.resize(new_nb_facet, UInt(-1));
#else
conn_facet.resize(new_nb_facet);
#endif
Element facet{type_facet, 0, gt_facet};
for (auto el : arange(old_nb_facet, new_nb_facet)) {
facet.element = el;
event.getList().push_back(facet);
}
auto conn_facet_begin = conn_facet.begin(nb_nodes_per_facet);
auto & subfacet_to_facet =
mesh_facets.getSubelementToElement(type_facet, gt_facet);
#ifndef AKANTU_NDEBUG
subfacet_to_facet.resize(new_nb_facet, ElementNull);
#else
subfacet_to_facet.resize(new_nb_facet);
#endif
auto subfacet_to_facet_begin =
subfacet_to_facet.begin(nb_subfacet_per_facet);
Element new_facet{type_facet, old_nb_facet, gt_facet};
auto conn_facet_new_it = conn_facet_begin + new_facet.element;
auto subfacet_to_facet_new_it =
subfacet_to_facet_begin + new_facet.element;
for (UInt facet = 0; facet < nb_facet_to_double; ++facet,
++new_facet.element, ++conn_facet_new_it,
++subfacet_to_facet_new_it) {
UInt old_facet = facets_to_double(facet);
/// adding a new facet by copying original one
/// copy connectivity in new facet
*conn_facet_new_it = conn_facet_begin[old_facet];
/// update subfacet_to_facet
*subfacet_to_facet_new_it = subfacet_to_facet_begin[old_facet];
/// loop on every subfacet
for (UInt sf = 0; sf < nb_subfacet_per_facet; ++sf) {
Element & subfacet = subfacet_to_facet(old_facet, sf);
if (subfacet == ElementNull)
continue;
/// update facet_to_subfacet array
mesh_facets.getElementToSubelement(subfacet).push_back(new_facet);
}
}
/// update facet_to_subfacet and _segment_3 facets if any
if (not facet_mode) {
updateSubfacetToFacet(mesh_facets, type_facet, gt_facet, true);
updateFacetToSubfacet(mesh_facets, type_facet, gt_facet, true);
updateQuadraticSegments<true>(mesh, mesh_facets, type_facet, gt_facet,
doubled_nodes);
} else
updateQuadraticSegments<false>(mesh, mesh_facets, type_facet, gt_facet,
doubled_nodes);
}
}
mesh_facets.sendEvent(event);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
UInt MeshUtils::updateFacetToDouble(
Mesh & mesh_facets, const ElementTypeMapArray<bool> & facet_insertion) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh_facets.getSpatialDimension();
UInt nb_facets_to_double = 0.;
for (auto gt_facet : ghost_types) {
for (auto type_facet :
mesh_facets.elementTypes(spatial_dimension - 1, gt_facet)) {
const auto & f_insertion = facet_insertion(type_facet, gt_facet);
auto & f_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_facet, gt_facet);
auto & element_to_facet =
mesh_facets.getElementToSubelement(type_facet, gt_facet);
Element old_facet_el{type_facet, 0, gt_facet};
UInt nb_facets = mesh_facets.getNbElement(type_facet, gt_facet);
for (UInt f = 0; f < f_insertion.size(); ++f) {
if (f_insertion(f) == false)
continue;
++nb_facets_to_double;
if (element_to_facet(f)[1].type == _not_defined
#if defined(AKANTU_COHESIVE_ELEMENT)
|| element_to_facet(f)[1].kind() == _ek_cohesive
#endif
) {
AKANTU_DEBUG_WARNING("attempt to double a facet on the boundary");
continue;
}
f_to_double.push_back(f);
UInt new_facet = nb_facets + f_to_double.size() - 1;
old_facet_el.element = f;
/// update facet_to_element vector
auto & elem_to_update = element_to_facet(f)[1];
UInt el = elem_to_update.element;
auto & facet_to_element = mesh_facets.getSubelementToElement(
elem_to_update.type, elem_to_update.ghost_type);
auto el_facets = Vector<Element>(
make_view(facet_to_element, facet_to_element.getNbComponent())
.begin()[el]);
auto f_update =
std::find(el_facets.begin(), el_facets.end(), old_facet_el);
AKANTU_DEBUG_ASSERT(f_update != el_facets.end(), "Facet not found");
f_update->element = new_facet;
/// update elements connected to facet
const auto & first_facet_list = element_to_facet(f);
element_to_facet.push_back(first_facet_list);
/// set new and original facets as boundary facets
element_to_facet(new_facet)[0] = element_to_facet(new_facet)[1];
element_to_facet(new_facet)[1] = ElementNull;
element_to_facet(f)[1] = ElementNull;
}
}
}
AKANTU_DEBUG_OUT();
return nb_facets_to_double;
}
/* -------------------------------------------------------------------------- */
void MeshUtils::resetFacetToDouble(Mesh & mesh_facets) {
AKANTU_DEBUG_IN();
for (auto gt : ghost_types) {
for (auto type : mesh_facets.elementTypes(_all_dimensions, gt)) {
mesh_facets.getDataPointer<UInt>("facet_to_double", type, gt, 1, false);
mesh_facets.getDataPointer<std::vector<Element>>(
"facets_to_subfacet_double", type, gt, 1, false);
mesh_facets.getDataPointer<std::vector<Element>>(
"elements_to_subfacet_double", type, gt, 1, false);
mesh_facets.getDataPointer<std::vector<Element>>(
"subfacets_to_subsubfacet_double", type, gt, 1, false);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <bool subsubfacet_mode>
void MeshUtils::findSubfacetToDouble(Mesh & mesh_facets) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh_facets.getSpatialDimension();
if (spatial_dimension == 1)
return;
for (auto gt_facet : ghost_types) {
for (auto type_facet :
mesh_facets.elementTypes(spatial_dimension - 1, gt_facet)) {
auto & facets_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_facet, gt_facet);
auto nb_facet_to_double = facets_to_double.size();
if (nb_facet_to_double == 0)
continue;
ElementType type_subfacet = Mesh::getFacetType(type_facet);
GhostType gt_subfacet = _casper;
ElementType type_subsubfacet = Mesh::getFacetType(type_subfacet);
GhostType gt_subsubfacet = _casper;
Array<UInt> * conn_subfacet = nullptr;
Array<UInt> * sf_to_double = nullptr;
Array<std::vector<Element>> * sf_to_subfacet_double = nullptr;
Array<std::vector<Element>> * f_to_subfacet_double = nullptr;
Array<std::vector<Element>> * el_to_subfacet_double = nullptr;
UInt nb_subfacet = Mesh::getNbFacetsPerElement(type_facet);
UInt nb_subsubfacet;
UInt nb_nodes_per_sf_el;
if (subsubfacet_mode) {
nb_nodes_per_sf_el = Mesh::getNbNodesPerElement(type_subsubfacet);
nb_subsubfacet = Mesh::getNbFacetsPerElement(type_subfacet);
} else
nb_nodes_per_sf_el = Mesh::getNbNodesPerElement(type_subfacet);
Array<Element> & subfacet_to_facet =
mesh_facets.getSubelementToElement(type_facet, gt_facet);
Array<std::vector<Element>> & element_to_facet =
mesh_facets.getElementToSubelement(type_facet, gt_facet);
Array<Element> * subsubfacet_to_subfacet = nullptr;
UInt old_nb_facet = subfacet_to_facet.size() - nb_facet_to_double;
Element current_facet{type_facet, 0, gt_facet};
std::vector<Element> element_list;
std::vector<Element> facet_list;
std::vector<Element> * subfacet_list;
if (subsubfacet_mode)
subfacet_list = new std::vector<Element>;
/// map to filter subfacets
Array<std::vector<Element>> * facet_to_subfacet = nullptr;
/// this is used to make sure that both new and old facets are
/// checked
UInt facets[2];
/// loop on every facet
for (UInt f_index = 0; f_index < 2; ++f_index) {
for (UInt facet = 0; facet < nb_facet_to_double; ++facet) {
facets[bool(f_index)] = facets_to_double(facet);
facets[!bool(f_index)] = old_nb_facet + facet;
UInt old_facet = facets[0];
UInt new_facet = facets[1];
Element & starting_element = element_to_facet(new_facet)[0];
current_facet.element = old_facet;
/// loop on every subfacet
for (UInt sf = 0; sf < nb_subfacet; ++sf) {
Element & subfacet = subfacet_to_facet(old_facet, sf);
if (subfacet == ElementNull)
continue;
if (gt_subfacet != subfacet.ghost_type) {
gt_subfacet = subfacet.ghost_type;
if (subsubfacet_mode) {
subsubfacet_to_subfacet = &mesh_facets.getSubelementToElement(
type_subfacet, gt_subfacet);
} else {
conn_subfacet =
&mesh_facets.getConnectivity(type_subfacet, gt_subfacet);
sf_to_double = &mesh_facets.getData<UInt>(
"facet_to_double", type_subfacet, gt_subfacet);
f_to_subfacet_double =
&mesh_facets.getData<std::vector<Element>>(
"facets_to_subfacet_double", type_subfacet,
gt_subfacet);
el_to_subfacet_double =
&mesh_facets.getData<std::vector<Element>>(
"elements_to_subfacet_double", type_subfacet,
gt_subfacet);
facet_to_subfacet = &mesh_facets.getElementToSubelement(
type_subfacet, gt_subfacet);
}
}
if (subsubfacet_mode) {
/// loop on every subsubfacet
for (UInt ssf = 0; ssf < nb_subsubfacet; ++ssf) {
Element & subsubfacet =
(*subsubfacet_to_subfacet)(subfacet.element, ssf);
if (subsubfacet == ElementNull)
continue;
if (gt_subsubfacet != subsubfacet.ghost_type) {
gt_subsubfacet = subsubfacet.ghost_type;
conn_subfacet = &mesh_facets.getConnectivity(type_subsubfacet,
gt_subsubfacet);
sf_to_double = &mesh_facets.getData<UInt>(
"facet_to_double", type_subsubfacet, gt_subsubfacet);
sf_to_subfacet_double =
&mesh_facets.getData<std::vector<Element>>(
"subfacets_to_subsubfacet_double", type_subsubfacet,
gt_subsubfacet);
f_to_subfacet_double =
&mesh_facets.getData<std::vector<Element>>(
"facets_to_subfacet_double", type_subsubfacet,
gt_subsubfacet);
el_to_subfacet_double =
&mesh_facets.getData<std::vector<Element>>(
"elements_to_subfacet_double", type_subsubfacet,
gt_subsubfacet);
facet_to_subfacet = &mesh_facets.getElementToSubelement(
type_subsubfacet, gt_subsubfacet);
}
UInt global_ssf = subsubfacet.element;
Vector<UInt> subsubfacet_connectivity(
conn_subfacet->storage() + global_ssf * nb_nodes_per_sf_el,
nb_nodes_per_sf_el);
/// check if subsubfacet is to be doubled
if (findElementsAroundSubfacet<true>(
mesh_facets, starting_element, current_facet,
subsubfacet_connectivity, element_list, facet_list,
subfacet_list) == false &&
removeElementsInVector(*subfacet_list,
(*facet_to_subfacet)(global_ssf)) ==
false) {
sf_to_double->push_back(global_ssf);
sf_to_subfacet_double->push_back(*subfacet_list);
f_to_subfacet_double->push_back(facet_list);
el_to_subfacet_double->push_back(element_list);
}
}
} else {
const UInt global_sf = subfacet.element;
Vector<UInt> subfacet_connectivity(
conn_subfacet->storage() + global_sf * nb_nodes_per_sf_el,
nb_nodes_per_sf_el);
/// check if subfacet is to be doubled
if (findElementsAroundSubfacet<false>(
mesh_facets, starting_element, current_facet,
subfacet_connectivity, element_list,
facet_list) == false &&
removeElementsInVector(
facet_list, (*facet_to_subfacet)(global_sf)) == false) {
sf_to_double->push_back(global_sf);
f_to_subfacet_double->push_back(facet_list);
el_to_subfacet_double->push_back(element_list);
}
}
}
}
}
if (subsubfacet_mode)
delete subfacet_list;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_COHESIVE_ELEMENT)
void MeshUtils::updateCohesiveData(Mesh & mesh, Mesh & mesh_facets,
Array<Element> & new_elements) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
bool third_dimension = spatial_dimension == 3;
MeshAccessor mesh_facets_accessor(mesh_facets);
for (auto gt_facet : ghost_types) {
for (auto type_facet :
mesh_facets.elementTypes(spatial_dimension - 1, gt_facet)) {
Array<UInt> & f_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_facet, gt_facet);
UInt nb_facet_to_double = f_to_double.size();
if (nb_facet_to_double == 0)
continue;
ElementType type_cohesive = FEEngine::getCohesiveElementType(type_facet);
auto & facet_to_coh_element =
mesh_facets_accessor.getSubelementToElement(type_cohesive, gt_facet);
auto & conn_facet = mesh_facets.getConnectivity(type_facet, gt_facet);
auto & conn_cohesive = mesh.getConnectivity(type_cohesive, gt_facet);
UInt nb_nodes_per_facet = Mesh::getNbNodesPerElement(type_facet);
Array<std::vector<Element>> & element_to_facet =
mesh_facets.getElementToSubelement(type_facet, gt_facet);
UInt old_nb_cohesive_elements = conn_cohesive.size();
UInt new_nb_cohesive_elements = conn_cohesive.size() + nb_facet_to_double;
UInt old_nb_facet = element_to_facet.size() - nb_facet_to_double;
facet_to_coh_element.resize(new_nb_cohesive_elements);
conn_cohesive.resize(new_nb_cohesive_elements);
UInt new_elements_old_size = new_elements.size();
new_elements.resize(new_elements_old_size + nb_facet_to_double);
Element c_element{type_cohesive, 0, gt_facet};
Element f_element{type_facet, 0, gt_facet};
UInt facets[2];
for (UInt facet = 0; facet < nb_facet_to_double; ++facet) {
/// (in 3D cohesive elements connectivity is inverted)
facets[third_dimension ? 1 : 0] = f_to_double(facet);
facets[third_dimension ? 0 : 1] = old_nb_facet + facet;
UInt cohesive_element = old_nb_cohesive_elements + facet;
/// store doubled facets
f_element.element = facets[0];
facet_to_coh_element(cohesive_element, 0) = f_element;
f_element.element = facets[1];
facet_to_coh_element(cohesive_element, 1) = f_element;
/// modify cohesive elements' connectivity
for (UInt n = 0; n < nb_nodes_per_facet; ++n) {
conn_cohesive(cohesive_element, n) = conn_facet(facets[0], n);
conn_cohesive(cohesive_element, n + nb_nodes_per_facet) =
conn_facet(facets[1], n);
}
/// update element_to_facet vectors
c_element.element = cohesive_element;
element_to_facet(facets[0])[1] = c_element;
element_to_facet(facets[1])[1] = c_element;
/// add cohesive element to the element event list
new_elements(new_elements_old_size + facet) = c_element;
}
}
}
AKANTU_DEBUG_OUT();
}
#endif
/* -------------------------------------------------------------------------- */
void MeshUtils::doublePointFacet(Mesh & mesh, Mesh & mesh_facets,
Array<UInt> & doubled_nodes) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
if (spatial_dimension != 1)
return;
NewElementsEvent event;
auto & position = mesh.getNodes();
for (auto gt_facet : ghost_types) {
for (auto type_facet :
mesh_facets.elementTypes(spatial_dimension - 1, gt_facet)) {
auto & conn_facet = mesh_facets.getConnectivity(type_facet, gt_facet);
auto & element_to_facet =
mesh_facets.getElementToSubelement(type_facet, gt_facet);
const auto & facets_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_facet, gt_facet);
auto nb_facet_to_double = facets_to_double.size();
auto new_nb_facet = element_to_facet.size();
auto old_nb_facet = element_to_facet.size() - nb_facet_to_double;
auto old_nb_nodes = position.size();
auto new_nb_nodes = old_nb_nodes + nb_facet_to_double;
position.resize(new_nb_nodes);
conn_facet.resize(new_nb_facet);
Element facet{type_facet, 0, gt_facet};
for (auto el : arange(old_nb_facet, new_nb_facet)) {
facet.element = el;
event.getList().push_back(facet);
}
auto old_nb_doubled_nodes = doubled_nodes.size();
doubled_nodes.resize(old_nb_doubled_nodes + nb_facet_to_double);
for (auto && data_facet : enumerate(facets_to_double)) {
const auto & old_facet = std::get<1>(data_facet);
auto facet = std::get<0>(data_facet);
auto new_facet = old_nb_facet + facet;
auto el = element_to_facet(new_facet)[0];
auto old_node = conn_facet(old_facet);
auto new_node = old_nb_nodes + facet;
/// update position
position(new_node) = position(old_node);
conn_facet(new_facet) = new_node;
Vector<UInt> conn_segment = mesh.getConnectivity(el);
/// update facet connectivity
auto it = std::find(conn_segment.begin(), conn_segment.end(), old_node);
*it = new_node;
doubled_nodes(old_nb_doubled_nodes + facet, 0) = old_node;
doubled_nodes(old_nb_doubled_nodes + facet, 1) = new_node;
}
}
}
mesh_facets.sendEvent(event);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <bool third_dim_segments>
void MeshUtils::updateQuadraticSegments(Mesh & mesh, Mesh & mesh_facets,
ElementType type_facet,
GhostType gt_facet,
Array<UInt> & doubled_nodes) {
AKANTU_DEBUG_IN();
if (type_facet != _segment_3)
return;
Array<UInt> & f_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_facet, gt_facet);
UInt nb_facet_to_double = f_to_double.size();
UInt old_nb_facet =
mesh_facets.getNbElement(type_facet, gt_facet) - nb_facet_to_double;
Array<UInt> & conn_facet = mesh_facets.getConnectivity(type_facet, gt_facet);
Array<std::vector<Element>> & element_to_facet =
mesh_facets.getElementToSubelement(type_facet, gt_facet);
/// this ones matter only for segments in 3D
Array<std::vector<Element>> * el_to_subfacet_double = nullptr;
Array<std::vector<Element>> * f_to_subfacet_double = nullptr;
if (third_dim_segments) {
el_to_subfacet_double = &mesh_facets.getData<std::vector<Element>>(
"elements_to_subfacet_double", type_facet, gt_facet);
f_to_subfacet_double = &mesh_facets.getData<std::vector<Element>>(
"facets_to_subfacet_double", type_facet, gt_facet);
}
std::vector<UInt> middle_nodes;
for (UInt facet = 0; facet < nb_facet_to_double; ++facet) {
UInt old_facet = f_to_double(facet);
UInt node = conn_facet(old_facet, 2);
if (!mesh.isPureGhostNode(node))
middle_nodes.push_back(node);
}
UInt n = doubled_nodes.size();
doubleNodes(mesh, middle_nodes, doubled_nodes);
for (UInt facet = 0; facet < nb_facet_to_double; ++facet) {
UInt old_facet = f_to_double(facet);
UInt old_node = conn_facet(old_facet, 2);
if (mesh.isPureGhostNode(old_node))
continue;
UInt new_node = doubled_nodes(n, 1);
UInt new_facet = old_nb_facet + facet;
conn_facet(new_facet, 2) = new_node;
if (third_dim_segments) {
updateElementalConnectivity(mesh_facets, old_node, new_node,
element_to_facet(new_facet));
updateElementalConnectivity(mesh, old_node, new_node,
(*el_to_subfacet_double)(facet),
&(*f_to_subfacet_double)(facet));
} else {
updateElementalConnectivity(mesh, old_node, new_node,
element_to_facet(new_facet));
}
++n;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::updateSubfacetToFacet(Mesh & mesh_facets,
ElementType type_subfacet,
GhostType gt_subfacet, bool facet_mode) {
AKANTU_DEBUG_IN();
Array<UInt> & sf_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_subfacet, gt_subfacet);
UInt nb_subfacet_to_double = sf_to_double.size();
/// update subfacet_to_facet vector
ElementType type_facet = _not_defined;
GhostType gt_facet = _casper;
Array<Element> * subfacet_to_facet = nullptr;
UInt nb_subfacet_per_facet = 0;
UInt old_nb_subfacet = mesh_facets.getNbElement(type_subfacet, gt_subfacet) -
nb_subfacet_to_double;
Array<std::vector<Element>> * facet_list = nullptr;
if (facet_mode)
facet_list = &mesh_facets.getData<std::vector<Element>>(
"facets_to_subfacet_double", type_subfacet, gt_subfacet);
else
facet_list = &mesh_facets.getData<std::vector<Element>>(
"subfacets_to_subsubfacet_double", type_subfacet, gt_subfacet);
Element old_subfacet_el{type_subfacet, 0, gt_subfacet};
Element new_subfacet_el{type_subfacet, 0, gt_subfacet};
for (UInt sf = 0; sf < nb_subfacet_to_double; ++sf) {
old_subfacet_el.element = sf_to_double(sf);
new_subfacet_el.element = old_nb_subfacet + sf;
for (UInt f = 0; f < (*facet_list)(sf).size(); ++f) {
Element & facet = (*facet_list)(sf)[f];
if (facet.type != type_facet || facet.ghost_type != gt_facet) {
type_facet = facet.type;
gt_facet = facet.ghost_type;
subfacet_to_facet =
&mesh_facets.getSubelementToElement(type_facet, gt_facet);
nb_subfacet_per_facet = subfacet_to_facet->getNbComponent();
}
Element * sf_update = std::find(
subfacet_to_facet->storage() + facet.element * nb_subfacet_per_facet,
subfacet_to_facet->storage() + facet.element * nb_subfacet_per_facet +
nb_subfacet_per_facet,
old_subfacet_el);
AKANTU_DEBUG_ASSERT(subfacet_to_facet->storage() +
facet.element * nb_subfacet_per_facet !=
subfacet_to_facet->storage() +
facet.element * nb_subfacet_per_facet +
nb_subfacet_per_facet,
"Subfacet not found");
*sf_update = new_subfacet_el;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::updateFacetToSubfacet(Mesh & mesh_facets,
ElementType type_subfacet,
GhostType gt_subfacet, bool facet_mode) {
AKANTU_DEBUG_IN();
Array<UInt> & sf_to_double =
mesh_facets.getData<UInt>("facet_to_double", type_subfacet, gt_subfacet);
UInt nb_subfacet_to_double = sf_to_double.size();
Array<std::vector<Element>> & facet_to_subfacet =
mesh_facets.getElementToSubelement(type_subfacet, gt_subfacet);
Array<std::vector<Element>> * facet_to_subfacet_double = nullptr;
if (facet_mode) {
facet_to_subfacet_double = &mesh_facets.getData<std::vector<Element>>(
"facets_to_subfacet_double", type_subfacet, gt_subfacet);
} else {
facet_to_subfacet_double = &mesh_facets.getData<std::vector<Element>>(
"subfacets_to_subsubfacet_double", type_subfacet, gt_subfacet);
}
UInt old_nb_subfacet = facet_to_subfacet.size();
facet_to_subfacet.resize(old_nb_subfacet + nb_subfacet_to_double);
for (UInt sf = 0; sf < nb_subfacet_to_double; ++sf)
facet_to_subfacet(old_nb_subfacet + sf) = (*facet_to_subfacet_double)(sf);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MeshUtils::doubleSubfacet(Mesh & mesh, Mesh & mesh_facets,
Array<UInt> & doubled_nodes) {
AKANTU_DEBUG_IN();
if (spatial_dimension == 1)
return;
NewElementsEvent event;
for (auto gt_subfacet : ghost_types) {
for (auto type_subfacet : mesh_facets.elementTypes(0, gt_subfacet)) {
auto & sf_to_double = mesh_facets.getData<UInt>(
"facet_to_double", type_subfacet, gt_subfacet);
UInt nb_subfacet_to_double = sf_to_double.size();
if (nb_subfacet_to_double == 0)
continue;
AKANTU_DEBUG_ASSERT(
type_subfacet == _point_1,
"Only _point_1 subfacet doubling is supported at the moment");
auto & conn_subfacet =
mesh_facets.getConnectivity(type_subfacet, gt_subfacet);
UInt old_nb_subfacet = conn_subfacet.size();
UInt new_nb_subfacet = old_nb_subfacet + nb_subfacet_to_double;
conn_subfacet.resize(new_nb_subfacet);
Element subfacet{type_subfacet, 0, gt_subfacet};
for ( auto el : arange(old_nb_subfacet, new_nb_subfacet)) {
subfacet.element = el;
event.getList().push_back(subfacet);
}
std::vector<UInt> nodes_to_double;
UInt old_nb_doubled_nodes = doubled_nodes.size();
/// double nodes
for (UInt sf = 0; sf < nb_subfacet_to_double; ++sf) {
UInt old_subfacet = sf_to_double(sf);
nodes_to_double.push_back(conn_subfacet(old_subfacet));
}
doubleNodes(mesh, nodes_to_double, doubled_nodes);
/// add new nodes in connectivity
for (UInt sf = 0; sf < nb_subfacet_to_double; ++sf) {
UInt new_subfacet = old_nb_subfacet + sf;
UInt new_node = doubled_nodes(old_nb_doubled_nodes + sf, 1);
conn_subfacet(new_subfacet) = new_node;
}
/// update facet and element connectivity
Array<std::vector<Element>> & f_to_subfacet_double =
mesh_facets.getData<std::vector<Element>>("facets_to_subfacet_double",
type_subfacet, gt_subfacet);
Array<std::vector<Element>> & el_to_subfacet_double =
mesh_facets.getData<std::vector<Element>>(
"elements_to_subfacet_double", type_subfacet, gt_subfacet);
Array<std::vector<Element>> * sf_to_subfacet_double = nullptr;
if (spatial_dimension == 3)
sf_to_subfacet_double = &mesh_facets.getData<std::vector<Element>>(
"subfacets_to_subsubfacet_double", type_subfacet, gt_subfacet);
for (UInt sf = 0; sf < nb_subfacet_to_double; ++sf) {
UInt old_node = doubled_nodes(old_nb_doubled_nodes + sf, 0);
UInt new_node = doubled_nodes(old_nb_doubled_nodes + sf, 1);
updateElementalConnectivity(mesh, old_node, new_node,
el_to_subfacet_double(sf),
&f_to_subfacet_double(sf));
updateElementalConnectivity(mesh_facets, old_node, new_node,
f_to_subfacet_double(sf));
if (spatial_dimension == 3)
updateElementalConnectivity(mesh_facets, old_node, new_node,
(*sf_to_subfacet_double)(sf));
}
if (spatial_dimension == 2) {
updateSubfacetToFacet(mesh_facets, type_subfacet, gt_subfacet, true);
updateFacetToSubfacet(mesh_facets, type_subfacet, gt_subfacet, true);
} else if (spatial_dimension == 3) {
updateSubfacetToFacet(mesh_facets, type_subfacet, gt_subfacet, false);
updateFacetToSubfacet(mesh_facets, type_subfacet, gt_subfacet, false);
}
}
}
mesh_facets.sendEvent(event);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::flipFacets(
Mesh & mesh_facets,
const ElementTypeMapArray<UInt> & remote_global_connectivities,
GhostType gt_facet) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh_facets.getSpatialDimension();
/// get global connectivity for local mesh
ElementTypeMapArray<UInt> local_global_connectivities(
"local_global_connectivity", mesh_facets.getID(),
mesh_facets.getMemoryID());
local_global_connectivities.initialize(
mesh_facets, _spatial_dimension = spatial_dimension - 1,
_ghost_type = gt_facet, _with_nb_nodes_per_element = true,
_with_nb_element = true);
mesh_facets.getGlobalConnectivity(local_global_connectivities);
/// loop on every facet
for (auto type_facet :
mesh_facets.elementTypes(spatial_dimension - 1, gt_facet)) {
auto & connectivity = mesh_facets.getConnectivity(type_facet, gt_facet);
auto & local_global_connectivity =
local_global_connectivities(type_facet, gt_facet);
const auto & remote_global_connectivity =
remote_global_connectivities(type_facet, gt_facet);
auto & element_per_facet =
mesh_facets.getElementToSubelement(type_facet, gt_facet);
auto & subfacet_to_facet =
mesh_facets.getSubelementToElement(type_facet, gt_facet);
auto nb_nodes_per_facet = connectivity.getNbComponent();
auto nb_nodes_per_P1_facet =
Mesh::getNbNodesPerElement(Mesh::getP1ElementType(type_facet));
for (auto && data :
zip(make_view(connectivity, nb_nodes_per_facet),
make_view(local_global_connectivity, nb_nodes_per_facet),
make_view(remote_global_connectivity, nb_nodes_per_facet),
make_view(subfacet_to_facet, subfacet_to_facet.getNbComponent()),
make_view(element_per_facet))) {
auto & conn = std::get<0>(data);
auto & local_gconn = std::get<1>(data);
const auto & remote_gconn = std::get<2>(data);
/// skip facet if connectivities are the same
if (local_gconn == remote_gconn)
continue;
/// re-arrange connectivity
auto conn_tmp = conn;
auto begin = local_gconn.begin();
auto end = local_gconn.end();
std::transform(remote_gconn.begin(), remote_gconn.end(), conn.begin(),
[&](auto && gnode) {
auto it = std::find(begin, end, gnode);
AKANTU_DEBUG_ASSERT(it != end, "Node not found");
return conn_tmp(it - begin);
});
/// if 3D, check if facets are just rotated
if (spatial_dimension == 3) {
auto begin = remote_gconn.storage();
/// find first node
auto it = std::find(begin, begin + remote_gconn.size(), local_gconn(0));
UInt n, start = it - begin;
/// count how many nodes in the received connectivity follow
/// the same order of those in the local connectivity
for (n = 1; n < nb_nodes_per_P1_facet &&
local_gconn(n) ==
remote_gconn((start + n) % nb_nodes_per_P1_facet);
++n)
;
/// skip the facet inversion if facet is just rotated
if (n == nb_nodes_per_P1_facet)
continue;
}
/// update data to invert facet
auto & element_per_facet = std::get<4>(data);
std::swap(element_per_facet[0], element_per_facet[1]);
auto & subfacets_of_facet = std::get<3>(data);
std::swap(subfacets_of_facet(0), subfacets_of_facet(1));
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MeshUtils::fillElementToSubElementsData(Mesh & mesh) {
AKANTU_DEBUG_IN();
if (mesh.getNbElement(mesh.getSpatialDimension() - 1) == 0) {
AKANTU_DEBUG_INFO("There are not facets, add them in the mesh file or call "
"the buildFacet method.");
return;
}
UInt spatial_dimension = mesh.getSpatialDimension();
ElementTypeMapArray<Real> barycenters("barycenter_tmp", mesh.getID(),
mesh.getMemoryID());
barycenters.initialize(mesh, _nb_component = spatial_dimension,
_spatial_dimension = _all_dimensions);
// mesh.initElementTypeMapArray(barycenters, spatial_dimension,
// _all_dimensions);
Element element;
for (auto ghost_type : ghost_types) {
element.ghost_type = ghost_type;
for (auto & type : mesh.elementTypes(_all_dimensions, ghost_type)) {
element.type = type;
UInt nb_element = mesh.getNbElement(type, ghost_type);
Array<Real> & barycenters_arr = barycenters(type, ghost_type);
barycenters_arr.resize(nb_element);
auto bary = barycenters_arr.begin(spatial_dimension);
auto bary_end = barycenters_arr.end(spatial_dimension);
for (UInt el = 0; bary != bary_end; ++bary, ++el) {
element.element = el;
mesh.getBarycenter(element, *bary);
}
}
}
MeshAccessor mesh_accessor(mesh);
for (Int sp(spatial_dimension); sp >= 1; --sp) {
if (mesh.getNbElement(sp) == 0)
continue;
for (auto ghost_type : ghost_types) {
for (auto & type : mesh.elementTypes(sp, ghost_type)) {
mesh_accessor.getSubelementToElement(type, ghost_type)
.resize(mesh.getNbElement(type, ghost_type));
mesh_accessor.getSubelementToElement(type, ghost_type).set(ElementNull);
}
for (auto & type : mesh.elementTypes(sp - 1, ghost_type)) {
mesh_accessor.getElementToSubelement(type, ghost_type)
.resize(mesh.getNbElement(type, ghost_type));
mesh.getElementToSubelement(type, ghost_type).clear();
}
}
CSR<Element> nodes_to_elements;
buildNode2Elements(mesh, nodes_to_elements, sp);
Element facet_element;
for (auto ghost_type : ghost_types) {
facet_element.ghost_type = ghost_type;
for (auto & type : mesh.elementTypes(sp - 1, ghost_type)) {
facet_element.type = type;
auto & element_to_subelement =
mesh.getElementToSubelement(type, ghost_type);
const auto & connectivity = mesh.getConnectivity(type, ghost_type);
for (auto && data : enumerate(
make_view(connectivity, mesh.getNbNodesPerElement(type)))) {
const auto & facet = std::get<1>(data);
facet_element.element = std::get<0>(data);
std::map<Element, UInt> element_seen_counter;
auto nb_nodes_per_facet =
mesh.getNbNodesPerElement(Mesh::getP1ElementType(type));
// count the number of node in common between the facet and the other
// element connected to the nodes of the facet
for (auto node : arange(nb_nodes_per_facet)) {
for (auto & elem : nodes_to_elements.getRow(facet(node))) {
auto cit = element_seen_counter.find(elem);
if (cit != element_seen_counter.end()) {
cit->second++;
} else {
element_seen_counter[elem] = 1;
}
}
}
// check which are the connected elements
std::vector<Element> connected_elements;
for (auto && cit : element_seen_counter) {
if (cit.second == nb_nodes_per_facet)
connected_elements.push_back(cit.first);
}
// add the connected elements as sub-elements
for (auto & connected_element : connected_elements) {
element_to_subelement(facet_element.element)
.push_back(connected_element);
}
// add the element as sub-element to the connected elements
for (auto & connected_element : connected_elements) {
Vector<Element> subelements_to_element =
mesh.getSubelementToElement(connected_element);
// find the position where to insert the element
auto it = std::find(subelements_to_element.begin(),
subelements_to_element.end(), ElementNull);
AKANTU_DEBUG_ASSERT(
it != subelements_to_element.end(),
"The element "
<< connected_element << " seems to have too many facets!! ("
<< (it - subelements_to_element.begin()) << " < "
<< mesh.getNbFacetsPerElement(connected_element.type)
<< ")");
*it = facet_element;
}
}
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <bool third_dim_points>
bool MeshUtils::findElementsAroundSubfacet(
const Mesh & mesh_facets, const Element & starting_element,
const Element & end_facet, const Vector<UInt> & subfacet_connectivity,
std::vector<Element> & element_list, std::vector<Element> & facet_list,
std::vector<Element> * subfacet_list) {
AKANTU_DEBUG_IN();
bool facet_matched = false;
element_list.clear();
facet_list.clear();
if (third_dim_points) {
subfacet_list->clear();
}
element_list.push_back(starting_element);
std::queue<Element> elements_to_check;
elements_to_check.push(starting_element);
/// keep going as long as there are elements to check
while (not elements_to_check.empty()) {
/// check current element
Element & current_element = elements_to_check.front();
const Vector<Element> facets_to_element =
mesh_facets.getSubelementToElement(current_element);
// for every facet of the element
for (auto & current_facet : facets_to_element) {
if (current_facet == ElementNull)
continue;
if (current_facet == end_facet)
facet_matched = true;
// facet already listed
if (std::find(facet_list.begin(), facet_list.end(), current_facet) !=
facet_list.end())
continue;
// subfacet_connectivity is not in the connectivity of current_facet;
if ((std::find(facet_list.begin(), facet_list.end(), current_facet) !=
facet_list.end()) or
not hasElement(mesh_facets.getConnectivity(current_facet),
subfacet_connectivity))
continue;
facet_list.push_back(current_facet);
if (third_dim_points) {
const Vector<Element> subfacets_of_facet =
mesh_facets.getSubelementToElement(current_facet);
/// check subfacets
for (const auto & current_subfacet : subfacets_of_facet) {
if (current_subfacet == ElementNull)
continue;
if ((std::find(subfacet_list->begin(), subfacet_list->end(),
current_subfacet) == subfacet_list->end()) and
hasElement(mesh_facets.getConnectivity(current_subfacet),
subfacet_connectivity))
subfacet_list->push_back(current_subfacet);
}
}
/// consider opposing element
const auto & elements_to_facet =
mesh_facets.getElementToSubelement(current_facet);
UInt opposing = 0;
if (elements_to_facet[0] == current_element)
opposing = 1;
auto & opposing_element = elements_to_facet[opposing];
/// skip null elements since they are on a boundary
if (opposing_element == ElementNull)
continue;
/// skip this element if already added
if (std::find(element_list.begin(), element_list.end(),
opposing_element) != element_list.end())
continue;
/// only regular elements have to be checked
if (opposing_element.kind() == _ek_regular)
elements_to_check.push(opposing_element);
element_list.push_back(opposing_element);
AKANTU_DEBUG_ASSERT(
hasElement(
mesh_facets.getMeshParent().getConnectivity(opposing_element),
subfacet_connectivity),
"Subfacet doesn't belong to this element");
}
/// erased checked element from the list
elements_to_check.pop();
}
AKANTU_DEBUG_OUT();
return facet_matched;
}
/* -------------------------------------------------------------------------- */
void MeshUtils::updateElementalConnectivity(
Mesh & mesh, UInt old_node, UInt new_node,
const std::vector<Element> & element_list,
const std::vector<Element> *
#if defined(AKANTU_COHESIVE_ELEMENT)
facet_list
#endif
) {
AKANTU_DEBUG_IN();
for (auto & element : element_list) {
if (element.type == _not_defined)
continue;
Vector<UInt> connectivity = mesh.getConnectivity(element);
#if defined(AKANTU_COHESIVE_ELEMENT)
if (element.kind() == _ek_cohesive) {
AKANTU_DEBUG_ASSERT(
facet_list != nullptr,
"Provide a facet list in order to update cohesive elements");
const Vector<Element> facets =
mesh.getMeshFacets().getSubelementToElement(element);
auto facet_nb_nodes = connectivity.size() / 2;
/// loop over cohesive element's facets
for (const auto & facet : enumerate(facets)) {
/// skip facets if not present in the list
if (std::find(facet_list->begin(), facet_list->end(),
std::get<1>(facet)) == facet_list->end()) {
continue;
}
auto n = std::get<0>(facet);
auto begin = connectivity.begin() + n * facet_nb_nodes;
auto end = begin + facet_nb_nodes;
auto it = std::find(begin, end, old_node);
AKANTU_DEBUG_ASSERT(it != end, "Node not found in current element");
*it = new_node;
}
} else
#endif
{
auto it = std::find(connectivity.begin(), connectivity.end(), old_node);
AKANTU_DEBUG_ASSERT(it != connectivity.end(),
"Node not found in current element");
/// update connectivity
*it = new_node;
}
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/mesh_utils/mesh_utils.hh b/src/mesh_utils/mesh_utils.hh
index 5984ac6bd..373c9aaaa 100644
--- a/src/mesh_utils/mesh_utils.hh
+++ b/src/mesh_utils/mesh_utils.hh
@@ -1,229 +1,228 @@
/**
* @file mesh_utils.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Leonardo Snozzi <leonardo.snozzi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief All mesh utils necessary for various tasks
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_csr.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#include <vector>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_UTILS_HH__
#define __AKANTU_MESH_UTILS_HH__
namespace akantu {
class MeshUtils {
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// build a CSR<Element> that contains for each node the list of connected
/// elements of a given spatial dimension
static void buildNode2Elements(const Mesh & mesh, CSR<Element> & node_to_elem,
UInt spatial_dimension = _all_dimensions);
/// build a CSR<UInt> that contains for each node the number of
/// the connected elements of a given ElementType
static void
buildNode2ElementsElementTypeMap(const Mesh & mesh, CSR<UInt> & node_to_elem,
const ElementType & type,
const GhostType & ghost_type = _not_ghost);
/// build the facets elements on the boundaries of a mesh
static void buildFacets(Mesh & mesh);
/// build all the facets elements: boundary and internals and store them in
/// the mesh_facets for element of dimension from_dimension to to_dimension
static void buildAllFacets(const Mesh & mesh, Mesh & mesh_facets,
UInt from_dimension, UInt to_dimension);
/// build all the facets elements: boundary and internals and store them in
/// the mesh_facets
static void buildAllFacets(const Mesh & mesh, Mesh & mesh_facets,
UInt to_dimension = 0);
/// build facets for a given spatial dimension
static void buildFacetsDimension(const Mesh & mesh, Mesh & mesh_facets,
bool boundary_only, UInt dimension);
/// take the local_connectivity array as the array of local and ghost
/// connectivity, renumber the nodes and set the connectivity of the mesh
static void renumberMeshNodes(Mesh & mesh, Array<UInt> & local_connectivities,
UInt nb_local_element, UInt nb_ghost_element,
ElementType type, Array<UInt> & old_nodes);
/// compute pbc pair for a given direction
static void computePBCMap(const Mesh & mymesh, const UInt dir,
std::map<UInt, UInt> & pbc_pair);
/// compute pbc pair for a surface pair
static void computePBCMap(const Mesh & mymesh,
const std::pair<ID, ID> & surface_pair,
std::map<UInt, UInt> & pbc_pair);
/// remove not connected nodes /!\ this functions renumbers the nodes.
static void purifyMesh(Mesh & mesh);
#if defined(AKANTU_COHESIVE_ELEMENT)
/// function to insert cohesive elements on the selected facets
/// @return number of facets that have been doubled
static UInt
insertCohesiveElements(Mesh & mesh, Mesh & mesh_facets,
const ElementTypeMapArray<bool> & facet_insertion,
Array<UInt> & doubled_nodes,
Array<Element> & new_elements,
bool only_double_facets);
#endif
/// fill the subelement to element and the elements to subelements data
static void fillElementToSubElementsData(Mesh & mesh);
/// flip facets based on global connectivity
static void flipFacets(Mesh & mesh_facets,
const ElementTypeMapArray<UInt> & global_connectivity,
GhostType gt_facet);
/// provide list of elements around a node and check if a given
/// facet is reached
template <bool third_dim_points>
static bool findElementsAroundSubfacet(
- const Mesh & mesh_facets,
- const Element & starting_element, const Element & end_facet,
- const Vector<UInt> & subfacet_connectivity,
+ const Mesh & mesh_facets, const Element & starting_element,
+ const Element & end_facet, const Vector<UInt> & subfacet_connectivity,
std::vector<Element> & elem_list, std::vector<Element> & facet_list,
std::vector<Element> * subfacet_list = nullptr);
/// function to check if a node belongs to a given element
static inline bool hasElement(const Vector<UInt> & nodes_element,
const Vector<UInt> & nodes);
/// reset facet_to_double arrays in the Mesh
static void resetFacetToDouble(Mesh & mesh_facets);
private:
/// match pairs that are on the associated pbc's
static void matchPBCPairs(const Mesh & mymesh, const UInt dir,
Array<UInt> & selected_left,
Array<UInt> & selected_right,
std::map<UInt, UInt> & pbc_pair);
/// function used by all the renumbering functions
static void
renumberNodesInConnectivity(Array<UInt> & list_nodes, UInt nb_nodes,
std::map<UInt, UInt> & renumbering_map);
/// update facet_to_subfacet
static void updateFacetToSubfacet(Mesh & mesh_facets,
ElementType type_subfacet,
GhostType gt_subfacet, bool facet_mode);
/// update subfacet_to_facet
static void updateSubfacetToFacet(Mesh & mesh_facets,
ElementType type_subfacet,
GhostType gt_subfacet, bool facet_mode);
/// function to double a given facet and update the list of doubled
/// nodes
static void doubleFacet(Mesh & mesh, Mesh & mesh_facets, UInt facet_dimension,
Array<UInt> & doubled_nodes, bool facet_mode);
/// function to double a subfacet given start and end index for
/// local facet_to_subfacet vector, and update the list of doubled
/// nodes
template <UInt spatial_dimension>
static void doubleSubfacet(Mesh & mesh, Mesh & mesh_facets,
Array<UInt> & doubled_nodes);
/// double a node
static void doubleNodes(Mesh & mesh, const std::vector<UInt> & old_nodes,
Array<UInt> & doubled_nodes);
/// fill facet_to_double array in the mesh
/// returns the number of facets to be doubled
static UInt
updateFacetToDouble(Mesh & mesh_facets,
const ElementTypeMapArray<bool> & facet_insertion);
/// find subfacets to be doubled
template <bool subsubfacet_mode>
static void findSubfacetToDouble(Mesh & mesh_facets);
/// double facets (points) in 1D
static void doublePointFacet(Mesh & mesh, Mesh & mesh_facets,
Array<UInt> & doubled_nodes);
#if defined(AKANTU_COHESIVE_ELEMENT)
/// update cohesive element data
static void updateCohesiveData(Mesh & mesh, Mesh & mesh_facets,
Array<Element> & new_elements);
#endif
/// update elemental connectivity after doubling a node
inline static void updateElementalConnectivity(
Mesh & mesh, UInt old_node, UInt new_node,
const std::vector<Element> & element_list,
const std::vector<Element> * facet_list = nullptr);
/// double middle nodes if facets are _segment_3
template <bool third_dim_segments>
static void updateQuadraticSegments(Mesh & mesh, Mesh & mesh_facets,
ElementType type_facet,
GhostType gt_facet,
Array<UInt> & doubled_nodes);
/// remove elements on a vector
inline static bool
removeElementsInVector(const std::vector<Element> & elem_to_remove,
std::vector<Element> & elem_list);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "mesh_utils_inline_impl.cc"
#endif /* __AKANTU_MESH_UTILS_HH__ */
diff --git a/src/mesh_utils/mesh_utils_distribution.hh b/src/mesh_utils/mesh_utils_distribution.hh
index 82112b2dc..c30a46f20 100644
--- a/src/mesh_utils/mesh_utils_distribution.hh
+++ b/src/mesh_utils/mesh_utils_distribution.hh
@@ -1,55 +1,55 @@
/**
* @file mesh_utils_distribution.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sat Apr 01 2017
*
* @brief Mesh utils to distribute a mesh
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_UTILS_DISTRIBUTION_HH__
#define __AKANTU_MESH_UTILS_DISTRIBUTION_HH__
namespace akantu {
class Mesh;
class MeshPartition;
-} // akantu
+} // namespace akantu
namespace akantu {
namespace MeshUtilsDistribution {
/// Master call to distribute a mesh in a centralized manner (the UInt is just
/// to avoid some shitty access from the slave...)
void distributeMeshCentralized(Mesh & mesh, UInt,
const MeshPartition & partition);
/// Slave call to distribute a mesh in a centralized manner
void distributeMeshCentralized(Mesh & mesh, UInt root);
-} // MeshUtilsDistribution
+} // namespace MeshUtilsDistribution
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MESH_UTILS_DISTRIBUTION_HH__ */
diff --git a/src/mesh_utils/mesh_utils_inline_impl.cc b/src/mesh_utils/mesh_utils_inline_impl.cc
index 7871ecb7d..8ae060fc3 100644
--- a/src/mesh_utils/mesh_utils_inline_impl.cc
+++ b/src/mesh_utils/mesh_utils_inline_impl.cc
@@ -1,87 +1,87 @@
/**
* @file mesh_utils_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Aug 20 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Mesh utils inline functions
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MESH_UTILS_INLINE_IMPL_CC__
#define __AKANTU_MESH_UTILS_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline bool MeshUtils::hasElement(const Vector<UInt> & nodes_element,
const Vector<UInt> & nodes) {
// one of the nodes of nodes is not in nodes_element stops
auto it = std::mismatch(nodes.begin(), nodes.end(), nodes_element.begin(),
[&](auto && node, auto && /*node2*/) -> bool {
- auto it =
- std::find(nodes_element.begin(), nodes_element.end(), node);
+ auto it = std::find(nodes_element.begin(),
+ nodes_element.end(), node);
return (it != nodes_element.end());
});
// true if all nodes where found in nodes_element
return (it.first == nodes.end());
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
inline bool
MeshUtils::removeElementsInVector(const std::vector<Element> & elem_to_remove,
std::vector<Element> & elem_list) {
if (elem_list.size() <= elem_to_remove.size())
return true;
auto el_it = elem_to_remove.begin();
auto el_last = elem_to_remove.end();
std::vector<Element>::iterator el_del;
UInt deletions = 0;
for (; el_it != el_last; ++el_it) {
el_del = std::find(elem_list.begin(), elem_list.end(), *el_it);
if (el_del != elem_list.end()) {
elem_list.erase(el_del);
++deletions;
}
}
AKANTU_DEBUG_ASSERT(deletions == 0 || deletions == elem_to_remove.size(),
"Not all elements have been erased");
return deletions == 0;
}
-}
+} // namespace akantu
#endif /* __AKANTU_MESH_UTILS_INLINE_IMPL_CC__ */
diff --git a/src/mesh_utils/mesh_utils_pbc.cc b/src/mesh_utils/mesh_utils_pbc.cc
index ad44e0ae7..6847ae9f2 100644
--- a/src/mesh_utils/mesh_utils_pbc.cc
+++ b/src/mesh_utils/mesh_utils_pbc.cc
@@ -1,299 +1,299 @@
/**
* @file mesh_utils_pbc.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Wed Feb 09 2011
* @date last modification: Tue Feb 20 2018
*
* @brief periodic boundary condition connectivity tweak
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
#include "element_group.hh"
#include "mesh_accessor.hh"
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/// class that sorts a set of nodes of same coordinates in 'dir' direction
class CoordinatesComparison {
public:
CoordinatesComparison(const UInt dimension, const UInt dir_1,
const UInt dir_2, Real normalization, Real tolerance,
const Array<Real> & coords)
: dim(dimension), dir_1(dir_1), dir_2(dir_2),
normalization(normalization), tolerance(tolerance),
coords_it(coords.begin(dim)) {}
// answers the question whether n2 is larger or equal to n1
bool operator()(const UInt n1, const UInt n2) {
Vector<Real> coords_n1 = coords_it[n1];
Vector<Real> coords_n2 = coords_it[n2];
return this->operator()(coords_n1, coords_n2);
}
bool operator()(const Vector<Real> & coords_n1,
const Vector<Real> & coords_n2) {
Real diff = coords_n1(dir_1) - coords_n2(dir_1);
;
if (dim == 2 || std::abs(diff) / normalization > tolerance)
return diff > 0. ? false : true;
else if (dim > 2) {
diff = coords_n1(dir_2) - coords_n2(dir_2);
;
return diff > 0 ? false : true;
}
return true;
}
private:
UInt dim;
UInt dir_1;
UInt dir_2;
Real normalization;
Real tolerance;
const Array<Real>::const_vector_iterator coords_it;
};
/* -------------------------------------------------------------------------- */
void MeshUtils::computePBCMap(const Mesh & mesh, const UInt dir,
std::map<UInt, UInt> & pbc_pair) {
Array<UInt> selected_left;
Array<UInt> selected_right;
const UInt dim = mesh.getSpatialDimension();
auto it = mesh.getNodes().begin(dim);
auto end = mesh.getNodes().end(dim);
if (dim <= dir)
return;
const Vector<Real> & lower_bounds = mesh.getLowerBounds();
const Vector<Real> & upper_bounds = mesh.getUpperBounds();
AKANTU_DEBUG_INFO("min " << lower_bounds(dir));
AKANTU_DEBUG_INFO("max " << upper_bounds(dir));
for (UInt node = 0; it != end; ++it, ++node) {
const Vector<Real> & coords = *it;
AKANTU_DEBUG_TRACE("treating " << coords(dir));
if (Math::are_float_equal(coords(dir), lower_bounds(dir))) {
AKANTU_DEBUG_TRACE("pushing node " << node << " on the left side");
selected_left.push_back(node);
} else if (Math::are_float_equal(coords(dir), upper_bounds(dir))) {
selected_right.push_back(node);
AKANTU_DEBUG_TRACE("pushing node " << node << " on the right side");
}
}
AKANTU_DEBUG_INFO("found "
<< selected_left.size() << " and " << selected_right.size()
<< " nodes at each boundary for direction " << dir);
// match pairs
MeshUtils::matchPBCPairs(mesh, dir, selected_left, selected_right, pbc_pair);
}
/* -------------------------------------------------------------------------- */
void MeshUtils::computePBCMap(const Mesh & mesh,
const std::pair<ID, ID> & surface_pair,
std::map<UInt, UInt> & pbc_pair) {
Array<UInt> selected_first;
Array<UInt> selected_second;
// find nodes on surfaces
const ElementGroup & first_surf = mesh.getElementGroup(surface_pair.first);
const ElementGroup & second_surf = mesh.getElementGroup(surface_pair.second);
// if this surface pair is not on this proc
if (first_surf.getNbNodes() == 0 || second_surf.getNbNodes() == 0) {
AKANTU_DEBUG_WARNING("computePBCMap has at least one surface without any "
"nodes. I will ignore it.");
return;
}
// copy nodes from element group
selected_first.copy(first_surf.getNodeGroup().getNodes());
selected_second.copy(second_surf.getNodeGroup().getNodes());
// coordinates
const Array<Real> & coords = mesh.getNodes();
const UInt dim = mesh.getSpatialDimension();
// variables to find min and max of surfaces
Real first_max[3], first_min[3];
Real second_max[3], second_min[3];
for (UInt i = 0; i < dim; ++i) {
first_min[i] = std::numeric_limits<Real>::max();
second_min[i] = std::numeric_limits<Real>::max();
first_max[i] = -std::numeric_limits<Real>::max();
second_max[i] = -std::numeric_limits<Real>::max();
}
// find min and max of surface nodes
for (auto it = selected_first.begin(); it != selected_first.end(); ++it) {
for (UInt i = 0; i < dim; ++i) {
if (first_min[i] > coords(*it, i))
first_min[i] = coords(*it, i);
if (first_max[i] < coords(*it, i))
first_max[i] = coords(*it, i);
}
}
for (auto it = selected_second.begin(); it != selected_second.end(); ++it) {
for (UInt i = 0; i < dim; ++i) {
if (second_min[i] > coords(*it, i))
second_min[i] = coords(*it, i);
if (second_max[i] < coords(*it, i))
second_max[i] = coords(*it, i);
}
}
// find direction of pbc
Int first_dir = -1;
#ifndef AKANTU_NDEBUG
Int second_dir = -2;
#endif
for (UInt i = 0; i < dim; ++i) {
if (Math::are_float_equal(first_min[i], first_max[i])) {
first_dir = i;
}
#ifndef AKANTU_NDEBUG
if (Math::are_float_equal(second_min[i], second_max[i])) {
second_dir = i;
}
#endif
}
AKANTU_DEBUG_ASSERT(first_dir == second_dir,
"Surface pair has not same direction. Surface "
<< surface_pair.first << " dir=" << first_dir
<< " ; Surface " << surface_pair.second
<< " dir=" << second_dir);
UInt dir = first_dir;
// match pairs
if (first_min[dir] < second_min[dir])
MeshUtils::matchPBCPairs(mesh, dir, selected_first, selected_second,
pbc_pair);
else
MeshUtils::matchPBCPairs(mesh, dir, selected_second, selected_first,
pbc_pair);
}
/* -------------------------------------------------------------------------- */
void MeshUtils::matchPBCPairs(const Mesh & mesh, const UInt dir,
Array<UInt> & selected_left,
Array<UInt> & selected_right,
std::map<UInt, UInt> & pbc_pair) {
// tolerance is that large because most meshers generate points coordinates
// with single precision only (it is the case of GMSH for instance)
Real tolerance = 1e-7;
const UInt dim = mesh.getSpatialDimension();
Real normalization = mesh.getUpperBounds()(dir) - mesh.getLowerBounds()(dir);
AKANTU_DEBUG_ASSERT(std::abs(normalization) > Math::getTolerance(),
"In matchPBCPairs: The normalization is zero. "
<< "Did you compute the bounding box of the mesh?");
auto odir_1 = UInt(-1), odir_2 = UInt(-1);
if (dim == 3) {
if (dir == _x) {
odir_1 = _y;
odir_2 = _z;
} else if (dir == _y) {
odir_1 = _x;
odir_2 = _z;
} else if (dir == _z) {
odir_1 = _x;
odir_2 = _y;
}
} else if (dim == 2) {
if (dir == _x) {
odir_1 = _y;
} else if (dir == _y) {
odir_1 = _x;
}
}
CoordinatesComparison compare_nodes(dim, odir_1, odir_2, normalization,
tolerance, mesh.getNodes());
std::sort(selected_left.begin(), selected_left.end(), compare_nodes);
std::sort(selected_right.begin(), selected_right.end(), compare_nodes);
auto it_left = selected_left.begin();
auto end_left = selected_left.end();
auto it_right = selected_right.begin();
auto end_right = selected_right.end();
auto nit = mesh.getNodes().begin(dim);
while ((it_left != end_left) && (it_right != end_right)) {
UInt i1 = *it_left;
UInt i2 = *it_right;
Vector<Real> coords1 = nit[i1];
Vector<Real> coords2 = nit[i2];
AKANTU_DEBUG_TRACE("do I pair? " << i1 << "(" << coords1 << ") with" << i2
<< "(" << coords2 << ") in direction "
<< dir);
Real dx = 0.0;
Real dy = 0.0;
if (dim >= 2)
dx = coords1(odir_1) - coords2(odir_1);
if (dim == 3)
dy = coords1(odir_2) - coords2(odir_2);
if (std::abs(dx * dx + dy * dy) / normalization < tolerance) {
// then i match these pairs
if (pbc_pair.count(i2)) {
i2 = pbc_pair[i2];
}
pbc_pair[i1] = i2;
AKANTU_DEBUG_TRACE("pairing " << i1 << "(" << coords1 << ") with" << i2
<< "(" << coords2 << ") in direction "
<< dir);
++it_left;
++it_right;
} else if (compare_nodes(coords1, coords2)) {
++it_left;
} else {
++it_right;
}
}
AKANTU_DEBUG_INFO("found " << pbc_pair.size() << " pairs for direction "
<< dir);
}
-} // akantu
+} // namespace akantu
diff --git a/src/model/common/boundary_condition/boundary_condition.hh b/src/model/common/boundary_condition/boundary_condition.hh
index 82a5b154b..ca4e858ff 100644
--- a/src/model/common/boundary_condition/boundary_condition.hh
+++ b/src/model/common/boundary_condition/boundary_condition.hh
@@ -1,101 +1,101 @@
/**
* @file boundary_condition.hh
*
* @author Dana Christen <dana.christen@gmail.com>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief XXX
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_BOUNDARY_CONDITION_HH__
#define __AKANTU_BOUNDARY_CONDITION_HH__
#include "aka_common.hh"
#include "boundary_condition_functor.hh"
#include "fe_engine.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
namespace akantu {
template <class ModelType> class BoundaryCondition {
/* ------------------------------------------------------------------------ */
/* Typedefs */
/* ------------------------------------------------------------------------ */
private:
/* ------------------------------------------------------------------------ */
/* Constructors / Destructors / Initializers */
/* ------------------------------------------------------------------------ */
public:
BoundaryCondition() : model(nullptr) {}
/// Initialize the boundary conditions
void initBC(ModelType & ptr, Array<Real> & primal, Array<Real> & dual);
void initBC(ModelType & ptr, Array<Real> & primal,
Array<Real> & primal_increment, Array<Real> & dual);
/* ------------------------------------------------------------------------ */
/* Methods and accessors */
/* ------------------------------------------------------------------------ */
public:
// inline void initBoundaryCondition();
template <typename FunctorType>
/// Apply the boundary conditions
inline void applyBC(const FunctorType & func);
template <class FunctorType>
inline void applyBC(const FunctorType & func, const std::string & group_name);
template <class FunctorType>
inline void applyBC(const FunctorType & func,
const ElementGroup & element_group);
AKANTU_GET_MACRO_NOT_CONST(Model, *model, ModelType &);
AKANTU_GET_MACRO_NOT_CONST(Primal, *primal, Array<Real> &);
AKANTU_GET_MACRO_NOT_CONST(Dual, *dual, Array<Real> &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
public:
template <class FunctorType, BC::Functor::Type type = FunctorType::type>
struct TemplateFunctionWrapper;
private:
ModelType * model;
Array<Real> * primal{nullptr};
Array<Real> * dual{nullptr};
Array<Real> * primal_increment{nullptr};
};
-} // akantu
+} // namespace akantu
#include "boundary_condition_tmpl.hh"
#endif /* __AKANTU_BOUNDARY_CONDITION_HH__ */
diff --git a/src/model/common/boundary_condition/boundary_condition_tmpl.hh b/src/model/common/boundary_condition/boundary_condition_tmpl.hh
index c64b4b44e..3671e54ec 100644
--- a/src/model/common/boundary_condition/boundary_condition_tmpl.hh
+++ b/src/model/common/boundary_condition/boundary_condition_tmpl.hh
@@ -1,230 +1,230 @@
/**
* @file boundary_condition_tmpl.hh
*
* @author Dana Christen <dana.christen@gmail.com>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri May 03 2013
* @date last modification: Tue Feb 20 2018
*
* @brief implementation of the applyBC
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "boundary_condition.hh"
#include "element_group.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_BOUNDARY_CONDITION_TMPL_HH__
#define __AKANTU_BOUNDARY_CONDITION_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename ModelType>
void BoundaryCondition<ModelType>::initBC(ModelType & model,
Array<Real> & primal,
Array<Real> & dual) {
this->model = &model;
this->primal = &primal;
this->dual = &dual;
}
/* -------------------------------------------------------------------------- */
template <typename ModelType>
void BoundaryCondition<ModelType>::initBC(ModelType & model,
Array<Real> & primal,
Array<Real> & primal_increment,
Array<Real> & dual) {
this->initBC(model, primal, dual);
this->primal_increment = &primal_increment;
}
/* -------------------------------------------------------------------------- */
/* Partial specialization for DIRICHLET functors */
template <typename ModelType>
template <typename FunctorType>
struct BoundaryCondition<ModelType>::TemplateFunctionWrapper<
FunctorType, BC::Functor::_dirichlet> {
static inline void applyBC(const FunctorType & func,
const ElementGroup & group,
BoundaryCondition<ModelType> & bc_instance) {
auto & model = bc_instance.getModel();
auto & primal = bc_instance.getPrimal();
const auto & coords = model.getMesh().getNodes();
auto & boundary_flags = model.getBlockedDOFs();
UInt dim = model.getMesh().getSpatialDimension();
auto primal_iter = primal.begin(primal.getNbComponent());
auto coords_iter = coords.begin(dim);
auto flags_iter = boundary_flags.begin(boundary_flags.getNbComponent());
for (auto n : group.getNodeGroup()) {
Vector<bool> flag(flags_iter[n]);
Vector<Real> primal(primal_iter[n]);
Vector<Real> coords(coords_iter[n]);
func(n, flag, primal, coords);
}
}
};
/* -------------------------------------------------------------------------- */
/* Partial specialization for NEUMANN functors */
template <typename ModelType>
template <typename FunctorType>
struct BoundaryCondition<ModelType>::TemplateFunctionWrapper<
FunctorType, BC::Functor::_neumann> {
static inline void applyBC(const FunctorType & func,
const ElementGroup & group,
BoundaryCondition<ModelType> & bc_instance) {
UInt dim = bc_instance.getModel().getSpatialDimension();
switch (dim) {
case 1: {
AKANTU_TO_IMPLEMENT();
break;
}
case 2:
case 3: {
applyBC(func, group, bc_instance, _not_ghost);
applyBC(func, group, bc_instance, _ghost);
break;
}
}
}
static inline void applyBC(const FunctorType & func,
const ElementGroup & group,
BoundaryCondition<ModelType> & bc_instance,
GhostType ghost_type) {
auto & model = bc_instance.getModel();
auto & dual = bc_instance.getDual();
const auto & mesh = model.getMesh();
const auto & nodes_coords = mesh.getNodes();
const auto & fem_boundary = model.getFEEngineBoundary();
UInt dim = model.getSpatialDimension();
UInt nb_degree_of_freedom = dual.getNbComponent();
IntegrationPoint quad_point;
quad_point.ghost_type = ghost_type;
// Loop over the boundary element types
for (auto && type : group.elementTypes(dim - 1, ghost_type)) {
const auto & element_ids = group.getElements(type, ghost_type);
UInt nb_quad_points =
fem_boundary.getNbIntegrationPoints(type, ghost_type);
UInt nb_elements = element_ids.size();
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
Array<Real> dual_before_integ(nb_elements * nb_quad_points,
nb_degree_of_freedom, 0.);
Array<Real> quad_coords(nb_elements * nb_quad_points, dim);
const auto & normals_on_quad =
fem_boundary.getNormalsOnIntegrationPoints(type, ghost_type);
fem_boundary.interpolateOnIntegrationPoints(
nodes_coords, quad_coords, dim, type, ghost_type, element_ids);
auto normals_begin = normals_on_quad.begin(dim);
decltype(normals_begin) normals_iter;
auto quad_coords_iter = quad_coords.begin(dim);
auto dual_iter = dual_before_integ.begin(nb_degree_of_freedom);
quad_point.type = type;
for (auto el : element_ids) {
quad_point.element = el;
normals_iter = normals_begin + el * nb_quad_points;
for (auto && q : arange(nb_quad_points)) {
quad_point.num_point = q;
func(quad_point, *dual_iter, *quad_coords_iter, *normals_iter);
++dual_iter;
++quad_coords_iter;
++normals_iter;
}
}
Array<Real> dual_by_shapes(nb_elements * nb_quad_points,
nb_degree_of_freedom * nb_nodes_per_element);
fem_boundary.computeNtb(dual_before_integ, dual_by_shapes, type,
ghost_type, element_ids);
- Array<Real> dual_by_shapes_integ(
- nb_elements, nb_degree_of_freedom * nb_nodes_per_element);
+ Array<Real> dual_by_shapes_integ(nb_elements, nb_degree_of_freedom *
+ nb_nodes_per_element);
fem_boundary.integrate(dual_by_shapes, dual_by_shapes_integ,
nb_degree_of_freedom * nb_nodes_per_element, type,
ghost_type, element_ids);
// assemble the result into force vector
model.getDOFManager().assembleElementalArrayLocalArray(
dual_by_shapes_integ, dual, type, ghost_type, 1., element_ids);
}
}
};
/* -------------------------------------------------------------------------- */
template <typename ModelType>
template <typename FunctorType>
inline void BoundaryCondition<ModelType>::applyBC(const FunctorType & func) {
auto bit = model->getMesh().getGroupManager().element_group_begin();
auto bend = model->getMesh().getGroupManager().element_group_end();
for (; bit != bend; ++bit)
applyBC(func, *bit);
}
/* -------------------------------------------------------------------------- */
template <typename ModelType>
template <typename FunctorType>
inline void
BoundaryCondition<ModelType>::applyBC(const FunctorType & func,
const std::string & group_name) {
try {
const ElementGroup & element_group =
model->getMesh().getElementGroup(group_name);
applyBC(func, element_group);
} catch (akantu::debug::Exception & e) {
AKANTU_EXCEPTION("Error applying a boundary condition onto \""
<< group_name << "\"! [" << e.what() << "]");
}
}
/* -------------------------------------------------------------------------- */
template <typename ModelType>
template <typename FunctorType>
inline void
BoundaryCondition<ModelType>::applyBC(const FunctorType & func,
const ElementGroup & element_group) {
#if !defined(AKANTU_NDEBUG)
if (element_group.getDimension() != model->getSpatialDimension() - 1)
AKANTU_DEBUG_WARNING("The group "
<< element_group.getName()
<< " does not contain only boundaries elements");
#endif
TemplateFunctionWrapper<FunctorType>::applyBC(func, element_group, *this);
}
#endif /* __AKANTU_BOUNDARY_CONDITION_TMPL_HH__ */
} // namespace akantu
diff --git a/src/model/common/dof_manager/dof_manager_default.cc b/src/model/common/dof_manager/dof_manager_default.cc
index bba19d4bf..9026a33b7 100644
--- a/src/model/common/dof_manager/dof_manager_default.cc
+++ b/src/model/common/dof_manager/dof_manager_default.cc
@@ -1,485 +1,486 @@
/**
* @file dof_manager_default.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Aug 18 2015
* @date last modification: Thu Feb 08 2018
*
* @brief Implementation of the default DOFManager
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager_default.hh"
#include "communicator.hh"
#include "dof_synchronizer.hh"
#include "element_group.hh"
#include "non_linear_solver_default.hh"
#include "periodic_node_synchronizer.hh"
#include "solver_vector_default.hh"
#include "solver_vector_distributed.hh"
#include "sparse_matrix_aij.hh"
#include "time_step_solver_default.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <memory>
#include <numeric>
#include <unordered_map>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
DOFManagerDefault::DOFManagerDefault(const ID & id, const MemoryID & memory_id)
: DOFManager(id, memory_id), synchronizer(nullptr) {
residual = std::make_unique<SolverVectorDefault>(
*this, std::string(id + ":residual"));
solution = std::make_unique<SolverVectorDefault>(
*this, std::string(id + ":solution"));
data_cache = std::make_unique<SolverVectorDefault>(
*this, std::string(id + ":data_cache"));
}
/* -------------------------------------------------------------------------- */
DOFManagerDefault::DOFManagerDefault(Mesh & mesh, const ID & id,
const MemoryID & memory_id)
: DOFManager(mesh, id, memory_id), synchronizer(nullptr) {
if (this->mesh->isDistributed()) {
this->synchronizer = std::make_unique<DOFSynchronizer>(
*this, this->id + ":dof_synchronizer", this->memory_id);
residual = std::make_unique<SolverVectorDistributed>(
*this, std::string(id + ":residual"));
solution = std::make_unique<SolverVectorDistributed>(
*this, std::string(id + ":solution"));
data_cache = std::make_unique<SolverVectorDistributed>(
*this, std::string(id + ":data_cache"));
} else {
residual = std::make_unique<SolverVectorDefault>(
*this, std::string(id + ":residual"));
solution = std::make_unique<SolverVectorDefault>(
*this, std::string(id + ":solution"));
data_cache = std::make_unique<SolverVectorDefault>(
*this, std::string(id + ":data_cache"));
}
}
/* -------------------------------------------------------------------------- */
DOFManagerDefault::~DOFManagerDefault() = default;
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::makeConsistentForPeriodicity(const ID & dof_id,
SolverVector & array) {
auto & dof_data = this->getDOFDataTyped<DOFDataDefault>(dof_id);
if (dof_data.support_type != _dst_nodal)
return;
if (not mesh->isPeriodic())
return;
this->mesh->getPeriodicNodeSynchronizer()
.reduceSynchronizeWithPBCSlaves<AddOperation>(
aka::as_type<SolverVectorDefault>(array).getVector());
}
/* -------------------------------------------------------------------------- */
template <typename T>
void DOFManagerDefault::assembleToGlobalArray(
const ID & dof_id, const Array<T> & array_to_assemble,
Array<T> & global_array, T scale_factor) {
AKANTU_DEBUG_IN();
auto & dof_data = this->getDOFDataTyped<DOFDataDefault>(dof_id);
AKANTU_DEBUG_ASSERT(dof_data.local_equation_number.size() ==
array_to_assemble.size() *
array_to_assemble.getNbComponent(),
"The array to assemble does not have a correct size."
<< " (" << array_to_assemble.getID() << ")");
if (dof_data.support_type == _dst_nodal and mesh->isPeriodic()) {
for (auto && data :
zip(dof_data.local_equation_number, dof_data.associated_nodes,
make_view(array_to_assemble))) {
auto && equ_num = std::get<0>(data);
auto && node = std::get<1>(data);
auto && arr = std::get<2>(data);
global_array(equ_num) +=
scale_factor * (arr) * (not this->mesh->isPeriodicSlave(node));
}
} else {
for (auto && data :
zip(dof_data.local_equation_number, make_view(array_to_assemble))) {
auto && equ_num = std::get<0>(data);
auto && arr = std::get<1>(data);
global_array(equ_num) += scale_factor * (arr);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::assembleToGlobalArray(
const ID & dof_id, const Array<Real> & array_to_assemble,
SolverVector & global_array_v, Real scale_factor) {
assembleToGlobalArray(
dof_id, array_to_assemble,
aka::as_type<SolverVectorDefault>(global_array_v).getVector(),
scale_factor);
}
/* -------------------------------------------------------------------------- */
DOFManagerDefault::DOFDataDefault::DOFDataDefault(const ID & dof_id)
: DOFData(dof_id) {}
/* -------------------------------------------------------------------------- */
auto DOFManagerDefault::getNewDOFData(const ID & dof_id)
-> std::unique_ptr<DOFData> {
return std::make_unique<DOFDataDefault>(dof_id);
}
/* -------------------------------------------------------------------------- */
std::tuple<UInt, UInt, UInt>
DOFManagerDefault::registerDOFsInternal(const ID & dof_id,
Array<Real> & dofs_array) {
auto ret = DOFManager::registerDOFsInternal(dof_id, dofs_array);
// update the synchronizer if needed
if (this->synchronizer)
this->synchronizer->registerDOFs(dof_id);
return ret;
}
/* -------------------------------------------------------------------------- */
SparseMatrix & DOFManagerDefault::getNewMatrix(const ID & id,
const MatrixType & matrix_type) {
return this->registerSparseMatrix<SparseMatrixAIJ>(*this, id, matrix_type);
}
/* -------------------------------------------------------------------------- */
SparseMatrix & DOFManagerDefault::getNewMatrix(const ID & id,
const ID & matrix_to_copy_id) {
return this->registerSparseMatrix<SparseMatrixAIJ>(id, matrix_to_copy_id);
}
/* -------------------------------------------------------------------------- */
SolverVector & DOFManagerDefault::getNewLumpedMatrix(const ID & id) {
return this->registerLumpedMatrix<SolverVectorDefault>(*this, id);
}
/* -------------------------------------------------------------------------- */
SparseMatrixAIJ & DOFManagerDefault::getMatrix(const ID & id) {
auto & matrix = DOFManager::getMatrix(id);
return aka::as_type<SparseMatrixAIJ>(matrix);
}
/* -------------------------------------------------------------------------- */
NonLinearSolver &
DOFManagerDefault::getNewNonLinearSolver(const ID & id,
const NonLinearSolverType & type) {
switch (type) {
#if defined(AKANTU_IMPLICIT)
case NonLinearSolverType::_newton_raphson:
/* FALLTHRU */
/* [[fallthrough]]; un-comment when compiler will get it */
case NonLinearSolverType::_newton_raphson_contact:
case NonLinearSolverType::_newton_raphson_modified: {
return this->registerNonLinearSolver<NonLinearSolverNewtonRaphson>(
*this, id, type);
}
case NonLinearSolverType::_linear: {
return this->registerNonLinearSolver<NonLinearSolverLinear>(*this, id,
type);
}
#endif
case NonLinearSolverType::_lumped: {
return this->registerNonLinearSolver<NonLinearSolverLumped>(*this, id,
type);
}
default:
AKANTU_EXCEPTION("The asked type of non linear solver is not supported by "
"this dof manager");
}
}
/* -------------------------------------------------------------------------- */
TimeStepSolver & DOFManagerDefault::getNewTimeStepSolver(
const ID & id, const TimeStepSolverType & type,
NonLinearSolver & non_linear_solver, SolverCallback & solver_callback) {
return this->registerTimeStepSolver<TimeStepSolverDefault>(
*this, id, type, non_linear_solver, solver_callback);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void DOFManagerDefault::getArrayPerDOFs(const ID & dof_id,
const Array<T> & global_array,
Array<T> & local_array) const {
AKANTU_DEBUG_IN();
const Array<Int> & equation_number = this->getLocalEquationsNumbers(dof_id);
UInt nb_degree_of_freedoms = equation_number.size();
local_array.resize(nb_degree_of_freedoms / local_array.getNbComponent());
auto loc_it = local_array.begin_reinterpret(nb_degree_of_freedoms);
auto equ_it = equation_number.begin();
for (UInt d = 0; d < nb_degree_of_freedoms; ++d, ++loc_it, ++equ_it) {
(*loc_it) = global_array(*equ_it);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::getArrayPerDOFs(const ID & dof_id,
const SolverVector & global_array,
Array<Real> & local_array) {
getArrayPerDOFs(dof_id,
aka::as_type<SolverVectorDefault>(global_array).getVector(),
local_array);
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::assembleLumpedMatMulVectToResidual(
const ID & dof_id, const ID & A_id, const Array<Real> & x,
Real scale_factor) {
const Array<Real> & A = this->getLumpedMatrix(A_id);
auto & cache = aka::as_type<SolverVectorArray>(*this->data_cache);
cache.clear();
this->assembleToGlobalArray(dof_id, x, cache.getVector(), scale_factor);
for (auto && data : zip(make_view(A), make_view(cache.getVector()),
make_view(this->getResidualArray()))) {
const auto & A = std::get<0>(data);
const auto & x = std::get<1>(data);
auto & r = std::get<2>(data);
r += A * x;
}
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::assembleElementalMatricesToMatrix(
const ID & matrix_id, const ID & dof_id, const Array<Real> & elementary_mat,
const ElementType & type, const GhostType & ghost_type,
const MatrixType & elemental_matrix_type,
const Array<UInt> & filter_elements) {
this->addToProfile(matrix_id, dof_id, type, ghost_type);
auto & A = getMatrix(matrix_id);
DOFManager::assembleElementalMatricesToMatrix_(
A, dof_id, elementary_mat, type, ghost_type, elemental_matrix_type,
filter_elements);
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::assemblePreassembledMatrix(
const ID & dof_id_m, const ID & dof_id_n, const ID & matrix_id,
const TermsToAssemble & terms) {
auto & A = getMatrix(matrix_id);
DOFManager::assemblePreassembledMatrix_(A, dof_id_m, dof_id_n, terms);
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::assembleMatMulVectToArray(const ID & dof_id,
const ID & A_id,
const Array<Real> & x,
Array<Real> & array,
Real scale_factor) {
if (mesh->isDistributed()) {
DOFManager::assembleMatMulVectToArray_<SolverVectorDistributed>(
dof_id, A_id, x, array, scale_factor);
} else {
DOFManager::assembleMatMulVectToArray_<SolverVectorDefault>(
dof_id, A_id, x, array, scale_factor);
}
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::addToProfile(const ID & matrix_id, const ID & dof_id,
const ElementType & type,
const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
const auto & dof_data = this->getDOFData(dof_id);
if (dof_data.support_type != _dst_nodal)
return;
auto mat_dof = std::make_pair(matrix_id, dof_id);
auto type_pair = std::make_pair(type, ghost_type);
auto prof_it = this->matrix_profiled_dofs.find(mat_dof);
if (prof_it != this->matrix_profiled_dofs.end() &&
std::find(prof_it->second.begin(), prof_it->second.end(), type_pair) !=
prof_it->second.end())
return;
auto nb_degree_of_freedom_per_node = dof_data.dof->getNbComponent();
const auto & equation_number = this->getLocalEquationsNumbers(dof_id);
auto & A = this->getMatrix(matrix_id);
+ A.resize(system_size);
auto size = A.size();
auto nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
const auto & connectivity = this->mesh->getConnectivity(type, ghost_type);
auto cbegin = connectivity.begin(nb_nodes_per_element);
auto cit = cbegin;
auto nb_elements = connectivity.size();
UInt * ge_it = nullptr;
if (dof_data.group_support != "__mesh__") {
const auto & group_elements =
this->mesh->getElementGroup(dof_data.group_support)
.getElements(type, ghost_type);
ge_it = group_elements.storage();
nb_elements = group_elements.size();
}
UInt size_mat = nb_nodes_per_element * nb_degree_of_freedom_per_node;
Vector<Int> element_eq_nb(size_mat);
for (UInt e = 0; e < nb_elements; ++e) {
if (ge_it)
cit = cbegin + *ge_it;
this->extractElementEquationNumber(
equation_number, *cit, nb_degree_of_freedom_per_node, element_eq_nb);
std::transform(
element_eq_nb.storage(), element_eq_nb.storage() + element_eq_nb.size(),
element_eq_nb.storage(),
[&](auto & local) { return this->localToGlobalEquationNumber(local); });
if (ge_it)
++ge_it;
else
++cit;
for (UInt i = 0; i < size_mat; ++i) {
UInt c_irn = element_eq_nb(i);
if (c_irn < size) {
for (UInt j = 0; j < size_mat; ++j) {
UInt c_jcn = element_eq_nb(j);
if (c_jcn < size) {
A.add(c_irn, c_jcn);
}
}
}
}
}
this->matrix_profiled_dofs[mat_dof].push_back(type_pair);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Array<Real> & DOFManagerDefault::getSolutionArray() {
return dynamic_cast<SolverVectorDefault *>(this->solution.get())->getVector();
}
/* -------------------------------------------------------------------------- */
const Array<Real> & DOFManagerDefault::getResidualArray() const {
return dynamic_cast<SolverVectorDefault *>(this->residual.get())->getVector();
}
/* -------------------------------------------------------------------------- */
Array<Real> & DOFManagerDefault::getResidualArray() {
return dynamic_cast<SolverVectorDefault *>(this->residual.get())->getVector();
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::onNodesAdded(const Array<UInt> & nodes_list,
const NewNodesEvent & event) {
DOFManager::onNodesAdded(nodes_list, event);
if (this->synchronizer)
this->synchronizer->onNodesAdded(nodes_list);
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::resizeGlobalArrays() {
DOFManager::resizeGlobalArrays();
this->global_blocked_dofs.resize(this->local_system_size, true);
this->previous_global_blocked_dofs.resize(this->local_system_size, true);
matrix_profiled_dofs.clear();
}
/* -------------------------------------------------------------------------- */
void DOFManagerDefault::updateGlobalBlockedDofs() {
DOFManager::updateGlobalBlockedDofs();
if (this->global_blocked_dofs_release ==
this->previous_global_blocked_dofs_release)
return;
global_blocked_dofs_uint.resize(local_system_size);
global_blocked_dofs_uint.set(false);
for (const auto & dof : global_blocked_dofs) {
global_blocked_dofs_uint[dof] = true;
}
}
/* -------------------------------------------------------------------------- */
Array<bool> & DOFManagerDefault::getBlockedDOFs() {
return global_blocked_dofs_uint;
}
/* -------------------------------------------------------------------------- */
const Array<bool> & DOFManagerDefault::getBlockedDOFs() const {
return global_blocked_dofs_uint;
}
/* -------------------------------------------------------------------------- */
// register in factory
// static bool default_dof_manager_is_registered [[gnu::unused]] =
// DefaultDOFManagerFactory::getInstance().registerAllocator(
// "default",
// [](const ID & id,
// const MemoryID & mem_id) -> std::unique_ptr<DOFManager> {
// return std::make_unique<DOFManagerDefault>(id, mem_id);
// });
static bool dof_manager_is_registered [[gnu::unused]] =
DOFManagerFactory::getInstance().registerAllocator(
"default",
[](Mesh & mesh, const ID & id,
const MemoryID & mem_id) -> std::unique_ptr<DOFManager> {
return std::make_unique<DOFManagerDefault>(mesh, id, mem_id);
});
static bool dof_manager_is_registered_mumps [[gnu::unused]] =
DOFManagerFactory::getInstance().registerAllocator(
"mumps",
[](Mesh & mesh, const ID & id,
const MemoryID & mem_id) -> std::unique_ptr<DOFManager> {
return std::make_unique<DOFManagerDefault>(mesh, id, mem_id);
});
} // namespace akantu
diff --git a/src/model/common/dof_manager/dof_manager_default.hh b/src/model/common/dof_manager/dof_manager_default.hh
index 5238608de..2b5a0133b 100644
--- a/src/model/common/dof_manager/dof_manager_default.hh
+++ b/src/model/common/dof_manager/dof_manager_default.hh
@@ -1,257 +1,256 @@
/**
* @file dof_manager_default.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Aug 18 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Default implementation of the dof manager
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager.hh"
/* -------------------------------------------------------------------------- */
#include <functional>
#include <unordered_map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DOF_MANAGER_DEFAULT_HH__
#define __AKANTU_DOF_MANAGER_DEFAULT_HH__
namespace akantu {
class SparseMatrixAIJ;
class NonLinearSolverDefault;
class TimeStepSolverDefault;
class DOFSynchronizer;
} // namespace akantu
namespace akantu {
class DOFManagerDefault : public DOFManager {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DOFManagerDefault(const ID & id = "dof_manager_default",
const MemoryID & memory_id = 0);
DOFManagerDefault(Mesh & mesh, const ID & id = "dof_manager_default",
const MemoryID & memory_id = 0);
~DOFManagerDefault() override;
protected:
struct DOFDataDefault : public DOFData {
explicit DOFDataDefault(const ID & dof_id);
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
// /// register an array of degree of freedom
// void registerDOFs(const ID & dof_id, Array<Real> & dofs_array,
// const DOFSupportType & support_type) override;
// /// the dof as an implied type of _dst_nodal and is defined only on a
// subset
// /// of nodes
// void registerDOFs(const ID & dof_id, Array<Real> & dofs_array,
// const ID & group_support) override;
/**
* Assemble elementary values to the global matrix. The dof number is
* implicitly considered as conn(el, n) * nb_nodes_per_element + d.
* With 0 < n < nb_nodes_per_element and 0 < d < nb_dof_per_node
**/
void assembleElementalMatricesToMatrix(
const ID & matrix_id, const ID & dof_id,
const Array<Real> & elementary_mat, const ElementType & type,
const GhostType & ghost_type, const MatrixType & elemental_matrix_type,
const Array<UInt> & filter_elements) override;
void assembleMatMulVectToArray(const ID & dof_id, const ID & A_id,
const Array<Real> & x, Array<Real> & array,
Real scale_factor = 1.) override;
/// multiply a vector by a lumped matrix and assemble the result to the
/// residual
void assembleLumpedMatMulVectToResidual(const ID & dof_id, const ID & A_id,
const Array<Real> & x,
Real scale_factor = 1) override;
/// assemble coupling terms between to dofs
void assemblePreassembledMatrix(const ID & dof_id_m, const ID & dof_id_n,
const ID & matrix_id,
const TermsToAssemble & terms) override;
protected:
void assembleToGlobalArray(const ID & dof_id,
const Array<Real> & array_to_assemble,
SolverVector & global_array,
Real scale_factor) override;
template <typename T>
void assembleToGlobalArray(const ID & dof_id,
const Array<T> & array_to_assemble,
Array<T> & global_array, T scale_factor);
void getArrayPerDOFs(const ID & dof_id, const SolverVector & global,
Array<Real> & local) override;
template <typename T>
void getArrayPerDOFs(const ID & dof_id, const Array<T> & global_array,
Array<T> & local_array) const;
void makeConsistentForPeriodicity(const ID & dof_id,
SolverVector & array) override;
-
public:
- /// update the global dofs vector
+ /// update the global dofs vector
void updateGlobalBlockedDofs() override;
-// /// apply boundary conditions to jacobian matrix
-// void applyBoundary(const ID & matrix_id = "J") override;
+ // /// apply boundary conditions to jacobian matrix
+ // void applyBoundary(const ID & matrix_id = "J") override;
private:
/// Add a symmetric matrices to a symmetric sparse matrix
void addSymmetricElementalMatrixToSymmetric(
SparseMatrixAIJ & matrix, const Matrix<Real> & element_mat,
const Vector<Int> & equation_numbers, UInt max_size);
/// Add a unsymmetric matrices to a symmetric sparse matrix (i.e. cohesive
/// elements)
void addUnsymmetricElementalMatrixToSymmetric(
SparseMatrixAIJ & matrix, const Matrix<Real> & element_mat,
const Vector<Int> & equation_numbers, UInt max_size);
/// Add a matrices to a unsymmetric sparse matrix
void addElementalMatrixToUnsymmetric(SparseMatrixAIJ & matrix,
const Matrix<Real> & element_mat,
const Vector<Int> & equation_numbers,
UInt max_size);
void addToProfile(const ID & matrix_id, const ID & dof_id,
const ElementType & type, const GhostType & ghost_type);
/* ------------------------------------------------------------------------ */
/* MeshEventHandler interface */
/* ------------------------------------------------------------------------ */
protected:
std::tuple<UInt, UInt, UInt>
registerDOFsInternal(const ID & dof_id, Array<Real> & dofs_array) override;
// std::pair<UInt, UInt>
// updateNodalDOFs(const ID & dof_id, const Array<UInt> & nodes_list)
// override;
void resizeGlobalArrays() override;
public:
/// function to implement to react on akantu::NewNodesEvent
void onNodesAdded(const Array<UInt> & nodes_list,
const NewNodesEvent & event) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// Get an instance of a new SparseMatrix
SparseMatrix & getNewMatrix(const ID & matrix_id,
const MatrixType & matrix_type) override;
/// Get an instance of a new SparseMatrix as a copy of the SparseMatrix
/// matrix_to_copy_id
SparseMatrix & getNewMatrix(const ID & matrix_id,
const ID & matrix_to_copy_id) override;
/// Get the reference of an existing matrix
SparseMatrixAIJ & getMatrix(const ID & matrix_id);
/// Get an instance of a new lumped matrix
SolverVector & getNewLumpedMatrix(const ID & matrix_id) override;
/* ------------------------------------------------------------------------ */
/* Non Linear Solver */
/* ------------------------------------------------------------------------ */
/// Get instance of a non linear solver
NonLinearSolver & getNewNonLinearSolver(
const ID & nls_solver_id,
const NonLinearSolverType & _non_linear_solver_type) override;
/* ------------------------------------------------------------------------ */
/* Time-Step Solver */
/* ------------------------------------------------------------------------ */
/// Get instance of a time step solver
TimeStepSolver &
getNewTimeStepSolver(const ID & id, const TimeStepSolverType & type,
NonLinearSolver & non_linear_solver,
SolverCallback & solver_callback) override;
/* ------------------------------------------------------------------------ */
private:
/// Get the solution array
Array<Real> & getSolutionArray();
/// Get the residual array
const Array<Real> & getResidualArray() const;
/// Get the residual array
Array<Real> & getResidualArray();
public:
/// access the internal dof_synchronizer
AKANTU_GET_MACRO_NOT_CONST(Synchronizer, *synchronizer, DOFSynchronizer &);
/// access the internal dof_synchronizer
bool hasSynchronizer() const { return synchronizer != nullptr; }
Array<bool> & getBlockedDOFs();
const Array<bool> & getBlockedDOFs() const;
-
+
protected:
std::unique_ptr<DOFData> getNewDOFData(const ID & dof_id) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
using DOFToMatrixProfile =
std::map<std::pair<ID, ID>,
std::vector<std::pair<ElementType, GhostType>>>;
/// contains the the dofs that where added to the profile of a given matrix.
DOFToMatrixProfile matrix_profiled_dofs;
/// synchronizer to maintain coherency in dof fields
std::unique_ptr<DOFSynchronizer> synchronizer;
friend class DOFSynchronizer;
/// Array containing the true or false if the node is in global_blocked_dofs
Array<bool> global_blocked_dofs_uint;
};
} // namespace akantu
#include "dof_manager_default_inline_impl.cc"
#endif /* __AKANTU_DOF_MANAGER_DEFAULT_HH__ */
diff --git a/src/model/common/dof_manager/dof_manager_default_inline_impl.cc b/src/model/common/dof_manager/dof_manager_default_inline_impl.cc
index 817e1d566..cdb1d7b0d 100644
--- a/src/model/common/dof_manager/dof_manager_default_inline_impl.cc
+++ b/src/model/common/dof_manager/dof_manager_default_inline_impl.cc
@@ -1,43 +1,40 @@
/**
* @file dof_manager_default_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Aug 18 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Implementation of the DOFManagerDefault inline functions
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager_default.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DOF_MANAGER_DEFAULT_INLINE_IMPL_CC__
#define __AKANTU_DOF_MANAGER_DEFAULT_INLINE_IMPL_CC__
-namespace akantu {
-
-
-} // akantu
+namespace akantu {} // namespace akantu
#endif /* __AKANTU_DOF_MANAGER_DEFAULT_INLINE_IMPL_CC_ */
diff --git a/src/model/common/dof_manager/dof_manager_petsc.hh b/src/model/common/dof_manager/dof_manager_petsc.hh
index 3c9491c23..e57512415 100644
--- a/src/model/common/dof_manager/dof_manager_petsc.hh
+++ b/src/model/common/dof_manager/dof_manager_petsc.hh
@@ -1,217 +1,219 @@
/**
* @file dof_manager_petsc.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Aug 18 2015
* @date last modification: Wed Jan 31 2018
*
* @brief PETSc implementation of the dof manager
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager.hh"
/* -------------------------------------------------------------------------- */
#include <petscis.h>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DOF_MANAGER_PETSC_HH__
#define __AKANTU_DOF_MANAGER_PETSC_HH__
#define PETSc_call(func, ...) \
do { \
auto ierr = func(__VA_ARGS__); \
if (PetscUnlikely(ierr != 0)) { \
const char * desc; \
PetscErrorMessage(ierr, &desc, nullptr); \
AKANTU_EXCEPTION("Error in PETSc call to \'" << #func \
<< "\': " << desc); \
} \
} while (false)
namespace akantu {
namespace detail {
template <typename T> void PETScSetName(T t, const ID & id) {
PETSc_call(PetscObjectSetName, reinterpret_cast<PetscObject>(t),
id.c_str());
}
} // namespace detail
} // namespace akantu
namespace akantu {
class SparseMatrixPETSc;
class SolverVectorPETSc;
} // namespace akantu
namespace akantu {
class DOFManagerPETSc : public DOFManager {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DOFManagerPETSc(const ID & id = "dof_manager_petsc",
const MemoryID & memory_id = 0);
DOFManagerPETSc(Mesh & mesh, const ID & id = "dof_manager_petsc",
const MemoryID & memory_id = 0);
virtual ~DOFManagerPETSc();
protected:
void init();
struct DOFDataPETSc : public DOFData {
explicit DOFDataPETSc(const ID & dof_id);
/// petsc compressed version of local_equation_number
Array<PetscInt> local_equation_number_petsc;
- virtual Array<Int> & getLocalEquationsNumbers() {return local_equation_number_petsc;}
+ virtual Array<Int> & getLocalEquationsNumbers() {
+ return local_equation_number_petsc;
+ }
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void assembleToLumpedMatrix(const ID & /*dof_id*/,
Array<Real> & /*array_to_assemble*/,
const ID & /*lumped_mtx*/,
Real /*scale_factor*/ = 1.) {
AKANTU_TO_IMPLEMENT();
}
void assembleElementalMatricesToMatrix(
const ID & /*matrix_id*/, const ID & /*dof_id*/,
const Array<Real> & /*elementary_mat*/, const ElementType & /*type*/,
const GhostType & /*ghost_type*/,
const MatrixType & /*elemental_matrix_type*/,
const Array<UInt> & /*filter_elements*/) override;
void assembleMatMulVectToArray(const ID & /*dof_id*/, const ID & /*A_id*/,
const Array<Real> & /*x*/,
Array<Real> & /*array*/,
Real /*scale_factor*/ = 1.) override;
void assembleLumpedMatMulVectToResidual(const ID & /*dof_id*/,
const ID & /*A_id*/,
const Array<Real> & /*x*/,
Real /*scale_factor*/ = 1) override {
AKANTU_TO_IMPLEMENT();
}
void assemblePreassembledMatrix(const ID & /* dof_id_m*/,
const ID & /*dof_id_n*/,
const ID & /*matrix_id*/,
const TermsToAssemble & /*terms*/) override;
protected:
void assembleToGlobalArray(const ID & dof_id,
const Array<Real> & array_to_assemble,
SolverVector & global_array,
Real scale_factor) override;
void getArrayPerDOFs(const ID & dof_id, const SolverVector & global,
Array<Real> & local) override;
void makeConsistentForPeriodicity(const ID & dof_id,
SolverVector & array) override;
std::unique_ptr<DOFData> getNewDOFData(const ID & dof_id) override;
std::tuple<UInt, UInt, UInt>
registerDOFsInternal(const ID & dof_id, Array<Real> & dofs_array) override;
void updateDOFsData(DOFDataPETSc & dof_data, UInt nb_new_local_dofs,
UInt nb_new_pure_local, UInt nb_node,
const std::function<UInt(UInt)> & getNode);
protected:
void getLumpedMatrixPerDOFs(const ID & /*dof_id*/, const ID & /*lumped_mtx*/,
Array<Real> & /*lumped*/) override {}
NonLinearSolver & getNewNonLinearSolver(
const ID & nls_solver_id,
const NonLinearSolverType & non_linear_solver_type) override;
TimeStepSolver &
getNewTimeStepSolver(const ID & id, const TimeStepSolverType & type,
NonLinearSolver & non_linear_solver,
SolverCallback & solver_callback) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// Get an instance of a new SparseMatrix
SparseMatrix & getNewMatrix(const ID & matrix_id,
const MatrixType & matrix_type) override;
/// Get an instance of a new SparseMatrix as a copy of the SparseMatrix
/// matrix_to_copy_id
SparseMatrix & getNewMatrix(const ID & matrix_id,
const ID & matrix_to_copy_id) override;
/// Get the reference of an existing matrix
SparseMatrixPETSc & getMatrix(const ID & matrix_id);
/// Get an instance of a new lumped matrix
SolverVector & getNewLumpedMatrix(const ID & matrix_id) override;
/// Get the blocked dofs array
// AKANTU_GET_MACRO(BlockedDOFs, blocked_dofs, const Array<bool> &);
AKANTU_GET_MACRO(MPIComm, mpi_communicator, MPI_Comm);
AKANTU_GET_MACRO_NOT_CONST(ISLocalToGlobalMapping, is_ltog_map,
ISLocalToGlobalMapping &);
SolverVectorPETSc & getSolution();
const SolverVectorPETSc & getSolution() const;
SolverVectorPETSc & getResidual();
const SolverVectorPETSc & getResidual() const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
using PETScMatrixMap = std::map<ID, SparseMatrixPETSc *>;
using PETScLumpedMatrixMap = std::map<ID, SolverVectorPETSc *>;
/// list of matrices registered to the dof manager
PETScMatrixMap petsc_matrices;
/// list of lumped matrices registered
PETScLumpedMatrixMap petsc_lumped_matrices;
/// PETSc local to global mapping of dofs
ISLocalToGlobalMapping is_ltog_map{nullptr};
/// Communicator associated to PETSc
MPI_Comm mpi_communicator;
/// list of the dof ids to be able to always iterate in the same order
std::vector<ID> dofs_ids;
};
/* -------------------------------------------------------------------------- */
} // namespace akantu
#endif /* __AKANTU_DOF_MANAGER_PETSC_HH__ */
diff --git a/src/model/common/integration_scheme/generalized_trapezoidal.cc b/src/model/common/integration_scheme/generalized_trapezoidal.cc
index b60c12009..515c9e7cd 100644
--- a/src/model/common/integration_scheme/generalized_trapezoidal.cc
+++ b/src/model/common/integration_scheme/generalized_trapezoidal.cc
@@ -1,194 +1,194 @@
/**
* @file generalized_trapezoidal.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 23 2015
* @date last modification: Wed Jan 31 2018
*
* @brief implementation of inline functions
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "generalized_trapezoidal.hh"
#include "aka_array.hh"
#include "dof_manager.hh"
#include "mesh.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
GeneralizedTrapezoidal::GeneralizedTrapezoidal(DOFManager & dof_manager,
const ID & dof_id, Real alpha)
: IntegrationScheme1stOrder(dof_manager, dof_id), alpha(alpha) {
this->registerParam("alpha", this->alpha, alpha, _pat_parsmod,
"The alpha parameter");
}
/* -------------------------------------------------------------------------- */
void GeneralizedTrapezoidal::predictor(Real delta_t, Array<Real> & u,
Array<Real> & u_dot,
const Array<bool> & blocked_dofs) const {
AKANTU_DEBUG_IN();
UInt nb_nodes = u.size();
UInt nb_degree_of_freedom = u.getNbComponent() * nb_nodes;
Real * u_val = u.storage();
Real * u_dot_val = u_dot.storage();
bool * blocked_dofs_val = blocked_dofs.storage();
for (UInt d = 0; d < nb_degree_of_freedom; d++) {
if (!(*blocked_dofs_val)) {
*u_val += (1. - alpha) * delta_t * *u_dot_val;
}
u_val++;
u_dot_val++;
blocked_dofs_val++;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void GeneralizedTrapezoidal::corrector(const SolutionType & type, Real delta_t,
Array<Real> & u, Array<Real> & u_dot,
const Array<bool> & blocked_dofs,
const Array<Real> & delta) const {
AKANTU_DEBUG_IN();
switch (type) {
case _temperature:
this->allCorrector<_temperature>(delta_t, u, u_dot, blocked_dofs, delta);
break;
case _temperature_rate:
this->allCorrector<_temperature_rate>(delta_t, u, u_dot, blocked_dofs,
delta);
break;
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real GeneralizedTrapezoidal::getTemperatureCoefficient(
const SolutionType & type, Real delta_t) const {
switch (type) {
case _temperature:
return 1.;
case _temperature_rate:
return alpha * delta_t;
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
}
/* -------------------------------------------------------------------------- */
Real GeneralizedTrapezoidal::getTemperatureRateCoefficient(
const SolutionType & type, Real delta_t) const {
switch (type) {
case _temperature:
return 1. / (alpha * delta_t);
case _temperature_rate:
return 1.;
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
}
/* -------------------------------------------------------------------------- */
template <IntegrationScheme::SolutionType type>
void GeneralizedTrapezoidal::allCorrector(Real delta_t, Array<Real> & u,
Array<Real> & u_dot,
const Array<bool> & blocked_dofs,
const Array<Real> & delta) const {
AKANTU_DEBUG_IN();
UInt nb_nodes = u.size();
UInt nb_degree_of_freedom = u.getNbComponent() * nb_nodes;
Real e = getTemperatureCoefficient(type, delta_t);
Real d = getTemperatureRateCoefficient(type, delta_t);
Real * u_val = u.storage();
Real * u_dot_val = u_dot.storage();
Real * delta_val = delta.storage();
bool * blocked_dofs_val = blocked_dofs.storage();
for (UInt dof = 0; dof < nb_degree_of_freedom; dof++) {
if (!(*blocked_dofs_val)) {
*u_val += e * *delta_val;
*u_dot_val += d * *delta_val;
}
u_val++;
u_dot_val++;
delta_val++;
blocked_dofs_val++;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void GeneralizedTrapezoidal::assembleJacobian(const SolutionType & type,
Real delta_t) {
AKANTU_DEBUG_IN();
SparseMatrix & J = this->dof_manager.getMatrix("J");
const SparseMatrix & M = this->dof_manager.getMatrix("M");
const SparseMatrix & K = this->dof_manager.getMatrix("K");
bool does_j_need_update = false;
does_j_need_update |= M.getRelease() != m_release;
does_j_need_update |= K.getRelease() != k_release;
if (!does_j_need_update) {
AKANTU_DEBUG_OUT();
return;
}
J.copyProfile(K);
- //J.clear();
+ // J.clear();
Real c = this->getTemperatureRateCoefficient(type, delta_t);
Real e = this->getTemperatureCoefficient(type, delta_t);
J.add(M, e);
J.add(K, c);
m_release = M.getRelease();
k_release = K.getRelease();
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
diff --git a/src/model/common/integration_scheme/integration_scheme_1st_order.cc b/src/model/common/integration_scheme/integration_scheme_1st_order.cc
index af6e9d8e0..f3ef667f1 100644
--- a/src/model/common/integration_scheme/integration_scheme_1st_order.cc
+++ b/src/model/common/integration_scheme/integration_scheme_1st_order.cc
@@ -1,96 +1,96 @@
/**
* @file integration_scheme_1st_order.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Implementation of the common functions for 1st order time
* integrations
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "integration_scheme_1st_order.hh"
#include "dof_manager.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
std::vector<std::string> IntegrationScheme1stOrder::getNeededMatrixList() {
return {"K", "M"};
}
/* -------------------------------------------------------------------------- */
void IntegrationScheme1stOrder::predictor(Real delta_t) {
AKANTU_DEBUG_IN();
Array<Real> & u = this->dof_manager.getDOFs(this->dof_id);
Array<Real> & u_dot = this->dof_manager.getDOFsDerivatives(this->dof_id, 1);
const Array<bool> & blocked_dofs =
this->dof_manager.getBlockedDOFs(this->dof_id);
this->predictor(delta_t, u, u_dot, blocked_dofs);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void IntegrationScheme1stOrder::corrector(const SolutionType & type,
Real delta_t) {
AKANTU_DEBUG_IN();
Array<Real> & u = this->dof_manager.getDOFs(this->dof_id);
Array<Real> & u_dot = this->dof_manager.getDOFsDerivatives(this->dof_id, 1);
const Array<Real> & solution = this->dof_manager.getSolution(this->dof_id);
const Array<bool> & blocked_dofs =
this->dof_manager.getBlockedDOFs(this->dof_id);
this->corrector(type, delta_t, u, u_dot, blocked_dofs, solution);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void IntegrationScheme1stOrder::assembleResidual(bool is_lumped) {
AKANTU_DEBUG_IN();
const Array<Real> & first_derivative =
dof_manager.getDOFsDerivatives(this->dof_id, 1);
if (not is_lumped) {
if (this->dof_manager.hasMatrix("M"))
this->dof_manager.assembleMatMulVectToResidual(this->dof_id, "M",
first_derivative, -1);
} else {
if (this->dof_manager.hasLumpedMatrix("M"))
this->dof_manager.assembleLumpedMatMulVectToResidual(
this->dof_id, "M", first_derivative, -1);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/model/common/integration_scheme/integration_scheme_1st_order.hh b/src/model/common/integration_scheme/integration_scheme_1st_order.hh
index 1f77217b6..c6e3fb0bb 100644
--- a/src/model/common/integration_scheme/integration_scheme_1st_order.hh
+++ b/src/model/common/integration_scheme/integration_scheme_1st_order.hh
@@ -1,94 +1,94 @@
/**
* @file integration_scheme_1st_order.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Interface of the time integrator of first order
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "integration_scheme.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_INTEGRATION_SCHEME_1ST_ORDER_HH__
#define __AKANTU_INTEGRATION_SCHEME_1ST_ORDER_HH__
namespace akantu {
class IntegrationScheme1stOrder : public IntegrationScheme {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
IntegrationScheme1stOrder(DOFManager & dof_manager, const ID & dof_id)
: IntegrationScheme(dof_manager, dof_id, 1){};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// get list of needed matrices
std::vector<std::string> getNeededMatrixList() override;
/// generic interface of a predictor
void predictor(Real delta_t) override;
/// generic interface of a corrector
void corrector(const SolutionType & type, Real delta_t) override;
/// assemble the residual
void assembleResidual(bool is_lumped) override;
protected:
/// generic interface of a predictor of 1st order
virtual void predictor(Real delta_t, Array<Real> & u, Array<Real> & u_dot,
const Array<bool> & boundary) const = 0;
/// generic interface of a corrector of 1st order
virtual void corrector(const SolutionType & type, Real delta_t,
Array<Real> & u, Array<Real> & u_dot,
const Array<bool> & boundary,
const Array<Real> & delta) const = 0;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
protected:
virtual Real getTemperatureCoefficient(const SolutionType & type,
Real delta_t) const = 0;
virtual Real getTemperatureRateCoefficient(const SolutionType & type,
Real delta_t) const = 0;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
-} // akantu
+} // namespace akantu
#include "generalized_trapezoidal.hh"
#endif /* __AKANTU_INTEGRATION_SCHEME_1ST_ORDER_HH__ */
diff --git a/src/model/common/integration_scheme/integration_scheme_2nd_order.cc b/src/model/common/integration_scheme/integration_scheme_2nd_order.cc
index 2041da71d..ee1dd2a39 100644
--- a/src/model/common/integration_scheme/integration_scheme_2nd_order.cc
+++ b/src/model/common/integration_scheme/integration_scheme_2nd_order.cc
@@ -1,106 +1,106 @@
/**
* @file integration_scheme_2nd_order.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 23 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Implementation of the common part of 2nd order integration schemes
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "integration_scheme_2nd_order.hh"
#include "dof_manager.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
std::vector<std::string> IntegrationScheme2ndOrder::getNeededMatrixList() {
return {"K", "M", "C"};
}
/* -------------------------------------------------------------------------- */
void IntegrationScheme2ndOrder::predictor(Real delta_t) {
AKANTU_DEBUG_IN();
Array<Real> & u = this->dof_manager.getDOFs(this->dof_id);
Array<Real> & u_dot = this->dof_manager.getDOFsDerivatives(this->dof_id, 1);
Array<Real> & u_dot_dot =
this->dof_manager.getDOFsDerivatives(this->dof_id, 2);
const Array<bool> & blocked_dofs =
this->dof_manager.getBlockedDOFs(this->dof_id);
this->predictor(delta_t, u, u_dot, u_dot_dot, blocked_dofs);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void IntegrationScheme2ndOrder::corrector(const SolutionType & type,
Real delta_t) {
AKANTU_DEBUG_IN();
Array<Real> & u = this->dof_manager.getDOFs(this->dof_id);
Array<Real> & u_dot = this->dof_manager.getDOFsDerivatives(this->dof_id, 1);
Array<Real> & u_dot_dot =
this->dof_manager.getDOFsDerivatives(this->dof_id, 2);
const Array<Real> & solution = this->dof_manager.getSolution(this->dof_id);
const Array<bool> & blocked_dofs =
this->dof_manager.getBlockedDOFs(this->dof_id);
this->corrector(type, delta_t, u, u_dot, u_dot_dot, blocked_dofs, solution);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void IntegrationScheme2ndOrder::assembleResidual(bool is_lumped) {
AKANTU_DEBUG_IN();
if (this->dof_manager.hasMatrix("C")) {
const Array<Real> & first_derivative =
this->dof_manager.getDOFsDerivatives(this->dof_id, 1);
this->dof_manager.assembleMatMulVectToResidual(this->dof_id, "C",
first_derivative, -1);
}
const Array<Real> & second_derivative =
this->dof_manager.getDOFsDerivatives(this->dof_id, 2);
if (not is_lumped) {
this->dof_manager.assembleMatMulVectToResidual(this->dof_id, "M",
second_derivative, -1);
} else {
this->dof_manager.assembleLumpedMatMulVectToResidual(this->dof_id, "M",
second_derivative, -1);
}
-
+
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/common/integration_scheme/integration_scheme_2nd_order.hh b/src/model/common/integration_scheme/integration_scheme_2nd_order.hh
index d171a2e8b..efb38a54b 100644
--- a/src/model/common/integration_scheme/integration_scheme_2nd_order.hh
+++ b/src/model/common/integration_scheme/integration_scheme_2nd_order.hh
@@ -1,107 +1,107 @@
/**
* @file integration_scheme_2nd_order.hh
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Interface of the integrator of second order
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "integration_scheme.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_INTEGRATION_SCHEME_2ND_ORDER_HH__
#define __AKANTU_INTEGRATION_SCHEME_2ND_ORDER_HH__
namespace akantu {
class SparseMatrix;
}
namespace akantu {
class IntegrationScheme2ndOrder : public IntegrationScheme {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
IntegrationScheme2ndOrder(DOFManager & dof_manager, const ID & dof_id)
: IntegrationScheme(dof_manager, dof_id, 2){};
~IntegrationScheme2ndOrder() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// get list of needed matrices
std::vector<std::string> getNeededMatrixList() override;
/// generic interface of a predictor
void predictor(Real delta_t) override;
/// generic interface of a corrector
void corrector(const SolutionType & type, Real delta_t) override;
void assembleResidual(bool is_lumped) override;
protected:
/// generic interface of a predictor of 2nd order
virtual void predictor(Real delta_t, Array<Real> & u, Array<Real> & u_dot,
Array<Real> & u_dot_dot,
const Array<bool> & blocked_dofs) const = 0;
/// generic interface of a corrector of 2nd order
virtual void corrector(const SolutionType & type, Real delta_t,
Array<Real> & u, Array<Real> & u_dot,
Array<Real> & u_dot_dot,
const Array<bool> & blocked_dofs,
const Array<Real> & delta) const = 0;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
protected:
virtual Real getAccelerationCoefficient(const SolutionType & type,
Real delta_t) const = 0;
virtual Real getVelocityCoefficient(const SolutionType & type,
Real delta_t) const = 0;
virtual Real getDisplacementCoefficient(const SolutionType & type,
Real delta_t) const = 0;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
-} // akantu
+} // namespace akantu
#include "newmark-beta.hh"
#endif /* __AKANTU_INTEGRATION_SCHEME_2ND_ORDER_HH__ */
diff --git a/src/model/common/integration_scheme/newmark-beta.cc b/src/model/common/integration_scheme/newmark-beta.cc
index fadc8c8a0..42c561be4 100644
--- a/src/model/common/integration_scheme/newmark-beta.cc
+++ b/src/model/common/integration_scheme/newmark-beta.cc
@@ -1,261 +1,261 @@
/**
* @file newmark-beta.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Oct 23 2015
* @date last modification: Wed Jan 31 2018
*
* @brief implementation of the newmark-@f$\beta@f$ integration scheme. This
* implementation is taken from Méthodes numériques en mécanique des solides by
* Alain Curnier \note{ISBN: 2-88074-247-1}
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "newmark-beta.hh"
#include "dof_manager.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
NewmarkBeta::NewmarkBeta(DOFManager & dof_manager, const ID & dof_id,
Real alpha, Real beta)
: IntegrationScheme2ndOrder(dof_manager, dof_id), beta(beta), alpha(alpha),
k(0.), h(0.), m_release(0), k_release(0), c_release(0) {
this->registerParam("alpha", this->alpha, alpha, _pat_parsmod,
"The alpha parameter");
this->registerParam("beta", this->beta, beta, _pat_parsmod,
"The beta parameter");
}
/* -------------------------------------------------------------------------- */
/*
* @f$ \tilde{u_{n+1}} = u_{n} + \Delta t \dot{u}_n + \frac{\Delta t^2}{2}
* \ddot{u}_n @f$
* @f$ \tilde{\dot{u}_{n+1}} = \dot{u}_{n} + \Delta t \ddot{u}_{n} @f$
* @f$ \tilde{\ddot{u}_{n}} = \ddot{u}_{n} @f$
*/
void NewmarkBeta::predictor(Real delta_t, Array<Real> & u, Array<Real> & u_dot,
Array<Real> & u_dot_dot,
const Array<bool> & blocked_dofs) const {
AKANTU_DEBUG_IN();
UInt nb_nodes = u.size();
UInt nb_degree_of_freedom = u.getNbComponent() * nb_nodes;
Real * u_val = u.storage();
Real * u_dot_val = u_dot.storage();
Real * u_dot_dot_val = u_dot_dot.storage();
bool * blocked_dofs_val = blocked_dofs.storage();
for (UInt d = 0; d < nb_degree_of_freedom; d++) {
if (!(*blocked_dofs_val)) {
Real dt_a_n = delta_t * *u_dot_dot_val;
*u_val += (1 - k * alpha) * delta_t * *u_dot_val +
(.5 - h * alpha * beta) * delta_t * dt_a_n;
*u_dot_val = (1 - k) * *u_dot_val + (1 - h * beta) * dt_a_n;
*u_dot_dot_val = (1 - h) * *u_dot_dot_val;
}
u_val++;
u_dot_val++;
u_dot_dot_val++;
blocked_dofs_val++;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NewmarkBeta::corrector(const SolutionType & type, Real delta_t,
Array<Real> & u, Array<Real> & u_dot,
Array<Real> & u_dot_dot,
const Array<bool> & blocked_dofs,
const Array<Real> & delta) const {
AKANTU_DEBUG_IN();
switch (type) {
case _acceleration: {
this->allCorrector<_acceleration>(delta_t, u, u_dot, u_dot_dot,
blocked_dofs, delta);
break;
}
case _velocity: {
this->allCorrector<_velocity>(delta_t, u, u_dot, u_dot_dot, blocked_dofs,
delta);
break;
}
case _displacement: {
this->allCorrector<_displacement>(delta_t, u, u_dot, u_dot_dot,
blocked_dofs, delta);
break;
}
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real NewmarkBeta::getAccelerationCoefficient(const SolutionType & type,
Real delta_t) const {
switch (type) {
case _acceleration:
return 1.;
case _velocity:
return 1. / (beta * delta_t);
case _displacement:
return 1. / (alpha * beta * delta_t * delta_t);
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
}
/* -------------------------------------------------------------------------- */
Real NewmarkBeta::getVelocityCoefficient(const SolutionType & type,
Real delta_t) const {
switch (type) {
case _acceleration:
return beta * delta_t;
case _velocity:
return 1.;
case _displacement:
return 1. / (alpha * delta_t);
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
}
/* -------------------------------------------------------------------------- */
Real NewmarkBeta::getDisplacementCoefficient(const SolutionType & type,
Real delta_t) const {
switch (type) {
case _acceleration:
return alpha * beta * delta_t * delta_t;
case _velocity:
return alpha * delta_t;
case _displacement:
return 1.;
default:
AKANTU_EXCEPTION("The corrector type : "
<< type
<< " is not supported by this type of integration scheme");
}
}
/* -------------------------------------------------------------------------- */
template <IntegrationScheme::SolutionType type>
void NewmarkBeta::allCorrector(Real delta_t, Array<Real> & u,
Array<Real> & u_dot, Array<Real> & u_dot_dot,
const Array<bool> & blocked_dofs,
const Array<Real> & delta) const {
AKANTU_DEBUG_IN();
UInt nb_nodes = u.size();
UInt nb_degree_of_freedom = u.getNbComponent() * nb_nodes;
Real c = getAccelerationCoefficient(type, delta_t);
Real d = getVelocityCoefficient(type, delta_t);
Real e = getDisplacementCoefficient(type, delta_t);
Real * u_val = u.storage();
Real * u_dot_val = u_dot.storage();
Real * u_dot_dot_val = u_dot_dot.storage();
Real * delta_val = delta.storage();
bool * blocked_dofs_val = blocked_dofs.storage();
for (UInt dof = 0; dof < nb_degree_of_freedom; dof++) {
if (!(*blocked_dofs_val)) {
*u_val += e * *delta_val;
*u_dot_val += d * *delta_val;
*u_dot_dot_val += c * *delta_val;
}
u_val++;
u_dot_val++;
u_dot_dot_val++;
delta_val++;
blocked_dofs_val++;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NewmarkBeta::assembleJacobian(const SolutionType & type, Real delta_t) {
AKANTU_DEBUG_IN();
SparseMatrix & J = this->dof_manager.getMatrix("J");
const SparseMatrix & M = this->dof_manager.getMatrix("M");
const SparseMatrix & K = this->dof_manager.getMatrix("K");
bool does_j_need_update = false;
does_j_need_update |= M.getRelease() != m_release;
does_j_need_update |= K.getRelease() != k_release;
if (this->dof_manager.hasMatrix("C")) {
const SparseMatrix & C = this->dof_manager.getMatrix("C");
does_j_need_update |= C.getRelease() != c_release;
}
if (!does_j_need_update) {
AKANTU_DEBUG_OUT();
return;
}
J.copyProfile(K);
- //J.clear();
+ // J.clear();
Real c = this->getAccelerationCoefficient(type, delta_t);
Real e = this->getDisplacementCoefficient(type, delta_t);
if (!(e == 0.)) { // in explicit this coefficient is exactly 0.
J.add(K, e);
}
J.add(M, c);
m_release = M.getRelease();
k_release = K.getRelease();
if (this->dof_manager.hasMatrix("C")) {
Real d = this->getVelocityCoefficient(type, delta_t);
const SparseMatrix & C = this->dof_manager.getMatrix("C");
J.add(C, d);
c_release = C.getRelease();
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/model/common/integration_scheme/pseudo_time.cc b/src/model/common/integration_scheme/pseudo_time.cc
index 5a62f80f1..d4a8e195d 100644
--- a/src/model/common/integration_scheme/pseudo_time.cc
+++ b/src/model/common/integration_scheme/pseudo_time.cc
@@ -1,82 +1,82 @@
/**
* @file pseudo_time.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Feb 19 2016
* @date last modification: Wed Jan 31 2018
*
* @brief Implementation of a really simple integration scheme
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "pseudo_time.hh"
#include "dof_manager.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
PseudoTime::PseudoTime(DOFManager & dof_manager, const ID & dof_id)
: IntegrationScheme(dof_manager, dof_id, 0), k_release(0) {}
/* -------------------------------------------------------------------------- */
std::vector<std::string> PseudoTime::getNeededMatrixList() { return {"K"}; }
/* -------------------------------------------------------------------------- */
void PseudoTime::predictor(Real) {}
/* -------------------------------------------------------------------------- */
void PseudoTime::corrector(const SolutionType &, Real) {
auto & us = this->dof_manager.getDOFs(this->dof_id);
const auto & deltas = this->dof_manager.getSolution(this->dof_id);
const auto & blocked_dofs = this->dof_manager.getBlockedDOFs(this->dof_id);
for (auto && tuple : zip(make_view(us), deltas, make_view(blocked_dofs))) {
auto & u = std::get<0>(tuple);
const auto & delta = std::get<1>(tuple);
const auto & bld = std::get<2>(tuple);
if (not bld)
u += delta;
}
}
/* -------------------------------------------------------------------------- */
void PseudoTime::assembleJacobian(const SolutionType &, Real) {
SparseMatrix & J = this->dof_manager.getMatrix("J");
const SparseMatrix & K = this->dof_manager.getMatrix("K");
if (K.getRelease() == k_release)
return;
J.copyProfile(K);
- //J.clear();
+ // J.clear();
J.add(K);
k_release = K.getRelease();
}
/* -------------------------------------------------------------------------- */
void PseudoTime::assembleResidual(bool) {}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/model/common/model_solver.cc b/src/model/common/model_solver.cc
index e2d824d93..730d4899a 100644
--- a/src/model/common/model_solver.cc
+++ b/src/model/common/model_solver.cc
@@ -1,381 +1,386 @@
/**
* @file model_solver.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Aug 18 2015
* @date last modification: Wed Feb 21 2018
*
* @brief Implementation of ModelSolver
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "model_solver.hh"
#include "dof_manager.hh"
#include "dof_manager_default.hh"
#include "mesh.hh"
#include "non_linear_solver.hh"
#include "time_step_solver.hh"
#if defined(AKANTU_USE_PETSC)
#include "dof_manager_petsc.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T> static T getOptionToType(const std::string & opt_str) {
std::stringstream sstr(opt_str);
T opt;
sstr >> opt;
return opt;
}
/* -------------------------------------------------------------------------- */
ModelSolver::ModelSolver(Mesh & mesh, const ModelType & type, const ID & id,
UInt memory_id,
std::shared_ptr<DOFManager> dof_manager)
: Parsable(ParserType::_model, id), SolverCallback(), model_type(type),
parent_id(id), parent_memory_id(memory_id), mesh(mesh) {
if (not dof_manager) {
initDOFManager();
} else {
this->dof_manager = dof_manager;
this->setDOFManager(*this->dof_manager);
}
}
/* -------------------------------------------------------------------------- */
ModelSolver::~ModelSolver() = default;
/* -------------------------------------------------------------------------- */
std::tuple<ParserSection, bool> ModelSolver::getParserSection() {
auto sub_sections = getStaticParser().getSubSections(ParserType::_model);
auto it = std::find_if(
sub_sections.begin(), sub_sections.end(), [&](auto && section) {
ModelType type = getOptionToType<ModelType>(section.getName());
// default id should be the model type if not defined
std::string name = section.getParameter("name", this->parent_id);
return type == model_type and name == this->parent_id;
});
if (it == sub_sections.end())
return std::make_tuple(ParserSection(), true);
return std::make_tuple(*it, false);
}
/* -------------------------------------------------------------------------- */
void ModelSolver::initDOFManager() {
// default without external solver activated at compilation same as mumps that
// is the historical solver but with only the lumped solver
ID solver_type = "default";
#if defined(AKANTU_USE_MUMPS)
solver_type = "default";
#elif defined(AKANTU_USE_PETSC)
solver_type = "petsc";
#endif
ParserSection section;
bool is_empty;
std::tie(section, is_empty) = this->getParserSection();
if (not is_empty) {
solver_type = section.getOption(solver_type);
this->initDOFManager(section, solver_type);
} else {
this->initDOFManager(solver_type);
}
}
/* -------------------------------------------------------------------------- */
void ModelSolver::initDOFManager(const ID & solver_type) {
if (dof_manager) {
AKANTU_EXCEPTION("The DOF manager for this model is already initialized !");
}
try {
this->dof_manager = DOFManagerFactory::getInstance().allocate(
solver_type, mesh, this->parent_id + ":dof_manager_" + solver_type,
this->parent_memory_id);
} catch (...) {
AKANTU_EXCEPTION(
"To use the solver "
<< solver_type
<< " you will have to code it. This is an unknown solver type.");
}
this->setDOFManager(*this->dof_manager);
}
/* -------------------------------------------------------------------------- */
void ModelSolver::initDOFManager(const ParserSection & section,
const ID & solver_type) {
this->initDOFManager(solver_type);
auto sub_sections = section.getSubSections(ParserType::_time_step_solver);
// parsing the time step solvers
for (auto && section : sub_sections) {
ID type = section.getName();
ID solver_id = section.getParameter("name", type);
auto tss_type = getOptionToType<TimeStepSolverType>(type);
auto tss_options = this->getDefaultSolverOptions(tss_type);
auto sub_solvers_sect =
section.getSubSections(ParserType::_non_linear_solver);
auto nb_non_linear_solver_section =
section.getNbSubSections(ParserType::_non_linear_solver);
auto nls_type = tss_options.non_linear_solver_type;
if (nb_non_linear_solver_section == 1) {
auto && nls_section = *(sub_solvers_sect.first);
nls_type = getOptionToType<NonLinearSolverType>(nls_section.getName());
} else if (nb_non_linear_solver_section > 0) {
AKANTU_EXCEPTION("More than one non linear solver are provided for the "
"time step solver "
<< solver_id);
}
this->getNewSolver(solver_id, tss_type, nls_type);
if (nb_non_linear_solver_section == 1) {
const auto & nls_section = *(sub_solvers_sect.first);
this->dof_manager->getNonLinearSolver(solver_id).parseSection(
nls_section);
}
auto sub_integrator_sections =
section.getSubSections(ParserType::_integration_scheme);
for (auto && is_section : sub_integrator_sections) {
const auto & dof_type_str = is_section.getName();
ID dof_id;
try {
ID tmp = is_section.getParameter("name");
dof_id = tmp;
} catch (...) {
AKANTU_EXCEPTION("No degree of freedom name specified for the "
"integration scheme of type "
<< dof_type_str);
}
auto it_type = getOptionToType<IntegrationSchemeType>(dof_type_str);
IntegrationScheme::SolutionType s_type = is_section.getParameter(
"solution_type", tss_options.solution_type[dof_id]);
this->setIntegrationScheme(solver_id, dof_id, it_type, s_type);
}
for (auto & is_type : tss_options.integration_scheme_type) {
if (!this->hasIntegrationScheme(solver_id, is_type.first)) {
this->setIntegrationScheme(solver_id, is_type.first, is_type.second,
tss_options.solution_type[is_type.first]);
}
}
}
if (section.hasParameter("default_solver")) {
ID default_solver = section.getParameter("default_solver");
if (this->hasSolver(default_solver)) {
this->setDefaultSolver(default_solver);
} else
AKANTU_EXCEPTION(
"The solver \""
<< default_solver
<< "\" was not created, it cannot be set as default solver");
}
}
/* -------------------------------------------------------------------------- */
TimeStepSolver & ModelSolver::getSolver(const ID & solver_id) {
ID tmp_solver_id = solver_id;
if (tmp_solver_id == "")
tmp_solver_id = this->default_solver_id;
TimeStepSolver & tss = this->dof_manager->getTimeStepSolver(tmp_solver_id);
return tss;
}
/* -------------------------------------------------------------------------- */
const TimeStepSolver & ModelSolver::getSolver(const ID & solver_id) const {
ID tmp_solver_id = solver_id;
if (solver_id == "")
tmp_solver_id = this->default_solver_id;
const TimeStepSolver & tss =
this->dof_manager->getTimeStepSolver(tmp_solver_id);
return tss;
}
/* -------------------------------------------------------------------------- */
TimeStepSolver & ModelSolver::getTimeStepSolver(const ID & solver_id) {
return this->getSolver(solver_id);
}
/* -------------------------------------------------------------------------- */
const TimeStepSolver &
ModelSolver::getTimeStepSolver(const ID & solver_id) const {
return this->getSolver(solver_id);
}
/* -------------------------------------------------------------------------- */
NonLinearSolver & ModelSolver::getNonLinearSolver(const ID & solver_id) {
return this->getSolver(solver_id).getNonLinearSolver();
}
/* -------------------------------------------------------------------------- */
const NonLinearSolver &
ModelSolver::getNonLinearSolver(const ID & solver_id) const {
return this->getSolver(solver_id).getNonLinearSolver();
}
/* -------------------------------------------------------------------------- */
bool ModelSolver::hasSolver(const ID & solver_id) const {
ID tmp_solver_id = solver_id;
if (solver_id == "")
tmp_solver_id = this->default_solver_id;
if (not this->dof_manager) {
AKANTU_EXCEPTION("No DOF manager was initialized");
}
return this->dof_manager->hasTimeStepSolver(tmp_solver_id);
}
/* -------------------------------------------------------------------------- */
void ModelSolver::setDefaultSolver(const ID & solver_id) {
AKANTU_DEBUG_ASSERT(
this->hasSolver(solver_id),
"Cannot set the default solver to a solver that does not exists");
this->default_solver_id = solver_id;
}
/* -------------------------------------------------------------------------- */
void ModelSolver::solveStep(const ID & solver_id) {
solveStep(*this, solver_id);
}
/* -------------------------------------------------------------------------- */
void ModelSolver::solveStep(SolverCallback & callback, const ID & solver_id) {
AKANTU_DEBUG_IN();
TimeStepSolver & tss = this->getSolver(solver_id);
// make one non linear solve
tss.solveStep(callback);
AKANTU_DEBUG_OUT();
}
+/* -------------------------------------------------------------------------- */
+void ModelSolver::solveStep(const ID & solver_id) {
+ solveStep(*this, solver_id);
+}
+
/* -------------------------------------------------------------------------- */
void ModelSolver::getNewSolver(const ID & solver_id,
TimeStepSolverType time_step_solver_type,
NonLinearSolverType non_linear_solver_type) {
if (this->default_solver_id == "") {
this->default_solver_id = solver_id;
}
if (non_linear_solver_type == NonLinearSolverType::_auto) {
switch (time_step_solver_type) {
case TimeStepSolverType::_dynamic:
case TimeStepSolverType::_static:
non_linear_solver_type = NonLinearSolverType::_newton_raphson;
break;
case TimeStepSolverType::_dynamic_lumped:
non_linear_solver_type = NonLinearSolverType::_lumped;
break;
case TimeStepSolverType::_not_defined:
AKANTU_EXCEPTION(time_step_solver_type
<< " is not a valid time step solver type");
break;
}
}
this->initSolver(time_step_solver_type, non_linear_solver_type);
NonLinearSolver & nls = this->dof_manager->getNewNonLinearSolver(
solver_id, non_linear_solver_type);
- this->dof_manager->getNewTimeStepSolver(solver_id, time_step_solver_type,
- nls, *this);
+ this->dof_manager->getNewTimeStepSolver(solver_id, time_step_solver_type, nls,
+ *this);
}
/* -------------------------------------------------------------------------- */
Real ModelSolver::getTimeStep(const ID & solver_id) const {
const TimeStepSolver & tss = this->getSolver(solver_id);
return tss.getTimeStep();
}
/* -------------------------------------------------------------------------- */
void ModelSolver::setTimeStep(Real time_step, const ID & solver_id) {
TimeStepSolver & tss = this->getSolver(solver_id);
return tss.setTimeStep(time_step);
}
/* -------------------------------------------------------------------------- */
void ModelSolver::setIntegrationScheme(
const ID & solver_id, const ID & dof_id,
const IntegrationSchemeType & integration_scheme_type,
IntegrationScheme::SolutionType solution_type) {
TimeStepSolver & tss = this->dof_manager->getTimeStepSolver(solver_id);
tss.setIntegrationScheme(dof_id, integration_scheme_type, solution_type);
}
/* -------------------------------------------------------------------------- */
bool ModelSolver::hasDefaultSolver() const {
return (this->default_solver_id != "");
}
/* -------------------------------------------------------------------------- */
bool ModelSolver::hasIntegrationScheme(const ID & solver_id,
const ID & dof_id) const {
TimeStepSolver & tss = this->dof_manager->getTimeStepSolver(solver_id);
return tss.hasIntegrationScheme(dof_id);
}
/* -------------------------------------------------------------------------- */
void ModelSolver::predictor() {}
/* -------------------------------------------------------------------------- */
void ModelSolver::corrector() {}
/* -------------------------------------------------------------------------- */
TimeStepSolverType ModelSolver::getDefaultSolverType() const {
return TimeStepSolverType::_dynamic_lumped;
}
/* -------------------------------------------------------------------------- */
ModelSolverOptions
ModelSolver::getDefaultSolverOptions(__attribute__((unused))
const TimeStepSolverType & type) const {
ModelSolverOptions options;
options.non_linear_solver_type = NonLinearSolverType::_auto;
return options;
}
} // namespace akantu
diff --git a/src/model/common/non_linear_solver/non_linear_solver.hh b/src/model/common/non_linear_solver/non_linear_solver.hh
index 9ff9e5af5..66a33a43e 100644
--- a/src/model/common/non_linear_solver/non_linear_solver.hh
+++ b/src/model/common/non_linear_solver/non_linear_solver.hh
@@ -1,113 +1,113 @@
/**
* @file non_linear_solver.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Non linear solver interface
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_memory.hh"
#include "parsable.hh"
/* -------------------------------------------------------------------------- */
#include <set>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NON_LINEAR_SOLVER_HH__
#define __AKANTU_NON_LINEAR_SOLVER_HH__
namespace akantu {
class DOFManager;
class SolverCallback;
} // namespace akantu
namespace akantu {
class NonLinearSolver : private Memory, public Parsable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NonLinearSolver(DOFManager & dof_manager,
const NonLinearSolverType & non_linear_solver_type,
const ID & id = "non_linear_solver", UInt memory_id = 0);
~NonLinearSolver() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// solve the system described by the jacobian matrix, and rhs contained in
/// the dof manager
virtual void solve(SolverCallback & callback) = 0;
/// intercept the call to set for options
template <typename T> void set(const ID & param, T && t) {
- if(has_internal_set_param) {
+ if (has_internal_set_param) {
set_param(param, std::to_string(t));
- } else {
+ } else {
ParameterRegistry::set(param, t);
}
}
protected:
void checkIfTypeIsSupported();
void assembleResidual(SolverCallback & callback);
/// internal set param for solvers that should intercept the parameters
virtual void set_param(const ID & /*param*/, const std::string & /*value*/) {}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
DOFManager & _dof_manager;
/// type of non linear solver
NonLinearSolverType non_linear_solver_type;
/// list of supported non linear solver types
std::set<NonLinearSolverType> supported_type;
/// specifies if the set param should be redirected
bool has_internal_set_param{false};
};
namespace debug {
class NLSNotConvergedException : public Exception {
public:
NLSNotConvergedException(Real threshold, UInt niter, Real error)
: Exception("The non linear solver did not converge."),
threshold(threshold), niter(niter), error(error) {}
Real threshold;
UInt niter;
Real error;
};
} // namespace debug
} // namespace akantu
#endif /* __AKANTU_NON_LINEAR_SOLVER_HH__ */
diff --git a/src/model/common/non_linear_solver/non_linear_solver_linear.cc b/src/model/common/non_linear_solver/non_linear_solver_linear.cc
index ebeceda92..84f969a63 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_linear.cc
+++ b/src/model/common/non_linear_solver/non_linear_solver_linear.cc
@@ -1,74 +1,74 @@
/**
* @file non_linear_solver_linear.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jul 20 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Implementation of the default NonLinearSolver
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver_linear.hh"
#include "dof_manager_default.hh"
#include "solver_callback.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
NonLinearSolverLinear::NonLinearSolverLinear(
DOFManagerDefault & dof_manager,
const NonLinearSolverType & non_linear_solver_type, const ID & id,
UInt memory_id)
: NonLinearSolver(dof_manager, non_linear_solver_type, id, memory_id),
dof_manager(dof_manager),
solver(dof_manager, "J", id + ":sparse_solver", memory_id) {
this->supported_type.insert(NonLinearSolverType::_linear);
this->checkIfTypeIsSupported();
}
/* -------------------------------------------------------------------------- */
NonLinearSolverLinear::~NonLinearSolverLinear() = default;
/* ------------------------------------------------------------------------ */
void NonLinearSolverLinear::solve(SolverCallback & solver_callback) {
this->dof_manager.updateGlobalBlockedDofs();
solver_callback.predictor();
solver_callback.assembleMatrix("J");
// Residual computed after J to allow the model to use K to compute the
// residual
this->assembleResidual(solver_callback);
this->solver.solve();
solver_callback.corrector();
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/model/common/non_linear_solver/non_linear_solver_linear.hh b/src/model/common/non_linear_solver/non_linear_solver_linear.hh
index 155fb8246..d5dd66047 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_linear.hh
+++ b/src/model/common/non_linear_solver/non_linear_solver_linear.hh
@@ -1,80 +1,80 @@
/**
* @file non_linear_solver_linear.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Default implementation of NonLinearSolver, in case no external
* library
* is there to do the job
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver.hh"
#include "sparse_solver_mumps.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NON_LINEAR_SOLVER_LINEAR_HH__
#define __AKANTU_NON_LINEAR_SOLVER_LINEAR_HH__
namespace akantu {
class DOFManagerDefault;
}
namespace akantu {
class NonLinearSolverLinear : public NonLinearSolver {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NonLinearSolverLinear(DOFManagerDefault & dof_manager,
const NonLinearSolverType & non_linear_solver_type,
const ID & id = "non_linear_solver_linear",
UInt memory_id = 0);
~NonLinearSolverLinear() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// Function that solve the non linear system described by the dof manager and
/// the solver callback functions
void solve(SolverCallback & solver_callback) override;
AKANTU_GET_MACRO_NOT_CONST(Solver, solver, SparseSolverMumps &);
AKANTU_GET_MACRO(Solver, solver, const SparseSolverMumps &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
DOFManagerDefault & dof_manager;
/// Sparse solver used for the linear solves
SparseSolverMumps solver;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_NON_LINEAR_SOLVER_LINEAR_HH__ */
diff --git a/src/model/common/non_linear_solver/non_linear_solver_lumped.cc b/src/model/common/non_linear_solver/non_linear_solver_lumped.cc
index 1b665d709..632841e17 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_lumped.cc
+++ b/src/model/common/non_linear_solver/non_linear_solver_lumped.cc
@@ -1,102 +1,101 @@
/**
* @file non_linear_solver_lumped.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Feb 16 2016
* @date last modification: Wed Jan 31 2018
*
* @brief Implementation of the default NonLinearSolver
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver_lumped.hh"
#include "communicator.hh"
#include "dof_manager_default.hh"
#include "solver_callback.hh"
#include "solver_vector_default.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
NonLinearSolverLumped::NonLinearSolverLumped(
DOFManagerDefault & dof_manager,
const NonLinearSolverType & non_linear_solver_type, const ID & id,
UInt memory_id)
: NonLinearSolver(dof_manager, non_linear_solver_type, id, memory_id),
dof_manager(dof_manager) {
this->supported_type.insert(NonLinearSolverType::_lumped);
this->checkIfTypeIsSupported();
this->registerParam("b_a2x", this->alpha, 1., _pat_parsmod,
"Conversion coefficient between x and A^{-1} b");
}
/* -------------------------------------------------------------------------- */
NonLinearSolverLumped::~NonLinearSolverLumped() = default;
/* ------------------------------------------------------------------------ */
void NonLinearSolverLumped::solve(SolverCallback & solver_callback) {
this->dof_manager.updateGlobalBlockedDofs();
solver_callback.predictor();
solver_callback.assembleResidual();
-
- auto & x =
- aka::as_type<SolverVectorDefault>(this->dof_manager.getSolution());
+
+ auto & x = aka::as_type<SolverVectorDefault>(this->dof_manager.getSolution());
const auto & b = this->dof_manager.getResidual();
x.resize();
const auto & blocked_dofs = this->dof_manager.getBlockedDOFs();
const auto & A = this->dof_manager.getLumpedMatrix("M");
// alpha is the conversion factor from from force/mass to acceleration needed
// in model coupled with atomistic \todo find a way to define alpha per dof
// type
this->solveLumped(A, x, b, alpha, blocked_dofs);
this->dof_manager.splitSolutionPerDOFs();
solver_callback.corrector();
}
/* -------------------------------------------------------------------------- */
void NonLinearSolverLumped::solveLumped(const Array<Real> & A, Array<Real> & x,
const Array<Real> & b, Real alpha,
const Array<bool> & blocked_dofs) {
for (auto && data :
zip(make_view(A), make_view(x), make_view(b), make_view(blocked_dofs))) {
const auto & A = std::get<0>(data);
auto & x = std::get<1>(data);
const auto & b = std::get<2>(data);
const auto & blocked = std::get<3>(data);
if (not blocked) {
x = alpha * (b / A);
}
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/common/non_linear_solver/non_linear_solver_newton_raphson.hh b/src/model/common/non_linear_solver/non_linear_solver_newton_raphson.hh
index b6287de2a..8e4829892 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_newton_raphson.hh
+++ b/src/model/common/non_linear_solver/non_linear_solver_newton_raphson.hh
@@ -1,107 +1,107 @@
/**
* @file non_linear_solver_newton_raphson.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Default implementation of NonLinearSolver, in case no external
* library
* is there to do the job
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NON_LINEAR_SOLVER_NEWTON_RAPHSON_HH__
#define __AKANTU_NON_LINEAR_SOLVER_NEWTON_RAPHSON_HH__
namespace akantu {
class DOFManagerDefault;
class SparseSolverMumps;
class SolverVector;
-}
+} // namespace akantu
namespace akantu {
class NonLinearSolverNewtonRaphson : public NonLinearSolver {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NonLinearSolverNewtonRaphson(
DOFManagerDefault & dof_manager,
const NonLinearSolverType & non_linear_solver_type,
const ID & id = "non_linear_solver_newton_raphson", UInt memory_id = 0);
~NonLinearSolverNewtonRaphson() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// Function that solve the non linear system described by the dof manager and
/// the solver callback functions
void solve(SolverCallback & solver_callback) override;
AKANTU_GET_MACRO_NOT_CONST(Solver, *solver, SparseSolverMumps &);
AKANTU_GET_MACRO(Solver, *solver, const SparseSolverMumps &);
protected:
/// test the convergence compare norm of array to convergence_criteria
bool testConvergence(const SolverVector & array);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
DOFManagerDefault & dof_manager;
/// Sparse solver used for the linear solves
std::unique_ptr<SparseSolverMumps> solver;
/// Type of convergence criteria
SolveConvergenceCriteria convergence_criteria_type;
/// convergence threshold
Real convergence_criteria;
/// Max number of iterations
int max_iterations;
/// Number of iterations at last solve call
int n_iter{0};
/// Convergence error at last solve call
Real error{0.};
/// Did the last call to solve reached convergence
bool converged{false};
/// Force a re-computation of the jacobian matrix
bool force_linear_recompute{true};
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_NON_LINEAR_SOLVER_NEWTON_RAPHSON_HH__ */
diff --git a/src/model/common/non_linear_solver/non_linear_solver_petsc.cc b/src/model/common/non_linear_solver/non_linear_solver_petsc.cc
index cdeb04ac3..e7a9be640 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_petsc.cc
+++ b/src/model/common/non_linear_solver/non_linear_solver_petsc.cc
@@ -1,208 +1,207 @@
/**
* @file non_linear_solver_petsc.cc
*
* @author Nicolas Richart
*
* @date creation Mon Dec 31 2018
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver_petsc.hh"
#include "dof_manager_petsc.hh"
#include "mpi_communicator_data.hh"
#include "solver_callback.hh"
#include "solver_vector_petsc.hh"
#include "sparse_matrix_petsc.hh"
/* -------------------------------------------------------------------------- */
#include <petscoptions.h>
/* -------------------------------------------------------------------------- */
namespace akantu {
NonLinearSolverPETSc::NonLinearSolverPETSc(
DOFManagerPETSc & dof_manager,
const NonLinearSolverType & non_linear_solver_type, const ID & id,
UInt memory_id)
: NonLinearSolver(dof_manager, non_linear_solver_type, id, memory_id),
dof_manager(dof_manager) {
std::unordered_map<NonLinearSolverType, SNESType>
petsc_non_linear_solver_types{
{NonLinearSolverType::_newton_raphson, SNESNEWTONLS},
{NonLinearSolverType::_linear, SNESKSPONLY},
{NonLinearSolverType::_gmres, SNESNGMRES},
{NonLinearSolverType::_bfgs, SNESQN},
{NonLinearSolverType::_cg, SNESNCG}};
this->has_internal_set_param = true;
for (const auto & pair : petsc_non_linear_solver_types) {
supported_type.insert(pair.first);
}
this->checkIfTypeIsSupported();
auto mpi_comm = dof_manager.getMPIComm();
PETSc_call(SNESCreate, mpi_comm, &snes);
auto it = petsc_non_linear_solver_types.find(non_linear_solver_type);
if (it != petsc_non_linear_solver_types.end()) {
PETSc_call(SNESSetType, snes, it->second);
}
SNESSetFromOptions(snes);
}
/* -------------------------------------------------------------------------- */
NonLinearSolverPETSc::~NonLinearSolverPETSc() {
PETSc_call(SNESDestroy, &snes);
}
/* -------------------------------------------------------------------------- */
class NonLinearSolverPETScCallback {
public:
NonLinearSolverPETScCallback(DOFManagerPETSc & dof_manager,
SolverVectorPETSc & x)
: dof_manager(dof_manager), x(x), x_prev(x, "previous_solution") {}
void corrector() {
auto & dx = dof_manager.getSolution();
PETSc_call(VecWAXPY, dx, -1., x_prev, x);
dof_manager.splitSolutionPerDOFs();
callback->corrector();
PETSc_call(VecCopy, x, x_prev);
}
void assembleResidual() {
corrector();
callback->assembleResidual();
}
void assembleJacobian() {
- //corrector();
+ // corrector();
callback->assembleMatrix("J");
}
void setInitialSolution(SolverVectorPETSc & x) {
PETSc_call(VecCopy, x, x_prev);
}
void setCallback(SolverCallback & callback) { this->callback = &callback; }
private:
// SNES & snes;
SolverCallback * callback;
DOFManagerPETSc & dof_manager;
SolverVectorPETSc & x;
SolverVectorPETSc x_prev;
}; // namespace akantu
/* -------------------------------------------------------------------------- */
PetscErrorCode NonLinearSolverPETSc::FormFunction(SNES /*snes*/, Vec /*dx*/,
Vec /*f*/, void * ctx) {
auto * _this = reinterpret_cast<NonLinearSolverPETScCallback *>(ctx);
_this->assembleResidual();
return 0;
}
/* -------------------------------------------------------------------------- */
PetscErrorCode NonLinearSolverPETSc::FormJacobian(SNES /*snes*/, Vec /*dx*/,
Mat /*J*/, Mat /*P*/,
void * ctx) {
auto * _this = reinterpret_cast<NonLinearSolverPETScCallback *>(ctx);
_this->assembleJacobian();
return 0;
}
/* -------------------------------------------------------------------------- */
void NonLinearSolverPETSc::solve(SolverCallback & callback) {
this->dof_manager.updateGlobalBlockedDofs();
callback.assembleMatrix("J");
auto & global_x = dof_manager.getSolution();
global_x.clear();
-
+
if (not x) {
x = std::make_unique<SolverVectorPETSc>(global_x, "temporary_solution");
}
*x = global_x;
-
+
if (not ctx) {
ctx = std::make_unique<NonLinearSolverPETScCallback>(dof_manager, *x);
}
-
+
ctx->setCallback(callback);
ctx->setInitialSolution(global_x);
-
+
auto & rhs = dof_manager.getResidual();
auto & J = dof_manager.getMatrix("J");
-
+
PETSc_call(SNESSetFunction, snes, rhs, NonLinearSolverPETSc::FormFunction,
ctx.get());
PETSc_call(SNESSetJacobian, snes, J, J, NonLinearSolverPETSc::FormJacobian,
ctx.get());
rhs.clear();
callback.predictor();
callback.assembleResidual();
PETSc_call(SNESSolve, snes, nullptr, *x);
PETSc_call(VecAXPY, global_x, -1.0, *x);
-
dof_manager.splitSolutionPerDOFs();
callback.corrector();
}
/* -------------------------------------------------------------------------- */
void NonLinearSolverPETSc::set_param(const ID & param,
const std::string & value) {
std::map<ID, ID> akantu_to_petsc_option = {{"max_iterations", "snes_max_it"},
{"threshold", "snes_stol"}};
auto it = akantu_to_petsc_option.find(param);
auto p = it == akantu_to_petsc_option.end() ? param : it->second;
PetscOptionsSetValue(NULL, p.c_str(), value.c_str());
SNESSetFromOptions(snes);
PetscOptionsClear(NULL);
}
/* -------------------------------------------------------------------------- */
void NonLinearSolverPETSc::parseSection(const ParserSection & section) {
auto parameters = section.getParameters();
for (auto && param : range(parameters.first, parameters.second)) {
PetscOptionsSetValue(NULL, param.getName().c_str(),
param.getValue().c_str());
}
SNESSetFromOptions(snes);
PetscOptionsClear(NULL);
}
} // namespace akantu
diff --git a/src/model/common/non_linear_solver/non_linear_solver_petsc.hh b/src/model/common/non_linear_solver/non_linear_solver_petsc.hh
index 2c711d12c..88873ab62 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_petsc.hh
+++ b/src/model/common/non_linear_solver/non_linear_solver_petsc.hh
@@ -1,94 +1,93 @@
/**
* @file non_linear_solver_petsc.hh
*
* @author Nicolas Richart
*
* @date creation Tue Jan 01 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver.hh"
/* -------------------------------------------------------------------------- */
#include <petscsnes.h>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NON_LINEAR_SOLVER_PETSC_HH__
#define __AKANTU_NON_LINEAR_SOLVER_PETSC_HH__
namespace akantu {
class DOFManagerPETSc;
class NonLinearSolverPETScCallback;
class SolverVectorPETSc;
-} // namespace akanatu
+} // namespace akantu
namespace akantu {
class NonLinearSolverPETSc : public NonLinearSolver {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NonLinearSolverPETSc(DOFManagerPETSc & dof_manager,
const NonLinearSolverType & non_linear_solver_type,
const ID & id = "non_linear_solver_petsc",
UInt memory_id = 0);
~NonLinearSolverPETSc() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// solve the system described by the jacobian matrix, and rhs contained in
/// the dof manager
void solve(SolverCallback & callback) override;
/// parse the arguments from the input file
void parseSection(const ParserSection & section) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
- static PetscErrorCode FormFunction(SNES snes, Vec dx, Vec f,
+ static PetscErrorCode FormFunction(SNES snes, Vec dx, Vec f, void * ctx);
+ static PetscErrorCode FormJacobian(SNES snes, Vec dx, Mat J, Mat P,
void * ctx);
- static PetscErrorCode FormJacobian(SNES snes, Vec dx, Mat J,
- Mat P, void * ctx);
-
+
void set_param(const ID & param, const std::string & value) override;
-
+
DOFManagerPETSc & dof_manager;
/// PETSc non linear solver
SNES snes;
SolverCallback * callback{nullptr};
std::unique_ptr<SolverVectorPETSc> x;
std::unique_ptr<NonLinearSolverPETScCallback> ctx;
-
+
Int n_iter{0};
};
-} // namepsace akantu
+} // namespace akantu
#endif /* __AKANTU_NON_LINEAR_SOLVER_PETSC_HH__ */
diff --git a/src/model/common/non_local_toolbox/base_weight_function_inline_impl.cc b/src/model/common/non_local_toolbox/base_weight_function_inline_impl.cc
index d80ccb2cf..ca0694f35 100644
--- a/src/model/common/non_local_toolbox/base_weight_function_inline_impl.cc
+++ b/src/model/common/non_local_toolbox/base_weight_function_inline_impl.cc
@@ -1,71 +1,71 @@
/**
* @file base_weight_function_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Cyprien Wolff <cyprien.wolff@epfl.ch>
*
* @date creation: Wed Sep 01 2010
* @date last modification: Wed Sep 27 2017
*
* @brief Implementation of inline function of base weight function
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "base_weight_function.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_BASE_WEIGHT_FUNCTION_INLINE_IMPL_CC__
#define __AKANTU_BASE_WEIGHT_FUNCTION_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline void BaseWeightFunction::init() {
/// compute R^2 for a given non-local radius
this->R2 = this->R * this->R;
}
/* -------------------------------------------------------------------------- */
inline void BaseWeightFunction::setRadius(Real radius) {
/// set the non-local radius and update R^2 accordingly
this->R = radius;
this->R2 = this->R * this->R;
}
/* -------------------------------------------------------------------------- */
inline Real BaseWeightFunction::operator()(Real r, const IntegrationPoint &,
const IntegrationPoint &) {
/// initialize the weight
Real w = 0;
/// compute weight for given r
if (r <= this->R) {
Real alpha = (1. - r * r / this->R2);
w = alpha * alpha;
// *weight = 1 - sqrt(r / radius);
}
return w;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_BASE_WEIGHT_FUNCTION_INLINE_IMPL_CC__ */
diff --git a/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.hh b/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.hh
index 8ff079040..049f2aaaa 100644
--- a/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.hh
+++ b/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion.hh
@@ -1,117 +1,117 @@
/**
* @file neighborhood_max_criterion.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @date creation: Sat Sep 26 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Neighborhood to find a maximum value in a neighborhood
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NEIGHBORHOOD_MAX_CRITERION_BASE_HH__
#define __AKANTU_NEIGHBORHOOD_MAX_CRITERION_BASE_HH__
/* -------------------------------------------------------------------------- */
#include "neighborhood_base.hh"
#include "parsable.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class NeighborhoodMaxCriterion : public NeighborhoodBase, public Parsable {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
NeighborhoodMaxCriterion(Model & model,
const ElementTypeMapReal & quad_coordinates,
const ID & criterion_id,
const ID & id = "neighborhood_max_criterion",
const MemoryID & memory_id = 0);
~NeighborhoodMaxCriterion() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the neighborhood
void initNeighborhood() override;
/// create grid synchronizer and exchange ghost cells
void createGridSynchronizer() override;
/// find the quads which have the maximum criterion in their neighborhood
void findMaxQuads(std::vector<IntegrationPoint> & max_quads);
protected:
/// remove unneccessary ghost elements
void
cleanupExtraGhostElements(const ElementTypeMap<UInt> & nb_ghost_protected);
/// insert the quadrature points in the grid
void insertAllQuads(const GhostType & ghost_type);
/// compare criterion with neighbors
void checkNeighbors(const GhostType & ghost_type);
/* --------------------------------------------------------------------------
*/
/* DataAccessor inherited members */
/* --------------------------------------------------------------------------
*/
public:
virtual inline UInt getNbDataForElements(const Array<Element> & elements,
SynchronizationTag tag) const;
virtual inline void packElementData(CommunicationBuffer & buffer,
const Array<Element> & elements,
SynchronizationTag tag) const;
virtual inline void unpackElementData(CommunicationBuffer & buffer,
const Array<Element> & elements,
SynchronizationTag tag);
/* --------------------------------------------------------------------------
*/
/* Accessors */
/* --------------------------------------------------------------------------
*/
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// a boolean to store the information if a quad has the max
/// criterion in the neighborhood
ElementTypeMapArray<bool> is_highest;
/// an element type map to store the flattened internal of the criterion
ElementTypeMapReal criterion;
};
-} // akantu
+} // namespace akantu
#include "neighborhood_max_criterion_inline_impl.cc"
#endif /* __AKANTU_NEIGHBORHOOD_MAX_CRITERION_BASE_HH__ */
diff --git a/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion_inline_impl.cc b/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion_inline_impl.cc
index 3d4128e13..cd8903c27 100644
--- a/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion_inline_impl.cc
+++ b/src/model/common/non_local_toolbox/neighborhoods_criterion_evaluation/neighborhood_max_criterion_inline_impl.cc
@@ -1,82 +1,82 @@
/**
* @file neighborhood_max_criterion_inline_impl.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sat Sep 26 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Implementation of inline functions for class NeighborhoodMaxCriterion
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "model.hh"
#include "neighborhood_max_criterion.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NEIGHBORHOOD_MAX_CRITERION_INLINE_IMPL_CC__
#define __AKANTU_NEIGHBORHOOD_MAX_CRITERION_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline UInt
NeighborhoodMaxCriterion::getNbDataForElements(const Array<Element> & elements,
SynchronizationTag tag) const {
UInt nb_quadrature_points = this->model.getNbIntegrationPoints(elements);
UInt size = 0;
if (tag == SynchronizationTag::_nh_criterion) {
size += sizeof(Real) * nb_quadrature_points;
}
return size;
}
/* -------------------------------------------------------------------------- */
inline void
NeighborhoodMaxCriterion::packElementData(CommunicationBuffer & buffer,
const Array<Element> & elements,
SynchronizationTag tag) const {
if (tag == SynchronizationTag::_nh_criterion) {
this->packElementalDataHelper(criterion, buffer, elements, true,
this->model.getFEEngine());
}
}
/* -------------------------------------------------------------------------- */
inline void
NeighborhoodMaxCriterion::unpackElementData(CommunicationBuffer & buffer,
const Array<Element> & elements,
SynchronizationTag tag) {
if (tag == SynchronizationTag::_nh_criterion) {
this->unpackElementalDataHelper(criterion, buffer, elements, true,
this->model.getFEEngine());
}
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_NEIGHBORHOOD_MAX_CRITERION_INLINE_IMPL_CC__ */
diff --git a/src/model/common/non_local_toolbox/non_local_manager.cc b/src/model/common/non_local_toolbox/non_local_manager.cc
index e99926e97..5e15884f2 100644
--- a/src/model/common/non_local_toolbox/non_local_manager.cc
+++ b/src/model/common/non_local_toolbox/non_local_manager.cc
@@ -1,638 +1,638 @@
/**
* @file non_local_manager.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Apr 13 2012
* @date last modification: Tue Jan 16 2018
*
* @brief Implementation of non-local manager
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_local_manager.hh"
#include "grid_synchronizer.hh"
#include "model.hh"
#include "non_local_neighborhood.hh"
/* -------------------------------------------------------------------------- */
#include <numeric>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
NonLocalManager::NonLocalManager(Model & model,
NonLocalManagerCallback & callback,
const ID & id, const MemoryID & memory_id)
: Memory(id, memory_id), Parsable(ParserType::_neighborhoods, id),
spatial_dimension(model.getMesh().getSpatialDimension()), model(model),
integration_points_positions("integration_points_positions", id,
memory_id),
volumes("volumes", id, memory_id), compute_stress_calls(0),
dummy_registry(nullptr), dummy_grid(nullptr) {
/// parse the neighborhood information from the input file
const Parser & parser = getStaticParser();
/// iterate over all the non-local sections and store them in a map
std::pair<Parser::const_section_iterator, Parser::const_section_iterator>
weight_sect = parser.getSubSections(ParserType::_non_local);
Parser::const_section_iterator it = weight_sect.first;
for (; it != weight_sect.second; ++it) {
const ParserSection & section = *it;
ID name = section.getName();
this->weight_function_types[name] = section;
}
this->callback = &callback;
}
/* -------------------------------------------------------------------------- */
NonLocalManager::~NonLocalManager() = default;
/* -------------------------------------------------------------------------- */
void NonLocalManager::initialize() {
volumes.initialize(this->model.getFEEngine(),
_spatial_dimension = spatial_dimension);
AKANTU_DEBUG_ASSERT(this->callback,
"A callback should be registered prior to this call");
this->callback->insertIntegrationPointsInNeighborhoods(_not_ghost);
auto & mesh = this->model.getMesh();
mesh.registerEventHandler(*this, _ehp_non_local_manager);
/// store the number of current ghost elements for each type in the mesh
// ElementTypeMap<UInt> nb_ghost_protected;
// for (auto type : mesh.elementTypes(spatial_dimension, _ghost))
// nb_ghost_protected(mesh.getNbElement(type, _ghost), type, _ghost);
/// exchange the missing ghosts for the non-local neighborhoods
this->createNeighborhoodSynchronizers();
/// insert the ghost quadrature points of the non-local materials into the
/// non-local neighborhoods
this->callback->insertIntegrationPointsInNeighborhoods(_ghost);
FEEngine & fee = this->model.getFEEngine();
this->updatePairLists();
/// cleanup the unneccessary ghost elements
this->cleanupExtraGhostElements(); // nb_ghost_protected);
this->callback->initializeNonLocal();
this->setJacobians(fee, _ek_regular);
this->initNonLocalVariables();
this->computeWeights();
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::setJacobians(const FEEngine & fe_engine,
const ElementKind & kind) {
Mesh & mesh = this->model.getMesh();
for (auto ghost_type : ghost_types) {
for (auto type : mesh.elementTypes(spatial_dimension, ghost_type, kind)) {
jacobians(type, ghost_type) =
&fe_engine.getIntegratorInterface().getJacobians(type, ghost_type);
}
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::createNeighborhood(const ID & weight_func,
const ID & neighborhood_id) {
AKANTU_DEBUG_IN();
auto weight_func_it = this->weight_function_types.find(weight_func);
AKANTU_DEBUG_ASSERT(weight_func_it != weight_function_types.end(),
"No info found in the input file for the weight_function "
<< weight_func << " in the neighborhood "
<< neighborhood_id);
const ParserSection & section = weight_func_it->second;
const ID weight_func_type = section.getOption();
/// create new neighborhood for given ID
std::stringstream sstr;
sstr << id << ":neighborhood:" << neighborhood_id;
if (weight_func_type == "base_wf")
neighborhoods[neighborhood_id] =
std::make_unique<NonLocalNeighborhood<BaseWeightFunction>>(
*this, this->integration_points_positions, sstr.str());
#if defined(AKANTU_DAMAGE_NON_LOCAL)
else if (weight_func_type == "remove_wf")
neighborhoods[neighborhood_id] =
std::make_unique<NonLocalNeighborhood<RemoveDamagedWeightFunction>>(
*this, this->integration_points_positions, sstr.str());
else if (weight_func_type == "stress_wf")
neighborhoods[neighborhood_id] =
std::make_unique<NonLocalNeighborhood<StressBasedWeightFunction>>(
*this, this->integration_points_positions, sstr.str());
else if (weight_func_type == "damage_wf")
neighborhoods[neighborhood_id] =
std::make_unique<NonLocalNeighborhood<DamagedWeightFunction>>(
*this, this->integration_points_positions, sstr.str());
#endif
else
AKANTU_EXCEPTION("error in weight function type provided in material file");
neighborhoods[neighborhood_id]->parseSection(section);
neighborhoods[neighborhood_id]->initNeighborhood();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::createNeighborhoodSynchronizers() {
/// exchange all the neighborhood IDs, so that every proc knows how many
/// neighborhoods exist globally
/// First: Compute locally the maximum ID size
UInt max_id_size = 0;
UInt current_size = 0;
NeighborhoodMap::const_iterator it;
for (it = neighborhoods.begin(); it != neighborhoods.end(); ++it) {
current_size = it->first.size();
if (current_size > max_id_size)
max_id_size = current_size;
}
/// get the global maximum ID size on each proc
const Communicator & static_communicator = model.getMesh().getCommunicator();
static_communicator.allReduce(max_id_size, SynchronizerOperation::_max);
/// get the rank for this proc and the total nb proc
UInt prank = static_communicator.whoAmI();
UInt psize = static_communicator.getNbProc();
/// exchange the number of neighborhoods on each proc
Array<Int> nb_neighborhoods_per_proc(psize);
nb_neighborhoods_per_proc(prank) = neighborhoods.size();
static_communicator.allGather(nb_neighborhoods_per_proc);
/// compute the total number of neighborhoods
UInt nb_neighborhoods_global = std::accumulate(
nb_neighborhoods_per_proc.begin(), nb_neighborhoods_per_proc.end(), 0);
/// allocate an array of chars to store the names of all neighborhoods
Array<char> buffer(nb_neighborhoods_global, max_id_size);
/// starting index on this proc
UInt starting_index =
std::accumulate(nb_neighborhoods_per_proc.begin(),
nb_neighborhoods_per_proc.begin() + prank, 0);
it = neighborhoods.begin();
/// store the names of local neighborhoods in the buffer
for (UInt i = 0; i < neighborhoods.size(); ++i, ++it) {
UInt c = 0;
for (; c < it->first.size(); ++c)
buffer(i + starting_index, c) = it->first[c];
for (; c < max_id_size; ++c)
buffer(i + starting_index, c) = char(0);
}
/// store the nb of data to send in the all gather
Array<Int> buffer_size(nb_neighborhoods_per_proc);
buffer_size *= max_id_size;
/// exchange the names of all the neighborhoods with all procs
static_communicator.allGatherV(buffer, buffer_size);
for (UInt i = 0; i < nb_neighborhoods_global; ++i) {
std::stringstream neighborhood_id;
for (UInt c = 0; c < max_id_size; ++c) {
if (buffer(i, c) == char(0))
break;
neighborhood_id << buffer(i, c);
}
global_neighborhoods.insert(neighborhood_id.str());
}
/// this proc does not know all the neighborhoods -> create dummy
/// grid so that this proc can participate in the all gather for
/// detecting the overlap of neighborhoods this proc doesn't know
Vector<Real> grid_center(this->spatial_dimension,
std::numeric_limits<Real>::max());
Vector<Real> spacing(this->spatial_dimension, 0.);
dummy_grid = std::make_unique<SpatialGrid<IntegrationPoint>>(
this->spatial_dimension, spacing, grid_center);
for (auto & neighborhood_id : global_neighborhoods) {
it = neighborhoods.find(neighborhood_id);
if (it != neighborhoods.end()) {
it->second->createGridSynchronizer();
} else {
dummy_synchronizers[neighborhood_id] = std::make_unique<GridSynchronizer>(
this->model.getMesh(), *dummy_grid,
std::string(this->id + ":" + neighborhood_id + ":grid_synchronizer"),
this->memory_id, false);
}
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::synchronize(DataAccessor<Element> & data_accessor,
const SynchronizationTag & tag) {
for (auto & neighborhood_id : global_neighborhoods) {
auto it = neighborhoods.find(neighborhood_id);
if (it != neighborhoods.end()) {
it->second->synchronize(data_accessor, tag);
} else {
auto synchronizer_it = dummy_synchronizers.find(neighborhood_id);
if (synchronizer_it == dummy_synchronizers.end())
continue;
synchronizer_it->second->synchronizeOnce(data_accessor, tag);
}
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::averageInternals(const GhostType & ghost_type) {
/// update the weights of the weight function
if (ghost_type == _not_ghost)
this->computeWeights();
/// loop over all neighborhoods and compute the non-local variables
for (auto & neighborhood : neighborhoods) {
/// loop over all the non-local variables of the given neighborhood
for (auto & non_local_variable : non_local_variables) {
NonLocalVariable & non_local_var = *non_local_variable.second;
neighborhood.second->weightedAverageOnNeighbours(
non_local_var.local, non_local_var.non_local,
non_local_var.nb_component, ghost_type);
}
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::computeWeights() {
AKANTU_DEBUG_IN();
this->updateWeightFunctionInternals();
this->volumes.clear();
for (const auto & global_neighborhood : global_neighborhoods) {
auto it = neighborhoods.find(global_neighborhood);
if (it != neighborhoods.end())
it->second->updateWeights();
else {
- dummy_synchronizers[global_neighborhood]->synchronize(dummy_accessor,
- SynchronizationTag::_mnl_weight);
+ dummy_synchronizers[global_neighborhood]->synchronize(
+ dummy_accessor, SynchronizationTag::_mnl_weight);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::updatePairLists() {
AKANTU_DEBUG_IN();
integration_points_positions.initialize(
this->model.getFEEngine(), _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension);
/// compute the position of the quadrature points
this->model.getFEEngine().computeIntegrationPointsCoordinates(
integration_points_positions);
for (auto & pair : neighborhoods)
pair.second->updatePairList();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::registerNonLocalVariable(const ID & variable_name,
const ID & nl_variable_name,
UInt nb_component) {
AKANTU_DEBUG_IN();
auto non_local_variable_it = non_local_variables.find(variable_name);
if (non_local_variable_it == non_local_variables.end())
non_local_variables[nl_variable_name] = std::make_unique<NonLocalVariable>(
variable_name, nl_variable_name, this->id, nb_component);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
ElementTypeMapReal &
NonLocalManager::registerWeightFunctionInternal(const ID & field_name) {
AKANTU_DEBUG_IN();
auto it = this->weight_function_internals.find(field_name);
if (it == weight_function_internals.end()) {
weight_function_internals[field_name] =
std::make_unique<ElementTypeMapReal>(field_name, this->id,
this->memory_id);
}
AKANTU_DEBUG_OUT();
return *(weight_function_internals[field_name]);
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::updateWeightFunctionInternals() {
for (auto & pair : this->weight_function_internals) {
auto & internals = *pair.second;
internals.clear();
for (auto ghost_type : ghost_types)
this->callback->updateLocalInternal(internals, ghost_type, _ek_regular);
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::initNonLocalVariables() {
/// loop over all the non-local variables
for (auto & pair : non_local_variables) {
auto & variable = *pair.second;
variable.non_local.initialize(this->model.getFEEngine(),
_nb_component = variable.nb_component,
_spatial_dimension = spatial_dimension);
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::computeAllNonLocalStresses() {
/// update the flattened version of the internals
for (auto & pair : non_local_variables) {
auto & variable = *pair.second;
variable.local.clear();
variable.non_local.clear();
for (auto ghost_type : ghost_types) {
this->callback->updateLocalInternal(variable.local, ghost_type,
_ek_regular);
}
}
this->volumes.clear();
for (auto & pair : neighborhoods) {
auto & neighborhood = *pair.second;
neighborhood.asynchronousSynchronize(SynchronizationTag::_mnl_for_average);
}
this->averageInternals(_not_ghost);
AKANTU_DEBUG_INFO("Wait distant non local stresses");
for (auto & pair : neighborhoods) {
auto & neighborhood = *pair.second;
neighborhood.waitEndSynchronize(SynchronizationTag::_mnl_for_average);
}
this->averageInternals(_ghost);
/// copy the results in the materials
for (auto & pair : non_local_variables) {
auto & variable = *pair.second;
for (auto ghost_type : ghost_types) {
this->callback->updateNonLocalInternal(variable.non_local, ghost_type,
_ek_regular);
}
}
this->callback->computeNonLocalStresses(_not_ghost);
++this->compute_stress_calls;
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::cleanupExtraGhostElements() {
// ElementTypeMap<UInt> & nb_ghost_protected) {
using ElementSet = std::set<Element>;
ElementSet relevant_ghost_elements;
/// loop over all the neighborhoods and get their protected ghosts
for (auto & pair : neighborhoods) {
auto & neighborhood = *pair.second;
ElementSet to_keep_per_neighborhood;
neighborhood.cleanupExtraGhostElements(to_keep_per_neighborhood);
for (auto & element : to_keep_per_neighborhood)
relevant_ghost_elements.insert(element);
}
// /// remove all unneccessary ghosts from the mesh
// /// Create list of element to remove and new numbering for element to keep
// Mesh & mesh = this->model.getMesh();
// ElementSet ghost_to_erase;
// RemovedElementsEvent remove_elem(mesh);
// auto & new_numberings = remove_elem.getNewNumbering();
// Element element;
// element.ghost_type = _ghost;
// for (auto & type : mesh.elementTypes(spatial_dimension, _ghost)) {
// element.type = type;
// UInt nb_ghost_elem = mesh.getNbElement(type, _ghost);
// // UInt nb_ghost_elem_protected = 0;
// // try {
// // nb_ghost_elem_protected = nb_ghost_protected(type, _ghost);
// // } catch (...) {
// // }
// if (!new_numberings.exists(type, _ghost))
// new_numberings.alloc(nb_ghost_elem, 1, type, _ghost);
// else
// new_numberings(type, _ghost).resize(nb_ghost_elem);
// Array<UInt> & new_numbering = new_numberings(type, _ghost);
// for (UInt g = 0; g < nb_ghost_elem; ++g) {
// element.element = g;
// if (element.element >= nb_ghost_elem_protected &&
// relevant_ghost_elements.find(element) ==
// relevant_ghost_elements.end()) {
// remove_elem.getList().push_back(element);
// new_numbering(element.element) = UInt(-1);
// }
// }
// /// renumber remaining ghosts
// UInt ng = 0;
// for (UInt g = 0; g < nb_ghost_elem; ++g) {
// if (new_numbering(g) != UInt(-1)) {
// new_numbering(g) = ng;
// ++ng;
// }
// }
// }
// for (auto & type : mesh.elementTypes(spatial_dimension, _not_ghost)) {
// UInt nb_elem = mesh.getNbElement(type, _not_ghost);
// if (!new_numberings.exists(type, _not_ghost))
// new_numberings.alloc(nb_elem, 1, type, _not_ghost);
// Array<UInt> & new_numbering = new_numberings(type, _not_ghost);
// for (UInt e = 0; e < nb_elem; ++e) {
// new_numbering(e) = e;
// }
// }
// mesh.sendEvent(remove_elem);
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::onElementsRemoved(
const Array<Element> & element_list,
const ElementTypeMapArray<UInt> & new_numbering,
__attribute__((unused)) const RemovedElementsEvent & event) {
FEEngine & fee = this->model.getFEEngine();
this->removeIntegrationPointsFromMap(
event.getNewNumbering(), spatial_dimension, integration_points_positions,
fee, _ek_regular);
this->removeIntegrationPointsFromMap(event.getNewNumbering(), 1, volumes, fee,
_ek_regular);
/// loop over all the neighborhoods and call onElementsRemoved
auto global_neighborhood_it = global_neighborhoods.begin();
NeighborhoodMap::iterator it;
for (; global_neighborhood_it != global_neighborhoods.end();
++global_neighborhood_it) {
it = neighborhoods.find(*global_neighborhood_it);
if (it != neighborhoods.end())
it->second->onElementsRemoved(element_list, new_numbering, event);
else
dummy_synchronizers[*global_neighborhood_it]->onElementsRemoved(
element_list, new_numbering, event);
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::onElementsAdded(const Array<Element> &,
const NewElementsEvent &) {
this->resizeElementTypeMap(1, volumes, model.getFEEngine());
this->resizeElementTypeMap(spatial_dimension, integration_points_positions,
model.getFEEngine());
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::resizeElementTypeMap(UInt nb_component,
ElementTypeMapReal & element_map,
const FEEngine & fee,
const ElementKind el_kind) {
Mesh & mesh = this->model.getMesh();
for (auto gt : ghost_types) {
for (auto type : mesh.elementTypes(spatial_dimension, gt, el_kind)) {
UInt nb_element = mesh.getNbElement(type, gt);
UInt nb_quads = fee.getNbIntegrationPoints(type, gt);
if (!element_map.exists(type, gt))
element_map.alloc(nb_element * nb_quads, nb_component, type, gt);
else
element_map(type, gt).resize(nb_element * nb_quads);
}
}
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::removeIntegrationPointsFromMap(
const ElementTypeMapArray<UInt> & new_numbering, UInt nb_component,
ElementTypeMapReal & element_map, const FEEngine & fee,
const ElementKind el_kind) {
for (auto gt : ghost_types) {
for (auto type : new_numbering.elementTypes(_all_dimensions, gt, el_kind)) {
if (element_map.exists(type, gt)) {
const Array<UInt> & renumbering = new_numbering(type, gt);
Array<Real> & vect = element_map(type, gt);
UInt nb_quad_per_elem = fee.getNbIntegrationPoints(type, gt);
Array<Real> tmp(renumbering.size() * nb_quad_per_elem, nb_component);
AKANTU_DEBUG_ASSERT(
tmp.size() == vect.size(),
"Something strange append some mater was created or disappeared in "
<< vect.getID() << "(" << vect.size() << "!=" << tmp.size()
<< ") "
"!!");
UInt new_size = 0;
for (UInt i = 0; i < renumbering.size(); ++i) {
UInt new_i = renumbering(i);
if (new_i != UInt(-1)) {
memcpy(tmp.storage() + new_i * nb_component * nb_quad_per_elem,
vect.storage() + i * nb_component * nb_quad_per_elem,
nb_component * nb_quad_per_elem * sizeof(Real));
++new_size;
}
}
tmp.resize(new_size * nb_quad_per_elem);
vect.copy(tmp);
}
}
}
}
/* -------------------------------------------------------------------------- */
UInt NonLocalManager::getNbData(const Array<Element> & elements,
const ID & id) const {
UInt size = 0;
UInt nb_quadrature_points = this->model.getNbIntegrationPoints(elements);
auto it = non_local_variables.find(id);
AKANTU_DEBUG_ASSERT(it != non_local_variables.end(),
"The non-local variable " << id << " is not registered");
size += it->second->nb_component * sizeof(Real) * nb_quadrature_points;
return size;
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const ID & id) const {
auto it = non_local_variables.find(id);
AKANTU_DEBUG_ASSERT(it != non_local_variables.end(),
"The non-local variable " << id << " is not registered");
DataAccessor<Element>::packElementalDataHelper<Real>(
it->second->local, buffer, elements, true, this->model.getFEEngine());
}
/* -------------------------------------------------------------------------- */
void NonLocalManager::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const ID & id) const {
auto it = non_local_variables.find(id);
AKANTU_DEBUG_ASSERT(it != non_local_variables.end(),
"The non-local variable " << id << " is not registered");
DataAccessor<Element>::unpackElementalDataHelper<Real>(
it->second->local, buffer, elements, true, this->model.getFEEngine());
}
} // namespace akantu
diff --git a/src/model/common/non_local_toolbox/non_local_neighborhood_base.cc b/src/model/common/non_local_toolbox/non_local_neighborhood_base.cc
index 9bcc942c1..52195c7bf 100644
--- a/src/model/common/non_local_toolbox/non_local_neighborhood_base.cc
+++ b/src/model/common/non_local_toolbox/non_local_neighborhood_base.cc
@@ -1,117 +1,118 @@
/**
* @file non_local_neighborhood_base.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sat Sep 26 2015
* @date last modification: Fri Dec 08 2017
*
* @brief Implementation of non-local neighborhood base
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_local_neighborhood_base.hh"
#include "grid_synchronizer.hh"
#include "model.hh"
/* -------------------------------------------------------------------------- */
#include <memory>
namespace akantu {
/* -------------------------------------------------------------------------- */
NonLocalNeighborhoodBase::NonLocalNeighborhoodBase(
Model & model, const ElementTypeMapReal & quad_coordinates, const ID & id,
const MemoryID & memory_id)
: NeighborhoodBase(model, quad_coordinates, id, memory_id),
Parsable(ParserType::_non_local, id) {
AKANTU_DEBUG_IN();
this->registerParam("radius", neighborhood_radius, 100.,
_pat_parsable | _pat_readable, "Non local radius");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
NonLocalNeighborhoodBase::~NonLocalNeighborhoodBase() = default;
/* -------------------------------------------------------------------------- */
void NonLocalNeighborhoodBase::createGridSynchronizer() {
this->is_creating_grid = true;
this->grid_synchronizer = std::make_unique<GridSynchronizer>(
this->model.getMesh(), *spatial_grid, *this,
- std::set<SynchronizationTag>{SynchronizationTag::_mnl_weight, SynchronizationTag::_mnl_for_average},
+ std::set<SynchronizationTag>{SynchronizationTag::_mnl_weight,
+ SynchronizationTag::_mnl_for_average},
std::string(getID() + ":grid_synchronizer"), this->memory_id, false);
this->is_creating_grid = false;
}
/* -------------------------------------------------------------------------- */
void NonLocalNeighborhoodBase::synchronize(
DataAccessor<Element> & data_accessor, const SynchronizationTag & tag) {
if (not grid_synchronizer)
return;
grid_synchronizer->synchronizeOnce(data_accessor, tag);
}
/* -------------------------------------------------------------------------- */
void NonLocalNeighborhoodBase::cleanupExtraGhostElements(
std::set<Element> & relevant_ghost_elements) {
for (auto && pair : pair_list[_ghost]) {
const auto & q2 = pair.second;
relevant_ghost_elements.insert(q2);
}
Array<Element> ghosts_to_erase(0);
auto & mesh = this->model.getMesh();
Element element;
element.ghost_type = _ghost;
auto end = relevant_ghost_elements.end();
for (auto & type : mesh.elementTypes(spatial_dimension, _ghost)) {
element.type = type;
UInt nb_ghost_elem = mesh.getNbElement(type, _ghost);
for (UInt g = 0; g < nb_ghost_elem; ++g) {
element.element = g;
if (relevant_ghost_elements.find(element) == end) {
ghosts_to_erase.push_back(element);
}
}
}
/// remove the unneccessary ghosts from the synchronizer
// this->grid_synchronizer->removeElements(ghosts_to_erase);
mesh.eraseElements(ghosts_to_erase);
}
/* -------------------------------------------------------------------------- */
void NonLocalNeighborhoodBase::registerNonLocalVariable(const ID & id) {
this->non_local_variables.insert(id);
}
} // namespace akantu
diff --git a/src/model/common/solver_callback.hh b/src/model/common/solver_callback.hh
index c282dcec2..2ad22a62d 100644
--- a/src/model/common/solver_callback.hh
+++ b/src/model/common/solver_callback.hh
@@ -1,109 +1,109 @@
/**
* @file solver_callback.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Class defining the interface for non_linear_solver callbacks
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_CALLBACK_HH__
#define __AKANTU_SOLVER_CALLBACK_HH__
namespace akantu {
class DOFManager;
}
namespace akantu {
class SolverCallback {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
explicit SolverCallback(DOFManager & dof_manager);
explicit SolverCallback();
/* ------------------------------------------------------------------------ */
virtual ~SolverCallback();
protected:
void setDOFManager(DOFManager & dof_manager);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// get the type of matrix needed
virtual MatrixType getMatrixType(const ID &) = 0;
/// callback to assemble a Matrix
virtual void assembleMatrix(const ID &) = 0;
/// callback to assemble a lumped Matrix
virtual void assembleLumpedMatrix(const ID &) = 0;
/// callback to assemble the residual (rhs)
virtual void assembleResidual() = 0;
/// callback to assemble the rhs parts, (e.g. internal_forces +
/// external_forces)
virtual void assembleResidual(const ID & /*residual_part*/) {}
/* ------------------------------------------------------------------------ */
/* Dynamic simulations part */
/* ------------------------------------------------------------------------ */
/// callback for the predictor (in case of dynamic simulation)
virtual void predictor() {}
/// callback for the corrector (in case of dynamic simulation)
virtual void corrector() {}
/// tells if the residual can be computed in separated parts
virtual bool canSplitResidual() { return false; }
/* ------------------------------------------------------------------------ */
/* management callbacks */
/* ------------------------------------------------------------------------ */
virtual void beforeSolveStep(){};
virtual void afterSolveStep(){};
protected:
/// DOFManager prefixed to avoid collision in multiple inheritance cases
DOFManager * sc_dof_manager{nullptr};
};
namespace debug {
class SolverCallbackResidualPartUnknown : public Exception {
public:
SolverCallbackResidualPartUnknown(const ID & residual_part)
: Exception(residual_part + " is not known here.") {}
};
-}
+} // namespace debug
} // namespace akantu
#endif /* __AKANTU_SOLVER_CALLBACK_HH__ */
diff --git a/src/model/common/time_step_solvers/time_step_solver_default_explicit.hh b/src/model/common/time_step_solvers/time_step_solver_default_explicit.hh
index 633730538..da5568c5c 100644
--- a/src/model/common/time_step_solvers/time_step_solver_default_explicit.hh
+++ b/src/model/common/time_step_solvers/time_step_solver_default_explicit.hh
@@ -1,78 +1,78 @@
/**
* @file time_step_solver_default_explicit.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Default solver for explicit resolution
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TIME_STEP_SOLVER_DEFAULT_EXPLICIT_HH__
#define __AKANTU_TIME_STEP_SOLVER_DEFAULT_EXPLICIT_HH__
namespace akantu {
class TimeStepSolverDefaultExplicit : public TimeStepSolverDefault {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
TimeStepSolverDefaultExplicit();
virtual ~TimeStepSolverDefaultExplicit();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void solveStep();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "time_step_solver_default_explicit_inline_impl.cc"
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const TimeStepSolverDefaultExplicit & _this) {
_this.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_TIME_STEP_SOLVER_DEFAULT_EXPLICIT_HH__ */
diff --git a/src/model/heat_transfer/heat_transfer_model.cc b/src/model/heat_transfer/heat_transfer_model.cc
index 6cfd59e28..6d34c3498 100644
--- a/src/model/heat_transfer/heat_transfer_model.cc
+++ b/src/model/heat_transfer/heat_transfer_model.cc
@@ -1,958 +1,943 @@
/**
* @file heat_transfer_model.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Emil Gallyamov <emil.gallyamov@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Srinivasa Babu Ramisetti <srinivasa.ramisetti@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Rui Wang <rui.wang@epfl.ch>
*
* @date creation: Sun May 01 2011
* @date last modification: Tue Feb 20 2018
*
* @brief Implementation of HeatTransferModel class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "heat_transfer_model.hh"
#include "dumpable_inline_impl.hh"
#include "element_synchronizer.hh"
#include "fe_engine_template.hh"
#include "generalized_trapezoidal.hh"
#include "group_manager_inline_impl.cc"
#include "integrator_gauss.hh"
#include "mesh.hh"
#include "parser.hh"
#include "shape_lagrange.hh"
#ifdef AKANTU_USE_IOHELPER
#include "dumper_element_partition.hh"
#include "dumper_elemental_field.hh"
#include "dumper_internal_material_field.hh"
#include "dumper_iohelper_paraview.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
namespace heat_transfer {
namespace details {
class ComputeRhoFunctor {
public:
ComputeRhoFunctor(const HeatTransferModel & model) : model(model){};
void operator()(Matrix<Real> & rho, const Element &) const {
rho.set(model.getCapacity() * model.getDensity());
}
private:
const HeatTransferModel & model;
};
} // namespace details
} // namespace heat_transfer
/* -------------------------------------------------------------------------- */
HeatTransferModel::HeatTransferModel(Mesh & mesh, UInt dim, const ID & id,
const MemoryID & memory_id,
std::shared_ptr<DOFManager> dof_manager)
: Model(mesh, ModelType::_heat_transfer_model, dof_manager, dim, id, memory_id),
temperature_gradient("temperature_gradient", id),
temperature_on_qpoints("temperature_on_qpoints", id),
conductivity_on_qpoints("conductivity_on_qpoints", id),
k_gradt_on_qpoints("k_gradt_on_qpoints", id) {
AKANTU_DEBUG_IN();
conductivity = Matrix<Real>(this->spatial_dimension, this->spatial_dimension);
this->registerDataAccessor(*this);
if (this->mesh.isDistributed()) {
auto & synchronizer = this->mesh.getElementSynchronizer();
- this->registerSynchronizer(synchronizer, SynchronizationTag::_htm_temperature);
- this->registerSynchronizer(synchronizer, SynchronizationTag::_htm_gradient_temperature);
+ this->registerSynchronizer(synchronizer,
+ SynchronizationTag::_htm_temperature);
+ this->registerSynchronizer(synchronizer,
+ SynchronizationTag::_htm_gradient_temperature);
}
registerFEEngineObject<FEEngineType>(id + ":fem", mesh, spatial_dimension);
#ifdef AKANTU_USE_IOHELPER
this->mesh.registerDumper<DumperParaview>("heat_transfer", id, true);
this->mesh.addDumpMesh(mesh, spatial_dimension, _not_ghost, _ek_regular);
#endif
this->registerParam("conductivity", conductivity, _pat_parsmod);
this->registerParam("conductivity_variation", conductivity_variation, 0.,
_pat_parsmod);
this->registerParam("temperature_reference", T_ref, 0., _pat_parsmod);
this->registerParam("capacity", capacity, _pat_parsmod);
this->registerParam("density", density, _pat_parsmod);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::initModel() {
auto & fem = this->getFEEngine();
fem.initShapeFunctions(_not_ghost);
fem.initShapeFunctions(_ghost);
temperature_on_qpoints.initialize(fem, _nb_component = 1);
temperature_gradient.initialize(fem, _nb_component = spatial_dimension);
conductivity_on_qpoints.initialize(fem, _nb_component = spatial_dimension *
spatial_dimension);
k_gradt_on_qpoints.initialize(fem, _nb_component = spatial_dimension);
}
/* -------------------------------------------------------------------------- */
FEEngine & HeatTransferModel::getFEEngineBoundary(const ID & name) {
return aka::as_type<FEEngine>(getFEEngineClassBoundary<FEEngineType>(name));
}
/* -------------------------------------------------------------------------- */
template <typename T>
void HeatTransferModel::allocNodalField(Array<T> *& array, const ID & name) {
if (array == nullptr) {
UInt nb_nodes = mesh.getNbNodes();
std::stringstream sstr_disp;
sstr_disp << id << ":" << name;
array = &(alloc<T>(sstr_disp.str(), nb_nodes, 1, T()));
}
}
/* -------------------------------------------------------------------------- */
HeatTransferModel::~HeatTransferModel() = default;
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleCapacityLumped(const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
auto & fem = getFEEngineClass<FEEngineType>();
heat_transfer::details::ComputeRhoFunctor compute_rho(*this);
for (auto & type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_regular)) {
fem.assembleFieldLumped(compute_rho, "M", "temperature",
this->getDOFManager(), type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
MatrixType HeatTransferModel::getMatrixType(const ID & matrix_id) {
if (matrix_id == "K" or matrix_id == "M") {
return _symmetric;
}
return _mt_not_defined;
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleMatrix(const ID & matrix_id) {
if (matrix_id == "K") {
this->assembleConductivityMatrix();
} else if (matrix_id == "M" and need_to_reassemble_capacity) {
this->assembleCapacity();
}
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleLumpedMatrix(const ID & matrix_id) {
if (matrix_id == "M" and need_to_reassemble_capacity) {
this->assembleCapacityLumped();
}
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleResidual() {
AKANTU_DEBUG_IN();
this->assembleInternalHeatRate();
this->getDOFManager().assembleToResidual("temperature",
*this->external_heat_rate, 1);
this->getDOFManager().assembleToResidual("temperature",
*this->internal_heat_rate, 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::predictor() { ++temperature_release; }
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleCapacityLumped() {
AKANTU_DEBUG_IN();
if (!this->getDOFManager().hasLumpedMatrix("M")) {
this->getDOFManager().getNewLumpedMatrix("M");
}
this->getDOFManager().clearLumpedMatrix("M");
assembleCapacityLumped(_not_ghost);
assembleCapacityLumped(_ghost);
need_to_reassemble_capacity_lumped = false;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::initSolver(TimeStepSolverType time_step_solver_type,
NonLinearSolverType) {
DOFManager & dof_manager = this->getDOFManager();
this->allocNodalField(this->temperature, "temperature");
this->allocNodalField(this->external_heat_rate, "external_heat_rate");
this->allocNodalField(this->internal_heat_rate, "internal_heat_rate");
this->allocNodalField(this->blocked_dofs, "blocked_dofs");
if (!dof_manager.hasDOFs("temperature")) {
dof_manager.registerDOFs("temperature", *this->temperature, _dst_nodal);
dof_manager.registerBlockedDOFs("temperature", *this->blocked_dofs);
}
if (time_step_solver_type == TimeStepSolverType::_dynamic ||
time_step_solver_type == TimeStepSolverType::_dynamic_lumped) {
this->allocNodalField(this->temperature_rate, "temperature_rate");
if (!dof_manager.hasDOFsDerivatives("temperature", 1)) {
dof_manager.registerDOFsDerivative("temperature", 1,
*this->temperature_rate);
}
}
}
/* -------------------------------------------------------------------------- */
std::tuple<ID, TimeStepSolverType>
HeatTransferModel::getDefaultSolverID(const AnalysisMethod & method) {
switch (method) {
case _explicit_lumped_mass: {
- return std::make_tuple("explicit_lumped", TimeStepSolverType::_dynamic_lumped);
+ return std::make_tuple("explicit_lumped",
+ TimeStepSolverType::_dynamic_lumped);
}
case _static: {
return std::make_tuple("static", TimeStepSolverType::_static);
}
case _implicit_dynamic: {
return std::make_tuple("implicit", TimeStepSolverType::_dynamic);
}
default:
return std::make_tuple("unknown", TimeStepSolverType::_not_defined);
}
}
/* -------------------------------------------------------------------------- */
ModelSolverOptions HeatTransferModel::getDefaultSolverOptions(
const TimeStepSolverType & type) const {
ModelSolverOptions options;
switch (type) {
case TimeStepSolverType::_dynamic_lumped: {
options.non_linear_solver_type = NonLinearSolverType::_lumped;
- options.integration_scheme_type["temperature"] = IntegrationSchemeType::_forward_euler;
+ options.integration_scheme_type["temperature"] =
+ IntegrationSchemeType::_forward_euler;
options.solution_type["temperature"] = IntegrationScheme::_temperature_rate;
break;
}
case TimeStepSolverType::_static: {
options.non_linear_solver_type = NonLinearSolverType::_newton_raphson;
- options.integration_scheme_type["temperature"] = IntegrationSchemeType::_pseudo_time;
+ options.integration_scheme_type["temperature"] =
+ IntegrationSchemeType::_pseudo_time;
options.solution_type["temperature"] = IntegrationScheme::_not_defined;
break;
}
case TimeStepSolverType::_dynamic: {
if (this->method == _explicit_consistent_mass) {
options.non_linear_solver_type = NonLinearSolverType::_newton_raphson;
- options.integration_scheme_type["temperature"] = IntegrationSchemeType::_forward_euler;
+ options.integration_scheme_type["temperature"] =
+ IntegrationSchemeType::_forward_euler;
options.solution_type["temperature"] =
IntegrationScheme::_temperature_rate;
} else {
options.non_linear_solver_type = NonLinearSolverType::_newton_raphson;
- options.integration_scheme_type["temperature"] = IntegrationSchemeType::_backward_euler;
+ options.integration_scheme_type["temperature"] =
+ IntegrationSchemeType::_backward_euler;
options.solution_type["temperature"] = IntegrationScheme::_temperature;
}
break;
}
default:
AKANTU_EXCEPTION(type << " is not a valid time step solver type");
}
return options;
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleConductivityMatrix() {
AKANTU_DEBUG_IN();
this->computeConductivityOnQuadPoints(_not_ghost);
+
if (conductivity_release[_not_ghost] == conductivity_matrix_release)
return;
- if (!this->getDOFManager().hasMatrix("K")) {
- this->getDOFManager().getNewMatrix("K", getMatrixType("K"));
- }
- this->getDOFManager().clearMatrix("K");
+ AKANTU_DEBUG_ASSERT(this->getDOFManager().hasMatrix("K"),
+ "The K matrix has not been initialized yet.");
- switch (mesh.getSpatialDimension()) {
- case 1:
- this->assembleConductivityMatrix<1>(_not_ghost);
- break;
- case 2:
- this->assembleConductivityMatrix<2>(_not_ghost);
- break;
- case 3:
- this->assembleConductivityMatrix<3>(_not_ghost);
- break;
- }
-
- AKANTU_DEBUG_OUT();
-}
-
-/* -------------------------------------------------------------------------- */
-template <UInt dim>
-void HeatTransferModel::assembleConductivityMatrix(
- const GhostType & ghost_type) {
- AKANTU_DEBUG_IN();
+ this->getDOFManager().clearMatrix("K");
auto & fem = this->getFEEngine();
- for (auto && type :
- mesh.elementTypes(spatial_dimension, ghost_type, _ek_regular)) {
- auto nb_element = mesh.getNbElement(type, ghost_type);
+ for (auto && type : mesh.elementTypes(spatial_dimension)) {
+ auto nb_element = mesh.getNbElement(type);
auto nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
- auto nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
+ auto nb_quadrature_points = fem.getNbIntegrationPoints(type);
auto bt_d_b = std::make_unique<Array<Real>>(
nb_element * nb_quadrature_points,
nb_nodes_per_element * nb_nodes_per_element, "B^t*D*B");
- fem.computeBtDB(conductivity_on_qpoints(type, ghost_type), *bt_d_b, 2, type,
- ghost_type);
+ fem.computeBtDB(conductivity_on_qpoints(type), *bt_d_b, 2, type);
/// compute @f$ k_e = \int_e \mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
auto K_e = std::make_unique<Array<Real>>(
nb_element, nb_nodes_per_element * nb_nodes_per_element, "K_e");
fem.integrate(*bt_d_b, *K_e, nb_nodes_per_element * nb_nodes_per_element,
- type, ghost_type);
+ type);
this->getDOFManager().assembleElementalMatricesToMatrix(
- "K", "temperature", *K_e, type, ghost_type, _symmetric);
+ "K", "temperature", *K_e, type, _not_ghost, _symmetric);
}
- conductivity_matrix_release = conductivity_release[ghost_type];
+ conductivity_matrix_release = conductivity_release[_not_ghost];
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::computeConductivityOnQuadPoints(
const GhostType & ghost_type) {
// if already computed once check if need to compute
if (not initial_conductivity[ghost_type]) {
- // if temperature did not change, condictivity will not vary
+ // if temperature did not change, conductivity will not vary
if (temperature_release == conductivity_release[ghost_type])
return;
// if conductivity_variation is 0 no need to recompute
if (conductivity_variation == 0.)
return;
}
for (auto & type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_regular)) {
auto & temperature_interpolated = temperature_on_qpoints(type, ghost_type);
// compute the temperature on quadrature points
this->getFEEngine().interpolateOnIntegrationPoints(
*temperature, temperature_interpolated, 1, type, ghost_type);
auto & cond = conductivity_on_qpoints(type, ghost_type);
for (auto && tuple :
zip(make_view(cond, spatial_dimension, spatial_dimension),
temperature_interpolated)) {
auto & C = std::get<0>(tuple);
auto & T = std::get<1>(tuple);
C = conductivity;
Matrix<Real> variation(spatial_dimension, spatial_dimension,
conductivity_variation * (T - T_ref));
// @TODO: Guillaume are you sure ? why due you compute variation then ?
C += conductivity_variation;
}
}
conductivity_release[ghost_type] = temperature_release;
initial_conductivity[ghost_type] = false;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::computeKgradT(const GhostType & ghost_type) {
computeConductivityOnQuadPoints(ghost_type);
for (auto & type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_regular)) {
auto & gradient = temperature_gradient(type, ghost_type);
this->getFEEngine().gradientOnIntegrationPoints(*temperature, gradient, 1,
type, ghost_type);
for (auto && values :
zip(make_view(conductivity_on_qpoints(type, ghost_type),
spatial_dimension, spatial_dimension),
make_view(gradient, spatial_dimension),
make_view(k_gradt_on_qpoints(type, ghost_type),
spatial_dimension))) {
const auto & C = std::get<0>(values);
const auto & BT = std::get<1>(values);
auto & k_BT = std::get<2>(values);
k_BT.mul<false>(C, BT);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleInternalHeatRate() {
AKANTU_DEBUG_IN();
this->internal_heat_rate->clear();
this->synchronize(SynchronizationTag::_htm_temperature);
auto & fem = this->getFEEngine();
for (auto ghost_type : ghost_types) {
// compute k \grad T
computeKgradT(ghost_type);
for (auto type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_regular)) {
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
auto & k_gradt_on_qpoints_vect = k_gradt_on_qpoints(type, ghost_type);
UInt nb_quad_points = k_gradt_on_qpoints_vect.size();
Array<Real> bt_k_gT(nb_quad_points, nb_nodes_per_element);
fem.computeBtD(k_gradt_on_qpoints_vect, bt_k_gT, type, ghost_type);
UInt nb_elements = mesh.getNbElement(type, ghost_type);
Array<Real> int_bt_k_gT(nb_elements, nb_nodes_per_element);
fem.integrate(bt_k_gT, int_bt_k_gT, nb_nodes_per_element, type,
ghost_type);
this->getDOFManager().assembleElementalArrayLocalArray(
int_bt_k_gT, *this->internal_heat_rate, type, ghost_type, -1);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real HeatTransferModel::getStableTimeStep() {
AKANTU_DEBUG_IN();
Real el_size;
Real min_el_size = std::numeric_limits<Real>::max();
Real conductivitymax = conductivity(0, 0);
// get the biggest parameter from k11 until k33//
for (UInt i = 0; i < spatial_dimension; i++)
for (UInt j = 0; j < spatial_dimension; j++)
conductivitymax = std::max(conductivity(i, j), conductivitymax);
for (auto & type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
Array<Real> coord(0, nb_nodes_per_element * spatial_dimension);
FEEngine::extractNodalToElementField(mesh, mesh.getNodes(), coord, type,
_not_ghost);
auto el_coord = coord.begin(spatial_dimension, nb_nodes_per_element);
UInt nb_element = mesh.getNbElement(type);
for (UInt el = 0; el < nb_element; ++el, ++el_coord) {
el_size = getFEEngine().getElementInradius(*el_coord, type);
min_el_size = std::min(min_el_size, el_size);
}
AKANTU_DEBUG_INFO("The minimum element size : "
<< min_el_size
<< " and the max conductivity is : " << conductivitymax);
}
Real min_dt = 2. * min_el_size * min_el_size / 4. * density * capacity /
conductivitymax;
mesh.getCommunicator().allReduce(min_dt, SynchronizerOperation::_min);
AKANTU_DEBUG_OUT();
return min_dt;
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::setTimeStep(Real time_step, const ID & solver_id) {
Model::setTimeStep(time_step, solver_id);
#if defined(AKANTU_USE_IOHELPER)
this->mesh.getDumper("heat_transfer").setTimeStep(time_step);
#endif
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::readMaterials() {
auto sect = this->getParserSection();
if (not std::get<1>(sect)) {
const auto & section = std::get<0>(sect);
this->parseSection(section);
}
conductivity_on_qpoints.set(conductivity);
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::initFullImpl(const ModelOptions & options) {
Model::initFullImpl(options);
readMaterials();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::assembleCapacity() {
AKANTU_DEBUG_IN();
auto ghost_type = _not_ghost;
this->getDOFManager().clearMatrix("M");
auto & fem = getFEEngineClass<FEEngineType>();
heat_transfer::details::ComputeRhoFunctor rho_functor(*this);
for (auto && type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_regular)) {
fem.assembleFieldMatrix(rho_functor, "M", "temperature",
this->getDOFManager(), type, ghost_type);
}
need_to_reassemble_capacity = false;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::computeRho(Array<Real> & rho, ElementType type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
FEEngine & fem = this->getFEEngine();
UInt nb_element = mesh.getNbElement(type, ghost_type);
UInt nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
rho.resize(nb_element * nb_quadrature_points);
rho.set(this->capacity);
// Real * rho_1_val = rho.storage();
// /// compute @f$ rho @f$ for each nodes of each element
// for (UInt el = 0; el < nb_element; ++el) {
// for (UInt n = 0; n < nb_quadrature_points; ++n) {
// *rho_1_val++ = this->capacity;
// }
// }
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real HeatTransferModel::computeThermalEnergyByNode() {
AKANTU_DEBUG_IN();
Real ethermal = 0.;
for (auto && pair : enumerate(make_view(
*internal_heat_rate, internal_heat_rate->getNbComponent()))) {
auto n = std::get<0>(pair);
auto & heat_rate = std::get<1>(pair);
Real heat = 0.;
bool is_local_node = mesh.isLocalOrMasterNode(n);
bool count_node = is_local_node;
for (UInt i = 0; i < heat_rate.size(); ++i) {
if (count_node)
heat += heat_rate[i] * time_step;
}
ethermal += heat;
}
mesh.getCommunicator().allReduce(ethermal, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
return ethermal;
}
/* -------------------------------------------------------------------------- */
template <class iterator>
void HeatTransferModel::getThermalEnergy(
iterator Eth, Array<Real>::const_iterator<Real> T_it,
Array<Real>::const_iterator<Real> T_end) const {
for (; T_it != T_end; ++T_it, ++Eth) {
*Eth = capacity * density * *T_it;
}
}
/* -------------------------------------------------------------------------- */
Real HeatTransferModel::getThermalEnergy(const ElementType & type, UInt index) {
AKANTU_DEBUG_IN();
UInt nb_quadrature_points = getFEEngine().getNbIntegrationPoints(type);
Vector<Real> Eth_on_quarature_points(nb_quadrature_points);
auto T_it = this->temperature_on_qpoints(type).begin();
T_it += index * nb_quadrature_points;
auto T_end = T_it + nb_quadrature_points;
getThermalEnergy(Eth_on_quarature_points.storage(), T_it, T_end);
return getFEEngine().integrate(Eth_on_quarature_points, type, index);
}
/* -------------------------------------------------------------------------- */
Real HeatTransferModel::getThermalEnergy() {
Real Eth = 0;
auto & fem = getFEEngine();
for (auto && type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
auto nb_element = mesh.getNbElement(type, _not_ghost);
auto nb_quadrature_points = fem.getNbIntegrationPoints(type, _not_ghost);
Array<Real> Eth_per_quad(nb_element * nb_quadrature_points, 1);
auto & temperature_interpolated = temperature_on_qpoints(type);
// compute the temperature on quadrature points
this->getFEEngine().interpolateOnIntegrationPoints(
*temperature, temperature_interpolated, 1, type);
auto T_it = temperature_interpolated.begin();
auto T_end = temperature_interpolated.end();
getThermalEnergy(Eth_per_quad.begin(), T_it, T_end);
Eth += fem.integrate(Eth_per_quad, type);
}
return Eth;
}
/* -------------------------------------------------------------------------- */
Real HeatTransferModel::getEnergy(const std::string & id) {
AKANTU_DEBUG_IN();
Real energy = 0;
if (id == "thermal")
energy = getThermalEnergy();
// reduction sum over all processors
mesh.getCommunicator().allReduce(energy, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
return energy;
}
/* -------------------------------------------------------------------------- */
Real HeatTransferModel::getEnergy(const std::string & id,
const ElementType & type, UInt index) {
AKANTU_DEBUG_IN();
Real energy = 0.;
if (id == "thermal")
energy = getThermalEnergy(type, index);
AKANTU_DEBUG_OUT();
return energy;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
std::shared_ptr<dumper::Field> HeatTransferModel::createNodalFieldBool(
const std::string & field_name, const std::string & group_name,
__attribute__((unused)) bool padding_flag) {
std::map<std::string, Array<bool> *> uint_nodal_fields;
uint_nodal_fields["blocked_dofs"] = blocked_dofs;
auto field = mesh.createNodalField(uint_nodal_fields[field_name], group_name);
return field;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> HeatTransferModel::createNodalFieldReal(
const std::string & field_name, const std::string & group_name,
__attribute__((unused)) bool padding_flag) {
if (field_name == "capacity_lumped") {
AKANTU_EXCEPTION(
"Capacity lumped is a nodal field now stored in the DOF manager."
"Therefore it cannot be used by a dumper anymore");
}
std::map<std::string, Array<Real> *> real_nodal_fields;
real_nodal_fields["temperature"] = temperature;
real_nodal_fields["temperature_rate"] = temperature_rate;
real_nodal_fields["external_heat_rate"] = external_heat_rate;
real_nodal_fields["internal_heat_rate"] = internal_heat_rate;
real_nodal_fields["increment"] = increment;
std::shared_ptr<dumper::Field> field =
mesh.createNodalField(real_nodal_fields[field_name], group_name);
return field;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> HeatTransferModel::createElementalField(
const std::string & field_name, const std::string & group_name,
__attribute__((unused)) bool padding_flag,
__attribute__((unused)) const UInt & spatial_dimension,
const ElementKind & element_kind) {
std::shared_ptr<dumper::Field> field;
if (field_name == "partitions")
field = mesh.createElementalField<UInt, dumper::ElementPartitionField>(
mesh.getConnectivities(), group_name, this->spatial_dimension,
element_kind);
else if (field_name == "temperature_gradient") {
ElementTypeMap<UInt> nb_data_per_elem =
- this->mesh.getNbDataPerElem(temperature_gradient, element_kind);
+ this->mesh.getNbDataPerElem(temperature_gradient);
field = mesh.createElementalField<Real, dumper::InternalMaterialField>(
temperature_gradient, group_name, this->spatial_dimension, element_kind,
nb_data_per_elem);
} else if (field_name == "conductivity") {
ElementTypeMap<UInt> nb_data_per_elem =
- this->mesh.getNbDataPerElem(conductivity_on_qpoints, element_kind);
+ this->mesh.getNbDataPerElem(conductivity_on_qpoints);
field = mesh.createElementalField<Real, dumper::InternalMaterialField>(
conductivity_on_qpoints, group_name, this->spatial_dimension,
element_kind, nb_data_per_elem);
}
return field;
}
/* -------------------------------------------------------------------------- */
#else
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> HeatTransferModel::createElementalField(
__attribute__((unused)) const std::string & field_name,
__attribute__((unused)) const std::string & group_name,
__attribute__((unused)) bool padding_flag,
__attribute__((unused)) const ElementKind & element_kind) {
return nullptr;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> HeatTransferModel::createNodalFieldBool(
__attribute__((unused)) const std::string & field_name,
__attribute__((unused)) const std::string & group_name,
__attribute__((unused)) bool padding_flag) {
return nullptr;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> HeatTransferModel::createNodalFieldReal(
__attribute__((unused)) const std::string & field_name,
__attribute__((unused)) const std::string & group_name,
__attribute__((unused)) bool padding_flag) {
return nullptr;
}
#endif
/* -------------------------------------------------------------------------- */
void HeatTransferModel::dump(const std::string & dumper_name) {
mesh.dump(dumper_name);
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::dump(const std::string & dumper_name, UInt step) {
mesh.dump(dumper_name, step);
}
/* ------------------------------------------------------------------------- */
void HeatTransferModel::dump(const std::string & dumper_name, Real time,
UInt step) {
mesh.dump(dumper_name, time, step);
}
/* -------------------------------------------------------------------------- */
void HeatTransferModel::dump() { mesh.dump(); }
/* -------------------------------------------------------------------------- */
void HeatTransferModel::dump(UInt step) { mesh.dump(step); }
/* -------------------------------------------------------------------------- */
void HeatTransferModel::dump(Real time, UInt step) { mesh.dump(time, step); }
/* -------------------------------------------------------------------------- */
inline UInt HeatTransferModel::getNbData(const Array<UInt> & indexes,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
UInt nb_nodes = indexes.size();
switch (tag) {
case SynchronizationTag::_htm_temperature: {
size += nb_nodes * sizeof(Real);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
inline void HeatTransferModel::packData(CommunicationBuffer & buffer,
const Array<UInt> & indexes,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
for (auto index : indexes) {
switch (tag) {
case SynchronizationTag::_htm_temperature: {
buffer << (*temperature)(index);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
inline void HeatTransferModel::unpackData(CommunicationBuffer & buffer,
const Array<UInt> & indexes,
const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
for (auto index : indexes) {
switch (tag) {
case SynchronizationTag::_htm_temperature: {
buffer >> (*temperature)(index);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
inline UInt HeatTransferModel::getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
UInt nb_nodes_per_element = 0;
Array<Element>::const_iterator<Element> it = elements.begin();
Array<Element>::const_iterator<Element> end = elements.end();
for (; it != end; ++it) {
const Element & el = *it;
nb_nodes_per_element += Mesh::getNbNodesPerElement(el.type);
}
switch (tag) {
case SynchronizationTag::_htm_temperature: {
size += nb_nodes_per_element * sizeof(Real); // temperature
break;
}
case SynchronizationTag::_htm_gradient_temperature: {
// temperature gradient
size += getNbIntegrationPoints(elements) * spatial_dimension * sizeof(Real);
size += nb_nodes_per_element * sizeof(Real); // nodal temperatures
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
inline void HeatTransferModel::packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const {
switch (tag) {
case SynchronizationTag::_htm_temperature: {
packNodalDataHelper(*temperature, buffer, elements, mesh);
break;
}
case SynchronizationTag::_htm_gradient_temperature: {
packElementalDataHelper(temperature_gradient, buffer, elements, true,
getFEEngine());
packNodalDataHelper(*temperature, buffer, elements, mesh);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
}
/* -------------------------------------------------------------------------- */
inline void HeatTransferModel::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
switch (tag) {
case SynchronizationTag::_htm_temperature: {
unpackNodalDataHelper(*temperature, buffer, elements, mesh);
break;
}
case SynchronizationTag::_htm_gradient_temperature: {
unpackElementalDataHelper(temperature_gradient, buffer, elements, true,
getFEEngine());
unpackNodalDataHelper(*temperature, buffer, elements, mesh);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/heat_transfer/heat_transfer_model.hh b/src/model/heat_transfer/heat_transfer_model.hh
index 0f5e49769..4435a544a 100644
--- a/src/model/heat_transfer/heat_transfer_model.hh
+++ b/src/model/heat_transfer/heat_transfer_model.hh
@@ -1,344 +1,337 @@
/**
* @file heat_transfer_model.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Srinivasa Babu Ramisetti <srinivasa.ramisetti@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Rui Wang <rui.wang@epfl.ch>
*
* @date creation: Sun May 01 2011
* @date last modification: Mon Feb 05 2018
*
* @brief Model of Heat Transfer
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "data_accessor.hh"
#include "fe_engine.hh"
#include "model.hh"
/* -------------------------------------------------------------------------- */
#include <array>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_HEAT_TRANSFER_MODEL_HH__
#define __AKANTU_HEAT_TRANSFER_MODEL_HH__
namespace akantu {
template <ElementKind kind, class IntegrationOrderFunctor>
class IntegratorGauss;
template <ElementKind kind> class ShapeLagrange;
} // namespace akantu
namespace akantu {
class HeatTransferModel : public Model,
public DataAccessor<Element>,
public DataAccessor<UInt> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
using FEEngineType = FEEngineTemplate<IntegratorGauss, ShapeLagrange>;
HeatTransferModel(Mesh & mesh, UInt spatial_dimension = _all_dimensions,
const ID & id = "heat_transfer_model",
const MemoryID & memory_id = 0,
std::shared_ptr<DOFManager> dof_manager = nullptr);
virtual ~HeatTransferModel();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
protected:
/// generic function to initialize everything ready for explicit dynamics
void initFullImpl(const ModelOptions & options) override;
/// read one material file to instantiate all the materials
void readMaterials();
/// allocate all vectors
void initSolver(TimeStepSolverType, NonLinearSolverType) override;
/// initialize the model
void initModel() override;
void predictor() override;
/// compute the heat flux
void assembleResidual() override;
/// get the type of matrix needed
MatrixType getMatrixType(const ID &) override;
/// callback to assemble a Matrix
void assembleMatrix(const ID &) override;
/// callback to assemble a lumped Matrix
void assembleLumpedMatrix(const ID &) override;
std::tuple<ID, TimeStepSolverType>
getDefaultSolverID(const AnalysisMethod & method) override;
ModelSolverOptions
getDefaultSolverOptions(const TimeStepSolverType & type) const;
/* ------------------------------------------------------------------------ */
/* Methods for explicit */
/* ------------------------------------------------------------------------ */
public:
/// compute and get the stable time step
Real getStableTimeStep();
/// set the stable timestep
void setTimeStep(Real time_step, const ID & solver_id = "") override;
// temporary protection to prevent bad usage: should check for bug
protected:
/// compute the internal heat flux \todo Need code review: currently not
/// public method
void assembleInternalHeatRate();
public:
/// calculate the lumped capacity vector for heat transfer problem
void assembleCapacityLumped();
- /* ------------------------------------------------------------------------ */
- /* Methods for static */
- /* ------------------------------------------------------------------------ */
public:
/// assemble the conductivity matrix
void assembleConductivityMatrix();
/// assemble the conductivity matrix
void assembleCapacity();
/// compute the capacity on quadrature points
void computeRho(Array<Real> & rho, ElementType type, GhostType ghost_type);
private:
/// calculate the lumped capacity vector for heat transfer problem (w
/// ghost type)
void assembleCapacityLumped(const GhostType & ghost_type);
- /// assemble the conductivity matrix (w/ ghost type)
- template <UInt dim>
- void assembleConductivityMatrix(const GhostType & ghost_type);
-
/// compute the conductivity tensor for each quadrature point in an array
void computeConductivityOnQuadPoints(const GhostType & ghost_type);
/// compute vector k \grad T for each quadrature point
void computeKgradT(const GhostType & ghost_type);
/// compute the thermal energy
Real computeThermalEnergyByNode();
/* ------------------------------------------------------------------------ */
/* Data Accessor inherited members */
/* ------------------------------------------------------------------------ */
public:
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
inline UInt getNbData(const Array<UInt> & indexes,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<UInt> & indexes,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<UInt> & indexes,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* Dumpable interface */
/* ------------------------------------------------------------------------ */
public:
std::shared_ptr<dumper::Field>
createNodalFieldReal(const std::string & field_name,
const std::string & group_name,
bool padding_flag) override;
std::shared_ptr<dumper::Field>
createNodalFieldBool(const std::string & field_name,
const std::string & group_name,
bool padding_flag) override;
std::shared_ptr<dumper::Field>
createElementalField(const std::string & field_name,
const std::string & group_name, bool padding_flag,
const UInt & spatial_dimension,
const ElementKind & kind) override;
virtual void dump(const std::string & dumper_name);
virtual void dump(const std::string & dumper_name, UInt step);
virtual void dump(const std::string & dumper_name, Real time, UInt step);
void dump() override;
virtual void dump(UInt step);
virtual void dump(Real time, UInt step);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(Density, density, Real);
AKANTU_GET_MACRO(Capacity, capacity, Real);
/// get the dimension of the system space
AKANTU_GET_MACRO(SpatialDimension, spatial_dimension, UInt);
/// get the current value of the time step
AKANTU_GET_MACRO(TimeStep, time_step, Real);
/// get the assembled heat flux
AKANTU_GET_MACRO(InternalHeatRate, *internal_heat_rate, Array<Real> &);
/// get the boundary vector
AKANTU_GET_MACRO(BlockedDOFs, *blocked_dofs, Array<bool> &);
/// get the external heat rate vector
AKANTU_GET_MACRO(ExternalHeatRate, *external_heat_rate, Array<Real> &);
/// get the temperature gradient
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(TemperatureGradient,
temperature_gradient, Real);
/// get the conductivity on q points
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(ConductivityOnQpoints,
conductivity_on_qpoints, Real);
/// get the conductivity on q points
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(TemperatureOnQpoints,
temperature_on_qpoints, Real);
/// internal variables
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(KgradT, k_gradt_on_qpoints, Real);
/// get the temperature
AKANTU_GET_MACRO(Temperature, *temperature, Array<Real> &);
/// get the temperature derivative
AKANTU_GET_MACRO(TemperatureRate, *temperature_rate, Array<Real> &);
/// get the energy denominated by thermal
Real getEnergy(const std::string & energy_id, const ElementType & type,
UInt index);
/// get the energy denominated by thermal
Real getEnergy(const std::string & energy_id);
/// get the thermal energy for a given element
Real getThermalEnergy(const ElementType & type, UInt index);
/// get the thermal energy for a given element
Real getThermalEnergy();
protected:
/* ------------------------------------------------------------------------ */
FEEngine & getFEEngineBoundary(const ID & name = "") override;
/* ----------------------------------------------------------------------- */
template <class iterator>
void getThermalEnergy(iterator Eth, Array<Real>::const_iterator<Real> T_it,
Array<Real>::const_iterator<Real> T_end) const;
template <typename T>
void allocNodalField(Array<T> *& array, const ID & name);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// number of iterations
UInt n_iter;
/// time step
Real time_step;
/// temperatures array
Array<Real> * temperature{nullptr};
/// temperatures derivatives array
Array<Real> * temperature_rate{nullptr};
/// increment array (@f$\delta \dot T@f$ or @f$\delta T@f$)
Array<Real> * increment{nullptr};
/// the density
Real density;
/// the speed of the changing temperature
ElementTypeMapArray<Real> temperature_gradient;
/// temperature field on quadrature points
ElementTypeMapArray<Real> temperature_on_qpoints;
/// conductivity tensor on quadrature points
ElementTypeMapArray<Real> conductivity_on_qpoints;
/// vector k \grad T on quad points
ElementTypeMapArray<Real> k_gradt_on_qpoints;
/// external flux vector
Array<Real> * external_heat_rate{nullptr};
/// residuals array
Array<Real> * internal_heat_rate{nullptr};
/// boundary vector
Array<bool> * blocked_dofs{nullptr};
// realtime
Real time;
/// capacity
Real capacity;
// conductivity matrix
Matrix<Real> conductivity;
// linear variation of the conductivity (for temperature dependent
// conductivity)
Real conductivity_variation;
// reference temperature for the interpretation of temperature variation
Real T_ref;
// the biggest parameter of conductivity matrix
Real conductivitymax;
bool need_to_reassemble_capacity{true};
bool need_to_reassemble_capacity_lumped{true};
UInt temperature_release{0};
- UInt conductivity_matrix_release{0};
+ UInt conductivity_matrix_release{UInt(-1)};
std::unordered_map<GhostType, bool> initial_conductivity{{_not_ghost, true},
{_ghost, true}};
std::unordered_map<GhostType, UInt> conductivity_release{{_not_ghost, 0},
{_ghost, 0}};
};
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "heat_transfer_model_inline_impl.cc"
#endif /* __AKANTU_HEAT_TRANSFER_MODEL_HH__ */
diff --git a/src/model/model_inline_impl.cc b/src/model/model_inline_impl.cc
index 2583a4ef8..afd4cc492 100644
--- a/src/model/model_inline_impl.cc
+++ b/src/model/model_inline_impl.cc
@@ -1,216 +1,215 @@
/**
* @file model_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 25 2010
* @date last modification: Wed Nov 08 2017
*
* @brief inline implementation of the model class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "model.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MODEL_INLINE_IMPL_CC__
#define __AKANTU_MODEL_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename FEEngineClass>
inline FEEngineClass & Model::getFEEngineClassBoundary(std::string name) {
AKANTU_DEBUG_IN();
if (name == "")
name = default_fem;
FEEngineMap::const_iterator it_boun = fems_boundary.find(name);
if (it_boun == fems_boundary.end()) {
AKANTU_DEBUG_INFO("Creating FEEngine boundary " << name);
FEEngineMap::const_iterator it = fems.find(name);
AKANTU_DEBUG_ASSERT(it != fems.end(),
"The FEEngine " << name << " is not registered");
UInt spatial_dimension = it->second->getElementDimension();
std::stringstream sstr;
sstr << id << ":fem_boundary:" << name;
fems_boundary[name] = std::make_unique<FEEngineClass>(
it->second->getMesh(), spatial_dimension - 1, sstr.str(), memory_id);
}
AKANTU_DEBUG_OUT();
return aka::as_type<FEEngineClass>(*fems_boundary[name]);
}
/* -------------------------------------------------------------------------- */
template <typename FEEngineClass>
inline FEEngineClass & Model::getFEEngineClass(std::string name) const {
AKANTU_DEBUG_IN();
if (name == "")
name = default_fem;
auto it = fems.find(name);
AKANTU_DEBUG_ASSERT(it != fems.end(),
"The FEEngine " << name << " is not registered");
AKANTU_DEBUG_OUT();
return aka::as_type<FEEngineClass>(*(it->second));
}
/* -------------------------------------------------------------------------- */
inline void Model::unRegisterFEEngineObject(const std::string & name) {
auto it = fems.find(name);
AKANTU_DEBUG_ASSERT(it != fems.end(),
"FEEngine object with name " << name << " was not found");
fems.erase(it);
if (!fems.empty())
default_fem = (*fems.begin()).first;
}
/* -------------------------------------------------------------------------- */
template <typename FEEngineClass>
inline void Model::registerFEEngineObject(const std::string & name, Mesh & mesh,
UInt spatial_dimension) {
if (fems.size() == 0)
default_fem = name;
#ifndef AKANTU_NDEBUG
auto it = fems.find(name);
- AKANTU_DEBUG_ASSERT(it == fems.end(),
- "FEEngine object with name " << name
- << " was already created");
+ AKANTU_DEBUG_ASSERT(it == fems.end(), "FEEngine object with name "
+ << name << " was already created");
#endif
std::stringstream sstr;
sstr << id << ":fem:" << name << memory_id;
fems[name] = std::make_unique<FEEngineClass>(mesh, spatial_dimension,
sstr.str(), memory_id);
}
/* -------------------------------------------------------------------------- */
inline FEEngine & Model::getFEEngine(const ID & name) const {
AKANTU_DEBUG_IN();
ID tmp_name = name;
if (name == "")
tmp_name = default_fem;
auto it = fems.find(tmp_name);
AKANTU_DEBUG_ASSERT(it != fems.end(),
"The FEEngine " << tmp_name << " is not registered");
AKANTU_DEBUG_OUT();
return *(it->second);
}
/* -------------------------------------------------------------------------- */
inline FEEngine & Model::getFEEngineBoundary(const ID & name) {
AKANTU_DEBUG_IN();
ID tmp_name = name;
if (name == "")
tmp_name = default_fem;
FEEngineMap::const_iterator it = fems_boundary.find(tmp_name);
- AKANTU_DEBUG_ASSERT(it != fems_boundary.end(),
- "The FEEngine boundary " << tmp_name
- << " is not registered");
- AKANTU_DEBUG_ASSERT(it->second != nullptr,
- "The FEEngine boundary " << tmp_name
- << " was not created");
+ AKANTU_DEBUG_ASSERT(it != fems_boundary.end(), "The FEEngine boundary "
+ << tmp_name
+ << " is not registered");
+ AKANTU_DEBUG_ASSERT(it->second != nullptr, "The FEEngine boundary "
+ << tmp_name
+ << " was not created");
AKANTU_DEBUG_OUT();
return *(it->second);
}
// /* --------------------------------------------------------------------------
// */
// /// @todo : should merge with a single function which handles local and
// global
// inline void Model::changeLocalEquationNumberForPBC(std::map<UInt,UInt> &
// pbc_pair,
// UInt dimension){
// for (std::map<UInt,UInt>::iterator it = pbc_pair.begin();
// it != pbc_pair.end();++it) {
// Int node_master = (*it).second;
// Int node_slave = (*it).first;
// for (UInt i = 0; i < dimension; ++i) {
// (*dof_synchronizer->getLocalDOFEquationNumbersPointer())
// (node_slave*dimension+i) = dimension*node_master+i;
// (*dof_synchronizer->getGlobalDOFEquationNumbersPointer())
// (node_slave*dimension+i) = dimension*node_master+i;
// }
// }
// }
// /* --------------------------------------------------------------------------
// */
// inline bool Model::isPBCSlaveNode(const UInt node) const {
// // if no pbc is defined, is_pbc_slave_node is of size zero
// if (is_pbc_slave_node.size() == 0)
// return false;
// else
// return is_pbc_slave_node(node);
// }
/* -------------------------------------------------------------------------- */
template <typename T>
void Model::allocNodalField(Array<T> *& array, UInt nb_component,
const ID & name) {
if (array == nullptr) {
UInt nb_nodes = mesh.getNbNodes();
std::stringstream sstr_disp;
sstr_disp << id << ":" << name;
array = &(alloc<T>(sstr_disp.str(), nb_nodes, nb_component, T()));
}
}
/* -------------------------------------------------------------------------- */
inline UInt Model::getNbIntegrationPoints(const Array<Element> & elements,
const ID & fem_id) const {
UInt nb_quad = 0;
Array<Element>::const_iterator<Element> it = elements.begin();
Array<Element>::const_iterator<Element> end = elements.end();
for (; it != end; ++it) {
const Element & el = *it;
nb_quad +=
getFEEngine(fem_id).getNbIntegrationPoints(el.type, el.ghost_type);
}
return nb_quad;
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MODEL_INLINE_IMPL_CC__ */
diff --git a/src/model/solid_mechanics/material.cc b/src/model/solid_mechanics/material.cc
index 7c55a2fd8..4e0339d51 100644
--- a/src/model/solid_mechanics/material.cc
+++ b/src/model/solid_mechanics/material.cc
@@ -1,1367 +1,1364 @@
/**
* @file material.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Jul 27 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Implementation of the common part of the material class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Material::Material(SolidMechanicsModel & model, const ID & id)
: Memory(id, model.getMemoryID()), Parsable(ParserType::_material, id),
is_init(false), fem(model.getFEEngine()), finite_deformation(false),
name(""), model(model),
spatial_dimension(this->model.getSpatialDimension()),
element_filter("element_filter", id, this->memory_id),
stress("stress", *this), eigengradu("eigen_grad_u", *this),
gradu("grad_u", *this), green_strain("green_strain", *this),
piola_kirchhoff_2("piola_kirchhoff_2", *this),
potential_energy("potential_energy", *this), is_non_local(false),
use_previous_stress(false), use_previous_gradu(false),
interpolation_inverse_coordinates("interpolation inverse coordinates",
*this),
interpolation_points_matrices("interpolation points matrices", *this) {
AKANTU_DEBUG_IN();
/// for each connectivity types allocate the element filer array of the
/// material
element_filter.initialize(model.getMesh(),
_spatial_dimension = spatial_dimension,
_element_kind = _ek_regular);
- // model.getMesh().initElementTypeMapArray(element_filter, 1,
- // spatial_dimension,
- // false, _ek_regular);
-
this->initialize();
+
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Material::Material(SolidMechanicsModel & model, UInt dim, const Mesh & mesh,
FEEngine & fe_engine, const ID & id)
: Memory(id, model.getMemoryID()), Parsable(ParserType::_material, id),
is_init(false), fem(fe_engine), finite_deformation(false), name(""),
model(model), spatial_dimension(dim),
element_filter("element_filter", id, this->memory_id),
stress("stress", *this, dim, fe_engine, this->element_filter),
eigengradu("eigen_grad_u", *this, dim, fe_engine, this->element_filter),
gradu("gradu", *this, dim, fe_engine, this->element_filter),
green_strain("green_strain", *this, dim, fe_engine, this->element_filter),
piola_kirchhoff_2("piola_kirchhoff_2", *this, dim, fe_engine,
this->element_filter),
potential_energy("potential_energy", *this, dim, fe_engine,
this->element_filter),
is_non_local(false), use_previous_stress(false),
use_previous_gradu(false),
interpolation_inverse_coordinates("interpolation inverse_coordinates",
*this, dim, fe_engine,
this->element_filter),
interpolation_points_matrices("interpolation points matrices", *this, dim,
fe_engine, this->element_filter) {
AKANTU_DEBUG_IN();
element_filter.initialize(mesh, _spatial_dimension = spatial_dimension,
_element_kind = _ek_regular);
// mesh.initElementTypeMapArray(element_filter, 1, spatial_dimension, false,
// _ek_regular);
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Material::~Material() = default;
/* -------------------------------------------------------------------------- */
void Material::initialize() {
registerParam("rho", rho, Real(0.), _pat_parsable | _pat_modifiable,
"Density");
registerParam("name", name, std::string(), _pat_parsable | _pat_readable);
registerParam("finite_deformation", finite_deformation, false,
_pat_parsable | _pat_readable, "Is finite deformation");
registerParam("inelastic_deformation", inelastic_deformation, false,
_pat_internal, "Is inelastic deformation");
/// allocate gradu stress for local elements
eigengradu.initialize(spatial_dimension * spatial_dimension);
gradu.initialize(spatial_dimension * spatial_dimension);
stress.initialize(spatial_dimension * spatial_dimension);
potential_energy.initialize(1);
this->model.registerEventHandler(*this);
}
/* -------------------------------------------------------------------------- */
void Material::initMaterial() {
AKANTU_DEBUG_IN();
if (finite_deformation) {
this->piola_kirchhoff_2.initialize(spatial_dimension * spatial_dimension);
if (use_previous_stress)
this->piola_kirchhoff_2.initializeHistory();
this->green_strain.initialize(spatial_dimension * spatial_dimension);
}
if (use_previous_stress)
this->stress.initializeHistory();
if (use_previous_gradu)
this->gradu.initializeHistory();
this->resizeInternals();
is_init = true;
updateInternalParameters();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::savePreviousState() {
AKANTU_DEBUG_IN();
for (auto pair : internal_vectors_real)
if (pair.second->hasHistory())
pair.second->saveCurrentValues();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::restorePreviousState() {
AKANTU_DEBUG_IN();
for (auto pair : internal_vectors_real)
if (pair.second->hasHistory())
pair.second->restorePreviousValues();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Compute the residual by assembling @f$\int_{e} \sigma_e \frac{\partial
* \varphi}{\partial X} dX @f$
*
* @param[in] displacements nodes displacements
* @param[in] ghost_type compute the residual for _ghost or _not_ghost element
*/
// void Material::updateResidual(GhostType ghost_type) {
// AKANTU_DEBUG_IN();
// computeAllStresses(ghost_type);
// assembleResidual(ghost_type);
// AKANTU_DEBUG_OUT();
// }
/* -------------------------------------------------------------------------- */
void Material::assembleInternalForces(GhostType ghost_type) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
if (!finite_deformation) {
auto & internal_force = const_cast<Array<Real> &>(model.getInternalForce());
// Mesh & mesh = fem.getMesh();
for (auto && type :
element_filter.elementTypes(spatial_dimension, ghost_type)) {
Array<UInt> & elem_filter = element_filter(type, ghost_type);
UInt nb_element = elem_filter.size();
if (nb_element == 0)
continue;
const Array<Real> & shapes_derivatives =
fem.getShapesDerivatives(type, ghost_type);
UInt size_of_shapes_derivatives = shapes_derivatives.getNbComponent();
UInt nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
/// compute @f$\sigma \frac{\partial \varphi}{\partial X}@f$ by
/// @f$\mathbf{B}^t \mathbf{\sigma}_q@f$
Array<Real> * sigma_dphi_dx =
new Array<Real>(nb_element * nb_quadrature_points,
size_of_shapes_derivatives, "sigma_x_dphi_/_dX");
fem.computeBtD(stress(type, ghost_type), *sigma_dphi_dx, type, ghost_type,
elem_filter);
/**
* compute @f$\int \sigma * \frac{\partial \varphi}{\partial X}dX@f$ by
* @f$ \sum_q \mathbf{B}^t
* \mathbf{\sigma}_q \overline w_q J_q@f$
*/
Array<Real> * int_sigma_dphi_dx =
new Array<Real>(nb_element, nb_nodes_per_element * spatial_dimension,
"int_sigma_x_dphi_/_dX");
fem.integrate(*sigma_dphi_dx, *int_sigma_dphi_dx,
size_of_shapes_derivatives, type, ghost_type, elem_filter);
delete sigma_dphi_dx;
/// assemble
model.getDOFManager().assembleElementalArrayLocalArray(
*int_sigma_dphi_dx, internal_force, type, ghost_type, -1,
elem_filter);
delete int_sigma_dphi_dx;
}
} else {
switch (spatial_dimension) {
case 1:
this->assembleInternalForces<1>(ghost_type);
break;
case 2:
this->assembleInternalForces<2>(ghost_type);
break;
case 3:
this->assembleInternalForces<3>(ghost_type);
break;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Compute the stress from the gradu
*
* @param[in] current_position nodes postition + displacements
* @param[in] ghost_type compute the residual for _ghost or _not_ghost element
*/
void Material::computeAllStresses(GhostType ghost_type) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
for (const auto & type :
element_filter.elementTypes(spatial_dimension, ghost_type)) {
Array<UInt> & elem_filter = element_filter(type, ghost_type);
if (elem_filter.size() == 0)
continue;
Array<Real> & gradu_vect = gradu(type, ghost_type);
/// compute @f$\nabla u@f$
fem.gradientOnIntegrationPoints(model.getDisplacement(), gradu_vect,
spatial_dimension, type, ghost_type,
elem_filter);
gradu_vect -= eigengradu(type, ghost_type);
/// compute @f$\mathbf{\sigma}_q@f$ from @f$\nabla u@f$
computeStress(type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::computeAllCauchyStresses(GhostType ghost_type) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(finite_deformation, "The Cauchy stress can only be "
"computed if you are working in "
"finite deformation.");
for (auto type : element_filter.elementTypes(spatial_dimension, ghost_type)) {
switch (spatial_dimension) {
case 1:
this->computeCauchyStress<1>(type, ghost_type);
break;
case 2:
this->computeCauchyStress<2>(type, ghost_type);
break;
case 3:
this->computeCauchyStress<3>(type, ghost_type);
break;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void Material::computeCauchyStress(ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Array<Real>::matrix_iterator gradu_it =
this->gradu(el_type, ghost_type).begin(dim, dim);
Array<Real>::matrix_iterator gradu_end =
this->gradu(el_type, ghost_type).end(dim, dim);
Array<Real>::matrix_iterator piola_it =
this->piola_kirchhoff_2(el_type, ghost_type).begin(dim, dim);
Array<Real>::matrix_iterator stress_it =
this->stress(el_type, ghost_type).begin(dim, dim);
Matrix<Real> F_tensor(dim, dim);
for (; gradu_it != gradu_end; ++gradu_it, ++piola_it, ++stress_it) {
Matrix<Real> & grad_u = *gradu_it;
Matrix<Real> & piola = *piola_it;
Matrix<Real> & sigma = *stress_it;
gradUToF<dim>(grad_u, F_tensor);
this->computeCauchyStressOnQuad<dim>(F_tensor, piola, sigma);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::setToSteadyState(GhostType ghost_type) {
AKANTU_DEBUG_IN();
const Array<Real> & displacement = model.getDisplacement();
// resizeInternalArray(gradu);
UInt spatial_dimension = model.getSpatialDimension();
for (auto type : element_filter.elementTypes(spatial_dimension, ghost_type)) {
Array<UInt> & elem_filter = element_filter(type, ghost_type);
Array<Real> & gradu_vect = gradu(type, ghost_type);
/// compute @f$\nabla u@f$
fem.gradientOnIntegrationPoints(displacement, gradu_vect, spatial_dimension,
type, ghost_type, elem_filter);
setToSteadyState(type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Compute the stiffness matrix by assembling @f$\int_{\omega} B^t \times D
* \times B d\omega @f$
*
* @param[in] current_position nodes postition + displacements
* @param[in] ghost_type compute the residual for _ghost or _not_ghost element
*/
void Material::assembleStiffnessMatrix(GhostType ghost_type) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
for (auto type : element_filter.elementTypes(spatial_dimension, ghost_type)) {
if (finite_deformation) {
switch (spatial_dimension) {
case 1: {
assembleStiffnessMatrixNL<1>(type, ghost_type);
assembleStiffnessMatrixL2<1>(type, ghost_type);
break;
}
case 2: {
assembleStiffnessMatrixNL<2>(type, ghost_type);
assembleStiffnessMatrixL2<2>(type, ghost_type);
break;
}
case 3: {
assembleStiffnessMatrixNL<3>(type, ghost_type);
assembleStiffnessMatrixL2<3>(type, ghost_type);
break;
}
}
} else {
switch (spatial_dimension) {
case 1: {
assembleStiffnessMatrix<1>(type, ghost_type);
break;
}
case 2: {
assembleStiffnessMatrix<2>(type, ghost_type);
break;
}
case 3: {
assembleStiffnessMatrix<3>(type, ghost_type);
break;
}
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void Material::assembleStiffnessMatrix(const ElementType & type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Array<UInt> & elem_filter = element_filter(type, ghost_type);
if (elem_filter.size() == 0) {
AKANTU_DEBUG_OUT();
return;
}
// const Array<Real> & shapes_derivatives =
// fem.getShapesDerivatives(type, ghost_type);
Array<Real> & gradu_vect = gradu(type, ghost_type);
UInt nb_element = elem_filter.size();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
gradu_vect.resize(nb_quadrature_points * nb_element);
fem.gradientOnIntegrationPoints(model.getDisplacement(), gradu_vect, dim,
type, ghost_type, elem_filter);
UInt tangent_size = getTangentStiffnessVoigtSize(dim);
Array<Real> * tangent_stiffness_matrix =
new Array<Real>(nb_element * nb_quadrature_points,
tangent_size * tangent_size, "tangent_stiffness_matrix");
tangent_stiffness_matrix->clear();
computeTangentModuli(type, *tangent_stiffness_matrix, ghost_type);
/// compute @f$\mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
UInt bt_d_b_size = dim * nb_nodes_per_element;
Array<Real> * bt_d_b = new Array<Real>(nb_element * nb_quadrature_points,
bt_d_b_size * bt_d_b_size, "B^t*D*B");
fem.computeBtDB(*tangent_stiffness_matrix, *bt_d_b, 4, type, ghost_type,
elem_filter);
delete tangent_stiffness_matrix;
/// compute @f$ k_e = \int_e \mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
Array<Real> * K_e =
new Array<Real>(nb_element, bt_d_b_size * bt_d_b_size, "K_e");
fem.integrate(*bt_d_b, *K_e, bt_d_b_size * bt_d_b_size, type, ghost_type,
elem_filter);
delete bt_d_b;
model.getDOFManager().assembleElementalMatricesToMatrix(
"K", "displacement", *K_e, type, ghost_type, _symmetric, elem_filter);
delete K_e;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void Material::assembleStiffnessMatrixNL(const ElementType & type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
const Array<Real> & shapes_derivatives =
fem.getShapesDerivatives(type, ghost_type);
Array<UInt> & elem_filter = element_filter(type, ghost_type);
// Array<Real> & gradu_vect = delta_gradu(type, ghost_type);
UInt nb_element = elem_filter.size();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
Array<Real> * shapes_derivatives_filtered = new Array<Real>(
nb_element * nb_quadrature_points, dim * nb_nodes_per_element,
"shapes derivatives filtered");
fem.filterElementalData(fem.getMesh(), shapes_derivatives,
*shapes_derivatives_filtered, type, ghost_type,
elem_filter);
/// compute @f$\mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
UInt bt_s_b_size = dim * nb_nodes_per_element;
Array<Real> * bt_s_b = new Array<Real>(nb_element * nb_quadrature_points,
bt_s_b_size * bt_s_b_size, "B^t*D*B");
UInt piola_matrix_size = getCauchyStressMatrixSize(dim);
Matrix<Real> B(piola_matrix_size, bt_s_b_size);
Matrix<Real> Bt_S(bt_s_b_size, piola_matrix_size);
Matrix<Real> S(piola_matrix_size, piola_matrix_size);
auto shapes_derivatives_filtered_it = shapes_derivatives_filtered->begin(
spatial_dimension, nb_nodes_per_element);
auto Bt_S_B_it = bt_s_b->begin(bt_s_b_size, bt_s_b_size);
auto Bt_S_B_end = bt_s_b->end(bt_s_b_size, bt_s_b_size);
auto piola_it = piola_kirchhoff_2(type, ghost_type).begin(dim, dim);
for (; Bt_S_B_it != Bt_S_B_end;
++Bt_S_B_it, ++shapes_derivatives_filtered_it, ++piola_it) {
auto & Bt_S_B = *Bt_S_B_it;
const auto & Piola_kirchhoff_matrix = *piola_it;
setCauchyStressMatrix<dim>(Piola_kirchhoff_matrix, S);
VoigtHelper<dim>::transferBMatrixToBNL(*shapes_derivatives_filtered_it, B,
nb_nodes_per_element);
Bt_S.template mul<true, false>(B, S);
Bt_S_B.template mul<false, false>(Bt_S, B);
}
delete shapes_derivatives_filtered;
/// compute @f$ k_e = \int_e \mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
Array<Real> * K_e =
new Array<Real>(nb_element, bt_s_b_size * bt_s_b_size, "K_e");
fem.integrate(*bt_s_b, *K_e, bt_s_b_size * bt_s_b_size, type, ghost_type,
elem_filter);
delete bt_s_b;
model.getDOFManager().assembleElementalMatricesToMatrix(
"K", "displacement", *K_e, type, ghost_type, _symmetric, elem_filter);
delete K_e;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void Material::assembleStiffnessMatrixL2(const ElementType & type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
const Array<Real> & shapes_derivatives =
fem.getShapesDerivatives(type, ghost_type);
Array<UInt> & elem_filter = element_filter(type, ghost_type);
Array<Real> & gradu_vect = gradu(type, ghost_type);
UInt nb_element = elem_filter.size();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
gradu_vect.resize(nb_quadrature_points * nb_element);
fem.gradientOnIntegrationPoints(model.getDisplacement(), gradu_vect, dim,
type, ghost_type, elem_filter);
UInt tangent_size = getTangentStiffnessVoigtSize(dim);
Array<Real> * tangent_stiffness_matrix =
new Array<Real>(nb_element * nb_quadrature_points,
tangent_size * tangent_size, "tangent_stiffness_matrix");
tangent_stiffness_matrix->clear();
computeTangentModuli(type, *tangent_stiffness_matrix, ghost_type);
Array<Real> * shapes_derivatives_filtered = new Array<Real>(
nb_element * nb_quadrature_points, dim * nb_nodes_per_element,
"shapes derivatives filtered");
fem.filterElementalData(fem.getMesh(), shapes_derivatives,
*shapes_derivatives_filtered, type, ghost_type,
elem_filter);
/// compute @f$\mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
UInt bt_d_b_size = dim * nb_nodes_per_element;
Array<Real> * bt_d_b = new Array<Real>(nb_element * nb_quadrature_points,
bt_d_b_size * bt_d_b_size, "B^t*D*B");
Matrix<Real> B(tangent_size, dim * nb_nodes_per_element);
Matrix<Real> B2(tangent_size, dim * nb_nodes_per_element);
Matrix<Real> Bt_D(dim * nb_nodes_per_element, tangent_size);
auto shapes_derivatives_filtered_it = shapes_derivatives_filtered->begin(
spatial_dimension, nb_nodes_per_element);
auto Bt_D_B_it = bt_d_b->begin(bt_d_b_size, bt_d_b_size);
auto grad_u_it = gradu_vect.begin(dim, dim);
auto D_it = tangent_stiffness_matrix->begin(tangent_size, tangent_size);
auto D_end = tangent_stiffness_matrix->end(tangent_size, tangent_size);
for (; D_it != D_end;
++D_it, ++Bt_D_B_it, ++shapes_derivatives_filtered_it, ++grad_u_it) {
const auto & grad_u = *grad_u_it;
const auto & D = *D_it;
auto & Bt_D_B = *Bt_D_B_it;
// transferBMatrixToBL1<dim > (*shapes_derivatives_filtered_it, B,
// nb_nodes_per_element);
VoigtHelper<dim>::transferBMatrixToSymVoigtBMatrix(
*shapes_derivatives_filtered_it, B, nb_nodes_per_element);
VoigtHelper<dim>::transferBMatrixToBL2(*shapes_derivatives_filtered_it,
grad_u, B2, nb_nodes_per_element);
B += B2;
Bt_D.template mul<true, false>(B, D);
Bt_D_B.template mul<false, false>(Bt_D, B);
}
delete tangent_stiffness_matrix;
delete shapes_derivatives_filtered;
/// compute @f$ k_e = \int_e \mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
Array<Real> * K_e =
new Array<Real>(nb_element, bt_d_b_size * bt_d_b_size, "K_e");
fem.integrate(*bt_d_b, *K_e, bt_d_b_size * bt_d_b_size, type, ghost_type,
elem_filter);
delete bt_d_b;
model.getDOFManager().assembleElementalMatricesToMatrix(
"K", "displacement", *K_e, type, ghost_type, _symmetric, elem_filter);
delete K_e;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void Material::assembleInternalForces(GhostType ghost_type) {
AKANTU_DEBUG_IN();
Array<Real> & internal_force = model.getInternalForce();
Mesh & mesh = fem.getMesh();
for (auto type : element_filter.elementTypes(_ghost_type = ghost_type)) {
const Array<Real> & shapes_derivatives =
fem.getShapesDerivatives(type, ghost_type);
Array<UInt> & elem_filter = element_filter(type, ghost_type);
if (elem_filter.size() == 0)
continue;
UInt size_of_shapes_derivatives = shapes_derivatives.getNbComponent();
UInt nb_element = elem_filter.size();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = fem.getNbIntegrationPoints(type, ghost_type);
Array<Real> * shapesd_filtered = new Array<Real>(
nb_element, size_of_shapes_derivatives, "filtered shapesd");
fem.filterElementalData(mesh, shapes_derivatives, *shapesd_filtered, type,
ghost_type, elem_filter);
Array<Real>::matrix_iterator shapes_derivatives_filtered_it =
shapesd_filtered->begin(dim, nb_nodes_per_element);
// Set stress vectors
UInt stress_size = getTangentStiffnessVoigtSize(dim);
// Set matrices B and BNL*
UInt bt_s_size = dim * nb_nodes_per_element;
auto * bt_s =
new Array<Real>(nb_element * nb_quadrature_points, bt_s_size, "B^t*S");
auto grad_u_it = this->gradu(type, ghost_type).begin(dim, dim);
auto grad_u_end = this->gradu(type, ghost_type).end(dim, dim);
auto stress_it = this->piola_kirchhoff_2(type, ghost_type).begin(dim, dim);
shapes_derivatives_filtered_it =
shapesd_filtered->begin(dim, nb_nodes_per_element);
Array<Real>::matrix_iterator bt_s_it = bt_s->begin(bt_s_size, 1);
Matrix<Real> S_vect(stress_size, 1);
Matrix<Real> B_tensor(stress_size, bt_s_size);
Matrix<Real> B2_tensor(stress_size, bt_s_size);
for (; grad_u_it != grad_u_end; ++grad_u_it, ++stress_it,
++shapes_derivatives_filtered_it,
++bt_s_it) {
auto & grad_u = *grad_u_it;
auto & r_it = *bt_s_it;
auto & S_it = *stress_it;
setCauchyStressArray<dim>(S_it, S_vect);
VoigtHelper<dim>::transferBMatrixToSymVoigtBMatrix(
*shapes_derivatives_filtered_it, B_tensor, nb_nodes_per_element);
VoigtHelper<dim>::transferBMatrixToBL2(*shapes_derivatives_filtered_it,
grad_u, B2_tensor,
nb_nodes_per_element);
B_tensor += B2_tensor;
r_it.template mul<true, false>(B_tensor, S_vect);
}
delete shapesd_filtered;
/// compute @f$ k_e = \int_e \mathbf{B}^t * \mathbf{D} * \mathbf{B}@f$
Array<Real> * r_e = new Array<Real>(nb_element, bt_s_size, "r_e");
fem.integrate(*bt_s, *r_e, bt_s_size, type, ghost_type, elem_filter);
delete bt_s;
model.getDOFManager().assembleElementalArrayLocalArray(
*r_e, internal_force, type, ghost_type, -1., elem_filter);
delete r_e;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::computePotentialEnergyByElements() {
AKANTU_DEBUG_IN();
for (auto type : element_filter.elementTypes(spatial_dimension, _not_ghost)) {
computePotentialEnergy(type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::computePotentialEnergy(ElementType) {
AKANTU_DEBUG_IN();
AKANTU_TO_IMPLEMENT();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real Material::getPotentialEnergy() {
AKANTU_DEBUG_IN();
Real epot = 0.;
computePotentialEnergyByElements();
/// integrate the potential energy for each type of elements
for (auto type : element_filter.elementTypes(spatial_dimension, _not_ghost)) {
epot += fem.integrate(potential_energy(type, _not_ghost), type, _not_ghost,
element_filter(type, _not_ghost));
}
AKANTU_DEBUG_OUT();
return epot;
}
/* -------------------------------------------------------------------------- */
Real Material::getPotentialEnergy(ElementType & type, UInt index) {
AKANTU_DEBUG_IN();
Real epot = 0.;
Vector<Real> epot_on_quad_points(fem.getNbIntegrationPoints(type));
computePotentialEnergyByElement(type, index, epot_on_quad_points);
epot = fem.integrate(epot_on_quad_points, type, element_filter(type)(index));
AKANTU_DEBUG_OUT();
return epot;
}
/* -------------------------------------------------------------------------- */
Real Material::getEnergy(const std::string & type) {
AKANTU_DEBUG_IN();
if (type == "potential")
return getPotentialEnergy();
AKANTU_DEBUG_OUT();
return 0.;
}
/* -------------------------------------------------------------------------- */
Real Material::getEnergy(const std::string & energy_id, ElementType type,
UInt index) {
AKANTU_DEBUG_IN();
if (energy_id == "potential")
return getPotentialEnergy(type, index);
AKANTU_DEBUG_OUT();
return 0.;
}
/* -------------------------------------------------------------------------- */
void Material::initElementalFieldInterpolation(
const ElementTypeMapArray<Real> & interpolation_points_coordinates) {
AKANTU_DEBUG_IN();
this->fem.initElementalFieldInterpolationFromIntegrationPoints(
interpolation_points_coordinates, this->interpolation_points_matrices,
this->interpolation_inverse_coordinates, &(this->element_filter));
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::interpolateStress(ElementTypeMapArray<Real> & result,
const GhostType ghost_type) {
this->fem.interpolateElementalFieldFromIntegrationPoints(
this->stress, this->interpolation_points_matrices,
this->interpolation_inverse_coordinates, result, ghost_type,
&(this->element_filter));
}
/* -------------------------------------------------------------------------- */
void Material::interpolateStressOnFacets(
ElementTypeMapArray<Real> & result,
ElementTypeMapArray<Real> & by_elem_result, const GhostType ghost_type) {
interpolateStress(by_elem_result, ghost_type);
UInt stress_size = this->stress.getNbComponent();
const Mesh & mesh = this->model.getMesh();
const Mesh & mesh_facets = mesh.getMeshFacets();
for (auto type : element_filter.elementTypes(spatial_dimension, ghost_type)) {
Array<UInt> & elem_fil = element_filter(type, ghost_type);
Array<Real> & by_elem_res = by_elem_result(type, ghost_type);
UInt nb_element = elem_fil.size();
UInt nb_element_full = this->model.getMesh().getNbElement(type, ghost_type);
UInt nb_interpolation_points_per_elem =
by_elem_res.size() / nb_element_full;
const Array<Element> & facet_to_element =
mesh_facets.getSubelementToElement(type, ghost_type);
ElementType type_facet = Mesh::getFacetType(type);
UInt nb_facet_per_elem = facet_to_element.getNbComponent();
UInt nb_quad_per_facet =
nb_interpolation_points_per_elem / nb_facet_per_elem;
Element element_for_comparison{type, 0, ghost_type};
const Array<std::vector<Element>> * element_to_facet = nullptr;
GhostType current_ghost_type = _casper;
Array<Real> * result_vec = nullptr;
Array<Real>::const_matrix_iterator result_it =
by_elem_res.begin_reinterpret(
stress_size, nb_interpolation_points_per_elem, nb_element_full);
for (UInt el = 0; el < nb_element; ++el) {
UInt global_el = elem_fil(el);
element_for_comparison.element = global_el;
for (UInt f = 0; f < nb_facet_per_elem; ++f) {
Element facet_elem = facet_to_element(global_el, f);
UInt global_facet = facet_elem.element;
if (facet_elem.ghost_type != current_ghost_type) {
current_ghost_type = facet_elem.ghost_type;
element_to_facet = &mesh_facets.getElementToSubelement(
type_facet, current_ghost_type);
result_vec = &result(type_facet, current_ghost_type);
}
bool is_second_element =
(*element_to_facet)(global_facet)[0] != element_for_comparison;
for (UInt q = 0; q < nb_quad_per_facet; ++q) {
Vector<Real> result_local(result_vec->storage() +
(global_facet * nb_quad_per_facet + q) *
result_vec->getNbComponent() +
is_second_element * stress_size,
stress_size);
const Matrix<Real> & result_tmp(result_it[global_el]);
result_local = result_tmp(f * nb_quad_per_facet + q);
}
}
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
const Array<T> & Material::getArray(const ID & /*vect_id*/,
const ElementType & /*type*/,
const GhostType & /*ghost_type*/) const {
AKANTU_TO_IMPLEMENT();
return NULL;
}
/* -------------------------------------------------------------------------- */
template <typename T>
Array<T> & Material::getArray(const ID & /*vect_id*/,
const ElementType & /*type*/,
const GhostType & /*ghost_type*/) {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
template <>
const Array<Real> & Material::getArray(const ID & vect_id,
const ElementType & type,
const GhostType & ghost_type) const {
std::stringstream sstr;
std::string ghost_id = "";
if (ghost_type == _ghost)
ghost_id = ":ghost";
sstr << getID() << ":" << vect_id << ":" << type << ghost_id;
ID fvect_id = sstr.str();
try {
return Memory::getArray<Real>(fvect_id);
} catch (debug::Exception & e) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain a vector "
<< vect_id << " (" << fvect_id
<< ") [" << e << "]");
}
}
/* -------------------------------------------------------------------------- */
template <>
Array<Real> & Material::getArray(const ID & vect_id, const ElementType & type,
const GhostType & ghost_type) {
std::stringstream sstr;
std::string ghost_id = "";
if (ghost_type == _ghost)
ghost_id = ":ghost";
sstr << getID() << ":" << vect_id << ":" << type << ghost_id;
ID fvect_id = sstr.str();
try {
return Memory::getArray<Real>(fvect_id);
} catch (debug::Exception & e) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain a vector "
<< vect_id << " (" << fvect_id
<< ") [" << e << "]");
}
}
/* -------------------------------------------------------------------------- */
template <>
const Array<UInt> & Material::getArray(const ID & vect_id,
const ElementType & type,
const GhostType & ghost_type) const {
std::stringstream sstr;
std::string ghost_id = "";
if (ghost_type == _ghost)
ghost_id = ":ghost";
sstr << getID() << ":" << vect_id << ":" << type << ghost_id;
ID fvect_id = sstr.str();
try {
return Memory::getArray<UInt>(fvect_id);
} catch (debug::Exception & e) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain a vector "
<< vect_id << " (" << fvect_id
<< ") [" << e << "]");
}
}
/* -------------------------------------------------------------------------- */
template <>
Array<UInt> & Material::getArray(const ID & vect_id, const ElementType & type,
const GhostType & ghost_type) {
std::stringstream sstr;
std::string ghost_id = "";
if (ghost_type == _ghost)
ghost_id = ":ghost";
sstr << getID() << ":" << vect_id << ":" << type << ghost_id;
ID fvect_id = sstr.str();
try {
return Memory::getArray<UInt>(fvect_id);
} catch (debug::Exception & e) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain a vector "
<< vect_id << "(" << fvect_id
<< ") [" << e << "]");
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
const InternalField<T> &
Material::getInternal([[gnu::unused]] const ID & int_id) const {
AKANTU_TO_IMPLEMENT();
return NULL;
}
/* -------------------------------------------------------------------------- */
template <typename T>
InternalField<T> & Material::getInternal([[gnu::unused]] const ID & int_id) {
AKANTU_TO_IMPLEMENT();
return NULL;
}
/* -------------------------------------------------------------------------- */
template <>
const InternalField<Real> & Material::getInternal(const ID & int_id) const {
auto it = internal_vectors_real.find(getID() + ":" + int_id);
if (it == internal_vectors_real.end()) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain an internal "
<< int_id << " ("
<< (getID() + ":" + int_id) << ")");
}
return *it->second;
}
/* -------------------------------------------------------------------------- */
template <> InternalField<Real> & Material::getInternal(const ID & int_id) {
auto it = internal_vectors_real.find(getID() + ":" + int_id);
if (it == internal_vectors_real.end()) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain an internal "
<< int_id << " ("
<< (getID() + ":" + int_id) << ")");
}
return *it->second;
}
/* -------------------------------------------------------------------------- */
template <>
const InternalField<UInt> & Material::getInternal(const ID & int_id) const {
auto it = internal_vectors_uint.find(getID() + ":" + int_id);
if (it == internal_vectors_uint.end()) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain an internal "
<< int_id << " ("
<< (getID() + ":" + int_id) << ")");
}
return *it->second;
}
/* -------------------------------------------------------------------------- */
template <> InternalField<UInt> & Material::getInternal(const ID & int_id) {
auto it = internal_vectors_uint.find(getID() + ":" + int_id);
if (it == internal_vectors_uint.end()) {
AKANTU_SILENT_EXCEPTION("The material " << name << "(" << getID()
<< ") does not contain an internal "
<< int_id << " ("
<< (getID() + ":" + int_id) << ")");
}
return *it->second;
}
/* -------------------------------------------------------------------------- */
void Material::addElements(const Array<Element> & elements_to_add) {
AKANTU_DEBUG_IN();
UInt mat_id = model.getInternalIndexFromID(getID());
Array<Element>::const_iterator<Element> el_begin = elements_to_add.begin();
Array<Element>::const_iterator<Element> el_end = elements_to_add.end();
for (; el_begin != el_end; ++el_begin) {
const Element & element = *el_begin;
Array<UInt> & mat_indexes =
model.getMaterialByElement(element.type, element.ghost_type);
Array<UInt> & mat_loc_num =
model.getMaterialLocalNumbering(element.type, element.ghost_type);
UInt index =
this->addElement(element.type, element.element, element.ghost_type);
mat_indexes(element.element) = mat_id;
mat_loc_num(element.element) = index;
}
this->resizeInternals();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::removeElements(const Array<Element> & elements_to_remove) {
AKANTU_DEBUG_IN();
Array<Element>::const_iterator<Element> el_begin = elements_to_remove.begin();
Array<Element>::const_iterator<Element> el_end = elements_to_remove.end();
if (el_begin == el_end)
return;
ElementTypeMapArray<UInt> material_local_new_numbering(
"remove mat filter elem", getID(), getMemoryID());
Element element;
for (auto ghost_type : ghost_types) {
element.ghost_type = ghost_type;
for (auto & type : element_filter.elementTypes(_ghost_type = ghost_type,
_element_kind = _ek_not_defined)) {
element.type = type;
Array<UInt> & elem_filter = this->element_filter(type, ghost_type);
Array<UInt> & mat_loc_num =
this->model.getMaterialLocalNumbering(type, ghost_type);
if (!material_local_new_numbering.exists(type, ghost_type))
material_local_new_numbering.alloc(elem_filter.size(), 1, type,
ghost_type);
Array<UInt> & mat_renumbering =
material_local_new_numbering(type, ghost_type);
UInt nb_element = elem_filter.size();
Array<UInt> elem_filter_tmp;
UInt new_id = 0;
for (UInt el = 0; el < nb_element; ++el) {
element.element = elem_filter(el);
if (std::find(el_begin, el_end, element) == el_end) {
elem_filter_tmp.push_back(element.element);
mat_renumbering(el) = new_id;
mat_loc_num(element.element) = new_id;
++new_id;
} else {
mat_renumbering(el) = UInt(-1);
}
}
elem_filter.resize(elem_filter_tmp.size());
elem_filter.copy(elem_filter_tmp);
}
}
for (auto it = internal_vectors_real.begin();
it != internal_vectors_real.end(); ++it)
it->second->removeIntegrationPoints(material_local_new_numbering);
for (auto it = internal_vectors_uint.begin();
it != internal_vectors_uint.end(); ++it)
it->second->removeIntegrationPoints(material_local_new_numbering);
for (auto it = internal_vectors_bool.begin();
it != internal_vectors_bool.end(); ++it)
it->second->removeIntegrationPoints(material_local_new_numbering);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::resizeInternals() {
AKANTU_DEBUG_IN();
for (auto it = internal_vectors_real.begin();
it != internal_vectors_real.end(); ++it)
it->second->resize();
for (auto it = internal_vectors_uint.begin();
it != internal_vectors_uint.end(); ++it)
it->second->resize();
for (auto it = internal_vectors_bool.begin();
it != internal_vectors_bool.end(); ++it)
it->second->resize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void Material::onElementsAdded(const Array<Element> &,
const NewElementsEvent &) {
this->resizeInternals();
}
/* -------------------------------------------------------------------------- */
void Material::onElementsRemoved(
const Array<Element> & element_list,
const ElementTypeMapArray<UInt> & new_numbering,
[[gnu::unused]] const RemovedElementsEvent & event) {
UInt my_num = model.getInternalIndexFromID(getID());
ElementTypeMapArray<UInt> material_local_new_numbering(
"remove mat filter elem", getID(), getMemoryID());
auto el_begin = element_list.begin();
auto el_end = element_list.end();
for (auto && gt : ghost_types) {
for (auto && type :
new_numbering.elementTypes(_all_dimensions, gt, _ek_not_defined)) {
if (not element_filter.exists(type, gt) ||
element_filter(type, gt).size() == 0)
continue;
auto & elem_filter = element_filter(type, gt);
auto & mat_indexes = this->model.getMaterialByElement(type, gt);
auto & mat_loc_num = this->model.getMaterialLocalNumbering(type, gt);
auto nb_element = this->model.getMesh().getNbElement(type, gt);
// all materials will resize of the same size...
mat_indexes.resize(nb_element);
mat_loc_num.resize(nb_element);
if (!material_local_new_numbering.exists(type, gt))
material_local_new_numbering.alloc(elem_filter.size(), 1, type, gt);
auto & mat_renumbering = material_local_new_numbering(type, gt);
const auto & renumbering = new_numbering(type, gt);
Array<UInt> elem_filter_tmp;
UInt ni = 0;
Element el{type, 0, gt};
for (UInt i = 0; i < elem_filter.size(); ++i) {
el.element = elem_filter(i);
if (std::find(el_begin, el_end, el) == el_end) {
UInt new_el = renumbering(el.element);
AKANTU_DEBUG_ASSERT(new_el != UInt(-1),
"A not removed element as been badly renumbered");
elem_filter_tmp.push_back(new_el);
mat_renumbering(i) = ni;
mat_indexes(new_el) = my_num;
mat_loc_num(new_el) = ni;
++ni;
} else {
mat_renumbering(i) = UInt(-1);
}
}
elem_filter.resize(elem_filter_tmp.size());
elem_filter.copy(elem_filter_tmp);
}
}
for (auto it = internal_vectors_real.begin();
it != internal_vectors_real.end(); ++it)
it->second->removeIntegrationPoints(material_local_new_numbering);
for (auto it = internal_vectors_uint.begin();
it != internal_vectors_uint.end(); ++it)
it->second->removeIntegrationPoints(material_local_new_numbering);
for (auto it = internal_vectors_bool.begin();
it != internal_vectors_bool.end(); ++it)
it->second->removeIntegrationPoints(material_local_new_numbering);
}
/* -------------------------------------------------------------------------- */
void Material::beforeSolveStep() { this->savePreviousState(); }
/* -------------------------------------------------------------------------- */
void Material::afterSolveStep() {
for (auto & type : element_filter.elementTypes(_all_dimensions, _not_ghost,
_ek_not_defined)) {
this->updateEnergies(type);
}
}
/* -------------------------------------------------------------------------- */
void Material::onDamageIteration() { this->savePreviousState(); }
/* -------------------------------------------------------------------------- */
void Material::onDamageUpdate() {
for (auto & type : element_filter.elementTypes(_all_dimensions, _not_ghost,
_ek_not_defined)) {
this->updateEnergiesAfterDamage(type);
}
}
/* -------------------------------------------------------------------------- */
void Material::onDump() {
if (this->isFiniteDeformation())
this->computeAllCauchyStresses(_not_ghost);
}
/* -------------------------------------------------------------------------- */
void Material::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
std::string type = getID().substr(getID().find_last_of(':') + 1);
stream << space << "Material " << type << " [" << std::endl;
Parsable::printself(stream, indent);
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
/// extrapolate internal values
void Material::extrapolateInternal(const ID & id, const Element & element,
[[gnu::unused]] const Matrix<Real> & point,
Matrix<Real> & extrapolated) {
if (this->isInternal<Real>(id, element.kind())) {
UInt nb_element =
this->element_filter(element.type, element.ghost_type).size();
const ID name = this->getID() + ":" + id;
UInt nb_quads =
this->internal_vectors_real[name]->getFEEngine().getNbIntegrationPoints(
element.type, element.ghost_type);
const Array<Real> & internal =
this->getArray<Real>(id, element.type, element.ghost_type);
UInt nb_component = internal.getNbComponent();
Array<Real>::const_matrix_iterator internal_it =
internal.begin_reinterpret(nb_component, nb_quads, nb_element);
Element local_element = this->convertToLocalElement(element);
/// instead of really extrapolating, here the value of the first GP
/// is copied into the result vector. This works only for linear
/// elements
/// @todo extrapolate!!!!
AKANTU_DEBUG_WARNING("This is a fix, values are not truly extrapolated");
const Matrix<Real> & values = internal_it[local_element.element];
UInt index = 0;
Vector<Real> tmp(nb_component);
for (UInt j = 0; j < values.cols(); ++j) {
tmp = values(j);
if (tmp.norm() > 0) {
index = j;
break;
}
}
for (UInt i = 0; i < extrapolated.size(); ++i) {
extrapolated(i) = values(index);
}
} else {
Matrix<Real> default_values(extrapolated.rows(), extrapolated.cols(), 0.);
extrapolated = default_values;
}
}
/* -------------------------------------------------------------------------- */
void Material::applyEigenGradU(const Matrix<Real> & prescribed_eigen_grad_u,
const GhostType ghost_type) {
for (auto && type : element_filter.elementTypes(_all_dimensions, _not_ghost,
_ek_not_defined)) {
if (!element_filter(type, ghost_type).size())
continue;
auto eigen_it = this->eigengradu(type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto eigen_end = this->eigengradu(type, ghost_type)
.end(spatial_dimension, spatial_dimension);
for (; eigen_it != eigen_end; ++eigen_it) {
auto & current_eigengradu = *eigen_it;
current_eigengradu = prescribed_eigen_grad_u;
}
}
}
/* -------------------------------------------------------------------------- */
MaterialFactory & Material::getFactory() {
return MaterialFactory::getInstance();
}
} // namespace akantu
diff --git a/src/model/solid_mechanics/material.hh b/src/model/solid_mechanics/material.hh
index 9a326f10d..62f025fef 100644
--- a/src/model/solid_mechanics/material.hh
+++ b/src/model/solid_mechanics/material.hh
@@ -1,665 +1,665 @@
/**
* @file material.hh
*
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Mother class for all materials
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_factory.hh"
#include "aka_voigthelper.hh"
#include "data_accessor.hh"
#include "integration_point.hh"
#include "parsable.hh"
#include "parser.hh"
/* -------------------------------------------------------------------------- */
#include "internal_field.hh"
#include "random_internal_field.hh"
/* -------------------------------------------------------------------------- */
#include "mesh_events.hh"
#include "solid_mechanics_model_event_handler.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_HH__
#define __AKANTU_MATERIAL_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
class Model;
class SolidMechanicsModel;
class Material;
} // namespace akantu
namespace akantu {
using MaterialFactory =
Factory<Material, ID, UInt, const ID &, SolidMechanicsModel &, const ID &>;
/**
* Interface of all materials
* Prerequisites for a new material
* - inherit from this class
* - implement the following methods:
* \code
* virtual Real getStableTimeStep(Real h, const Element & element =
* ElementNull);
*
* virtual void computeStress(ElementType el_type,
* GhostType ghost_type = _not_ghost);
*
* virtual void computeTangentStiffness(const ElementType & el_type,
* Array<Real> & tangent_matrix,
* GhostType ghost_type = _not_ghost);
* \endcode
*
*/
class Material : public Memory,
public DataAccessor<Element>,
public Parsable,
public MeshEventHandler,
protected SolidMechanicsModelEventHandler {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
#if __cplusplus > 199711L
Material(const Material & mat) = delete;
Material & operator=(const Material & mat) = delete;
#endif
/// Initialize material with defaults
Material(SolidMechanicsModel & model, const ID & id = "");
/// Initialize material with custom mesh & fe_engine
Material(SolidMechanicsModel & model, UInt dim, const Mesh & mesh,
FEEngine & fe_engine, const ID & id = "");
/// Destructor
~Material() override;
protected:
void initialize();
/* ------------------------------------------------------------------------ */
/* Function that materials can/should reimplement */
/* ------------------------------------------------------------------------ */
protected:
/// constitutive law
virtual void computeStress(__attribute__((unused)) ElementType el_type,
__attribute__((unused))
GhostType ghost_type = _not_ghost) {
AKANTU_TO_IMPLEMENT();
}
/// compute the tangent stiffness matrix
virtual void computeTangentModuli(__attribute__((unused))
const ElementType & el_type,
__attribute__((unused))
Array<Real> & tangent_matrix,
__attribute__((unused))
GhostType ghost_type = _not_ghost) {
AKANTU_TO_IMPLEMENT();
}
/// compute the potential energy
virtual void computePotentialEnergy(ElementType el_type);
/// compute the potential energy for an element
virtual void
computePotentialEnergyByElement(__attribute__((unused)) ElementType type,
__attribute__((unused)) UInt index,
__attribute__((unused))
Vector<Real> & epot_on_quad_points) {
AKANTU_TO_IMPLEMENT();
}
virtual void updateEnergies(__attribute__((unused)) ElementType el_type) {}
virtual void updateEnergiesAfterDamage(__attribute__((unused))
ElementType el_type) {}
/// set the material to steady state (to be implemented for materials that
/// need it)
virtual void setToSteadyState(__attribute__((unused)) ElementType el_type,
__attribute__((unused))
GhostType ghost_type = _not_ghost) {}
/// function called to update the internal parameters when the modifiable
/// parameters are modified
virtual void updateInternalParameters() {}
public:
/// extrapolate internal values
virtual void extrapolateInternal(const ID & id, const Element & element,
const Matrix<Real> & points,
Matrix<Real> & extrapolated);
/// compute the p-wave speed in the material
virtual Real getPushWaveSpeed(__attribute__((unused))
const Element & element) const {
AKANTU_TO_IMPLEMENT();
}
/// compute the s-wave speed in the material
virtual Real getShearWaveSpeed(__attribute__((unused))
const Element & element) const {
AKANTU_TO_IMPLEMENT();
}
/// get a material celerity to compute the stable time step (default: is the
/// push wave speed)
virtual Real getCelerity(const Element & element) const {
return getPushWaveSpeed(element);
}
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
template <typename T>
void registerInternal(__attribute__((unused)) InternalField<T> & vect) {
AKANTU_TO_IMPLEMENT();
}
template <typename T>
void unregisterInternal(__attribute__((unused)) InternalField<T> & vect) {
AKANTU_TO_IMPLEMENT();
}
/// initialize the material computed parameter
virtual void initMaterial();
/// compute the residual for this material
// virtual void updateResidual(GhostType ghost_type = _not_ghost);
/// assemble the residual for this material
virtual void assembleInternalForces(GhostType ghost_type);
/// save the stress in the previous_stress if needed
virtual void savePreviousState();
/// restore the stress from previous_stress if needed
virtual void restorePreviousState();
/// compute the stresses for this material
virtual void computeAllStresses(GhostType ghost_type = _not_ghost);
// virtual void
// computeAllStressesFromTangentModuli(GhostType ghost_type = _not_ghost);
virtual void computeAllCauchyStresses(GhostType ghost_type = _not_ghost);
/// set material to steady state
void setToSteadyState(GhostType ghost_type = _not_ghost);
/// compute the stiffness matrix
virtual void assembleStiffnessMatrix(GhostType ghost_type);
/// add an element to the local mesh filter
inline UInt addElement(const ElementType & type, UInt element,
const GhostType & ghost_type);
inline UInt addElement(const Element & element);
/// add many elements at once
void addElements(const Array<Element> & elements_to_add);
/// remove many element at once
void removeElements(const Array<Element> & elements_to_remove);
/// function to print the contain of the class
void printself(std::ostream & stream, int indent = 0) const override;
/**
* interpolate stress on given positions for each element by means
* of a geometrical interpolation on quadrature points
*/
void interpolateStress(ElementTypeMapArray<Real> & result,
const GhostType ghost_type = _not_ghost);
/**
* interpolate stress on given positions for each element by means
* of a geometrical interpolation on quadrature points and store the
* results per facet
*/
void interpolateStressOnFacets(ElementTypeMapArray<Real> & result,
ElementTypeMapArray<Real> & by_elem_result,
const GhostType ghost_type = _not_ghost);
/**
* function to initialize the elemental field interpolation
* function by inverting the quadrature points' coordinates
*/
void initElementalFieldInterpolation(
const ElementTypeMapArray<Real> & interpolation_points_coordinates);
/* ------------------------------------------------------------------------ */
/* Common part */
/* ------------------------------------------------------------------------ */
protected:
/* ------------------------------------------------------------------------ */
inline UInt getTangentStiffnessVoigtSize(UInt spatial_dimension) const;
/// compute the potential energy by element
void computePotentialEnergyByElements();
/// resize the intenals arrays
virtual void resizeInternals();
/* ------------------------------------------------------------------------ */
/* Finite deformation functions */
/* This functions area implementing what is described in the paper of Bathe */
/* et al, in IJNME, Finite Element Formulations For Large Deformation */
/* Dynamic Analysis, Vol 9, 353-386, 1975 */
/* ------------------------------------------------------------------------ */
protected:
/// assemble the residual
template <UInt dim> void assembleInternalForces(GhostType ghost_type);
/// Computation of Cauchy stress tensor in the case of finite deformation from
/// the 2nd Piola-Kirchhoff for a given element type
template <UInt dim>
void computeCauchyStress(ElementType el_type,
GhostType ghost_type = _not_ghost);
/// Computation the Cauchy stress the 2nd Piola-Kirchhoff and the deformation
/// gradient
template <UInt dim>
inline void computeCauchyStressOnQuad(const Matrix<Real> & F,
const Matrix<Real> & S,
Matrix<Real> & cauchy,
const Real & C33 = 1.0) const;
template <UInt dim>
void computeAllStressesFromTangentModuli(const ElementType & type,
GhostType ghost_type);
template <UInt dim>
void assembleStiffnessMatrix(const ElementType & type, GhostType ghost_type);
/// assembling in finite deformation
template <UInt dim>
void assembleStiffnessMatrixNL(const ElementType & type,
GhostType ghost_type);
template <UInt dim>
void assembleStiffnessMatrixL2(const ElementType & type,
GhostType ghost_type);
/// Size of the Stress matrix for the case of finite deformation see: Bathe et
/// al, IJNME, Vol 9, 353-386, 1975
inline UInt getCauchyStressMatrixSize(UInt spatial_dimension) const;
/// Sets the stress matrix according to Bathe et al, IJNME, Vol 9, 353-386,
/// 1975
template <UInt dim>
inline void setCauchyStressMatrix(const Matrix<Real> & S_t,
Matrix<Real> & sigma);
/// write the stress tensor in the Voigt notation.
template <UInt dim>
inline void setCauchyStressArray(const Matrix<Real> & S_t,
Matrix<Real> & sigma_voight);
/* ------------------------------------------------------------------------ */
/* Conversion functions */
/* ------------------------------------------------------------------------ */
public:
template <UInt dim>
static inline void gradUToF(const Matrix<Real> & grad_u, Matrix<Real> & F);
static inline void rightCauchy(const Matrix<Real> & F, Matrix<Real> & C);
static inline void leftCauchy(const Matrix<Real> & F, Matrix<Real> & B);
template <UInt dim>
static inline void gradUToEpsilon(const Matrix<Real> & grad_u,
Matrix<Real> & epsilon);
template <UInt dim>
static inline void gradUToGreenStrain(const Matrix<Real> & grad_u,
Matrix<Real> & epsilon);
static inline Real stressToVonMises(const Matrix<Real> & stress);
protected:
/// converts global element to local element
inline Element convertToLocalElement(const Element & global_element) const;
/// converts local element to global element
inline Element convertToGlobalElement(const Element & local_element) const;
/// converts global quadrature point to local quadrature point
inline IntegrationPoint
convertToLocalPoint(const IntegrationPoint & global_point) const;
/// converts local quadrature point to global quadrature point
inline IntegrationPoint
convertToGlobalPoint(const IntegrationPoint & local_point) const;
/* ------------------------------------------------------------------------ */
/* DataAccessor inherited members */
/* ------------------------------------------------------------------------ */
public:
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
template <typename T>
inline void packElementDataHelper(const ElementTypeMapArray<T> & data_to_pack,
CommunicationBuffer & buffer,
const Array<Element> & elements,
const ID & fem_id = ID()) const;
template <typename T>
inline void unpackElementDataHelper(ElementTypeMapArray<T> & data_to_unpack,
CommunicationBuffer & buffer,
const Array<Element> & elements,
const ID & fem_id = ID());
/* ------------------------------------------------------------------------ */
/* MeshEventHandler inherited members */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
void onNodesAdded(const Array<UInt> &, const NewNodesEvent &) override{};
void onNodesRemoved(const Array<UInt> &, const Array<UInt> &,
const RemovedNodesEvent &) override{};
void onElementsAdded(const Array<Element> & element_list,
const NewElementsEvent & event) override;
void onElementsRemoved(const Array<Element> & element_list,
const ElementTypeMapArray<UInt> & new_numbering,
const RemovedElementsEvent & event) override;
void onElementsChanged(const Array<Element> &, const Array<Element> &,
const ElementTypeMapArray<UInt> &,
const ChangedElementsEvent &) override{};
/* ------------------------------------------------------------------------ */
/* SolidMechanicsModelEventHandler inherited members */
/* ------------------------------------------------------------------------ */
public:
virtual void beforeSolveStep();
virtual void afterSolveStep();
void onDamageIteration() override;
void onDamageUpdate() override;
void onDump() override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(Name, name, const std::string &);
AKANTU_GET_MACRO(Model, model, const SolidMechanicsModel &)
AKANTU_GET_MACRO(ID, Memory::getID(), const ID &);
AKANTU_GET_MACRO(Rho, rho, Real);
AKANTU_SET_MACRO(Rho, rho, Real);
AKANTU_GET_MACRO(SpatialDimension, spatial_dimension, UInt);
/// return the potential energy for the subset of elements contained by the
/// material
Real getPotentialEnergy();
/// return the potential energy for the provided element
Real getPotentialEnergy(ElementType & type, UInt index);
/// return the energy (identified by id) for the subset of elements contained
/// by the material
virtual Real getEnergy(const std::string & energy_id);
/// return the energy (identified by id) for the provided element
virtual Real getEnergy(const std::string & energy_id, ElementType type,
UInt index);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(ElementFilter, element_filter, UInt);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(GradU, gradu, Real);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Stress, stress, Real);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(PotentialEnergy, potential_energy,
Real);
AKANTU_GET_MACRO(GradU, gradu, const ElementTypeMapArray<Real> &);
AKANTU_GET_MACRO(Stress, stress, const ElementTypeMapArray<Real> &);
AKANTU_GET_MACRO(ElementFilter, element_filter,
const ElementTypeMapArray<UInt> &);
AKANTU_GET_MACRO(FEEngine, fem, FEEngine &);
bool isNonLocal() const { return is_non_local; }
template <typename T>
const Array<T> & getArray(const ID & id, const ElementType & type,
const GhostType & ghost_type = _not_ghost) const;
template <typename T>
Array<T> & getArray(const ID & id, const ElementType & type,
const GhostType & ghost_type = _not_ghost);
template <typename T>
const InternalField<T> & getInternal(const ID & id) const;
template <typename T> InternalField<T> & getInternal(const ID & id);
template <typename T>
inline bool isInternal(const ID & id, const ElementKind & element_kind) const;
template <typename T>
ElementTypeMap<UInt>
getInternalDataPerElem(const ID & id, const ElementKind & element_kind) const;
bool isFiniteDeformation() const { return finite_deformation; }
bool isInelasticDeformation() const { return inelastic_deformation; }
template <typename T> inline void setParam(const ID & param, T value);
inline const Parameter & getParam(const ID & param) const;
template <typename T>
void flattenInternal(const std::string & field_id,
ElementTypeMapArray<T> & internal_flat,
const GhostType ghost_type = _not_ghost,
ElementKind element_kind = _ek_not_defined) const;
/// apply a constant eigengrad_u everywhere in the material
virtual void applyEigenGradU(const Matrix<Real> & prescribed_eigen_grad_u,
const GhostType = _not_ghost);
/// specify if the matrix need to be recomputed for this material
virtual bool hasStiffnessMatrixChanged() { return true; }
/// static method to reteive the material factory
static MaterialFactory & getFactory();
protected:
bool isInit() const { return is_init; }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// boolean to know if the material has been initialized
bool is_init;
std::map<ID, InternalField<Real> *> internal_vectors_real;
std::map<ID, InternalField<UInt> *> internal_vectors_uint;
std::map<ID, InternalField<bool> *> internal_vectors_bool;
protected:
/// Link to the fem object in the model
FEEngine & fem;
/// Finite deformation
bool finite_deformation;
/// Finite deformation
bool inelastic_deformation;
/// material name
std::string name;
/// The model to witch the material belong
SolidMechanicsModel & model;
/// density : rho
Real rho;
/// spatial dimension
UInt spatial_dimension;
/// list of element handled by the material
ElementTypeMapArray<UInt> element_filter;
/// stresses arrays ordered by element types
InternalField<Real> stress;
/// eigengrad_u arrays ordered by element types
InternalField<Real> eigengradu;
/// grad_u arrays ordered by element types
InternalField<Real> gradu;
/// Green Lagrange strain (Finite deformation)
InternalField<Real> green_strain;
/// Second Piola-Kirchhoff stress tensor arrays ordered by element types
/// (Finite deformation)
InternalField<Real> piola_kirchhoff_2;
/// potential energy by element
InternalField<Real> potential_energy;
/// tell if using in non local mode or not
bool is_non_local;
/// tell if the material need the previous stress state
bool use_previous_stress;
/// tell if the material need the previous strain state
bool use_previous_gradu;
/// elemental field interpolation coordinates
InternalField<Real> interpolation_inverse_coordinates;
/// elemental field interpolation points
InternalField<Real> interpolation_points_matrices;
/// vector that contains the names of all the internals that need to
/// be transferred when material interfaces move
std::vector<ID> internals_to_transfer;
};
/// standard output stream operator
inline std::ostream & operator<<(std::ostream & stream,
const Material & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#include "material_inline_impl.cc"
#include "internal_field_tmpl.hh"
#include "random_internal_field_tmpl.hh"
/* -------------------------------------------------------------------------- */
/* Auto loop */
/* -------------------------------------------------------------------------- */
/// This can be used to automatically write the loop on quadrature points in
/// functions such as computeStress. This macro in addition to write the loop
/// provides two tensors (matrices) sigma and grad_u
#define MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type) \
auto && grad_u_view = \
make_view(this->gradu(el_type, ghost_type), this->spatial_dimension, \
this->spatial_dimension); \
\
- auto stress_view = \
+ auto stress_view = \
make_view(this->stress(el_type, ghost_type), this->spatial_dimension, \
this->spatial_dimension); \
\
if (this->isFiniteDeformation()) { \
stress_view = make_view(this->piola_kirchhoff_2(el_type, ghost_type), \
this->spatial_dimension, this->spatial_dimension); \
} \
\
for (auto && data : zip(grad_u_view, stress_view)) { \
[[gnu::unused]] Matrix<Real> & grad_u = std::get<0>(data); \
[[gnu::unused]] Matrix<Real> & sigma = std::get<1>(data)
#define MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END }
/// This can be used to automatically write the loop on quadrature points in
/// functions such as computeTangentModuli. This macro in addition to write the
/// loop provides two tensors (matrices) sigma_tensor, grad_u, and a matrix
/// where the elemental tangent moduli should be stored in Voigt Notation
#define MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_mat) \
auto && grad_u_view = \
make_view(this->gradu(el_type, ghost_type), this->spatial_dimension, \
this->spatial_dimension); \
\
auto && stress_view = \
make_view(this->stress(el_type, ghost_type), this->spatial_dimension, \
this->spatial_dimension); \
\
auto tangent_size = \
this->getTangentStiffnessVoigtSize(this->spatial_dimension); \
\
- auto && tangent_view = make_view(tangent_mat, tangent_size, tangent_size); \
+ auto && tangent_view = make_view(tangent_mat, tangent_size, tangent_size); \
\
for (auto && data : zip(grad_u_view, stress_view, tangent_view)) { \
[[gnu::unused]] Matrix<Real> & grad_u = std::get<0>(data); \
[[gnu::unused]] Matrix<Real> & sigma = std::get<1>(data); \
Matrix<Real> & tangent = std::get<2>(data);
#define MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END }
/* -------------------------------------------------------------------------- */
#define INSTANTIATE_MATERIAL_ONLY(mat_name) \
template class mat_name<1>; \
template class mat_name<2>; \
template class mat_name<3>
#define MATERIAL_DEFAULT_PER_DIM_ALLOCATOR(id, mat_name) \
[](UInt dim, const ID &, SolidMechanicsModel & model, \
const ID & id) -> std::unique_ptr<Material> { \
switch (dim) { \
case 1: \
return std::make_unique<mat_name<1>>(model, id); \
case 2: \
return std::make_unique<mat_name<2>>(model, id); \
case 3: \
return std::make_unique<mat_name<3>>(model, id); \
default: \
AKANTU_EXCEPTION("The dimension " \
<< dim << "is not a valid dimension for the material " \
<< #id); \
} \
}
#define INSTANTIATE_MATERIAL(id, mat_name) \
INSTANTIATE_MATERIAL_ONLY(mat_name); \
static bool material_is_alocated_##id [[gnu::unused]] = \
MaterialFactory::getInstance().registerAllocator( \
#id, MATERIAL_DEFAULT_PER_DIM_ALLOCATOR(id, mat_name))
#endif /* __AKANTU_MATERIAL_HH__ */
diff --git a/src/model/solid_mechanics/material_inline_impl.cc b/src/model/solid_mechanics/material_inline_impl.cc
index 3f8d8b4ec..4fa6683c5 100644
--- a/src/model/solid_mechanics/material_inline_impl.cc
+++ b/src/model/solid_mechanics/material_inline_impl.cc
@@ -1,446 +1,447 @@
/**
* @file material_inline_impl.cc
*
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Jul 27 2010
* @date last modification: Tue Feb 20 2018
*
* @brief Implementation of the inline functions of the class material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_INLINE_IMPL_CC__
#define __AKANTU_MATERIAL_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
inline UInt Material::addElement(const ElementType & type, UInt element,
const GhostType & ghost_type) {
Array<UInt> & el_filter = this->element_filter(type, ghost_type);
el_filter.push_back(element);
return el_filter.size() - 1;
}
/* -------------------------------------------------------------------------- */
inline UInt Material::addElement(const Element & element) {
return this->addElement(element.type, element.element, element.ghost_type);
}
/* -------------------------------------------------------------------------- */
inline UInt Material::getTangentStiffnessVoigtSize(UInt dim) const {
return (dim * (dim - 1) / 2 + dim);
}
/* -------------------------------------------------------------------------- */
inline UInt Material::getCauchyStressMatrixSize(UInt dim) const {
return (dim * dim);
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void Material::gradUToF(const Matrix<Real> & grad_u, Matrix<Real> & F) {
AKANTU_DEBUG_ASSERT(F.size() >= grad_u.size() && grad_u.size() == dim * dim,
"The dimension of the tensor F should be greater or "
"equal to the dimension of the tensor grad_u.");
F.eye();
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
F(i, j) += grad_u(i, j);
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void Material::computeCauchyStressOnQuad(const Matrix<Real> & F,
const Matrix<Real> & piola,
Matrix<Real> & sigma,
const Real & C33) const {
Real J = F.det() * sqrt(C33);
Matrix<Real> F_S(dim, dim);
F_S.mul<false, false>(F, piola);
Real constant = J ? 1. / J : 0;
sigma.mul<false, true>(F_S, F, constant);
}
/* -------------------------------------------------------------------------- */
inline void Material::rightCauchy(const Matrix<Real> & F, Matrix<Real> & C) {
C.mul<true, false>(F, F);
}
/* -------------------------------------------------------------------------- */
inline void Material::leftCauchy(const Matrix<Real> & F, Matrix<Real> & B) {
B.mul<false, true>(F, F);
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void Material::gradUToEpsilon(const Matrix<Real> & grad_u,
Matrix<Real> & epsilon) {
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
epsilon(i, j) = 0.5 * (grad_u(i, j) + grad_u(j, i));
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void Material::gradUToGreenStrain(const Matrix<Real> & grad_u,
Matrix<Real> & epsilon) {
epsilon.mul<true, false>(grad_u, grad_u, .5);
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
epsilon(i, j) += 0.5 * (grad_u(i, j) + grad_u(j, i));
}
/* -------------------------------------------------------------------------- */
inline Real Material::stressToVonMises(const Matrix<Real> & stress) {
// compute deviatoric stress
UInt dim = stress.cols();
Matrix<Real> deviatoric_stress =
Matrix<Real>::eye(dim, -1. * stress.trace() / 3.);
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
deviatoric_stress(i, j) += stress(i, j);
// return Von Mises stress
return std::sqrt(3. * deviatoric_stress.doubleDot(deviatoric_stress) / 2.);
}
/* ---------------------------------------------------------------------------*/
template <UInt dim>
inline void Material::setCauchyStressArray(const Matrix<Real> & S_t,
Matrix<Real> & sigma_voight) {
AKANTU_DEBUG_IN();
sigma_voight.clear();
// see Finite element formulations for large deformation dynamic analysis,
// Bathe et al. IJNME vol 9, 1975, page 364 ^t\tau
/*
* 1d: [ s11 ]'
* 2d: [ s11 s22 s12 ]'
* 3d: [ s11 s22 s33 s23 s13 s12 ]
*/
for (UInt i = 0; i < dim; ++i) // diagonal terms
sigma_voight(i, 0) = S_t(i, i);
for (UInt i = 1; i < dim; ++i) // term s12 in 2D and terms s23 s13 in 3D
sigma_voight(dim + i - 1, 0) = S_t(dim - i - 1, dim - 1);
for (UInt i = 2; i < dim; ++i) // term s13 in 3D
sigma_voight(dim + i, 0) = S_t(0, 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void Material::setCauchyStressMatrix(const Matrix<Real> & S_t,
Matrix<Real> & sigma) {
AKANTU_DEBUG_IN();
sigma.clear();
/// see Finite ekement formulations for large deformation dynamic analysis,
/// Bathe et al. IJNME vol 9, 1975, page 364 ^t\tau
for (UInt i = 0; i < dim; ++i) {
for (UInt m = 0; m < dim; ++m) {
for (UInt n = 0; n < dim; ++n) {
sigma(i * dim + m, i * dim + n) = S_t(m, n);
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
inline Element
Material::convertToLocalElement(const Element & global_element) const {
UInt ge = global_element.element;
#ifndef AKANTU_NDEBUG
UInt model_mat_index = this->model.getMaterialByElement(
global_element.type, global_element.ghost_type)(ge);
UInt mat_index = this->model.getMaterialIndex(this->name);
AKANTU_DEBUG_ASSERT(model_mat_index == mat_index,
"Conversion of a global element in a local element for "
"the wrong material "
<< this->name << std::endl);
#endif
UInt le = this->model.getMaterialLocalNumbering(
global_element.type, global_element.ghost_type)(ge);
Element tmp_quad{global_element.type, le, global_element.ghost_type};
return tmp_quad;
}
/* -------------------------------------------------------------------------- */
inline Element
Material::convertToGlobalElement(const Element & local_element) const {
UInt le = local_element.element;
UInt ge =
this->element_filter(local_element.type, local_element.ghost_type)(le);
Element tmp_quad{local_element.type, ge, local_element.ghost_type};
return tmp_quad;
}
/* -------------------------------------------------------------------------- */
inline IntegrationPoint
Material::convertToLocalPoint(const IntegrationPoint & global_point) const {
const FEEngine & fem = this->model.getFEEngine();
UInt nb_quad = fem.getNbIntegrationPoints(global_point.type);
Element el =
this->convertToLocalElement(static_cast<const Element &>(global_point));
IntegrationPoint tmp_quad(el, global_point.num_point, nb_quad);
return tmp_quad;
}
/* -------------------------------------------------------------------------- */
inline IntegrationPoint
Material::convertToGlobalPoint(const IntegrationPoint & local_point) const {
const FEEngine & fem = this->model.getFEEngine();
UInt nb_quad = fem.getNbIntegrationPoints(local_point.type);
Element el =
this->convertToGlobalElement(static_cast<const Element &>(local_point));
IntegrationPoint tmp_quad(el, local_point.num_point, nb_quad);
return tmp_quad;
}
/* -------------------------------------------------------------------------- */
inline UInt Material::getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const {
if (tag == SynchronizationTag::_smm_stress) {
return (this->isFiniteDeformation() ? 3 : 1) * spatial_dimension *
spatial_dimension * sizeof(Real) *
this->getModel().getNbIntegrationPoints(elements);
}
return 0;
}
/* -------------------------------------------------------------------------- */
inline void Material::packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const {
if (tag == SynchronizationTag::_smm_stress) {
if (this->isFiniteDeformation()) {
packElementDataHelper(piola_kirchhoff_2, buffer, elements);
packElementDataHelper(gradu, buffer, elements);
}
packElementDataHelper(stress, buffer, elements);
}
}
/* -------------------------------------------------------------------------- */
inline void Material::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
if (tag == SynchronizationTag::_smm_stress) {
if (this->isFiniteDeformation()) {
unpackElementDataHelper(piola_kirchhoff_2, buffer, elements);
unpackElementDataHelper(gradu, buffer, elements);
}
unpackElementDataHelper(stress, buffer, elements);
}
}
/* -------------------------------------------------------------------------- */
inline const Parameter & Material::getParam(const ID & param) const {
try {
return get(param);
} catch (...) {
AKANTU_EXCEPTION("No parameter " << param << " in the material "
<< getID());
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Material::setParam(const ID & param, T value) {
try {
set<T>(param, value);
} catch (...) {
AKANTU_EXCEPTION("No parameter " << param << " in the material "
<< getID());
}
updateInternalParameters();
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Material::packElementDataHelper(
const ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer,
const Array<Element> & elements, const ID & fem_id) const {
DataAccessor::packElementalDataHelper<T>(data_to_pack, buffer, elements, true,
model.getFEEngine(fem_id));
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline void Material::unpackElementDataHelper(
ElementTypeMapArray<T> & data_to_unpack, CommunicationBuffer & buffer,
const Array<Element> & elements, const ID & fem_id) {
DataAccessor::unpackElementalDataHelper<T>(data_to_unpack, buffer, elements,
true, model.getFEEngine(fem_id));
}
/* -------------------------------------------------------------------------- */
template <>
inline void Material::registerInternal<Real>(InternalField<Real> & vect) {
internal_vectors_real[vect.getID()] = &vect;
}
template <>
inline void Material::registerInternal<UInt>(InternalField<UInt> & vect) {
internal_vectors_uint[vect.getID()] = &vect;
}
template <>
inline void Material::registerInternal<bool>(InternalField<bool> & vect) {
internal_vectors_bool[vect.getID()] = &vect;
}
/* -------------------------------------------------------------------------- */
template <>
inline void Material::unregisterInternal<Real>(InternalField<Real> & vect) {
internal_vectors_real.erase(vect.getID());
}
template <>
inline void Material::unregisterInternal<UInt>(InternalField<UInt> & vect) {
internal_vectors_uint.erase(vect.getID());
}
template <>
inline void Material::unregisterInternal<bool>(InternalField<bool> & vect) {
internal_vectors_bool.erase(vect.getID());
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline bool Material::isInternal(__attribute__((unused)) const ID & id,
__attribute__((unused))
const ElementKind & element_kind) const {
AKANTU_TO_IMPLEMENT();
}
template <>
inline bool Material::isInternal<Real>(const ID & id,
const ElementKind & element_kind) const {
auto internal_array = internal_vectors_real.find(this->getID() + ":" + id);
if (internal_array == internal_vectors_real.end() ||
internal_array->second->getElementKind() != element_kind)
return false;
return true;
}
/* -------------------------------------------------------------------------- */
template <typename T>
inline ElementTypeMap<UInt>
Material::getInternalDataPerElem(const ID & field_id,
const ElementKind & element_kind) const {
if (!this->template isInternal<T>(field_id, element_kind))
AKANTU_EXCEPTION("Cannot find internal field " << id << " in material "
<< this->name);
const InternalField<T> & internal_field =
this->template getInternal<T>(field_id);
const FEEngine & fe_engine = internal_field.getFEEngine();
UInt nb_data_per_quad = internal_field.getNbComponent();
ElementTypeMap<UInt> res;
for (auto ghost_type : ghost_types) {
for (auto & type : internal_field.elementTypes(ghost_type)) {
- UInt nb_quadrature_points = fe_engine.getNbIntegrationPoints(type, ghost_type);
+ UInt nb_quadrature_points =
+ fe_engine.getNbIntegrationPoints(type, ghost_type);
res(type, ghost_type) = nb_data_per_quad * nb_quadrature_points;
}
}
return res;
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Material::flattenInternal(const std::string & field_id,
ElementTypeMapArray<T> & internal_flat,
const GhostType ghost_type,
ElementKind element_kind) const {
if (!this->template isInternal<T>(field_id, element_kind))
AKANTU_EXCEPTION("Cannot find internal field " << id << " in material "
<< this->name);
const InternalField<T> & internal_field =
this->template getInternal<T>(field_id);
const FEEngine & fe_engine = internal_field.getFEEngine();
const Mesh & mesh = fe_engine.getMesh();
for (auto && type : internal_field.filterTypes(ghost_type)) {
const Array<Real> & src_vect = internal_field(type, ghost_type);
const Array<UInt> & filter = internal_field.getFilter(type, ghost_type);
// total number of elements in the corresponding mesh
UInt nb_element_dst = mesh.getNbElement(type, ghost_type);
// number of element in the internal field
UInt nb_element_src = filter.size();
// number of quadrature points per elem
UInt nb_quad_per_elem = fe_engine.getNbIntegrationPoints(type);
// number of data per quadrature point
UInt nb_data_per_quad = internal_field.getNbComponent();
if (!internal_flat.exists(type, ghost_type)) {
internal_flat.alloc(nb_element_dst * nb_quad_per_elem, nb_data_per_quad,
type, ghost_type);
}
if (nb_element_src == 0)
continue;
// number of data per element
UInt nb_data = nb_quad_per_elem * nb_data_per_quad;
Array<Real> & dst_vect = internal_flat(type, ghost_type);
dst_vect.resize(nb_element_dst * nb_quad_per_elem);
auto it_dst = make_view(dst_vect, nb_data).begin();
for (auto && data : zip(filter, make_view(src_vect, nb_data))) {
it_dst[std::get<0>(data)] = std::get<1>(data);
}
}
}
} // namespace akantu
#endif /* __AKANTU_MATERIAL_INLINE_IMPL_CC__ */
diff --git a/src/model/solid_mechanics/materials/internal_field.hh b/src/model/solid_mechanics/materials/internal_field.hh
index a4789c7c0..337b3db0c 100644
--- a/src/model/solid_mechanics/materials/internal_field.hh
+++ b/src/model/solid_mechanics/materials/internal_field.hh
@@ -1,277 +1,278 @@
/**
* @file internal_field.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Thu Feb 08 2018
*
* @brief Material internal properties
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "element_type_map.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_INTERNAL_FIELD_HH__
#define __AKANTU_INTERNAL_FIELD_HH__
namespace akantu {
class Material;
class FEEngine;
/**
* class for the internal fields of materials
* to store values for each quadrature
*/
template <typename T> class InternalField : public ElementTypeMapArray<T> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
InternalField(const ID & id, Material & material);
~InternalField() override;
/// This constructor is only here to let cohesive elements compile
InternalField(const ID & id, Material & material, FEEngine & fem,
const ElementTypeMapArray<UInt> & element_filter);
/// More general constructor
InternalField(const ID & id, Material & material, UInt dim, FEEngine & fem,
const ElementTypeMapArray<UInt> & element_filter);
InternalField(const ID & id, const InternalField<T> & other);
private:
- InternalField operator=(const InternalField & ) = delete;
+ InternalField operator=(const InternalField &) = delete;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// function to reset the FEEngine for the internal field
virtual void setFEEngine(FEEngine & fe_engine);
/// function to reset the element kind for the internal
virtual void setElementKind(ElementKind element_kind);
/// initialize the field to a given number of component
virtual void initialize(UInt nb_component);
/// activate the history of this field
virtual void initializeHistory();
/// resize the arrays and set the new element to 0
virtual void resize();
/// set the field to a given value v
virtual void setDefaultValue(const T & v);
/// reset all the fields to the default value
virtual void reset();
/// save the current values in the history
virtual void saveCurrentValues();
/// restore the previous values from the history
virtual void restorePreviousValues();
/// remove the quadrature points corresponding to suppressed elements
virtual void
removeIntegrationPoints(const ElementTypeMapArray<UInt> & new_numbering);
/// print the content
void printself(std::ostream & stream, int /*indent*/ = 0) const override;
/// get the default value
inline operator T() const;
virtual FEEngine & getFEEngine() { return *fem; }
virtual const FEEngine & getFEEngine() const { return *fem; }
/// AKANTU_GET_MACRO(FEEngine, *fem, FEEngine &);
protected:
/// initialize the arrays in the ElementTypeMapArray<T>
void internalInitialize(UInt nb_component);
/// set the values for new internals
virtual void setArrayValues(T * begin, T * end);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
// using type_iterator = typename ElementTypeMapArray<T>::type_iterator;
// using filter_type_iterator =
// typename ElementTypeMapArray<UInt>::type_iterator;
// /// get the type iterator on all types contained in the internal field
// type_iterator firstType(const GhostType & ghost_type = _not_ghost) const {
// return ElementTypeMapArray<T>::firstType(this->spatial_dimension,
// ghost_type, this->element_kind);
// }
// /// get the type iterator on the last type contained in the internal field
// type_iterator lastType(const GhostType & ghost_type = _not_ghost) const {
- // return ElementTypeMapArray<T>::lastType(this->spatial_dimension, ghost_type,
+ // return ElementTypeMapArray<T>::lastType(this->spatial_dimension,
+ // ghost_type,
// this->element_kind);
// }
// /// get the type iterator on all types contained in the internal field
// filter_type_iterator
// filterFirstType(const GhostType & ghost_type = _not_ghost) const {
- // return this->element_filter.firstType(this->spatial_dimension, ghost_type,
+ // return this->element_filter.firstType(this->spatial_dimension,
+ // ghost_type,
// this->element_kind);
// }
// /// get the type iterator on the last type contained in the internal field
// filter_type_iterator
// filterLastType(const GhostType & ghost_type = _not_ghost) const {
// return this->element_filter.lastType(this->spatial_dimension, ghost_type,
// this->element_kind);
// }
/// get filter types for range loop
- decltype(auto) elementTypes(const GhostType & ghost_type) const {
+ decltype(auto) elementTypes(const GhostType & ghost_type = _not_ghost) const {
return ElementTypeMapArray<T>::elementTypes(
_spatial_dimension = this->spatial_dimension,
_element_kind = this->element_kind, _ghost_type = ghost_type);
}
-
/// get filter types for range loop
- decltype(auto) filterTypes(const GhostType & ghost_type) const {
+ decltype(auto) filterTypes(const GhostType & ghost_type = _not_ghost) const {
return this->element_filter.elementTypes(
_spatial_dimension = this->spatial_dimension,
_element_kind = this->element_kind, _ghost_type = ghost_type);
}
/// get the array for a given type of the element_filter
const Array<UInt> &
getFilter(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const {
return this->element_filter(type, ghost_type);
}
/// get the Array corresponding to the type en ghost_type specified
virtual Array<T> & operator()(const ElementType & type,
const GhostType & ghost_type = _not_ghost) {
return ElementTypeMapArray<T>::operator()(type, ghost_type);
}
virtual const Array<T> &
operator()(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const {
return ElementTypeMapArray<T>::operator()(type, ghost_type);
}
virtual Array<T> & previous(const ElementType & type,
const GhostType & ghost_type = _not_ghost) {
AKANTU_DEBUG_ASSERT(previous_values != nullptr,
"The history of the internal "
<< this->getID() << " has not been activated");
return this->previous_values->operator()(type, ghost_type);
}
virtual const Array<T> &
previous(const ElementType & type,
const GhostType & ghost_type = _not_ghost) const {
AKANTU_DEBUG_ASSERT(previous_values != nullptr,
"The history of the internal "
<< this->getID() << " has not been activated");
return this->previous_values->operator()(type, ghost_type);
}
virtual InternalField<T> & previous() {
AKANTU_DEBUG_ASSERT(previous_values != nullptr,
"The history of the internal "
<< this->getID() << " has not been activated");
return *(this->previous_values);
}
virtual const InternalField<T> & previous() const {
AKANTU_DEBUG_ASSERT(previous_values != nullptr,
"The history of the internal "
<< this->getID() << " has not been activated");
return *(this->previous_values);
}
/// check if the history is used or not
bool hasHistory() const { return (previous_values != nullptr); }
/// get the kind treated by the internal
const ElementKind & getElementKind() const { return element_kind; }
/// return the number of components
UInt getNbComponent() const { return nb_component; }
/// return the spatial dimension corresponding to the internal element type
/// loop filter
UInt getSpatialDimension() const { return this->spatial_dimension; }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// the material for which this is an internal parameter
Material & material;
/// the fem containing the mesh and the element informations
FEEngine * fem{nullptr};
/// Element filter if needed
const ElementTypeMapArray<UInt> & element_filter;
/// default value
T default_value{};
/// spatial dimension of the element to consider
UInt spatial_dimension{0};
/// ElementKind of the element to consider
ElementKind element_kind{_ek_regular};
/// Number of component of the internal field
UInt nb_component{0};
/// Is the field initialized
bool is_init{false};
/// previous values
std::unique_ptr<InternalField<T>> previous_values;
};
/// standard output stream operator
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const InternalField<T> & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AKANTU_INTERNAL_FIELD_HH__ */
diff --git a/src/model/solid_mechanics/materials/internal_field_tmpl.hh b/src/model/solid_mechanics/materials/internal_field_tmpl.hh
index e565e0f66..201d24fdb 100644
--- a/src/model/solid_mechanics/materials/internal_field_tmpl.hh
+++ b/src/model/solid_mechanics/materials/internal_field_tmpl.hh
@@ -1,306 +1,308 @@
/**
* @file internal_field_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Wed Feb 21 2018
*
* @brief Material internal properties
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_INTERNAL_FIELD_TMPL_HH__
#define __AKANTU_INTERNAL_FIELD_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T>
InternalField<T>::InternalField(const ID & id, Material & material)
: ElementTypeMapArray<T>(id, material.getID(), material.getMemoryID()),
material(material), fem(&(material.getModel().getFEEngine())),
element_filter(material.getElementFilter()),
spatial_dimension(material.getModel().getSpatialDimension()) {}
/* -------------------------------------------------------------------------- */
template <typename T>
InternalField<T>::InternalField(
const ID & id, Material & material, FEEngine & fem,
const ElementTypeMapArray<UInt> & element_filter)
: ElementTypeMapArray<T>(id, material.getID(), material.getMemoryID()),
material(material), fem(&fem), element_filter(element_filter),
spatial_dimension(material.getSpatialDimension()) {}
/* -------------------------------------------------------------------------- */
template <typename T>
InternalField<T>::InternalField(
const ID & id, Material & material, UInt dim, FEEngine & fem,
const ElementTypeMapArray<UInt> & element_filter)
: ElementTypeMapArray<T>(id, material.getID(), material.getMemoryID()),
material(material), fem(&fem), element_filter(element_filter),
spatial_dimension(dim) {}
/* -------------------------------------------------------------------------- */
template <typename T>
InternalField<T>::InternalField(const ID & id, const InternalField<T> & other)
: ElementTypeMapArray<T>(id, other.material.getID(),
other.material.getMemoryID()),
material(other.material), fem(other.fem),
element_filter(other.element_filter), default_value(other.default_value),
spatial_dimension(other.spatial_dimension),
element_kind(other.element_kind), nb_component(other.nb_component) {
AKANTU_DEBUG_ASSERT(other.is_init,
"Cannot create a copy of a non initialized field");
this->internalInitialize(this->nb_component);
}
/* -------------------------------------------------------------------------- */
template <typename T> InternalField<T>::~InternalField() {
if (this->is_init) {
this->material.unregisterInternal(*this);
}
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::setFEEngine(FEEngine & fe_engine) {
this->fem = &fe_engine;
}
/* -------------------------------------------------------------------------- */
template <typename T>
void InternalField<T>::setElementKind(ElementKind element_kind) {
this->element_kind = element_kind;
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::initialize(UInt nb_component) {
internalInitialize(nb_component);
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::initializeHistory() {
if (!previous_values)
previous_values =
std::make_unique<InternalField<T>>("previous_" + this->getID(), *this);
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::resize() {
if (!this->is_init)
return;
for (auto ghost : ghost_types)
for (const auto & type : this->filterTypes(ghost)) {
UInt nb_element = this->element_filter(type, ghost).size();
UInt nb_quadrature_points =
this->fem->getNbIntegrationPoints(type, ghost);
UInt new_size = nb_element * nb_quadrature_points;
UInt old_size = 0;
Array<T> * vect = nullptr;
if (this->exists(type, ghost)) {
vect = &(this->operator()(type, ghost));
old_size = vect->size();
vect->resize(new_size);
} else {
vect = &(this->alloc(nb_element * nb_quadrature_points, nb_component,
type, ghost));
}
this->setArrayValues(vect->storage() + old_size * vect->getNbComponent(),
vect->storage() + new_size * vect->getNbComponent());
}
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::setDefaultValue(const T & value) {
this->default_value = value;
this->reset();
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::reset() {
for (auto ghost_type : ghost_types)
for (const auto & type : this->elementTypes(ghost_type)) {
Array<T> & vect = (*this)(type, ghost_type);
vect.clear();
this->setArrayValues(
vect.storage(), vect.storage() + vect.size() * vect.getNbComponent());
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
void InternalField<T>::internalInitialize(UInt nb_component) {
if (!this->is_init) {
this->nb_component = nb_component;
for (auto ghost : ghost_types) {
for (const auto & type : this->filterTypes(ghost)) {
UInt nb_element = this->element_filter(type, ghost).size();
UInt nb_quadrature_points =
this->fem->getNbIntegrationPoints(type, ghost);
if (this->exists(type, ghost))
this->operator()(type, ghost)
.resize(nb_element * nb_quadrature_points);
else
this->alloc(nb_element * nb_quadrature_points, nb_component, type,
ghost);
}
}
this->material.registerInternal(*this);
this->is_init = true;
}
this->reset();
if (this->previous_values)
this->previous_values->internalInitialize(nb_component);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void InternalField<T>::setArrayValues(T * begin, T * end) {
for (; begin < end; ++begin)
*begin = this->default_value;
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::saveCurrentValues() {
AKANTU_DEBUG_ASSERT(this->previous_values != nullptr,
"The history of the internal "
<< this->getID() << " has not been activated");
if (not this->is_init)
return;
for (auto ghost_type : ghost_types)
for (const auto & type : this->elementTypes(ghost_type))
- (*this->previous_values)(type, ghost_type).copy((*this)(type, ghost_type));
+ (*this->previous_values)(type, ghost_type)
+ .copy((*this)(type, ghost_type));
}
/* -------------------------------------------------------------------------- */
template <typename T> void InternalField<T>::restorePreviousValues() {
AKANTU_DEBUG_ASSERT(this->previous_values != nullptr,
"The history of the internal "
<< this->getID() << " has not been activated");
if (not this->is_init)
return;
for (auto ghost_type : ghost_types)
for (const auto & type : this->elementTypes(ghost_type))
- (*this)(type, ghost_type).copy((*this->previous_values)(type, ghost_type));
+ (*this)(type, ghost_type)
+ .copy((*this->previous_values)(type, ghost_type));
}
/* -------------------------------------------------------------------------- */
template <typename T>
void InternalField<T>::removeIntegrationPoints(
const ElementTypeMapArray<UInt> & new_numbering) {
for (auto ghost_type : ghost_types) {
for (auto type : new_numbering.elementTypes(_all_dimensions, ghost_type,
_ek_not_defined)) {
if (not this->exists(type, ghost_type))
continue;
Array<T> & vect = (*this)(type, ghost_type);
if (vect.size() == 0)
continue;
const Array<UInt> & renumbering = new_numbering(type, ghost_type);
UInt nb_quad_per_elem = fem->getNbIntegrationPoints(type, ghost_type);
UInt nb_component = vect.getNbComponent();
Array<T> tmp(renumbering.size() * nb_quad_per_elem, nb_component);
AKANTU_DEBUG_ASSERT(
tmp.size() == vect.size(),
"Something strange append some mater was created from nowhere!!");
AKANTU_DEBUG_ASSERT(
tmp.size() == vect.size(),
"Something strange append some mater was created or disappeared in "
<< vect.getID() << "(" << vect.size() << "!=" << tmp.size()
<< ") "
"!!");
UInt new_size = 0;
for (UInt i = 0; i < renumbering.size(); ++i) {
UInt new_i = renumbering(i);
if (new_i != UInt(-1)) {
memcpy(tmp.storage() + new_i * nb_component * nb_quad_per_elem,
vect.storage() + i * nb_component * nb_quad_per_elem,
nb_component * nb_quad_per_elem * sizeof(T));
++new_size;
}
}
tmp.resize(new_size * nb_quad_per_elem);
vect.copy(tmp);
}
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
void InternalField<T>::printself(std::ostream & stream,
- int indent[[gnu::unused]]) const {
+ int indent [[gnu::unused]]) const {
stream << "InternalField [ " << this->getID();
#if !defined(AKANTU_NDEBUG)
if (AKANTU_DEBUG_TEST(dblDump)) {
stream << std::endl;
ElementTypeMapArray<T>::printself(stream, indent + 3);
} else {
#endif
stream << " {" << this->getData(_not_ghost).size() << " types - "
<< this->getData(_ghost).size() << " ghost types"
<< "}";
#if !defined(AKANTU_NDEBUG)
}
#endif
stream << " ]";
}
/* -------------------------------------------------------------------------- */
template <>
inline void
ParameterTyped<InternalField<Real>>::setAuto(const ParserParameter & in_param) {
Parameter::setAuto(in_param);
Real r = in_param;
param.setDefaultValue(r);
}
/* -------------------------------------------------------------------------- */
template <typename T> inline InternalField<T>::operator T() const {
return default_value;
}
} // namespace akantu
#endif /* __AKANTU_INTERNAL_FIELD_TMPL_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage.cc b/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage.cc
new file mode 100644
index 000000000..996f4940c
--- /dev/null
+++ b/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage.cc
@@ -0,0 +1,79 @@
+/**
+ * @file material_anisotropic_damage.cc
+ *
+ * @author Nicolas Richart
+ *
+ * @date creation mer jun 26 2019
+ *
+ * @brief A Documented file.
+ *
+ * @section LICENSE
+ *
+ * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+ *
+ * Akantu is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Akantu. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+/* -------------------------------------------------------------------------- */
+#include "material_anisotropic_damage.hh"
+/* -------------------------------------------------------------------------- */
+
+namespace akantu {
+/* -------------------------------------------------------------------------- */
+
+namespace {
+ template <UInt dim>
+ std::unique_ptr<Material>
+ materialAnisotropicDamage(std::integral_constant<UInt, dim>,
+ const ID & option, SolidMechanicsModel & model,
+ const ID & id) {
+ if (option == "" or option == "mazars") {
+ return std::make_unique<MaterialAnisotropicDamage<
+ dim, EquivalentStrainMazars, DamageThresholdTan>>(model, id);
+ } else if (option == "mazars-drucker-prager") {
+ return std::make_unique<MaterialAnisotropicDamage<
+ dim, EquivalentStrainMazarsDruckerPrager, DamageThresholdTan>>(model,
+ id);
+ } else {
+ AKANTU_EXCEPTION("The option "
+ << option << " is not valid for the material " << id);
+ }
+ }
+
+ template <class... Args>
+ decltype(auto) dimensionDispatch(UInt dim, Args &&... args) {
+ switch (dim) {
+ case 1:
+ return materialAnisotropicDamage(std::integral_constant<UInt, 1>{},
+ std::forward<Args>(args)...);
+ case 2:
+ return materialAnisotropicDamage(std::integral_constant<UInt, 2>{},
+ std::forward<Args>(args)...);
+ case 3:
+ return materialAnisotropicDamage(std::integral_constant<UInt, 3>{},
+ std::forward<Args>(args)...);
+ default: { AKANTU_EXCEPTION("In what dimension are you leaving ?"); }
+ }
+ }
+} // namespace
+static bool material_is_alocated_anisotropic_damage [[gnu::unused]] =
+ MaterialFactory::getInstance().registerAllocator(
+ "anisotropic_damage",
+ [](UInt dim, const ID & option, SolidMechanicsModel & model,
+ const ID & id) -> std::unique_ptr<Material> {
+ return dimensionDispatch(dim, option, model, id);
+ });
+
+} // namespace akantu
diff --git a/src/model/common/non_linear_solver/non_linear_solver_petsc.hh b/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage.hh
similarity index 53%
copy from src/model/common/non_linear_solver/non_linear_solver_petsc.hh
copy to src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage.hh
index 2c711d12c..1f3dfb008 100644
--- a/src/model/common/non_linear_solver/non_linear_solver_petsc.hh
+++ b/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage.hh
@@ -1,94 +1,88 @@
/**
- * @file non_linear_solver_petsc.hh
+ * @file material_anisotropic_damage.hh
*
* @author Nicolas Richart
*
- * @date creation Tue Jan 01 2019
+ * @date creation mar jun 25 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
-#include "non_linear_solver.hh"
+#include "material_elastic.hh"
/* -------------------------------------------------------------------------- */
-#include <petscsnes.h>
-/* -------------------------------------------------------------------------- */
-
-#ifndef __AKANTU_NON_LINEAR_SOLVER_PETSC_HH__
-#define __AKANTU_NON_LINEAR_SOLVER_PETSC_HH__
-namespace akantu {
-class DOFManagerPETSc;
-class NonLinearSolverPETScCallback;
-class SolverVectorPETSc;
-} // namespace akanatu
+#ifndef __AKANTU_MATERIAL_ANISOTROPIC_DAMAGE_HH__
+#define __AKANTU_MATERIAL_ANISOTROPIC_DAMAGE_HH__
namespace akantu {
-class NonLinearSolverPETSc : public NonLinearSolver {
+template <UInt dim, template <UInt> class EquivalentStrain,
+ template <UInt> class DamageThreshold,
+ template <UInt> class Parent = MaterialElastic>
+class MaterialAnisotropicDamage : public Parent<dim> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- NonLinearSolverPETSc(DOFManagerPETSc & dof_manager,
- const NonLinearSolverType & non_linear_solver_type,
- const ID & id = "non_linear_solver_petsc",
- UInt memory_id = 0);
-
- ~NonLinearSolverPETSc() override;
+ MaterialAnisotropicDamage(SolidMechanicsModel & model, const ID & id = "");
+ ~MaterialAnisotropicDamage() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
- /// solve the system described by the jacobian matrix, and rhs contained in
- /// the dof manager
- void solve(SolverCallback & callback) override;
+ void computeStress(ElementType el_type, GhostType ghost_type);
+
+private:
+ void damageStress(Matrix<double> & sigma, const Matrix<double> & sigma_el,
+ const Matrix<double> & D, Real TrD);
- /// parse the arguments from the input file
- void parseSection(const ParserSection & section) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
-protected:
- static PetscErrorCode FormFunction(SNES snes, Vec dx, Vec f,
- void * ctx);
- static PetscErrorCode FormJacobian(SNES snes, Vec dx, Mat J,
- Mat P, void * ctx);
-
- void set_param(const ID & param, const std::string & value) override;
-
- DOFManagerPETSc & dof_manager;
+private:
+ Real Dc{0.99};
- /// PETSc non linear solver
- SNES snes;
+ /// damage internal variable
+ InternalField<Real> damage;
- SolverCallback * callback{nullptr};
+ /// elastic stress
+ InternalField<Real> elastic_stress;
- std::unique_ptr<SolverVectorPETSc> x;
- std::unique_ptr<NonLinearSolverPETScCallback> ctx;
-
- Int n_iter{0};
+ /// equivalent strain
+ InternalField<Real> equivalent_strain;
+
+ /// trace of the damageThreshold
+ InternalField<Real> trace_damage;
+
+ /// damage criteria
+ EquivalentStrain<dim> equivalent_strain_function;
+
+ /// damage evolution
+ DamageThreshold<dim> damage_threshold_function;
};
-} // namepsace akantu
+} // namespace akantu
+
+#include "material_anisotropic_damage_tmpl.hh"
-#endif /* __AKANTU_NON_LINEAR_SOLVER_PETSC_HH__ */
+#endif /* __AKANTU_MATERIAL_ANISOTROPIC_DAMAGE_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage_tmpl.hh b/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage_tmpl.hh
new file mode 100644
index 000000000..9350f2921
--- /dev/null
+++ b/src/model/solid_mechanics/materials/material_damage/material_anisotropic_damage_tmpl.hh
@@ -0,0 +1,366 @@
+/**
+ * @file material_anisotropic_damage_tmpl.hh
+ *
+ * @author Nicolas Richart
+ *
+ * @date creation mar jun 25 2019
+ *
+ * @brief A Documented file.
+ *
+ * @section LICENSE
+ *
+ * Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
+ * Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
+ *
+ * Akantu is free software: you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation, either version 3 of the License, or (at your option) any
+ * later version.
+ *
+ * Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ * A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+ * details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Akantu. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+/* -------------------------------------------------------------------------- */
+#include "aka_iterators.hh"
+#include "material_anisotropic_damage.hh"
+/* -------------------------------------------------------------------------- */
+
+#ifndef __AKANTU_MATERIAL_ANISOTROPIC_DAMAGE_TMPL_HH__
+#define __AKANTU_MATERIAL_ANISOTROPIC_DAMAGE_TMPL_HH__
+
+namespace akantu {
+struct EmptyIteratorContainer {
+ struct iterator {
+ auto & operator++() { return *this; }
+ Real operator*() { return 0; }
+ bool operator!=(const iterator &) const { return true; }
+ bool operator==(const iterator &) const { return false; }
+ };
+
+ auto begin() { return iterator(); }
+ auto end() { return iterator(); }
+};
+} // namespace akantu
+
+namespace std {
+template <> struct iterator_traits<::akantu::EmptyIteratorContainer::iterator> {
+ using iterator_category = forward_iterator_tag;
+ using value_type = akantu::Real;
+ using difference_type = std::ptrdiff_t;
+ using pointer = akantu::Real *;
+ using reference = akantu::Real &;
+};
+} // namespace std
+
+namespace akantu {
+namespace {
+ template <UInt dim, class Op>
+ void tensorPlus_(const Matrix<Real> & A, Op && oper) {
+ Vector<Real> A_eigs(dim);
+ A.eig(A_eigs);
+
+ for (auto & ap : A_eigs) {
+ oper(ap);
+ }
+ }
+
+ template <UInt dim> auto tensorPlus2(const Matrix<Real> & A) {
+ Real square = 0;
+ tensorPlus_<dim>(A, [&](Real eig) {
+ eig = std::max(eig, 0.);
+ square += eig * eig;
+ });
+
+ return square;
+ }
+
+ template <UInt dim> auto tensorPlusTrace(const Matrix<Real> & A) {
+ Real trace_plus = 0;
+ Real trace_minus = 0;
+ tensorPlus_<dim>(A, [&](Real eig) {
+ trace_plus += std::max(eig, 0.);
+ trace_minus += std::min(eig, 0.);
+ });
+
+ return std::make_pair(trace_plus, trace_minus);
+ }
+
+ template <UInt dim, class Op>
+ auto tensorPlusOp(const Matrix<Real> & A, Matrix<Real> & A_directions,
+ Op && oper, bool sorted = false) {
+ Vector<Real> A_eigs(dim);
+ Matrix<Real> A_diag(dim, dim);
+ A.eig(A_eigs, A_directions, sorted);
+
+ for (auto && data : enumerate(A_eigs)) {
+ auto i = std::get<0>(data);
+ A_diag(i, i) = oper(std::max(std::get<1>(data), 0.), i);
+ }
+
+ return A_directions * A_diag * A_directions.transpose();
+ }
+
+ template <UInt dim, class Op>
+ auto tensorPlus(const Matrix<Real> & A, Matrix<Real> & A_directions,
+ bool sorted = false) {
+ return tensorPlusOp<dim>(A, A_directions, [](Real x, Real) { return x; },
+ sorted);
+ }
+
+ template <UInt dim, class Op>
+ auto tensorPlusOp(const Matrix<Real> & A, Op && oper) {
+ Matrix<Real> A_directions(dim, dim);
+ return tensorPlusOp<dim>(A, A_directions, std::forward<Op>(oper));
+ }
+
+ template <UInt dim> auto tensorPlus(const Matrix<Real> & A) {
+ return tensorPlusOp<dim>(A, [](Real x, Real) { return x; });
+ }
+
+ template <UInt dim> auto tensorSqrt(const Matrix<Real> & A) {
+ return tensorPlusOp<dim>(A, [](Real x, UInt) { return std::sqrt(x); });
+ }
+
+} // namespace
+
+/* -------------------------------------------------------------------------- */
+
+/* -------------------------------------------------------------------------- */
+template <UInt dim, template <UInt> class EquivalentStrain,
+ template <UInt> class DamageThreshold, template <UInt> class Parent>
+MaterialAnisotropicDamage<dim, EquivalentStrain, DamageThreshold, Parent>::
+ MaterialAnisotropicDamage(SolidMechanicsModel & model, const ID & id)
+ : Parent<dim>(model, id), damage("damage_tensor", *this),
+ elastic_stress("elastic_stress", *this),
+ equivalent_strain("equivalent_strain", *this),
+ trace_damage("trace_damage", *this), equivalent_strain_function(*this),
+ damage_threshold_function(*this) {
+ this->registerParam("Dc", Dc, _pat_parsable, "Critical damage");
+
+ this->damage.initialize(dim * dim);
+ this->elastic_stress.initialize(dim * dim);
+ this->equivalent_strain.initialize(1);
+
+ this->trace_damage.initialize(1);
+ this->trace_damage.initializeHistory();
+}
+
+/* -------------------------------------------------------------------------- */
+template <UInt dim, template <UInt> class EquivalentStrain,
+ template <UInt> class DamageThreshold, template <UInt> class Parent>
+void MaterialAnisotropicDamage<dim, EquivalentStrain, DamageThreshold, Parent>::
+ damageStress(Matrix<Real> & sigma, const Matrix<Real> & sigma_el,
+ const Matrix<Real> & D, Real TrD) {
+ // σ_(n + 1) = (1 − D_(n + 1))^(1/2) σ~_(n + 1) (1 − D_(n + 1))^(1 / 2)
+ // - ((1 − D_(n + 1)) : σ~_(n + 1))/ (3 - Tr(D_(n+1))) (1 − D_(n + 1))
+ // + 1/3 (1 - Tr(D_(n+1)) <Tr(σ~_(n + 1))>_+ + <Tr(σ~_(n + 1))>_-) I
+
+ auto one_D = Matrix<Real>::eye(dim) - D;
+ auto sqrt_one_D = tensorSqrt<dim>(one_D);
+
+ Real Tr_sigma_plus, Tr_sigma_minus;
+ std::tie(Tr_sigma_plus, Tr_sigma_minus) = tensorPlusTrace<dim>(sigma_el);
+
+ auto I = Matrix<Real>::eye(dim);
+
+ sigma = sqrt_one_D * sigma_el * sqrt_one_D -
+ (one_D.doubleDot(sigma_el) / (dim - TrD) * one_D) +
+ 1. / dim * ((1 - TrD) * Tr_sigma_plus - Tr_sigma_minus) * I;
+}
+
+/* -------------------------------------------------------------------------- */
+template <UInt dim, template <UInt> class EquivalentStrain,
+ template <UInt> class DamageThreshold, template <UInt> class Parent>
+void MaterialAnisotropicDamage<dim, EquivalentStrain, DamageThreshold,
+ Parent>::computeStress(ElementType type,
+ GhostType ghost_type) {
+
+ for (auto && data :
+ zip(make_view(this->stress(type, ghost_type), dim, dim),
+ make_view(this->gradu(type, ghost_type), dim, dim),
+ make_view(this->sigma_th(type, ghost_type)),
+ make_view(this->elastic_stress(type, ghost_type), dim, dim),
+ make_view(this->equivalent_strain(type, ghost_type)),
+ make_view(this->damage(type, ghost_type), dim, dim),
+ make_view(this->trace_damage(type, ghost_type)),
+ make_view(this->trace_damage.previous(type, ghost_type)),
+ equivalent_strain_function, damage_threshold_function)) {
+ auto & sigma = std::get<0>(data);
+ auto & grad_u = std::get<1>(data);
+ auto & sigma_th = std::get<2>(data);
+ auto & sigma_el = std::get<3>(data);
+ auto & epsilon_hat = std::get<4>(data);
+ auto & D = std::get<5>(data);
+ auto & TrD_n_1 = std::get<6>(data);
+ auto & TrD = std::get<7>(data);
+ auto & equivalent_strain_data = std::get<8>(data);
+ auto & damage_threshold_data = std::get<9>(data);
+
+ Matrix<Real> Dtmp(dim, dim);
+ Real TrD_n_1_tmp;
+ Matrix<Real> epsilon(dim, dim);
+
+ // yes you read properly this is a label for a goto
+ auto computeDamage = [&]() {
+ MaterialElastic<dim>::computeStressOnQuad(grad_u, sigma_el, sigma_th);
+
+ this->template gradUToEpsilon<dim>(grad_u, epsilon);
+
+ // evaluate the damage criteria
+ epsilon_hat = equivalent_strain_function(epsilon, equivalent_strain_data);
+
+ // evolve the damage if needed
+ auto K_TrD = damage_threshold_function.K(TrD, damage_threshold_data);
+
+ auto f = epsilon_hat - K_TrD;
+
+ // if test function > 0 evolve the damage
+ if (f > 0) {
+ TrD_n_1_tmp =
+ damage_threshold_function.K_inv(epsilon_hat, damage_threshold_data);
+
+ auto epsilon_plus = tensorPlus<dim>(epsilon);
+ auto delta_lambda = (TrD_n_1_tmp - TrD) / (epsilon_hat * epsilon_hat);
+
+ Dtmp = D + delta_lambda * epsilon_plus;
+ return true;
+ }
+ return false;
+ };
+
+ // compute a temporary version of the new damage
+ auto is_damage_updated = computeDamage();
+
+ if (is_damage_updated) {
+ /// Check and correct for broken case
+ if (Dtmp.trace() > Dc) {
+ if (epsilon.trace() > 0) { // tensile loading
+ auto kpa = this->kpa;
+ auto lambda = this->lambda;
+
+ // change kappa to Kappa_broken = (1-Dc) Kappa
+ kpa = (1 - Dc) * kpa;
+ this->E = 9 * kpa * (kpa - lambda) / (3 * kpa - lambda);
+ this->nu = lambda / (3 * kpa - lambda);
+ this->updateInternalParameters();
+
+ computeDamage();
+ } else if (std::abs(epsilon.trace()) < 1e-10) { // deviatoric case
+ Matrix<Real> n(dim, dim);
+ std::vector<UInt> ns;
+ tensorPlusOp<dim>(Dtmp, n,
+ [&](Real x, UInt i) {
+ if (x > this->Dc) {
+ ns.push_back(i);
+ return this->Dc;
+ }
+
+ return x;
+ },
+ true);
+ }
+ }
+
+ TrD_n_1 = TrD_n_1_tmp;
+ D = Dtmp;
+ } else {
+ TrD_n_1 = TrD;
+ }
+
+ // apply the damage to the stress
+ damageStress(sigma, sigma_el, D, TrD_n_1);
+ }
+}
+
+/* -------------------------------------------------------------------------- */
+/* EquivalentStrain functions */
+/* -------------------------------------------------------------------------- */
+template <UInt dim>
+class EquivalentStrainMazars : public EmptyIteratorContainer {
+public:
+ EquivalentStrainMazars(Material & /*mat*/) {}
+
+ template <class... Other>
+ Real operator()(const Matrix<Real> & epsilon, Other &&... /*other*/) {
+ Real epsilon_hat = 0.;
+ std::tie(epsilon_hat, std::ignore) = tensorPlusTrace<dim>(epsilon);
+ return std::sqrt(epsilon_hat);
+ }
+};
+
+template <UInt dim>
+class EquivalentStrainMazarsDruckerPrager : public EquivalentStrainMazars<dim> {
+public:
+ EquivalentStrainMazarsDruckerPrager(Material & mat)
+ : EquivalentStrainMazars<dim>(mat) {
+ mat.registerParam("k", k, _pat_parsable, "k");
+ }
+
+ template <class... Other>
+ Real operator()(const Matrix<Real> & epsilon, Real) {
+ Real epsilon_hat = EquivalentStrainMazars<dim>::operator()(epsilon);
+ epsilon_hat += k * epsilon.trace();
+ return epsilon_hat;
+ }
+
+protected:
+ Real k;
+};
+
+/* -------------------------------------------------------------------------- */
+/* DamageThreshold functions */
+/* -------------------------------------------------------------------------- */
+template <UInt dim>
+class DamageThresholdLinear : public EmptyIteratorContainer {
+public:
+ DamageThresholdLinear(Material & mat) : mat(mat) {
+ mat.registerParam("A", A, _pat_parsable, "A");
+ mat.registerParam("K0", K0, _pat_parsable, "K0");
+ }
+
+ template <class... Other> Real K(Real x, Other &&... /*other*/) {
+ return 1. / A * x + K0;
+ }
+
+ template <class... Other> Real K_inv(Real x, Other &&... /*other*/) {
+ return A * (x - K0);
+ }
+
+private:
+ Material & mat;
+ Real A;
+ Real K0;
+};
+
+template <UInt dim> class DamageThresholdTan : public EmptyIteratorContainer {
+public:
+ DamageThresholdTan(Material & mat) : mat(mat) {
+ mat.registerParam("a", a, _pat_parsable, "a");
+ mat.registerParam("A", A, _pat_parsable, "A");
+ mat.registerParam("K0", K0, _pat_parsable, "K0");
+ }
+
+ template <class... Other> Real K(Real x, Other &&... /*other*/) {
+ return a * std::tan(std::atan2(x, a) - std::atan2(K0, a));
+ }
+
+ template <class... Other> Real K_inv(Real x, Other &&... /*other*/) {
+ return a * A * (std::atan2(x, a) - std::atan2(K0, a));
+ }
+
+private:
+ Material & mat;
+ Real a{2.93e-4};
+ Real A{5e3};
+ Real K0{5e-5};
+};
+
+} // namespace akantu
+
+#endif /* __AKANTU_MATERIAL_ANISOTROPIC_DAMAGE_TMPL_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_damage/material_damage.hh b/src/model/solid_mechanics/materials/material_damage/material_damage.hh
index b4fe71efc..73dc1e7d9 100644
--- a/src/model/solid_mechanics/materials/material_damage/material_damage.hh
+++ b/src/model/solid_mechanics/materials/material_damage/material_damage.hh
@@ -1,112 +1,113 @@
/**
* @file material_damage.hh
*
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Material isotropic elastic
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material_elastic.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_DAMAGE_HH__
#define __AKANTU_MATERIAL_DAMAGE_HH__
namespace akantu {
template <UInt spatial_dimension,
template <UInt> class Parent = MaterialElastic>
class MaterialDamage : public Parent<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialDamage(SolidMechanicsModel & model, const ID & id = "");
~MaterialDamage() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initMaterial() override;
/// compute the tangent stiffness matrix for an element type
void computeTangentModuli(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost) override;
+
bool hasStiffnessMatrixChanged() override { return true; }
protected:
/// update the dissipated energy, must be called after the stress have been
/// computed
void updateEnergies(ElementType el_type) override;
/// compute the tangent stiffness matrix for a given quadrature point
inline void computeTangentModuliOnQuad(Matrix<Real> & tangent, Real & dam);
/* ------------------------------------------------------------------------ */
/* DataAccessor inherited members */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// give the dissipated energy for the time step
Real getDissipatedEnergy() const;
Real getEnergy(const std::string & type) override;
Real getEnergy(const std::string & energy_id, ElementType type,
UInt index) override {
return Parent<spatial_dimension>::getEnergy(energy_id, type, index);
};
AKANTU_GET_MACRO_NOT_CONST(Damage, damage, ElementTypeMapArray<Real> &);
AKANTU_GET_MACRO(Damage, damage, const ElementTypeMapArray<Real> &);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Damage, damage, Real)
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// damage internal variable
InternalField<Real> damage;
/// dissipated energy
InternalField<Real> dissipated_energy;
/// contain the current value of @f$ \int_0^{\epsilon}\sigma(\omega)d\omega
/// @f$ the dissipated energy
InternalField<Real> int_sigma;
};
} // namespace akantu
#include "material_damage_tmpl.hh"
#endif /* __AKANTU_MATERIAL_DAMAGE_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_damage/material_damage_tmpl.hh b/src/model/solid_mechanics/materials/material_damage/material_damage_tmpl.hh
index d0c7a34b2..dfd2d5dc1 100644
--- a/src/model/solid_mechanics/materials/material_damage/material_damage_tmpl.hh
+++ b/src/model/solid_mechanics/materials/material_damage/material_damage_tmpl.hh
@@ -1,175 +1,175 @@
/**
* @file material_damage_tmpl.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <mchambart@stucky.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Specialization of the material class for the damage material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_damage.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
MaterialDamage<spatial_dimension, Parent>::MaterialDamage(
SolidMechanicsModel & model, const ID & id)
: Parent<spatial_dimension>(model, id), damage("damage", *this),
dissipated_energy("damage dissipated energy", *this),
int_sigma("integral of sigma", *this) {
AKANTU_DEBUG_IN();
this->is_non_local = false;
this->use_previous_stress = true;
this->use_previous_gradu = true;
this->damage.initialize(1);
this->dissipated_energy.initialize(1);
this->int_sigma.initialize(1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialDamage<spatial_dimension, Parent>::initMaterial() {
AKANTU_DEBUG_IN();
Parent<spatial_dimension>::initMaterial();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Compute the dissipated energy in each element by a trapezoidal approximation
* of
* @f$ Ed = \int_0^{\epsilon}\sigma(\omega)d\omega -
* \frac{1}{2}\sigma:\epsilon@f$
*/
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialDamage<spatial_dimension, Parent>::updateEnergies(
ElementType el_type) {
Parent<spatial_dimension>::updateEnergies(el_type);
this->computePotentialEnergy(el_type);
- auto epsilon_p = this->gradu.previous(el_type)
- .begin(spatial_dimension, spatial_dimension);
- auto sigma_p = this->stress.previous(el_type)
- .begin(spatial_dimension, spatial_dimension);
+ auto epsilon_p =
+ this->gradu.previous(el_type).begin(spatial_dimension, spatial_dimension);
+ auto sigma_p = this->stress.previous(el_type).begin(spatial_dimension,
+ spatial_dimension);
auto epot = this->potential_energy(el_type).begin();
auto ints = this->int_sigma(el_type).begin();
auto ed = this->dissipated_energy(el_type).begin();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
Matrix<Real> delta_gradu(grad_u);
delta_gradu -= *epsilon_p;
Matrix<Real> sigma_h(sigma);
sigma_h += *sigma_p;
Real dint = .5 * sigma_h.doubleDot(delta_gradu);
*ints += dint;
*ed = *ints - *epot;
++epsilon_p;
++sigma_p;
++epot;
++ints;
++ed;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialDamage<spatial_dimension, Parent>::computeTangentModuli(
const ElementType & el_type, Array<Real> & tangent_matrix,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Parent<spatial_dimension>::computeTangentModuli(el_type, tangent_matrix,
ghost_type);
Real * dam = this->damage(el_type, ghost_type).storage();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
computeTangentModuliOnQuad(tangent, *dam);
++dam;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
void MaterialDamage<spatial_dimension, Parent>::computeTangentModuliOnQuad(
Matrix<Real> & tangent, Real & dam) {
tangent *= (1 - dam);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
Real MaterialDamage<spatial_dimension, Parent>::getDissipatedEnergy() const {
AKANTU_DEBUG_IN();
Real de = 0.;
/// integrate the dissipated energy for each type of elements
for (auto & type :
this->element_filter.elementTypes(spatial_dimension, _not_ghost)) {
de +=
this->fem.integrate(dissipated_energy(type, _not_ghost), type,
_not_ghost, this->element_filter(type, _not_ghost));
}
AKANTU_DEBUG_OUT();
return de;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension, template <UInt> class Parent>
Real MaterialDamage<spatial_dimension, Parent>::getEnergy(
const std::string & type) {
if (type == "dissipated")
return getDissipatedEnergy();
else
return Parent<spatial_dimension>::getEnergy(type);
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_damage/material_marigo.hh b/src/model/solid_mechanics/materials/material_damage/material_marigo.hh
index 3f5b63277..b6306f0e3 100644
--- a/src/model/solid_mechanics/materials/material_damage/material_marigo.hh
+++ b/src/model/solid_mechanics/materials/material_damage/material_marigo.hh
@@ -1,123 +1,123 @@
/**
* @file material_marigo.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Marigo damage law
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material.hh"
#include "material_damage.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_MARIGO_HH__
#define __AKANTU_MATERIAL_MARIGO_HH__
namespace akantu {
/**
* Material marigo
*
* parameters in the material files :
* - Yd : (default: 50)
* - Sd : (default: 5000)
* - Ydrandomness : (default:0)
*/
template <UInt spatial_dimension>
class MaterialMarigo : public MaterialDamage<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialMarigo(SolidMechanicsModel & model, const ID & id = "");
~MaterialMarigo() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initMaterial() override;
void updateInternalParameters() override;
/// constitutive law for all element of a type
void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost) override;
protected:
/// constitutive law for a given quadrature point
inline void computeStressOnQuad(Matrix<Real> & grad_u, Matrix<Real> & sigma,
Real & dam, Real & Y, Real & Ydq);
inline void computeDamageAndStressOnQuad(Matrix<Real> & sigma, Real & dam,
Real & Y, Real & Ydq);
/* ------------------------------------------------------------------------ */
/* DataAccessor inherited members */
/* ------------------------------------------------------------------------ */
public:
inline UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const override;
inline void unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// resistance to damage
RandomInternalField<Real> Yd;
/// damage threshold
Real Sd;
/// critical epsilon when the material is considered as broken
Real epsilon_c;
Real Yc;
bool damage_in_y;
bool yc_limit;
};
-} // akantu
+} // namespace akantu
#include "material_marigo_inline_impl.cc"
#endif /* __AKANTU_MATERIAL_MARIGO_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_damage/material_marigo_inline_impl.cc b/src/model/solid_mechanics/materials/material_damage/material_marigo_inline_impl.cc
index d242d6ddc..67df58c36 100644
--- a/src/model/solid_mechanics/materials/material_damage/material_marigo_inline_impl.cc
+++ b/src/model/solid_mechanics/materials/material_damage/material_marigo_inline_impl.cc
@@ -1,131 +1,131 @@
/**
* @file material_marigo_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Fri Dec 02 2016
*
* @brief Implementation of the inline functions of the material marigo
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_marigo.hh"
#ifndef __AKANTU_MATERIAL_MARIGO_INLINE_IMPL_CC__
#define __AKANTU_MATERIAL_MARIGO_INLINE_IMPL_CC__
namespace akantu {
template <UInt spatial_dimension>
inline void MaterialMarigo<spatial_dimension>::computeStressOnQuad(
Matrix<Real> & grad_u, Matrix<Real> & sigma, Real & dam, Real & Y,
Real & Ydq) {
MaterialElastic<spatial_dimension>::computeStressOnQuad(grad_u, sigma);
Y = 0;
for (UInt i = 0; i < spatial_dimension; ++i) {
for (UInt j = 0; j < spatial_dimension; ++j) {
Y += sigma(i, j) * (grad_u(i, j) + grad_u(j, i)) / 2.;
}
}
Y *= 0.5;
if (damage_in_y)
Y *= (1 - dam);
if (yc_limit)
Y = std::min(Y, Yc);
if (!this->is_non_local) {
computeDamageAndStressOnQuad(sigma, dam, Y, Ydq);
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialMarigo<spatial_dimension>::computeDamageAndStressOnQuad(
Matrix<Real> & sigma, Real & dam, Real & Y, Real & Ydq) {
Real Fd = Y - Ydq - Sd * dam;
if (Fd > 0)
dam = (Y - Ydq) / Sd;
dam = std::min(dam, Real(1.));
sigma *= 1 - dam;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline UInt MaterialMarigo<spatial_dimension>::getNbData(
const Array<Element> & elements, const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
if (tag == SynchronizationTag::_smm_init_mat) {
size += sizeof(Real) * this->getModel().getNbIntegrationPoints(elements);
}
size += MaterialDamage<spatial_dimension>::getNbData(elements, tag);
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialMarigo<spatial_dimension>::packData(
CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
if (tag == SynchronizationTag::_smm_init_mat) {
this->packElementDataHelper(Yd, buffer, elements);
}
MaterialDamage<spatial_dimension>::packData(buffer, elements, tag);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void
MaterialMarigo<spatial_dimension>::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
if (tag == SynchronizationTag::_smm_init_mat) {
this->unpackElementDataHelper(Yd, buffer, elements);
}
MaterialDamage<spatial_dimension>::unpackData(buffer, elements, tag);
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_MARIGO_INLINE_IMPL_CC__ */
diff --git a/src/model/solid_mechanics/materials/material_damage/material_mazars_inline_impl.cc b/src/model/solid_mechanics/materials/material_damage/material_mazars_inline_impl.cc
index 2f7b3813b..6a158ff3d 100644
--- a/src/model/solid_mechanics/materials/material_damage/material_mazars_inline_impl.cc
+++ b/src/model/solid_mechanics/materials/material_damage/material_mazars_inline_impl.cc
@@ -1,155 +1,155 @@
/**
* @file material_mazars_inline_impl.cc
*
* @author Marion Estelle Chambart <mchambart@stucky.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Apr 06 2011
* @date last modification: Wed Feb 03 2016
*
* @brief Implementation of the inline functions of the material damage
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialMazars<spatial_dimension>::computeStressOnQuad(
const Matrix<Real> & grad_u, Matrix<Real> & sigma, Real & dam,
Real & Ehat) {
Matrix<Real> epsilon(3, 3);
epsilon.clear();
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j)
epsilon(i, j) = .5 * (grad_u(i, j) + grad_u(j, i));
Vector<Real> Fdiag(3);
Math::matrixEig(3, epsilon.storage(), Fdiag.storage());
Ehat = 0.;
for (UInt i = 0; i < 3; ++i) {
Real epsilon_p = std::max(Real(0.), Fdiag(i));
Ehat += epsilon_p * epsilon_p;
}
Ehat = sqrt(Ehat);
MaterialElastic<spatial_dimension>::computeStressOnQuad(grad_u, sigma);
if (damage_in_compute_stress) {
computeDamageOnQuad(Ehat, sigma, Fdiag, dam);
}
- if (!this->is_non_local) {
+ if (not this->is_non_local) {
computeDamageAndStressOnQuad(grad_u, sigma, dam, Ehat);
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialMazars<spatial_dimension>::computeDamageAndStressOnQuad(
const Matrix<Real> & grad_u, Matrix<Real> & sigma, Real & dam,
Real & Ehat) {
if (!damage_in_compute_stress) {
Vector<Real> Fdiag(3);
Fdiag.clear();
Matrix<Real> epsilon(3, 3);
epsilon.clear();
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j)
epsilon(i, j) = .5 * (grad_u(i, j) + grad_u(j, i));
Math::matrixEig(3, epsilon.storage(), Fdiag.storage());
computeDamageOnQuad(Ehat, sigma, Fdiag, dam);
}
sigma *= 1 - dam;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialMazars<spatial_dimension>::computeDamageOnQuad(
const Real & epsilon_equ,
__attribute__((unused)) const Matrix<Real> & sigma,
const Vector<Real> & epsilon_princ, Real & dam) {
Real Fs = epsilon_equ - K0;
if (Fs > 0.) {
Real dam_t;
Real dam_c;
dam_t =
1 - K0 * (1 - At) / epsilon_equ - At * (exp(-Bt * (epsilon_equ - K0)));
dam_c =
1 - K0 * (1 - Ac) / epsilon_equ - Ac * (exp(-Bc * (epsilon_equ - K0)));
Real Cdiag;
Cdiag = this->E * (1 - this->nu) / ((1 + this->nu) * (1 - 2 * this->nu));
Vector<Real> sigma_princ(3);
sigma_princ(0) = Cdiag * epsilon_princ(0) +
this->lambda * (epsilon_princ(1) + epsilon_princ(2));
sigma_princ(1) = Cdiag * epsilon_princ(1) +
this->lambda * (epsilon_princ(0) + epsilon_princ(2));
sigma_princ(2) = Cdiag * epsilon_princ(2) +
this->lambda * (epsilon_princ(1) + epsilon_princ(0));
Vector<Real> sigma_p(3);
for (UInt i = 0; i < 3; i++)
sigma_p(i) = std::max(Real(0.), sigma_princ(i));
- //sigma_p *= 1. - dam;
+ // sigma_p *= 1. - dam;
Real trace_p = this->nu / this->E * (sigma_p(0) + sigma_p(1) + sigma_p(2));
Real alpha_t = 0;
for (UInt i = 0; i < 3; ++i) {
Real epsilon_t = (1 + this->nu) / this->E * sigma_p(i) - trace_p;
Real epsilon_p = std::max(Real(0.), epsilon_princ(i));
alpha_t += epsilon_t * epsilon_p;
}
alpha_t /= epsilon_equ * epsilon_equ;
alpha_t = std::min(alpha_t, Real(1.));
Real alpha_c = 1. - alpha_t;
alpha_t = std::pow(alpha_t, beta);
alpha_c = std::pow(alpha_c, beta);
Real damtemp;
damtemp = alpha_t * dam_t + alpha_c * dam_c;
dam = std::max(damtemp, dam);
dam = std::min(dam, Real(1.));
}
}
/* -------------------------------------------------------------------------- */
// template<UInt spatial_dimension>
// inline void
// MaterialMazars<spatial_dimension>::computeTangentModuliOnQuad(Matrix<Real> &
// tangent) {
// MaterialElastic<spatial_dimension>::computeTangentModuliOnQuad(tangent);
// tangent *= (1-dam);
// }
diff --git a/src/model/solid_mechanics/materials/material_elastic.cc b/src/model/solid_mechanics/materials/material_elastic.cc
index 0e30cd69c..db805da7c 100644
--- a/src/model/solid_mechanics/materials/material_elastic.cc
+++ b/src/model/solid_mechanics/materials/material_elastic.cc
@@ -1,261 +1,261 @@
/**
* @file material_elastic.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Mon Jan 29 2018
*
* @brief Specialization of the material class for the elastic material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_elastic.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim>
MaterialElastic<dim>::MaterialElastic(SolidMechanicsModel & model,
const ID & id)
: Parent(model, id), was_stiffness_assembled(false) {
AKANTU_DEBUG_IN();
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
MaterialElastic<dim>::MaterialElastic(SolidMechanicsModel & model,
__attribute__((unused)) UInt a_dim,
const Mesh & mesh, FEEngine & fe_engine,
const ID & id)
: Parent(model, dim, mesh, fe_engine, id), was_stiffness_assembled(false) {
AKANTU_DEBUG_IN();
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialElastic<dim>::initialize() {
this->registerParam("lambda", lambda, _pat_readable,
"First Lamé coefficient");
this->registerParam("mu", mu, _pat_readable, "Second Lamé coefficient");
this->registerParam("kapa", kpa, _pat_readable, "Bulk coefficient");
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialElastic<dim>::initMaterial() {
AKANTU_DEBUG_IN();
Parent::initMaterial();
if (dim == 1)
this->nu = 0.;
this->updateInternalParameters();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialElastic<dim>::updateInternalParameters() {
MaterialThermal<dim>::updateInternalParameters();
this->lambda = this->nu * this->E / ((1 + this->nu) * (1 - 2 * this->nu));
this->mu = this->E / (2 * (1 + this->nu));
this->kpa = this->lambda + 2. / 3. * this->mu;
this->was_stiffness_assembled = false;
}
/* -------------------------------------------------------------------------- */
template <> void MaterialElastic<2>::updateInternalParameters() {
MaterialThermal<2>::updateInternalParameters();
this->lambda = this->nu * this->E / ((1 + this->nu) * (1 - 2 * this->nu));
this->mu = this->E / (2 * (1 + this->nu));
if (this->plane_stress)
this->lambda = this->nu * this->E / ((1 + this->nu) * (1 - this->nu));
this->kpa = this->lambda + 2. / 3. * this->mu;
this->was_stiffness_assembled = false;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialElastic<spatial_dimension>::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Parent::computeStress(el_type, ghost_type);
Array<Real>::const_scalar_iterator sigma_th_it =
this->sigma_th(el_type, ghost_type).begin();
if (!this->finite_deformation) {
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
const Real & sigma_th = *sigma_th_it;
this->computeStressOnQuad(grad_u, sigma, sigma_th);
++sigma_th_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
} else {
/// finite gradus
Matrix<Real> E(spatial_dimension, spatial_dimension);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
/// compute E
this->template gradUToGreenStrain<spatial_dimension>(grad_u, E);
const Real & sigma_th = *sigma_th_it;
/// compute second Piola-Kirchhoff stress tensor
this->computeStressOnQuad(E, sigma, sigma_th);
++sigma_th_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialElastic<spatial_dimension>::computeTangentModuli(
const ElementType & el_type, Array<Real> & tangent_matrix,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
this->computeTangentModuliOnQuad(tangent);
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
this->was_stiffness_assembled = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialElastic<spatial_dimension>::getPushWaveSpeed(
const Element &) const {
return sqrt((lambda + 2 * mu) / this->rho);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialElastic<spatial_dimension>::getShearWaveSpeed(
const Element &) const {
return sqrt(mu / this->rho);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialElastic<spatial_dimension>::computePotentialEnergy(
ElementType el_type) {
AKANTU_DEBUG_IN();
// MaterialThermal<dim>::computePotentialEnergy(ElementType)
// needs to be implemented
// MaterialThermal<spatial_dimension>::computePotentialEnergy(el_type);
auto epot = this->potential_energy(el_type, _not_ghost).begin();
if (!this->finite_deformation) {
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
this->computePotentialEnergyOnQuad(grad_u, sigma, *epot);
++epot;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
} else {
Matrix<Real> E(spatial_dimension, spatial_dimension);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
this->template gradUToGreenStrain<spatial_dimension>(grad_u, E);
this->computePotentialEnergyOnQuad(E, sigma, *epot);
++epot;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialElastic<spatial_dimension>::computePotentialEnergyByElement(
ElementType type, UInt index, Vector<Real> & epot_on_quad_points) {
auto gradu_it = this->gradu(type).begin(spatial_dimension, spatial_dimension);
auto gradu_end =
this->gradu(type).begin(spatial_dimension, spatial_dimension);
auto stress_it =
this->stress(type).begin(spatial_dimension, spatial_dimension);
if (this->finite_deformation)
stress_it = this->piola_kirchhoff_2(type).begin(spatial_dimension,
spatial_dimension);
UInt nb_quadrature_points = this->fem.getNbIntegrationPoints(type);
gradu_it += index * nb_quadrature_points;
gradu_end += (index + 1) * nb_quadrature_points;
stress_it += index * nb_quadrature_points;
Real * epot_quad = epot_on_quad_points.storage();
Matrix<Real> grad_u(spatial_dimension, spatial_dimension);
for (; gradu_it != gradu_end; ++gradu_it, ++stress_it, ++epot_quad) {
if (this->finite_deformation)
this->template gradUToGreenStrain<spatial_dimension>(*gradu_it, grad_u);
else
grad_u.copy(*gradu_it);
this->computePotentialEnergyOnQuad(grad_u, *stress_it, *epot_quad);
}
}
/* -------------------------------------------------------------------------- */
template <>
Real MaterialElastic<1>::getPushWaveSpeed(const Element & /*element*/) const {
return std::sqrt(this->E / this->rho);
}
template <>
Real MaterialElastic<1>::getShearWaveSpeed(const Element & /*element*/) const {
AKANTU_EXCEPTION("There is no shear wave speed in 1D");
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(elastic, MaterialElastic);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_elastic.hh b/src/model/solid_mechanics/materials/material_elastic.hh
index 1ac0b0758..ddc52590e 100644
--- a/src/model/solid_mechanics/materials/material_elastic.hh
+++ b/src/model/solid_mechanics/materials/material_elastic.hh
@@ -1,155 +1,155 @@
/**
* @file material_elastic.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Fri Nov 17 2017
*
* @brief Material isotropic elastic
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material_thermal.hh"
#include "plane_stress_toolbox.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ELASTIC_HH__
#define __AKANTU_MATERIAL_ELASTIC_HH__
namespace akantu {
/**
* Material elastic isotropic
*
* parameters in the material files :
* - E : Young's modulus (default: 0)
* - nu : Poisson's ratio (default: 1/2)
* - Plane_Stress : if 0: plane strain, else: plane stress (default: 0)
*/
template <UInt spatial_dimension>
class MaterialElastic
: public PlaneStressToolbox<spatial_dimension,
MaterialThermal<spatial_dimension>> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
private:
using Parent =
PlaneStressToolbox<spatial_dimension, MaterialThermal<spatial_dimension>>;
public:
MaterialElastic(SolidMechanicsModel & model, const ID & id = "");
MaterialElastic(SolidMechanicsModel & model, UInt dim, const Mesh & mesh,
FEEngine & fe_engine, const ID & id = "");
~MaterialElastic() override = default;
protected:
void initialize();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initMaterial() override;
/// constitutive law for all element of a type
void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute the tangent stiffness matrix for an element type
void computeTangentModuli(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost) override;
/// compute the elastic potential energy
void computePotentialEnergy(ElementType el_type) override;
void
computePotentialEnergyByElement(ElementType type, UInt index,
Vector<Real> & epot_on_quad_points) override;
/// compute the p-wave speed in the material
Real getPushWaveSpeed(const Element & element) const override;
/// compute the s-wave speed in the material
Real getShearWaveSpeed(const Element & element) const override;
protected:
/// constitutive law for a given quadrature point
inline void computeStressOnQuad(const Matrix<Real> & grad_u,
Matrix<Real> & sigma,
const Real sigma_th = 0) const;
/// compute the tangent stiffness matrix for an element
inline void computeTangentModuliOnQuad(Matrix<Real> & tangent) const;
/// recompute the lame coefficient if E or nu changes
void updateInternalParameters() override;
static inline void computePotentialEnergyOnQuad(const Matrix<Real> & grad_u,
const Matrix<Real> & sigma,
Real & epot);
bool hasStiffnessMatrixChanged() override {
return (!was_stiffness_assembled);
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get first Lame constant
AKANTU_GET_MACRO(Lambda, lambda, Real);
/// get second Lame constant
AKANTU_GET_MACRO(Mu, mu, Real);
/// get bulk modulus
AKANTU_GET_MACRO(Kappa, kpa, Real);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// First Lamé coefficient
Real lambda;
/// Second Lamé coefficient (shear modulus)
Real mu;
/// Bulk modulus
Real kpa;
/// defines if the stiffness was computed
bool was_stiffness_assembled;
};
-} // akantu
+} // namespace akantu
#include "material_elastic_inline_impl.cc"
#endif /* __AKANTU_MATERIAL_ELASTIC_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_elastic_inline_impl.cc b/src/model/solid_mechanics/materials/material_elastic_inline_impl.cc
index 606e7bb73..f9e233c98 100644
--- a/src/model/solid_mechanics/materials/material_elastic_inline_impl.cc
+++ b/src/model/solid_mechanics/materials/material_elastic_inline_impl.cc
@@ -1,120 +1,120 @@
/**
* @file material_elastic_inline_impl.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Fri Dec 16 2016
*
* @brief Implementation of the inline functions of the material elastic
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_elastic.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ELASTIC_INLINE_IMPL_CC__
#define __AKANTU_MATERIAL_ELASTIC_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialElastic<spatial_dimension>::computeStressOnQuad(
const Matrix<Real> & grad_u, Matrix<Real> & sigma,
const Real sigma_th) const {
Real trace = grad_u.trace(); // trace = (\nabla u)_{kk}
// \sigma_{ij} = \lambda * (\nabla u)_{kk} * \delta_{ij} + \mu * (\nabla
// u_{ij} + \nabla u_{ji})
for (UInt i = 0; i < spatial_dimension; ++i) {
for (UInt j = 0; j < spatial_dimension; ++j) {
sigma(i, j) = (i == j) * lambda * trace +
mu * (grad_u(i, j) + grad_u(j, i)) + (i == j) * sigma_th;
}
}
}
/* -------------------------------------------------------------------------- */
template <>
inline void MaterialElastic<1>::computeStressOnQuad(const Matrix<Real> & grad_u,
Matrix<Real> & sigma,
Real sigma_th) const {
sigma(0, 0) = this->E * grad_u(0, 0) + sigma_th;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
inline void MaterialElastic<spatial_dimension>::computeTangentModuliOnQuad(
Matrix<Real> & tangent) const {
UInt n = tangent.cols();
// Real Ep = E/((1+nu)*(1-2*nu));
Real Miiii = lambda + 2 * mu;
Real Miijj = lambda;
Real Mijij = mu;
if (spatial_dimension == 1)
tangent(0, 0) = this->E;
else
tangent(0, 0) = Miiii;
// test of dimension should by optimized out by the compiler due to the
// template
if (spatial_dimension >= 2) {
tangent(1, 1) = Miiii;
tangent(0, 1) = Miijj;
tangent(1, 0) = Miijj;
tangent(n - 1, n - 1) = Mijij;
}
if (spatial_dimension == 3) {
tangent(2, 2) = Miiii;
tangent(0, 2) = Miijj;
tangent(1, 2) = Miijj;
tangent(2, 0) = Miijj;
tangent(2, 1) = Miijj;
tangent(3, 3) = Mijij;
tangent(4, 4) = Mijij;
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialElastic<dim>::computePotentialEnergyOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & sigma, Real & epot) {
epot = .5 * sigma.doubleDot(grad_u);
}
/* -------------------------------------------------------------------------- */
template <>
inline void
MaterialElastic<1>::computeTangentModuliOnQuad(Matrix<Real> & tangent) const {
tangent(0, 0) = E;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_ELASTIC_INLINE_IMPL_CC__ */
diff --git a/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.cc b/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.cc
index f2663ace8..9da7a22e8 100644
--- a/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.cc
+++ b/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.cc
@@ -1,262 +1,262 @@
/**
* @file material_elastic_linear_anisotropic.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
* @author Enrico Milanese <enrico.milanese@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 25 2013
* @date last modification: Tue Feb 20 2018
*
* @brief Anisotropic elastic material
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "material_elastic_linear_anisotropic.hh"
#include "solid_mechanics_model.hh"
#include <algorithm>
#include <sstream>
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim>
MaterialElasticLinearAnisotropic<dim>::MaterialElasticLinearAnisotropic(
SolidMechanicsModel & model, const ID & id, bool symmetric)
: Material(model, id), rot_mat(dim, dim), Cprime(dim * dim, dim * dim),
C(voigt_h::size, voigt_h::size), eigC(voigt_h::size),
symmetric(symmetric), alpha(0), was_stiffness_assembled(false) {
AKANTU_DEBUG_IN();
this->dir_vecs.push_back(std::make_unique<Vector<Real>>(dim));
(*this->dir_vecs.back())[0] = 1.;
this->registerParam("n1", *(this->dir_vecs.back()), _pat_parsmod,
"Direction of main material axis");
if (dim > 1) {
this->dir_vecs.push_back(std::make_unique<Vector<Real>>(dim));
(*this->dir_vecs.back())[1] = 1.;
this->registerParam("n2", *(this->dir_vecs.back()), _pat_parsmod,
"Direction of secondary material axis");
}
if (dim > 2) {
this->dir_vecs.push_back(std::make_unique<Vector<Real>>(dim));
(*this->dir_vecs.back())[2] = 1.;
this->registerParam("n3", *(this->dir_vecs.back()), _pat_parsmod,
"Direction of tertiary material axis");
}
for (UInt i = 0; i < voigt_h::size; ++i) {
UInt start = 0;
if (this->symmetric) {
start = i;
}
for (UInt j = start; j < voigt_h::size; ++j) {
std::stringstream param("C");
param << "C" << i + 1 << j + 1;
this->registerParam(param.str(), this->Cprime(i, j), Real(0.),
_pat_parsmod, "Coefficient " + param.str());
}
}
this->registerParam("alpha", this->alpha, _pat_parsmod,
"Proportion of viscous stress");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim> void MaterialElasticLinearAnisotropic<dim>::initMaterial() {
AKANTU_DEBUG_IN();
Material::initMaterial();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialElasticLinearAnisotropic<dim>::updateInternalParameters() {
Material::updateInternalParameters();
if (this->symmetric) {
for (UInt i = 0; i < voigt_h::size; ++i) {
for (UInt j = i + 1; j < voigt_h::size; ++j) {
this->Cprime(j, i) = this->Cprime(i, j);
}
}
}
this->rotateCprime();
this->C.eig(this->eigC);
this->was_stiffness_assembled = false;
}
/* -------------------------------------------------------------------------- */
template <UInt Dim> void MaterialElasticLinearAnisotropic<Dim>::rotateCprime() {
// start by filling the empty parts fo Cprime
UInt diff = Dim * Dim - voigt_h::size;
for (UInt i = voigt_h::size; i < Dim * Dim; ++i) {
for (UInt j = 0; j < Dim * Dim; ++j) {
this->Cprime(i, j) = this->Cprime(i - diff, j);
}
}
for (UInt i = 0; i < Dim * Dim; ++i) {
for (UInt j = voigt_h::size; j < Dim * Dim; ++j) {
this->Cprime(i, j) = this->Cprime(i, j - diff);
}
}
// construction of rotator tensor
// normalise rotation matrix
for (UInt j = 0; j < Dim; ++j) {
Vector<Real> rot_vec = this->rot_mat(j);
rot_vec = *this->dir_vecs[j];
rot_vec.normalize();
}
// make sure the vectors form a right-handed base
Vector<Real> test_axis(3);
Vector<Real> v1(3), v2(3), v3(3, 0.);
if (Dim == 2) {
for (UInt i = 0; i < Dim; ++i) {
v1[i] = this->rot_mat(0, i);
v2[i] = this->rot_mat(1, i);
}
-
+
v3.crossProduct(v1, v2);
if (v3.norm() < 8 * std::numeric_limits<Real>::epsilon()) {
- AKANTU_ERROR("The axis vectors parallel.");
+ AKANTU_ERROR("The axis vectors parallel.");
}
-
+
v3.normalize();
} else if (Dim == 3) {
v1 = this->rot_mat(0);
v2 = this->rot_mat(1);
v3 = this->rot_mat(2);
}
test_axis.crossProduct(v1, v2);
test_axis -= v3;
if (test_axis.norm() > 8 * std::numeric_limits<Real>::epsilon()) {
AKANTU_ERROR("The axis vectors do not form a right-handed coordinate "
<< "system. I. e., ||n1 x n2 - n3|| should be zero, but "
<< "it is " << test_axis.norm() << ".");
}
// create the rotator and the reverse rotator
Matrix<Real> rotator(Dim * Dim, Dim * Dim);
Matrix<Real> revrotor(Dim * Dim, Dim * Dim);
for (UInt i = 0; i < Dim; ++i) {
for (UInt j = 0; j < Dim; ++j) {
for (UInt k = 0; k < Dim; ++k) {
for (UInt l = 0; l < Dim; ++l) {
UInt I = voigt_h::mat[i][j];
UInt J = voigt_h::mat[k][l];
rotator(I, J) = this->rot_mat(k, i) * this->rot_mat(l, j);
revrotor(I, J) = this->rot_mat(i, k) * this->rot_mat(j, l);
}
}
}
}
// create the full rotated matrix
Matrix<Real> Cfull(Dim * Dim, Dim * Dim);
Cfull = rotator * Cprime * revrotor;
for (UInt i = 0; i < voigt_h::size; ++i) {
for (UInt j = 0; j < voigt_h::size; ++j) {
this->C(i, j) = Cfull(i, j);
}
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialElasticLinearAnisotropic<dim>::computeStress(
ElementType el_type, GhostType ghost_type) {
// Wikipedia convention:
// 2*eps_ij (i!=j) = voigt_eps_I
// http://en.wikipedia.org/wiki/Voigt_notation
AKANTU_DEBUG_IN();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
this->computeStressOnQuad(grad_u, sigma);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialElasticLinearAnisotropic<dim>::computeTangentModuli(
const ElementType & el_type, Array<Real> & tangent_matrix,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
this->computeTangentModuliOnQuad(tangent);
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
this->was_stiffness_assembled = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialElasticLinearAnisotropic<dim>::computePotentialEnergy(
ElementType el_type) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(!this->finite_deformation,
"finite deformation not possible in material anisotropic "
"(TO BE IMPLEMENTED)");
Array<Real>::scalar_iterator epot =
this->potential_energy(el_type, _not_ghost).begin();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
computePotentialEnergyOnQuad(grad_u, sigma, *epot);
++epot;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
Real MaterialElasticLinearAnisotropic<dim>::getCelerity(
__attribute__((unused)) const Element & element) const {
return std::sqrt(this->eigC(0) / rho);
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(elastic_anisotropic, MaterialElasticLinearAnisotropic);
} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.hh b/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.hh
index 18d76e1bf..4399cad93 100644
--- a/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.hh
+++ b/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic.hh
@@ -1,139 +1,139 @@
/**
* @file material_elastic_linear_anisotropic.hh
*
* @author Till Junge <till.junge@epfl.ch>
* @author Enrico Milanese <enrico.milanese@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Fri Feb 16 2018
*
* @brief Orthotropic elastic material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material.hh"
#include "material_elastic.hh"
/* -------------------------------------------------------------------------- */
#include <vector>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ELASTIC_LINEAR_ANISOTROPIC_HH__
#define __AKANTU_MATERIAL_ELASTIC_LINEAR_ANISOTROPIC_HH__
namespace akantu {
/**
* General linear anisotropic elastic material
* The only constraint on the elastic tensor is that it can be represented
* as a symmetric 6x6 matrix (3D) or 3x3 (2D).
*
* parameters in the material files :
* - rho : density (default: 0)
* - C_ij : entry on the stiffness
*/
template <UInt Dim> class MaterialElasticLinearAnisotropic : public Material {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialElasticLinearAnisotropic(SolidMechanicsModel & model,
const ID & id = "", bool symmetric = true);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initMaterial() override;
/// constitutive law for all element of a type
void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute the tangent stiffness matrix for an element type
void computeTangentModuli(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost) override;
/// compute the elastic potential energy
void computePotentialEnergy(ElementType el_type) override;
void updateInternalParameters() override;
bool hasStiffnessMatrixChanged() override {
return (!was_stiffness_assembled);
}
protected:
// compute C from Cprime
void rotateCprime();
/// constitutive law for a given quadrature point
inline void computeStressOnQuad(const Matrix<Real> & grad_u,
Matrix<Real> & sigma) const;
/// tangent matrix for a given quadrature point
inline void computeTangentModuliOnQuad(Matrix<Real> & tangent) const;
inline void computePotentialEnergyOnQuad(const Matrix<Real> & grad_u,
const Matrix<Real> & sigma,
Real & epot);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// compute max wave celerity
Real getCelerity(const Element & element) const override;
AKANTU_GET_MACRO(VoigtStiffness, C, Matrix<Real>);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
using voigt_h = VoigtHelper<Dim>;
/// direction matrix and vectors
std::vector<std::unique_ptr<Vector<Real>>> dir_vecs;
Matrix<Real> rot_mat;
/// Elastic stiffness tensor in material frame and full vectorised notation
Matrix<Real> Cprime;
/// Elastic stiffness tensor in voigt notation
Matrix<Real> C;
/// eigenvalues of stiffness tensor
Vector<Real> eigC;
bool symmetric;
/// viscous proportion
Real alpha;
/// defines if the stiffness was computed
bool was_stiffness_assembled;
};
-} // akantu
+} // namespace akantu
#include "material_elastic_linear_anisotropic_inline_impl.cc"
#endif /* __AKANTU_MATERIAL_ELASTIC_LINEAR_ANISOTROPIC_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic_inline_impl.cc b/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic_inline_impl.cc
index 716978f67..ebf250f6e 100644
--- a/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic_inline_impl.cc
+++ b/src/model/solid_mechanics/materials/material_elastic_linear_anisotropic_inline_impl.cc
@@ -1,92 +1,92 @@
/**
* @file material_elastic_linear_anisotropic_inline_impl.cc
*
* @author Enrico Milanese <enrico.milanese@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Feb 16 2018
* @date last modification: Fri Feb 16 2018
*
* @brief Implementation of the inline functions of the material elastic linear
* anisotropic
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_elastic_linear_anisotropic.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ELASTIC_LINEAR_ANISOTROPIC_INLINE_IMPL_CC__
#define __AKANTU_MATERIAL_ELASTIC_LINEAR_ANISOTROPIC_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialElasticLinearAnisotropic<dim>::computeStressOnQuad(
const Matrix<Real> & grad_u, Matrix<Real> & sigma) const {
// Wikipedia convention:
// 2*eps_ij (i!=j) = voigt_eps_I
// http://en.wikipedia.org/wiki/Voigt_notation
Vector<Real> voigt_strain(voigt_h::size);
Vector<Real> voigt_stress(voigt_h::size);
for (UInt I = 0; I < voigt_h::size; ++I) {
Real voigt_factor = voigt_h::factors[I];
UInt i = voigt_h::vec[I][0];
UInt j = voigt_h::vec[I][1];
voigt_strain(I) = voigt_factor * (grad_u(i, j) + grad_u(j, i)) / 2.;
}
voigt_stress = this->C * voigt_strain;
for (UInt I = 0; I < voigt_h::size; ++I) {
UInt i = voigt_h::vec[I][0];
UInt j = voigt_h::vec[I][1];
sigma(i, j) = sigma(j, i) = voigt_stress(I);
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialElasticLinearAnisotropic<dim>::computeTangentModuliOnQuad(
Matrix<Real> & tangent) const {
tangent.copy(this->C);
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialElasticLinearAnisotropic<dim>::computePotentialEnergyOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & sigma, Real & epot) {
AKANTU_DEBUG_ASSERT(this->symmetric,
"The elastic constants matrix is not symmetric,"
"energy is not path independent.");
epot = .5 * sigma.doubleDot(grad_u);
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_ELASTIC_LINEAR_ANISOTROPIC_INLINE_IMPL_CC__ */
diff --git a/src/model/solid_mechanics/materials/material_elastic_orthotropic.hh b/src/model/solid_mechanics/materials/material_elastic_orthotropic.hh
index 0cea87042..299601f7f 100644
--- a/src/model/solid_mechanics/materials/material_elastic_orthotropic.hh
+++ b/src/model/solid_mechanics/materials/material_elastic_orthotropic.hh
@@ -1,136 +1,136 @@
/**
* @file material_elastic_orthotropic.hh
*
* @author Till Junge <till.junge@epfl.ch>
* @author Enrico Milanese <enrico.milanese@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Fri Feb 16 2018
*
* @brief Orthotropic elastic material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material_elastic_linear_anisotropic.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_ELASTIC_ORTHOTROPIC_HH__
#define __AKANTU_MATERIAL_ELASTIC_ORTHOTROPIC_HH__
namespace akantu {
/**
* Orthotropic elastic material
*
* parameters in the material files :
* - n1 : direction of x-axis in material base, normalisation not necessary
* (default: {1, 0, 0})
* - n2 : direction of y-axis in material base, normalisation not necessary
* (default: {0, 1, 0})
* - n3 : direction of z-axis in material base, normalisation not necessary
* (default: {0, 0, 1})
* - rho : density (default: 0)
* - E1 : Young's modulus along n1 (default: 0)
* - E2 : Young's modulus along n2 (default: 0)
* - E3 : Young's modulus along n3 (default: 0)
* - nu12 : Poisson's ratio along 12 (default: 0)
* - nu13 : Poisson's ratio along 13 (default: 0)
* - nu23 : Poisson's ratio along 23 (default: 0)
* - G12 : Shear modulus along 12 (default: 0)
* - G13 : Shear modulus along 13 (default: 0)
* - G23 : Shear modulus along 23 (default: 0)
*/
template <UInt Dim>
class MaterialElasticOrthotropic
: public MaterialElasticLinearAnisotropic<Dim> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialElasticOrthotropic(SolidMechanicsModel & model, const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initMaterial() override;
void updateInternalParameters() override;
void
computePotentialEnergyByElement(ElementType type, UInt index,
Vector<Real> & epot_on_quad_points) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
AKANTU_GET_MACRO(E1, E1, Real);
AKANTU_GET_MACRO(E2, E2, Real);
AKANTU_GET_MACRO(E3, E3, Real);
AKANTU_GET_MACRO(Nu12, nu12, Real);
AKANTU_GET_MACRO(Nu13, nu13, Real);
AKANTU_GET_MACRO(Nu23, nu23, Real);
AKANTU_GET_MACRO(G12, G12, Real);
AKANTU_GET_MACRO(G13, G13, Real);
AKANTU_GET_MACRO(G23, G23, Real);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// the n1 young modulus
Real E1;
/// the n2 young modulus
Real E2;
/// the n3 young modulus
Real E3;
/// 12 Poisson coefficient
Real nu12;
/// 13 Poisson coefficient
Real nu13;
/// 23 Poisson coefficient
Real nu23;
/// 12 shear modulus
Real G12;
/// 13 shear modulus
Real G13;
/// 23 shear modulus
Real G23;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_ELASTIC_ORTHOTROPIC_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_embedded/material_reinforcement.hh b/src/model/solid_mechanics/materials/material_embedded/material_reinforcement.hh
index 36a04ab7f..73473dbab 100644
--- a/src/model/solid_mechanics/materials/material_embedded/material_reinforcement.hh
+++ b/src/model/solid_mechanics/materials/material_embedded/material_reinforcement.hh
@@ -1,209 +1,209 @@
/**
* @file material_reinforcement.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Mar 13 2015
* @date last modification: Fri Feb 09 2018
*
* @brief Reinforcement material
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_REINFORCEMENT_HH__
#define __AKANTU_MATERIAL_REINFORCEMENT_HH__
#include "aka_common.hh"
#include "embedded_interface_model.hh"
#include "material.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* @brief Material used to represent embedded reinforcements
*
* This class is used for computing the reinforcement stiffness matrix
* along with the reinforcement residual. Room is made for constitutive law,
* but actual use of contitutive laws is made in MaterialReinforcementTemplate.
*
* Be careful with the dimensions in this class :
* - this->spatial_dimension is always 1
* - the template parameter dim is the dimension of the problem
*/
template <class Mat, UInt dim> class MaterialReinforcement : public Mat {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
/// Constructor
MaterialReinforcement(EmbeddedInterfaceModel & model, const ID & id = "");
/// Destructor
~MaterialReinforcement() override;
protected:
void initialize();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// Init the material
void initMaterial() override;
/// Init the filters for background elements
void initFilters();
/// Init the background shape derivatives
void initBackgroundShapeDerivatives();
/// Init the cosine matrices
void initDirectingCosines();
/// Assemble stiffness matrix
void assembleStiffnessMatrix(GhostType ghost_type) override;
/// Compute all the stresses !
void computeAllStresses(GhostType ghost_type) override;
/// Compute energy
Real getEnergy(const std::string & id) override;
/// Assemble the residual of one type of element (typically _segment_2)
void assembleInternalForces(GhostType ghost_type) override;
/* ------------------------------------------------------------------------ */
/* Protected methods */
/* ------------------------------------------------------------------------ */
protected:
/// Allocate the background shape derivatives
void allocBackgroundShapeDerivatives();
/// Compute the directing cosines matrix for one element type
void computeDirectingCosines(const ElementType & type, GhostType ghost_type);
/// Compute the directing cosines matrix on quadrature points.
inline void computeDirectingCosinesOnQuad(const Matrix<Real> & nodes,
Matrix<Real> & cosines);
/// Add the prestress to the computed stress
void addPrestress(const ElementType & type, GhostType ghost_type);
/// Compute displacement gradient in reinforcement
void computeGradU(const ElementType & interface_type, GhostType ghost_type);
/// Assemble the stiffness matrix for an element type (typically _segment_2)
void assembleStiffnessMatrix(const ElementType & type, GhostType ghost_type);
/// Assemble the stiffness matrix for background & interface types
void assembleStiffnessMatrixInterface(const ElementType & interface_type,
const ElementType & background_type,
GhostType ghost_type);
/// Compute the background shape derivatives for a type
void computeBackgroundShapeDerivatives(const ElementType & type,
GhostType ghost_type);
/// Compute the background shape derivatives for a type pair
void computeBackgroundShapeDerivatives(const ElementType & interface_type,
const ElementType & bg_type,
GhostType ghost_type,
const Array<UInt> & filter);
/// Filter elements crossed by interface of a type
void filterInterfaceBackgroundElements(Array<UInt> & foreground,
Array<UInt> & background,
const ElementType & type,
const ElementType & interface_type,
GhostType ghost_type);
/// Assemble the residual of one type of element (typically _segment_2)
void assembleInternalForces(const ElementType & type, GhostType ghost_type);
/// Assemble the residual for a pair of elements
void assembleInternalForcesInterface(const ElementType & interface_type,
const ElementType & background_type,
GhostType ghost_type);
// TODO figure out why voigt size is 4 in 2D
inline void stressTensorToVoigtVector(const Matrix<Real> & tensor,
Vector<Real> & vector);
inline void strainTensorToVoigtVector(const Matrix<Real> & tensor,
Vector<Real> & vector);
/// Get background filter
Array<UInt> & getBackgroundFilter(const ElementType & fg_type,
const ElementType & bg_type,
GhostType ghost_type) {
return (*background_filter(fg_type, ghost_type))(bg_type, ghost_type);
}
/// Get foreground filter
Array<UInt> & getForegroundFilter(const ElementType & fg_type,
const ElementType & bg_type,
GhostType ghost_type) {
return (*foreground_filter(fg_type, ghost_type))(bg_type, ghost_type);
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// Embedded model
EmbeddedInterfaceModel & emodel;
/// Gradu of concrete on reinforcement
InternalField<Real> gradu_embedded;
/// C matrix on quad
InternalField<Real> directing_cosines;
/// Prestress on quad
InternalField<Real> pre_stress;
/// Cross-sectional area
Real area;
template <typename T>
using CrossMap = ElementTypeMap<std::unique_ptr<ElementTypeMapArray<T>>>;
/// Background mesh shape derivatives
CrossMap<Real> shape_derivatives;
/// Foreground mesh filter (contains segment ids)
CrossMap<UInt> foreground_filter;
/// Background element filter (contains bg ids)
CrossMap<UInt> background_filter;
};
-} // akantu
+} // namespace akantu
#include "material_reinforcement_tmpl.hh"
#endif // __AKANTU_MATERIAL_REINFORCEMENT_HH__
diff --git a/src/model/solid_mechanics/materials/material_embedded/material_reinforcement_tmpl.hh b/src/model/solid_mechanics/materials/material_embedded/material_reinforcement_tmpl.hh
index 2016ac6b0..addab0d0f 100644
--- a/src/model/solid_mechanics/materials/material_embedded/material_reinforcement_tmpl.hh
+++ b/src/model/solid_mechanics/materials/material_embedded/material_reinforcement_tmpl.hh
@@ -1,779 +1,780 @@
/**
* @file material_reinforcement_tmpl.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Wed Mar 25 2015
* @date last modification: Tue Feb 20 2018
*
* @brief Reinforcement material
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_voigthelper.hh"
#include "material_reinforcement.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
MaterialReinforcement<Mat, dim>::MaterialReinforcement(
EmbeddedInterfaceModel & model, const ID & id)
: Mat(model, 1, model.getInterfaceMesh(),
model.getFEEngine("EmbeddedInterfaceFEEngine"), id),
emodel(model),
gradu_embedded("gradu_embedded", *this, 1,
model.getFEEngine("EmbeddedInterfaceFEEngine"),
this->element_filter),
directing_cosines("directing_cosines", *this, 1,
model.getFEEngine("EmbeddedInterfaceFEEngine"),
this->element_filter),
pre_stress("pre_stress", *this, 1,
model.getFEEngine("EmbeddedInterfaceFEEngine"),
this->element_filter),
area(1.0), shape_derivatives() {
AKANTU_DEBUG_IN();
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::initialize() {
AKANTU_DEBUG_IN();
this->registerParam("area", area, _pat_parsable | _pat_modifiable,
"Reinforcement cross-sectional area");
this->registerParam("pre_stress", pre_stress, _pat_parsable | _pat_modifiable,
"Uniform pre-stress");
// this->unregisterInternal(this->stress);
// Fool the AvgHomogenizingFunctor
// stress.initialize(dim * dim);
// Reallocate the element filter
this->element_filter.initialize(this->emodel.getInterfaceMesh(),
_spatial_dimension = 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
MaterialReinforcement<Mat, dim>::~MaterialReinforcement() {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::initMaterial() {
Mat::initMaterial();
gradu_embedded.initialize(dim * dim);
pre_stress.initialize(1);
/// We initialise the stuff that is not going to change during the simulation
this->initFilters();
this->allocBackgroundShapeDerivatives();
this->initBackgroundShapeDerivatives();
this->initDirectingCosines();
}
/* -------------------------------------------------------------------------- */
/// Initialize the filter for background elements
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::initFilters() {
for (auto gt : ghost_types) {
for (auto && type : emodel.getInterfaceMesh().elementTypes(1, gt)) {
std::string shaped_id = "filter";
if (gt == _ghost)
shaped_id += ":ghost";
auto & background =
background_filter(std::make_unique<ElementTypeMapArray<UInt>>(
"bg_" + shaped_id, this->name),
type, gt);
auto & foreground = foreground_filter(
std::make_unique<ElementTypeMapArray<UInt>>(shaped_id, this->name),
type, gt);
foreground->initialize(emodel.getMesh(), _nb_component = 1,
_ghost_type = gt);
background->initialize(emodel.getMesh(), _nb_component = 1,
_ghost_type = gt);
// Computing filters
for (auto && bg_type : background->elementTypes(dim, gt)) {
filterInterfaceBackgroundElements(
(*foreground)(bg_type), (*background)(bg_type), bg_type, type, gt);
}
}
}
}
/* -------------------------------------------------------------------------- */
/// Construct a filter for a (interface_type, background_type) pair
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::filterInterfaceBackgroundElements(
Array<UInt> & foreground, Array<UInt> & background,
const ElementType & type, const ElementType & interface_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
foreground.resize(0);
background.resize(0);
Array<Element> & elements =
emodel.getInterfaceAssociatedElements(interface_type, ghost_type);
Array<UInt> & elem_filter = this->element_filter(interface_type, ghost_type);
for (auto & elem_id : elem_filter) {
Element & elem = elements(elem_id);
if (elem.type == type) {
background.push_back(elem.element);
foreground.push_back(elem_id);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
namespace detail {
class BackgroundShapeDInitializer : public ElementTypeMapArrayInitializer {
public:
BackgroundShapeDInitializer(UInt spatial_dimension, FEEngine & engine,
const ElementType & foreground_type,
const ElementTypeMapArray<UInt> & filter,
const GhostType & ghost_type)
: ElementTypeMapArrayInitializer(
[](const ElementType & bgtype, const GhostType &) {
return ShapeFunctions::getShapeDerivativesSize(bgtype);
},
spatial_dimension, ghost_type, _ek_regular) {
auto nb_quad = engine.getNbIntegrationPoints(foreground_type);
// Counting how many background elements are affected by elements of
// interface_type
for (auto type : filter.elementTypes(this->spatial_dimension)) {
// Inserting size
array_size_per_bg_type(filter(type).size() * nb_quad, type,
this->ghost_type);
}
}
auto elementTypes() const -> decltype(auto) {
return array_size_per_bg_type.elementTypes();
}
UInt size(const ElementType & bgtype) const {
return array_size_per_bg_type(bgtype, this->ghost_type);
}
protected:
ElementTypeMap<UInt> array_size_per_bg_type;
};
} // namespace detail
/**
* Background shape derivatives need to be stored per background element
* types but also per embedded element type, which is why they are stored
* in an ElementTypeMap<ElementTypeMapArray<Real> *>. The outer ElementTypeMap
* refers to the embedded types, and the inner refers to the background types.
*/
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::allocBackgroundShapeDerivatives() {
AKANTU_DEBUG_IN();
for (auto gt : ghost_types) {
for (auto && type : emodel.getInterfaceMesh().elementTypes(1, gt)) {
std::string shaped_id = "embedded_shape_derivatives";
if (gt == _ghost)
shaped_id += ":ghost";
auto & shaped_etma = shape_derivatives(
std::make_unique<ElementTypeMapArray<Real>>(shaped_id, this->name),
type, gt);
shaped_etma->initialize(
detail::BackgroundShapeDInitializer(
emodel.getSpatialDimension(),
emodel.getFEEngine("EmbeddedInterfaceFEEngine"), type,
*background_filter(type, gt), gt),
0, true);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::initBackgroundShapeDerivatives() {
AKANTU_DEBUG_IN();
for (auto interface_type :
this->element_filter.elementTypes(this->spatial_dimension)) {
for (auto type : background_filter(interface_type)->elementTypes(dim)) {
computeBackgroundShapeDerivatives(interface_type, type, _not_ghost,
this->element_filter(interface_type));
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::computeBackgroundShapeDerivatives(
const ElementType & interface_type, const ElementType & bg_type,
GhostType ghost_type, const Array<UInt> & filter) {
auto & interface_engine = emodel.getFEEngine("EmbeddedInterfaceFEEngine");
auto & engine = emodel.getFEEngine();
auto & interface_mesh = emodel.getInterfaceMesh();
const auto nb_nodes_elem_bg = Mesh::getNbNodesPerElement(bg_type);
// const auto nb_strss = VoigtHelper<dim>::size;
const auto nb_quads_per_elem =
interface_engine.getNbIntegrationPoints(interface_type);
Array<Real> quad_pos(0, dim, "interface_quad_pos");
interface_engine.interpolateOnIntegrationPoints(interface_mesh.getNodes(),
quad_pos, dim, interface_type,
ghost_type, filter);
auto & background_shapesd =
(*shape_derivatives(interface_type, ghost_type))(bg_type, ghost_type);
auto & background_elements =
(*background_filter(interface_type, ghost_type))(bg_type, ghost_type);
auto & foreground_elements =
(*foreground_filter(interface_type, ghost_type))(bg_type, ghost_type);
auto shapesd_begin =
background_shapesd.begin(dim, nb_nodes_elem_bg, nb_quads_per_elem);
auto quad_begin = quad_pos.begin(dim, nb_quads_per_elem);
for (auto && tuple : zip(background_elements, foreground_elements)) {
UInt bg = std::get<0>(tuple), fg = std::get<1>(tuple);
for (UInt i = 0; i < nb_quads_per_elem; ++i) {
Matrix<Real> shapesd = Tensor3<Real>(shapesd_begin[fg])(i);
Vector<Real> quads = Matrix<Real>(quad_begin[fg])(i);
engine.computeShapeDerivatives(quads, bg, bg_type, shapesd, ghost_type);
}
}
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::initDirectingCosines() {
AKANTU_DEBUG_IN();
Mesh & mesh = emodel.getInterfaceMesh();
const UInt voigt_size = VoigtHelper<dim>::size;
directing_cosines.initialize(voigt_size);
for (auto && type : mesh.elementTypes(1, _not_ghost)) {
computeDirectingCosines(type, _not_ghost);
// computeDirectingCosines(*type_it, _ghost);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::assembleStiffnessMatrix(
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Mesh & interface_mesh = emodel.getInterfaceMesh();
for (auto && type : interface_mesh.elementTypes(1, _not_ghost)) {
assembleStiffnessMatrix(type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::assembleInternalForces(
GhostType ghost_type) {
AKANTU_DEBUG_IN();
Mesh & interface_mesh = emodel.getInterfaceMesh();
for (auto && type : interface_mesh.elementTypes(1, _not_ghost)) {
this->assembleInternalForces(type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::computeAllStresses(GhostType ghost_type) {
AKANTU_DEBUG_IN();
Mesh & interface_mesh = emodel.getInterfaceMesh();
for (auto && type : interface_mesh.elementTypes(_ghost_type = ghost_type)) {
computeGradU(type, ghost_type);
this->computeStress(type, ghost_type);
addPrestress(type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::addPrestress(const ElementType & type,
GhostType ghost_type) {
auto & stress = this->stress(type, ghost_type);
auto & sigma_p = this->pre_stress(type, ghost_type);
for (auto && tuple : zip(stress, sigma_p)) {
std::get<0>(tuple) += std::get<1>(tuple);
}
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::assembleInternalForces(
const ElementType & type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Mesh & mesh = emodel.getMesh();
for (auto && mesh_type : mesh.elementTypes(dim, ghost_type)) {
assembleInternalForcesInterface(type, mesh_type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Computes and assemble the residual. Residual in reinforcement is computed as:
*
* \f[
* \vec{r} = A_s \int_S{\mathbf{B}^T\mathbf{C}^T \vec{\sigma_s}\,\mathrm{d}s}
* \f]
*/
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::assembleInternalForcesInterface(
const ElementType & interface_type, const ElementType & background_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
UInt voigt_size = VoigtHelper<dim>::size;
FEEngine & interface_engine = emodel.getFEEngine("EmbeddedInterfaceFEEngine");
Array<UInt> & elem_filter = this->element_filter(interface_type, ghost_type);
UInt nodes_per_background_e = Mesh::getNbNodesPerElement(background_type);
UInt nb_quadrature_points =
interface_engine.getNbIntegrationPoints(interface_type, ghost_type);
UInt nb_element = elem_filter.size();
UInt back_dof = dim * nodes_per_background_e;
Array<Real> & shapesd = (*shape_derivatives(interface_type, ghost_type))(
background_type, ghost_type);
Array<Real> integrant(nb_quadrature_points * nb_element, back_dof,
"integrant");
auto integrant_it = integrant.begin(back_dof);
auto integrant_end = integrant.end(back_dof);
Array<Real>::matrix_iterator B_it =
shapesd.begin(dim, nodes_per_background_e);
auto C_it = directing_cosines(interface_type, ghost_type).begin(voigt_size);
auto sigma_it = this->stress(interface_type, ghost_type).begin();
Matrix<Real> Bvoigt(voigt_size, back_dof);
for (; integrant_it != integrant_end;
++integrant_it, ++B_it, ++C_it, ++sigma_it) {
VoigtHelper<dim>::transferBMatrixToSymVoigtBMatrix(*B_it, Bvoigt,
nodes_per_background_e);
Vector<Real> & C = *C_it;
Vector<Real> & BtCt_sigma = *integrant_it;
BtCt_sigma.mul<true>(Bvoigt, C);
BtCt_sigma *= *sigma_it * area;
}
Array<Real> residual_interface(nb_element, back_dof, "residual_interface");
interface_engine.integrate(integrant, residual_interface, back_dof,
interface_type, ghost_type, elem_filter);
integrant.resize(0);
Array<UInt> background_filter(nb_element, 1, "background_filter");
auto & filter =
getBackgroundFilter(interface_type, background_type, ghost_type);
emodel.getDOFManager().assembleElementalArrayLocalArray(
residual_interface, emodel.getInternalForce(), background_type,
ghost_type, -1., filter);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::computeDirectingCosines(
const ElementType & type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Mesh & interface_mesh = emodel.getInterfaceMesh();
const UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
const UInt steel_dof = dim * nb_nodes_per_element;
const UInt voigt_size = VoigtHelper<dim>::size;
const UInt nb_quad_points = emodel.getFEEngine("EmbeddedInterfaceFEEngine")
.getNbIntegrationPoints(type, ghost_type);
Array<Real> node_coordinates(this->element_filter(type, ghost_type).size(),
steel_dof);
this->emodel.getFEEngine().template extractNodalToElementField<Real>(
interface_mesh, interface_mesh.getNodes(), node_coordinates, type,
ghost_type, this->element_filter(type, ghost_type));
Array<Real>::matrix_iterator directing_cosines_it =
directing_cosines(type, ghost_type).begin(1, voigt_size);
Array<Real>::matrix_iterator node_coordinates_it =
node_coordinates.begin(dim, nb_nodes_per_element);
Array<Real>::matrix_iterator node_coordinates_end =
node_coordinates.end(dim, nb_nodes_per_element);
for (; node_coordinates_it != node_coordinates_end; ++node_coordinates_it) {
for (UInt i = 0; i < nb_quad_points; i++, ++directing_cosines_it) {
Matrix<Real> & nodes = *node_coordinates_it;
Matrix<Real> & cosines = *directing_cosines_it;
computeDirectingCosinesOnQuad(nodes, cosines);
}
}
// Mauro: the directing_cosines internal is defined on the quadrature points
// of each element
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::assembleStiffnessMatrix(
const ElementType & type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Mesh & mesh = emodel.getMesh();
for (auto && mesh_type : mesh.elementTypes(dim, ghost_type)) {
assembleStiffnessMatrixInterface(type, mesh_type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Computes the reinforcement stiffness matrix (Gomes & Awruch, 2001)
* \f[
* \mathbf{K}_e = \sum_{i=1}^R{A_i\int_{S_i}{\mathbf{B}^T
* \mathbf{C}_i^T \mathbf{D}_{s, i} \mathbf{C}_i \mathbf{B}\,\mathrm{d}s}}
* \f]
*/
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::assembleStiffnessMatrixInterface(
const ElementType & interface_type, const ElementType & background_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
UInt voigt_size = VoigtHelper<dim>::size;
FEEngine & interface_engine = emodel.getFEEngine("EmbeddedInterfaceFEEngine");
Array<UInt> & elem_filter = this->element_filter(interface_type, ghost_type);
Array<Real> & grad_u = gradu_embedded(interface_type, ghost_type);
UInt nb_element = elem_filter.size();
UInt nodes_per_background_e = Mesh::getNbNodesPerElement(background_type);
UInt nb_quadrature_points =
interface_engine.getNbIntegrationPoints(interface_type, ghost_type);
UInt back_dof = dim * nodes_per_background_e;
UInt integrant_size = back_dof;
grad_u.resize(nb_quadrature_points * nb_element);
Array<Real> tangent_moduli(nb_element * nb_quadrature_points, 1,
"interface_tangent_moduli");
this->computeTangentModuli(interface_type, tangent_moduli, ghost_type);
Array<Real> & shapesd = (*shape_derivatives(interface_type, ghost_type))(
background_type, ghost_type);
Array<Real> integrant(nb_element * nb_quadrature_points,
integrant_size * integrant_size, "B^t*C^t*D*C*B");
/// Temporary matrices for integrant product
Matrix<Real> Bvoigt(voigt_size, back_dof);
Matrix<Real> DCB(1, back_dof);
Matrix<Real> CtDCB(voigt_size, back_dof);
Array<Real>::scalar_iterator D_it = tangent_moduli.begin();
Array<Real>::scalar_iterator D_end = tangent_moduli.end();
Array<Real>::matrix_iterator C_it =
directing_cosines(interface_type, ghost_type).begin(1, voigt_size);
Array<Real>::matrix_iterator B_it =
shapesd.begin(dim, nodes_per_background_e);
Array<Real>::matrix_iterator integrant_it =
integrant.begin(integrant_size, integrant_size);
for (; D_it != D_end; ++D_it, ++C_it, ++B_it, ++integrant_it) {
Real & D = *D_it;
Matrix<Real> & C = *C_it;
Matrix<Real> & B = *B_it;
Matrix<Real> & BtCtDCB = *integrant_it;
VoigtHelper<dim>::transferBMatrixToSymVoigtBMatrix(B, Bvoigt,
nodes_per_background_e);
DCB.mul<false, false>(C, Bvoigt);
DCB *= D * area;
CtDCB.mul<true, false>(C, DCB);
BtCtDCB.mul<true, false>(Bvoigt, CtDCB);
}
tangent_moduli.resize(0);
Array<Real> K_interface(nb_element, integrant_size * integrant_size,
"K_interface");
interface_engine.integrate(integrant, K_interface,
integrant_size * integrant_size, interface_type,
ghost_type, elem_filter);
integrant.resize(0);
// Mauro: Here K_interface contains the local stiffness matrices,
// directing_cosines contains the information about the orientation
// of the reinforcements, any rotation of the local stiffness matrix
// can be done here
auto & filter =
getBackgroundFilter(interface_type, background_type, ghost_type);
emodel.getDOFManager().assembleElementalMatricesToMatrix(
"K", "displacement", K_interface, background_type, ghost_type, _symmetric,
filter);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
Real MaterialReinforcement<Mat, dim>::getEnergy(const std::string & id) {
AKANTU_DEBUG_IN();
if (id == "potential") {
Real epot = 0.;
this->computePotentialEnergyByElements();
- for (auto && type : this->element_filter.elementTypes(this->spatial_dimension)) {
+ for (auto && type :
+ this->element_filter.elementTypes(this->spatial_dimension)) {
FEEngine & interface_engine =
emodel.getFEEngine("EmbeddedInterfaceFEEngine");
epot += interface_engine.integrate(
this->potential_energy(type, _not_ghost), type, _not_ghost,
this->element_filter(type, _not_ghost));
epot *= area;
}
return epot;
}
AKANTU_DEBUG_OUT();
return 0;
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
void MaterialReinforcement<Mat, dim>::computeGradU(
const ElementType & interface_type, GhostType ghost_type) {
// Looping over background types
for (auto && bg_type :
background_filter(interface_type, ghost_type)->elementTypes(dim)) {
const UInt nodes_per_background_e = Mesh::getNbNodesPerElement(bg_type);
const UInt voigt_size = VoigtHelper<dim>::size;
auto & bg_shapesd =
(*shape_derivatives(interface_type, ghost_type))(bg_type, ghost_type);
auto & filter = getBackgroundFilter(interface_type, bg_type, ghost_type);
Array<Real> disp_per_element(0, dim * nodes_per_background_e, "disp_elem");
FEEngine::extractNodalToElementField(
emodel.getMesh(), emodel.getDisplacement(), disp_per_element, bg_type,
ghost_type, filter);
Matrix<Real> concrete_du(dim, dim);
Matrix<Real> epsilon(dim, dim);
Vector<Real> evoigt(voigt_size);
for (auto && tuple :
zip(make_view(disp_per_element, dim, nodes_per_background_e),
make_view(bg_shapesd, dim, nodes_per_background_e),
this->gradu(interface_type, ghost_type),
make_view(this->directing_cosines(interface_type, ghost_type),
voigt_size))) {
auto & u = std::get<0>(tuple);
auto & B = std::get<1>(tuple);
auto & du = std::get<2>(tuple);
auto & C = std::get<3>(tuple);
concrete_du.mul<false, true>(u, B);
auto epsilon = 0.5 * (concrete_du + concrete_du.transpose());
strainTensorToVoigtVector(epsilon, evoigt);
du = C.dot(evoigt);
}
}
}
/* -------------------------------------------------------------------------- */
/**
* The structure of the directing cosines matrix is :
* \f{eqnarray*}{
* C_{1,\cdot} & = & (l^2, m^2, n^2, mn, ln, lm) \\
* C_{i,j} & = & 0
* \f}
*
* with :
* \f[
* (l, m, n) = \frac{1}{\|\frac{\mathrm{d}\vec{r}(s)}{\mathrm{d}s}\|} \cdot
* \frac{\mathrm{d}\vec{r}(s)}{\mathrm{d}s}
* \f]
*/
template <class Mat, UInt dim>
inline void MaterialReinforcement<Mat, dim>::computeDirectingCosinesOnQuad(
const Matrix<Real> & nodes, Matrix<Real> & cosines) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(nodes.cols() == 2,
"Higher order reinforcement elements not implemented");
const Vector<Real> a = nodes(0), b = nodes(1);
Vector<Real> delta = b - a;
Real sq_length = 0.;
for (UInt i = 0; i < dim; i++) {
sq_length += delta(i) * delta(i);
}
if (dim == 2) {
cosines(0, 0) = delta(0) * delta(0); // l^2
cosines(0, 1) = delta(1) * delta(1); // m^2
cosines(0, 2) = delta(0) * delta(1); // lm
} else if (dim == 3) {
cosines(0, 0) = delta(0) * delta(0); // l^2
cosines(0, 1) = delta(1) * delta(1); // m^2
cosines(0, 2) = delta(2) * delta(2); // n^2
cosines(0, 3) = delta(1) * delta(2); // mn
cosines(0, 4) = delta(0) * delta(2); // ln
cosines(0, 5) = delta(0) * delta(1); // lm
}
cosines /= sq_length;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
inline void MaterialReinforcement<Mat, dim>::stressTensorToVoigtVector(
const Matrix<Real> & tensor, Vector<Real> & vector) {
AKANTU_DEBUG_IN();
for (UInt i = 0; i < dim; i++) {
vector(i) = tensor(i, i);
}
if (dim == 2) {
vector(2) = tensor(0, 1);
} else if (dim == 3) {
vector(3) = tensor(1, 2);
vector(4) = tensor(0, 2);
vector(5) = tensor(0, 1);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <class Mat, UInt dim>
inline void MaterialReinforcement<Mat, dim>::strainTensorToVoigtVector(
const Matrix<Real> & tensor, Vector<Real> & vector) {
AKANTU_DEBUG_IN();
for (UInt i = 0; i < dim; i++) {
vector(i) = tensor(i, i);
}
if (dim == 2) {
vector(2) = 2 * tensor(0, 1);
} else if (dim == 3) {
vector(3) = 2 * tensor(1, 2);
vector(4) = 2 * tensor(0, 2);
vector(5) = 2 * tensor(0, 1);
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_finite_deformation/material_neohookean.cc b/src/model/solid_mechanics/materials/material_finite_deformation/material_neohookean.cc
index 9ffb63fab..af08a8527 100644
--- a/src/model/solid_mechanics/materials/material_finite_deformation/material_neohookean.cc
+++ b/src/model/solid_mechanics/materials/material_finite_deformation/material_neohookean.cc
@@ -1,285 +1,284 @@
/**
* @file material_neohookean.cc
*
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
*
* @date creation: Mon Apr 08 2013
* @date last modification: Wed Nov 08 2017
*
* @brief Specialization of the material class for finite deformation
* neo-hookean material
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_neohookean.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialNeohookean<spatial_dimension>::MaterialNeohookean(
SolidMechanicsModel & model, const ID & id)
: PlaneStressToolbox<spatial_dimension>(model, id) {
AKANTU_DEBUG_IN();
this->registerParam("E", E, Real(0.), _pat_parsable | _pat_modifiable,
"Young's modulus");
this->registerParam("nu", nu, Real(0.5), _pat_parsable | _pat_modifiable,
"Poisson's ratio");
this->registerParam("lambda", lambda, _pat_readable,
"First Lamé coefficient");
this->registerParam("mu", mu, _pat_readable, "Second Lamé coefficient");
this->registerParam("kapa", kpa, _pat_readable, "Bulk coefficient");
this->finite_deformation = true;
this->initialize_third_axis_deformation = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialNeohookean<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
PlaneStressToolbox<spatial_dimension>::initMaterial();
if (spatial_dimension == 1)
nu = 0.;
this->updateInternalParameters();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <> void MaterialNeohookean<2>::initMaterial() {
AKANTU_DEBUG_IN();
PlaneStressToolbox<2>::initMaterial();
this->updateInternalParameters();
if (this->plane_stress)
this->third_axis_deformation.setDefaultValue(1.);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialNeohookean<spatial_dimension>::updateInternalParameters() {
lambda = nu * E / ((1 + nu) * (1 - 2 * nu));
mu = E / (2 * (1 + nu));
kpa = lambda + 2. / 3. * mu;
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialNeohookean<dim>::computeCauchyStressPlaneStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
PlaneStressToolbox<dim>::computeCauchyStressPlaneStress(el_type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <>
void MaterialNeohookean<2>::computeCauchyStressPlaneStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Array<Real>::matrix_iterator gradu_it =
this->gradu(el_type, ghost_type).begin(2, 2);
Array<Real>::matrix_iterator gradu_end =
this->gradu(el_type, ghost_type).end(2, 2);
Array<Real>::matrix_iterator piola_it =
this->piola_kirchhoff_2(el_type, ghost_type).begin(2, 2);
Array<Real>::matrix_iterator stress_it =
this->stress(el_type, ghost_type).begin(2, 2);
Array<Real>::const_scalar_iterator c33_it =
this->third_axis_deformation(el_type, ghost_type).begin();
Matrix<Real> F_tensor(2, 2);
for (; gradu_it != gradu_end; ++gradu_it, ++piola_it, ++stress_it, ++c33_it) {
Matrix<Real> & grad_u = *gradu_it;
Matrix<Real> & piola = *piola_it;
Matrix<Real> & sigma = *stress_it;
gradUToF<2>(grad_u, F_tensor);
computeCauchyStressOnQuad<2>(F_tensor, piola, sigma, *c33_it);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialNeohookean<dim>::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeStressOnQuad(grad_u, sigma);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <>
void MaterialNeohookean<2>::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
if (this->plane_stress) {
PlaneStressToolbox<2>::computeStress(el_type, ghost_type);
Array<Real>::const_scalar_iterator c33_it =
this->third_axis_deformation(el_type, ghost_type).begin();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeStressOnQuad(grad_u, sigma, *c33_it);
++c33_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
} else {
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeStressOnQuad(grad_u, sigma);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialNeohookean<dim>::computeThirdAxisDeformation(
ElementType /*el_type*/, GhostType /*ghost_type*/) {}
/* -------------------------------------------------------------------------- */
template <>
void MaterialNeohookean<2>::computeThirdAxisDeformation(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(this->plane_stress, "The third component of the strain "
"can only be computed for 2D "
"problems in Plane Stress!!");
Array<Real>::scalar_iterator c33_it =
this->third_axis_deformation(el_type, ghost_type).begin();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
computeThirdAxisDeformationOnQuad(grad_u, *c33_it);
++c33_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialNeohookean<spatial_dimension>::computePotentialEnergy(
ElementType el_type) {
AKANTU_DEBUG_IN();
Material::computePotentialEnergy(el_type);
- Array<Real>::scalar_iterator epot =
- this->potential_energy(el_type).begin();
+ Array<Real>::scalar_iterator epot = this->potential_energy(el_type).begin();
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, _not_ghost);
computePotentialEnergyOnQuad(grad_u, *epot);
++epot;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialNeohookean<spatial_dimension>::computeTangentModuli(
__attribute__((unused)) const ElementType & el_type,
Array<Real> & tangent_matrix,
__attribute__((unused)) GhostType ghost_type) {
AKANTU_DEBUG_IN();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
computeTangentModuliOnQuad(tangent, grad_u);
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <>
void MaterialNeohookean<2>::computeTangentModuli(__attribute__((unused))
const ElementType & el_type,
Array<Real> & tangent_matrix,
__attribute__((unused))
GhostType ghost_type) {
AKANTU_DEBUG_IN();
if (this->plane_stress) {
PlaneStressToolbox<2>::computeStress(el_type, ghost_type);
Array<Real>::const_scalar_iterator c33_it =
this->third_axis_deformation(el_type, ghost_type).begin();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
computeTangentModuliOnQuad(tangent, grad_u, *c33_it);
++c33_it;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
} else {
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
computeTangentModuliOnQuad(tangent, grad_u);
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialNeohookean<spatial_dimension>::getPushWaveSpeed(
__attribute__((unused)) const Element & element) const {
return sqrt((this->lambda + 2 * this->mu) / this->rho);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialNeohookean<spatial_dimension>::getShearWaveSpeed(
__attribute__((unused)) const Element & element) const {
return sqrt(this->mu / this->rho);
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(neohookean, MaterialNeohookean);
} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.cc b/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.cc
index d5094e32b..8daf858f8 100644
--- a/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.cc
+++ b/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.cc
@@ -1,202 +1,202 @@
/**
* @file material_linear_isotropic_hardening.cc
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Benjamin Paccaud <benjamin.paccaud@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Apr 07 2014
* @date last modification: Sat Dec 02 2017
*
* @brief Specialization of the material class for isotropic finite deformation
* linear hardening plasticity
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_linear_isotropic_hardening.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim>
MaterialLinearIsotropicHardening<dim>::MaterialLinearIsotropicHardening(
SolidMechanicsModel & model, const ID & id)
: MaterialPlastic<dim>(model, id) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialLinearIsotropicHardening<spatial_dimension>::
MaterialLinearIsotropicHardening(SolidMechanicsModel & model, UInt dim,
const Mesh & mesh, FEEngine & fe_engine,
const ID & id)
: MaterialPlastic<spatial_dimension>(model, dim, mesh, fe_engine, id) {}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialLinearIsotropicHardening<spatial_dimension>::computeStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
MaterialThermal<spatial_dimension>::computeStress(el_type, ghost_type);
// infinitesimal and finite deformation
auto sigma_th_it = this->sigma_th(el_type, ghost_type).begin();
auto previous_sigma_th_it =
this->sigma_th.previous(el_type, ghost_type).begin();
auto previous_gradu_it = this->gradu.previous(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto previous_stress_it = this->stress.previous(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto inelastic_strain_it = this->inelastic_strain(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto previous_inelastic_strain_it =
this->inelastic_strain.previous(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto iso_hardening_it = this->iso_hardening(el_type, ghost_type).begin();
auto previous_iso_hardening_it =
this->iso_hardening.previous(el_type, ghost_type).begin();
//
// Finite Deformations
//
if (this->finite_deformation) {
auto previous_piola_kirchhoff_2_it =
this->piola_kirchhoff_2.previous(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto green_strain_it = this->green_strain(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
auto & inelastic_strain_tensor = *inelastic_strain_it;
auto & previous_inelastic_strain_tensor = *previous_inelastic_strain_it;
auto & previous_grad_u = *previous_gradu_it;
auto & previous_sigma = *previous_piola_kirchhoff_2_it;
auto & green_strain = *green_strain_it;
this->template gradUToGreenStrain<spatial_dimension>(grad_u, green_strain);
Matrix<Real> previous_green_strain(spatial_dimension, spatial_dimension);
this->template gradUToGreenStrain<spatial_dimension>(previous_grad_u,
previous_green_strain);
Matrix<Real> F_tensor(spatial_dimension, spatial_dimension);
this->template gradUToF<spatial_dimension>(grad_u, F_tensor);
computeStressOnQuad(green_strain, previous_green_strain, sigma,
previous_sigma, inelastic_strain_tensor,
previous_inelastic_strain_tensor, *iso_hardening_it,
*previous_iso_hardening_it, *sigma_th_it,
*previous_sigma_th_it, F_tensor);
++sigma_th_it;
++inelastic_strain_it;
++iso_hardening_it;
++previous_sigma_th_it;
//++previous_stress_it;
++previous_gradu_it;
++green_strain_it;
++previous_inelastic_strain_it;
++previous_iso_hardening_it;
++previous_piola_kirchhoff_2_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
// Infinitesimal deformations
else {
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
auto & inelastic_strain_tensor = *inelastic_strain_it;
auto & previous_inelastic_strain_tensor = *previous_inelastic_strain_it;
auto & previous_grad_u = *previous_gradu_it;
auto & previous_sigma = *previous_stress_it;
computeStressOnQuad(
grad_u, previous_grad_u, sigma, previous_sigma, inelastic_strain_tensor,
previous_inelastic_strain_tensor, *iso_hardening_it,
*previous_iso_hardening_it, *sigma_th_it, *previous_sigma_th_it);
++sigma_th_it;
++inelastic_strain_it;
++iso_hardening_it;
++previous_sigma_th_it;
++previous_stress_it;
++previous_gradu_it;
++previous_inelastic_strain_it;
++previous_iso_hardening_it;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialLinearIsotropicHardening<spatial_dimension>::computeTangentModuli(
const ElementType & el_type, Array<Real> & tangent_matrix,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto previous_gradu_it = this->gradu.previous(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto previous_stress_it = this->stress.previous(el_type, ghost_type)
.begin(spatial_dimension, spatial_dimension);
auto iso_hardening = this->iso_hardening(el_type, ghost_type).begin();
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_BEGIN(tangent_matrix);
computeTangentModuliOnQuad(tangent, grad_u, *previous_gradu_it, sigma,
*previous_stress_it, *iso_hardening);
++previous_gradu_it;
++previous_stress_it;
++iso_hardening;
MATERIAL_TANGENT_QUADRATURE_POINT_LOOP_END;
this->was_stiffness_assembled = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(plastic_linear_isotropic_hardening,
MaterialLinearIsotropicHardening);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.hh b/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.hh
index dea48f6b9..67ccb4894 100644
--- a/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.hh
+++ b/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening.hh
@@ -1,113 +1,113 @@
/**
* @file material_linear_isotropic_hardening.hh
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Benjamin Paccaud <benjamin.paccaud@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sat Dec 02 2017
*
* @brief Specialization of the material class for isotropic finite deformation
* linear hardening plasticity
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_voigthelper.hh"
#include "material_plastic.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_LINEAR_ISOTROPIC_HARDENING_HH__
#define __AKANTU_MATERIAL_LINEAR_ISOTROPIC_HARDENING_HH__
namespace akantu {
/**
* Material plastic with a linear evolution of the yielding stress
*/
template <UInt spatial_dimension>
class MaterialLinearIsotropicHardening
: public MaterialPlastic<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialLinearIsotropicHardening(SolidMechanicsModel & model,
const ID & id = "");
MaterialLinearIsotropicHardening(SolidMechanicsModel & model, UInt dim,
const Mesh & mesh, FEEngine & fe_engine,
const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// constitutive law for all element of a type
void computeStress(ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute the tangent stiffness matrix for an element type
void computeTangentModuli(const ElementType & el_type,
Array<Real> & tangent_matrix,
GhostType ghost_type = _not_ghost) override;
protected:
/// Infinitesimal deformations
inline void computeStressOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & previous_grad_u,
Matrix<Real> & sigma, const Matrix<Real> & previous_sigma,
Matrix<Real> & inelas_strain, const Matrix<Real> & previous_inelas_strain,
Real & iso_hardening, const Real & previous_iso_hardening,
const Real & sigma_th, const Real & previous_sigma_th);
/// Finite deformations
inline void computeStressOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & previous_grad_u,
Matrix<Real> & sigma, const Matrix<Real> & previous_sigma,
Matrix<Real> & inelas_strain, const Matrix<Real> & previous_inelas_strain,
Real & iso_hardening, const Real & previous_iso_hardening,
const Real & sigma_th, const Real & previous_sigma_th,
const Matrix<Real> & F_tensor);
inline void computeTangentModuliOnQuad(
Matrix<Real> & tangent, const Matrix<Real> & grad_u,
const Matrix<Real> & previous_grad_u, const Matrix<Real> & sigma_tensor,
const Matrix<Real> & previous_sigma_tensor,
const Real & iso_hardening) const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#include "material_linear_isotropic_hardening_inline_impl.cc"
#endif /* __AKANTU_MATERIAL_LINEAR_ISOTROPIC_HARDENING_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening_inline_impl.cc b/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening_inline_impl.cc
index 06bb421f4..b53cfe8a9 100644
--- a/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening_inline_impl.cc
+++ b/src/model/solid_mechanics/materials/material_plastic/material_linear_isotropic_hardening_inline_impl.cc
@@ -1,298 +1,297 @@
/**
* @file material_linear_isotropic_hardening_inline_impl.cc
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Benjamin Paccaud <benjamin.paccaud@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Apr 07 2014
* @date last modification: Thu Nov 30 2017
*
* @brief Implementation of the inline functions of the material plasticity
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "material_linear_isotropic_hardening.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
/// Infinitesimal deformations
template <UInt dim>
inline void MaterialLinearIsotropicHardening<dim>::computeStressOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & previous_grad_u,
Matrix<Real> & sigma, const Matrix<Real> & previous_sigma,
Matrix<Real> & inelastic_strain,
const Matrix<Real> & previous_inelastic_strain, Real & iso_hardening,
const Real & previous_iso_hardening, const Real & sigma_th,
const Real & previous_sigma_th) {
Real delta_sigma_th = sigma_th - previous_sigma_th;
Matrix<Real> grad_delta_u(grad_u);
grad_delta_u -= previous_grad_u;
// Compute trial stress, sigma_tr
Matrix<Real> sigma_tr(dim, dim);
MaterialElastic<dim>::computeStressOnQuad(grad_delta_u, sigma_tr,
delta_sigma_th);
sigma_tr += previous_sigma;
// We need a full stress tensor, otherwise the VM stress is messed up
Matrix<Real> sigma_tr_dev(3, 3, 0);
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
sigma_tr_dev(i, j) = sigma_tr(i, j);
sigma_tr_dev -= Matrix<Real>::eye(3, sigma_tr.trace() / 3.0);
// Compute effective deviatoric trial stress
Real s = sigma_tr_dev.doubleDot(sigma_tr_dev);
Real sigma_tr_dev_eff = std::sqrt(3. / 2. * s);
bool initial_yielding =
((sigma_tr_dev_eff - iso_hardening - this->sigma_y) > 0);
Real dp = (initial_yielding)
? (sigma_tr_dev_eff - this->sigma_y - previous_iso_hardening) /
(3 * this->mu + this->h)
: 0;
iso_hardening = previous_iso_hardening + this->h * dp;
// Compute inelastic strain (ignore last components in 1-2D)
Matrix<Real> delta_inelastic_strain(dim, dim, 0.);
if (std::abs(sigma_tr_dev_eff) >
sigma_tr_dev.norm<L_inf>() * Math::getTolerance()) {
for (UInt i = 0; i < dim; ++i)
for (UInt j = 0; j < dim; ++j)
delta_inelastic_strain(i, j) = sigma_tr_dev(i, j);
delta_inelastic_strain *= 3. / 2. * dp / sigma_tr_dev_eff;
}
MaterialPlastic<dim>::computeStressAndInelasticStrainOnQuad(
grad_delta_u, sigma, previous_sigma, inelastic_strain,
previous_inelastic_strain, delta_inelastic_strain);
}
/* -------------------------------------------------------------------------- */
/// Finite deformations
template <UInt dim>
inline void MaterialLinearIsotropicHardening<dim>::computeStressOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & previous_grad_u,
Matrix<Real> & sigma, const Matrix<Real> & previous_sigma,
Matrix<Real> & inelastic_strain,
const Matrix<Real> & previous_inelastic_strain, Real & iso_hardening,
const Real & previous_iso_hardening, const Real & sigma_th,
const Real & previous_sigma_th, const Matrix<Real> & F_tensor) {
// Finite plasticity
Real dp = 0.0;
Real d_dp = 0.0;
UInt n = 0;
Real delta_sigma_th = sigma_th - previous_sigma_th;
Matrix<Real> grad_delta_u(grad_u);
grad_delta_u -= previous_grad_u;
// Compute trial stress, sigma_tr
Matrix<Real> sigma_tr(dim, dim);
MaterialElastic<dim>::computeStressOnQuad(grad_delta_u, sigma_tr,
delta_sigma_th);
sigma_tr += previous_sigma;
// Compute deviatoric trial stress, sigma_tr_dev
Matrix<Real> sigma_tr_dev(sigma_tr);
sigma_tr_dev -= Matrix<Real>::eye(dim, sigma_tr.trace() / 3.0);
// Compute effective deviatoric trial stress
Real s = sigma_tr_dev.doubleDot(sigma_tr_dev);
Real sigma_tr_dev_eff = std::sqrt(3. / 2. * s);
// compute the cauchy stress to apply the Von-Mises criterion
Matrix<Real> cauchy_stress(dim, dim);
Material::computeCauchyStressOnQuad<dim>(F_tensor, sigma_tr, cauchy_stress);
Matrix<Real> cauchy_stress_dev(cauchy_stress);
cauchy_stress_dev -= Matrix<Real>::eye(dim, cauchy_stress.trace() / 3.0);
Real c = cauchy_stress_dev.doubleDot(cauchy_stress_dev);
Real cauchy_stress_dev_eff = std::sqrt(3. / 2. * c);
const Real iso_hardening_t = previous_iso_hardening;
iso_hardening = iso_hardening_t;
// Loop for correcting stress based on yield function
// F is written in terms of S
// bool initial_yielding = ( (sigma_tr_dev_eff - iso_hardening -
// this->sigma_y) > 0) ;
// while ( initial_yielding && std::abs(sigma_tr_dev_eff - iso_hardening -
// this->sigma_y) > Math::getTolerance() ) {
// d_dp = (sigma_tr_dev_eff - 3. * this->mu *dp - iso_hardening -
// this->sigma_y)
// / (3. * this->mu + this->h);
// //r = r + h * dp;
// dp = dp + d_dp;
// iso_hardening = iso_hardening_t + this->h * dp;
// ++n;
// /// TODO : explicit this criterion with an error message
// if ((std::abs(d_dp) < 1e-9) || (n>50)){
// AKANTU_DEBUG_INFO("convergence of increment of plastic strain. d_dp:"
// << d_dp << "\tNumber of iteration:"<<n);
// break;
// }
// }
// F is written in terms of cauchy stress
bool initial_yielding =
((cauchy_stress_dev_eff - iso_hardening - this->sigma_y) > 0);
- while (initial_yielding &&
- std::abs(cauchy_stress_dev_eff - iso_hardening - this->sigma_y) >
- Math::getTolerance()) {
+ while (initial_yielding && std::abs(cauchy_stress_dev_eff - iso_hardening -
+ this->sigma_y) > Math::getTolerance()) {
d_dp = (cauchy_stress_dev_eff - 3. * this->mu * dp - iso_hardening -
this->sigma_y) /
(3. * this->mu + this->h);
// r = r + h * dp;
dp = dp + d_dp;
iso_hardening = iso_hardening_t + this->h * dp;
++n;
/// TODO : explicit this criterion with an error message
if ((d_dp < 1e-5) || (n > 50)) {
AKANTU_DEBUG_INFO("convergence of increment of plastic strain. d_dp:"
<< d_dp << "\tNumber of iteration:" << n);
break;
}
}
// Update internal variable
Matrix<Real> delta_inelastic_strain(dim, dim, 0.);
if (std::abs(sigma_tr_dev_eff) >
sigma_tr_dev.norm<L_inf>() * Math::getTolerance()) {
// /// compute the direction of the plastic strain as \frac{\partial
// F}{\partial S} = \frac{3}{2J\sigma_{effective}}} Ft \sigma_{dev} F
Matrix<Real> cauchy_dev_F(dim, dim);
cauchy_dev_F.mul<false, false>(F_tensor, cauchy_stress_dev);
Real J = F_tensor.det();
Real constant = J ? 1. / J : 0;
constant *= 3. * dp / (2. * cauchy_stress_dev_eff);
delta_inelastic_strain.mul<true, false>(F_tensor, cauchy_dev_F, constant);
// Direction given by the piola kirchhoff deviatoric tensor \frac{\partial
// F}{\partial S} = \frac{3}{2\sigma_{effective}}}S_{dev}
// delta_inelastic_strain.copy(sigma_tr_dev);
// delta_inelastic_strain *= 3./2. * dp / sigma_tr_dev_eff;
}
MaterialPlastic<dim>::computeStressAndInelasticStrainOnQuad(
grad_delta_u, sigma, previous_sigma, inelastic_strain,
previous_inelastic_strain, delta_inelastic_strain);
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialLinearIsotropicHardening<dim>::computeTangentModuliOnQuad(
Matrix<Real> & tangent, __attribute__((unused)) const Matrix<Real> & grad_u,
__attribute__((unused)) const Matrix<Real> & previous_grad_u,
__attribute__((unused)) const Matrix<Real> & sigma_tensor,
__attribute__((unused)) const Matrix<Real> & previous_sigma_tensor,
__attribute__((unused)) const Real & iso_hardening) const {
// Real r=iso_hardening;
// Matrix<Real> grad_delta_u(grad_u);
// grad_delta_u -= previous_grad_u;
// //Compute trial stress, sigma_tr
// Matrix<Real> sigma_tr(dim, dim);
// MaterialElastic<dim>::computeStressOnQuad(grad_delta_u, sigma_tr);
// sigma_tr += previous_sigma_tensor;
// // Compute deviatoric trial stress, sigma_tr_dev
// Matrix<Real> sigma_tr_dev(sigma_tr);
// sigma_tr_dev -= Matrix<Real>::eye(dim, sigma_tr.trace() / 3.0);
// // Compute effective deviatoric trial stress
// Real s = sigma_tr_dev.doubleDot(sigma_tr_dev);
// Real sigma_tr_dev_eff=std::sqrt(3./2. * s);
// // Compute deviatoric stress, sigma_dev
// Matrix<Real> sigma_dev(sigma_tensor);
// sigma_dev -= Matrix<Real>::eye(dim, sigma_tensor.trace() / 3.0);
// // Compute effective deviatoric stress
// s = sigma_dev.doubleDot(sigma_dev);
// Real sigma_dev_eff = std::sqrt(3./2. * s);
// Real xr = 0.0;
// if(sigma_tr_dev_eff > sigma_dev_eff * Math::getTolerance())
// xr = sigma_dev_eff / sigma_tr_dev_eff;
// Real __attribute__((unused)) q = 1.5 * (1. / (1. + 3. * this->mu /
// this->h) - xr);
/*
UInt cols = tangent.cols();
UInt rows = tangent.rows();
for (UInt m = 0; m < rows; ++m) {
UInt i = VoigtHelper<dim>::vec[m][0];
UInt j = VoigtHelper<dim>::vec[m][1];
for (UInt n = 0; n < cols; ++n) {
UInt k = VoigtHelper<dim>::vec[n][0];
UInt l = VoigtHelper<dim>::vec[n][1];
*/
// This section of the code is commented
// There were some problems with the convergence of plastic-coupled
// simulations with thermal expansion
// XXX: DO NOT REMOVE
/*if (((sigma_tr_dev_eff-iso_hardening-sigmay) > 0) && (xr > 0)) {
tangent(m,n) =
2. * this->mu * q * (sigma_tr_dev (i,j) / sigma_tr_dev_eff) * (sigma_tr_dev
(k,l) / sigma_tr_dev_eff) +
(i==k) * (j==l) * 2. * this->mu * xr +
(i==j) * (k==l) * (this->kpa - 2./3. * this->mu * xr);
if ((m == n) && (m>=dim))
tangent(m, n) = tangent(m, n) - this->mu * xr;
} else {*/
/*
tangent(m,n) = (i==k) * (j==l) * 2. * this->mu +
(i==j) * (k==l) * this->lambda;
tangent(m,n) -= (m==n) * (m>=dim) * this->mu;
*/
//}
// correct tangent stiffness for shear component
//}
//}
MaterialElastic<dim>::computeTangentModuliOnQuad(tangent);
}
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_plastic/material_plastic_inline_impl.cc b/src/model/solid_mechanics/materials/material_plastic/material_plastic_inline_impl.cc
index f70afb3a2..7b9f31aca 100644
--- a/src/model/solid_mechanics/materials/material_plastic/material_plastic_inline_impl.cc
+++ b/src/model/solid_mechanics/materials/material_plastic/material_plastic_inline_impl.cc
@@ -1,76 +1,76 @@
/**
* @file material_plastic_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Apr 07 2014
* @date last modification: Wed Jan 24 2018
*
* @brief Implementation of the inline functions of akantu::MaterialPlastic
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef MATERIAL_PLASTIC_INLINE_IMPL_H
#define MATERIAL_PLASTIC_INLINE_IMPL_H
#include "material_plastic.hh"
namespace akantu {
template <UInt dim>
inline void MaterialPlastic<dim>::computeStressAndInelasticStrainOnQuad(
const Matrix<Real> & delta_grad_u, Matrix<Real> & sigma,
const Matrix<Real> & previous_sigma, Matrix<Real> & inelastic_strain,
const Matrix<Real> & previous_inelastic_strain,
const Matrix<Real> & delta_inelastic_strain) const {
Matrix<Real> grad_u_elastic(dim, dim);
grad_u_elastic.copy(delta_grad_u);
grad_u_elastic -= delta_inelastic_strain;
Matrix<Real> sigma_elastic(dim, dim);
MaterialElastic<dim>::computeStressOnQuad(grad_u_elastic, sigma_elastic);
sigma.copy(previous_sigma);
sigma += sigma_elastic;
inelastic_strain.copy(previous_inelastic_strain);
inelastic_strain += delta_inelastic_strain;
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialPlastic<dim>::computeStressAndInelasticStrainOnQuad(
const Matrix<Real> & grad_u, const Matrix<Real> & previous_grad_u,
Matrix<Real> & sigma, const Matrix<Real> & previous_sigma,
Matrix<Real> & inelastic_strain,
const Matrix<Real> & previous_inelastic_strain,
const Matrix<Real> & delta_inelastic_strain) const {
Matrix<Real> delta_grad_u(grad_u);
delta_grad_u -= previous_grad_u;
computeStressAndInelasticStrainOnQuad(
delta_grad_u, sigma, previous_sigma, inelastic_strain,
previous_inelastic_strain, delta_inelastic_strain);
}
-} // Akantu
+} // namespace akantu
#endif /* MATERIAL_PLASTIC_INLINE_IMPL_H */
diff --git a/src/model/solid_mechanics/materials/material_thermal.cc b/src/model/solid_mechanics/materials/material_thermal.cc
index cb00402d1..de893ad66 100644
--- a/src/model/solid_mechanics/materials/material_thermal.cc
+++ b/src/model/solid_mechanics/materials/material_thermal.cc
@@ -1,120 +1,119 @@
/**
* @file material_thermal.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Mon Jan 29 2018
*
* @brief Specialization of the material class for the thermal material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_thermal.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialThermal<spatial_dimension>::MaterialThermal(SolidMechanicsModel & model,
const ID & id)
: Material(model, id), delta_T("delta_T", *this),
sigma_th("sigma_th", *this), use_previous_stress_thermal(false) {
AKANTU_DEBUG_IN();
this->initialize();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialThermal<spatial_dimension>::MaterialThermal(SolidMechanicsModel & model,
UInt dim, const Mesh & mesh,
FEEngine & fe_engine,
const ID & id)
: Material(model, dim, mesh, fe_engine, id),
delta_T("delta_T", *this, dim, fe_engine, this->element_filter),
sigma_th("sigma_th", *this, dim, fe_engine, this->element_filter),
use_previous_stress_thermal(false) {
AKANTU_DEBUG_IN();
this->initialize();
AKANTU_DEBUG_OUT();
}
template <UInt spatial_dimension>
void MaterialThermal<spatial_dimension>::initialize() {
this->registerParam("E", E, Real(0.), _pat_parsable | _pat_modifiable,
"Young's modulus");
this->registerParam("nu", nu, Real(0.5), _pat_parsable | _pat_modifiable,
"Poisson's ratio");
this->registerParam("alpha", alpha, Real(0.), _pat_parsable | _pat_modifiable,
"Thermal expansion coefficient");
this->registerParam("delta_T", delta_T, _pat_parsable | _pat_modifiable,
"Uniform temperature field");
delta_T.initialize(1);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialThermal<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
sigma_th.initialize(1);
if (use_previous_stress_thermal) {
sigma_th.initializeHistory();
}
Material::initMaterial();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialThermal<dim>::computeStress(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
for (auto && tuple : zip(this->delta_T(el_type, ghost_type),
this->sigma_th(el_type, ghost_type))) {
computeStressOnQuad(std::get<1>(tuple), std::get<0>(tuple));
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
void MaterialThermal<dim>::computePotentialEnergy(ElementType) {
AKANTU_DEBUG_IN();
AKANTU_TO_IMPLEMENT();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-
INSTANTIATE_MATERIAL_ONLY(MaterialThermal);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/material_thermal.hh b/src/model/solid_mechanics/materials/material_thermal.hh
index 126e8cb70..6593b4916 100644
--- a/src/model/solid_mechanics/materials/material_thermal.hh
+++ b/src/model/solid_mechanics/materials/material_thermal.hh
@@ -1,112 +1,113 @@
/**
* @file material_thermal.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Mon Jan 29 2018
*
* @brief Material isotropic thermo-elastic
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_THERMAL_HH__
#define __AKANTU_MATERIAL_THERMAL_HH__
namespace akantu {
template <UInt spatial_dimension> class MaterialThermal : public Material {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialThermal(SolidMechanicsModel & model, const ID & id = "");
MaterialThermal(SolidMechanicsModel & model, UInt dim, const Mesh & mesh,
FEEngine & fe_engine, const ID & id = "");
~MaterialThermal() override = default;
protected:
void initialize();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void initMaterial() override;
/// constitutive law for all element of a type
void computeStress(ElementType el_type, GhostType ghost_type) override;
/// local computation of thermal stress
inline void computeStressOnQuad(Real & sigma, const Real & deltaT);
/// local computation of thermal stress
void computePotentialEnergy(ElementType el_type);
-/* -------------------------------------------------------------------------- */
+ /* --------------------------------------------------------------------------
+ */
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// Young modulus
Real E;
/// Poisson ratio
Real nu;
/// Thermal expansion coefficient
/// TODO : implement alpha as a matrix
Real alpha;
/// Temperature field
InternalField<Real> delta_T;
/// Current thermal stress
InternalField<Real> sigma_th;
/// Tell if we need to use the previous thermal stress
bool use_previous_stress_thermal;
};
/* ------------------------------------------------------------------------ */
/* Inline impl */
/* ------------------------------------------------------------------------ */
template <UInt dim>
inline void MaterialThermal<dim>::computeStressOnQuad(Real & sigma,
const Real & deltaT) {
sigma = -this->E / (1. - 2. * this->nu) * this->alpha * deltaT;
}
template <>
inline void MaterialThermal<1>::computeStressOnQuad(Real & sigma,
const Real & deltaT) {
sigma = -this->E * this->alpha * deltaT;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_THERMAL_HH__ */
diff --git a/src/model/solid_mechanics/materials/material_viscoelastic/material_standard_linear_solid_deviatoric.cc b/src/model/solid_mechanics/materials/material_viscoelastic/material_standard_linear_solid_deviatoric.cc
index e103076ac..9f0398879 100644
--- a/src/model/solid_mechanics/materials/material_viscoelastic/material_standard_linear_solid_deviatoric.cc
+++ b/src/model/solid_mechanics/materials/material_viscoelastic/material_standard_linear_solid_deviatoric.cc
@@ -1,324 +1,325 @@
/**
* @file material_standard_linear_solid_deviatoric.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Vladislav Yastrebov <vladislav.yastrebov@epfl.ch>
*
* @date creation: Wed May 04 2011
* @date last modification: Tue Feb 20 2018
*
* @brief Material Visco-elastic
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_standard_linear_solid_deviatoric.hh"
#include "solid_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialStandardLinearSolidDeviatoric<spatial_dimension>::
MaterialStandardLinearSolidDeviatoric(SolidMechanicsModel & model,
const ID & id)
: MaterialElastic<spatial_dimension>(model, id),
stress_dev("stress_dev", *this),
history_integral("history_integral", *this),
dissipated_energy("dissipated_energy", *this) {
AKANTU_DEBUG_IN();
this->registerParam("Eta", eta, Real(1.), _pat_parsable | _pat_modifiable,
"Viscosity");
this->registerParam("Ev", Ev, Real(1.), _pat_parsable | _pat_modifiable,
"Stiffness of the viscous element");
this->registerParam("Einf", E_inf, Real(1.), _pat_readable,
"Stiffness of the elastic element");
UInt stress_size = spatial_dimension * spatial_dimension;
this->stress_dev.initialize(stress_size);
this->history_integral.initialize(stress_size);
this->dissipated_energy.initialize(1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialStandardLinearSolidDeviatoric<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
updateInternalParameters();
MaterialElastic<spatial_dimension>::initMaterial();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialStandardLinearSolidDeviatoric<
spatial_dimension>::updateInternalParameters() {
MaterialElastic<spatial_dimension>::updateInternalParameters();
E_inf = this->E - this->Ev;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialStandardLinearSolidDeviatoric<spatial_dimension>::setToSteadyState(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Array<Real> & stress_dev_vect = stress_dev(el_type, ghost_type);
Array<Real> & history_int_vect = history_integral(el_type, ghost_type);
Array<Real>::matrix_iterator stress_d =
stress_dev_vect.begin(spatial_dimension, spatial_dimension);
Array<Real>::matrix_iterator history_int =
history_int_vect.begin(spatial_dimension, spatial_dimension);
/// Loop on all quadrature points
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
Matrix<Real> & dev_s = *stress_d;
Matrix<Real> & h = *history_int;
/// Compute the first invariant of strain
Real Theta = grad_u.trace();
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j) {
- dev_s(i, j) = 2 * this->mu * (.5 * (grad_u(i, j) + grad_u(j, i)) -
- 1. / 3. * Theta * (i == j));
+ dev_s(i, j) =
+ 2 * this->mu *
+ (.5 * (grad_u(i, j) + grad_u(j, i)) - 1. / 3. * Theta * (i == j));
h(i, j) = 0.;
}
/// Save the deviator of stress
++stress_d;
++history_int;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialStandardLinearSolidDeviatoric<spatial_dimension>::computeStress(
ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
Real tau = 0.;
// if(std::abs(Ev) > std::numeric_limits<Real>::epsilon())
tau = eta / Ev;
Array<Real> & stress_dev_vect = stress_dev(el_type, ghost_type);
Array<Real> & history_int_vect = history_integral(el_type, ghost_type);
Array<Real>::matrix_iterator stress_d =
stress_dev_vect.begin(spatial_dimension, spatial_dimension);
Array<Real>::matrix_iterator history_int =
history_int_vect.begin(spatial_dimension, spatial_dimension);
Matrix<Real> s(spatial_dimension, spatial_dimension);
Real dt = this->model.getTimeStep();
Real exp_dt_tau = exp(-dt / tau);
Real exp_dt_tau_2 = exp(-.5 * dt / tau);
Matrix<Real> epsilon_d(spatial_dimension, spatial_dimension);
Matrix<Real> epsilon_v(spatial_dimension, spatial_dimension);
/// Loop on all quadrature points
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
Matrix<Real> & dev_s = *stress_d;
Matrix<Real> & h = *history_int;
s.clear();
sigma.clear();
/// Compute the first invariant of strain
Real gamma_inf = E_inf / this->E;
Real gamma_v = Ev / this->E;
this->template gradUToEpsilon<spatial_dimension>(grad_u, epsilon_d);
Real Theta = epsilon_d.trace();
epsilon_v.eye(Theta / Real(3.));
epsilon_d -= epsilon_v;
Matrix<Real> U_rond_prim(spatial_dimension, spatial_dimension);
U_rond_prim.eye(gamma_inf * this->kpa * Theta);
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j) {
s(i, j) = 2 * this->mu * epsilon_d(i, j);
h(i, j) = exp_dt_tau * h(i, j) + exp_dt_tau_2 * (s(i, j) - dev_s(i, j));
dev_s(i, j) = s(i, j);
sigma(i, j) = U_rond_prim(i, j) + gamma_inf * s(i, j) + gamma_v * h(i, j);
}
/// Save the deviator of stress
++stress_d;
++history_int;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
this->updateDissipatedEnergy(el_type, ghost_type);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialStandardLinearSolidDeviatoric<
spatial_dimension>::updateDissipatedEnergy(ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
// if(ghost_type == _ghost) return 0.;
Real tau = 0.;
tau = eta / Ev;
Real * dis_energy = dissipated_energy(el_type, ghost_type).storage();
Array<Real> & stress_dev_vect = stress_dev(el_type, ghost_type);
Array<Real> & history_int_vect = history_integral(el_type, ghost_type);
Array<Real>::matrix_iterator stress_d =
stress_dev_vect.begin(spatial_dimension, spatial_dimension);
Array<Real>::matrix_iterator history_int =
history_int_vect.begin(spatial_dimension, spatial_dimension);
Matrix<Real> q(spatial_dimension, spatial_dimension);
Matrix<Real> q_rate(spatial_dimension, spatial_dimension);
Matrix<Real> epsilon_d(spatial_dimension, spatial_dimension);
Matrix<Real> epsilon_v(spatial_dimension, spatial_dimension);
Real dt = this->model.getTimeStep();
Real gamma_v = Ev / this->E;
Real alpha = 1. / (2. * this->mu * gamma_v);
/// Loop on all quadrature points
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_BEGIN(el_type, ghost_type);
Matrix<Real> & dev_s = *stress_d;
Matrix<Real> & h = *history_int;
/// Compute the first invariant of strain
this->template gradUToEpsilon<spatial_dimension>(grad_u, epsilon_d);
Real Theta = epsilon_d.trace();
epsilon_v.eye(Theta / Real(3.));
epsilon_d -= epsilon_v;
q.copy(dev_s);
q -= h;
q *= gamma_v;
q_rate.copy(dev_s);
q_rate *= gamma_v;
q_rate -= q;
q_rate /= tau;
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j)
*dis_energy += (epsilon_d(i, j) - alpha * q(i, j)) * q_rate(i, j) * dt;
/// Save the deviator of stress
++stress_d;
++history_int;
++dis_energy;
MATERIAL_STRESS_QUADRATURE_POINT_LOOP_END;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialStandardLinearSolidDeviatoric<
spatial_dimension>::getDissipatedEnergy() const {
AKANTU_DEBUG_IN();
Real de = 0.;
/// integrate the dissipated energy for each type of elements
for (auto & type :
this->element_filter.elementTypes(spatial_dimension, _not_ghost)) {
de +=
this->fem.integrate(dissipated_energy(type, _not_ghost), type,
_not_ghost, this->element_filter(type, _not_ghost));
}
AKANTU_DEBUG_OUT();
return de;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialStandardLinearSolidDeviatoric<
spatial_dimension>::getDissipatedEnergy(ElementType type,
UInt index) const {
AKANTU_DEBUG_IN();
UInt nb_quadrature_points = this->fem.getNbIntegrationPoints(type);
auto it =
this->dissipated_energy(type, _not_ghost).begin(nb_quadrature_points);
UInt gindex = (this->element_filter(type, _not_ghost))(index);
AKANTU_DEBUG_OUT();
return this->fem.integrate(it[index], type, gindex);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialStandardLinearSolidDeviatoric<spatial_dimension>::getEnergy(
const std::string & type) {
if (type == "dissipated")
return getDissipatedEnergy();
else if (type == "dissipated_sls_deviatoric")
return getDissipatedEnergy();
else
return MaterialElastic<spatial_dimension>::getEnergy(type);
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
Real MaterialStandardLinearSolidDeviatoric<spatial_dimension>::getEnergy(
const std::string & energy_id, ElementType type, UInt index) {
if (energy_id == "dissipated")
return getDissipatedEnergy(type, index);
else if (energy_id == "dissipated_sls_deviatoric")
return getDissipatedEnergy(type, index);
else
return MaterialElastic<spatial_dimension>::getEnergy(energy_id, type,
index);
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(sls_deviatoric, MaterialStandardLinearSolidDeviatoric);
} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/plane_stress_toolbox.hh b/src/model/solid_mechanics/materials/plane_stress_toolbox.hh
index 00c017adc..3bd6e0168 100644
--- a/src/model/solid_mechanics/materials/plane_stress_toolbox.hh
+++ b/src/model/solid_mechanics/materials/plane_stress_toolbox.hh
@@ -1,103 +1,103 @@
/**
* @file plane_stress_toolbox.hh
*
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Sep 16 2014
* @date last modification: Tue Feb 20 2018
*
* @brief Tools to implement the plane stress behavior in a material
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PLANE_STRESS_TOOLBOX_HH__
#define __AKANTU_PLANE_STRESS_TOOLBOX_HH__
namespace akantu {
class SolidMechanicsModel;
class FEEngine;
-} // akantu
+} // namespace akantu
namespace akantu {
/**
* Empty class in dimensions different from 2
* This class is only specialized for 2D in the tmpl file
*/
template <UInt dim, class ParentMaterial = Material>
class PlaneStressToolbox : public ParentMaterial {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
PlaneStressToolbox(SolidMechanicsModel & model, const ID & id = "")
: ParentMaterial(model, id) {}
PlaneStressToolbox(SolidMechanicsModel & model, UInt spatial_dimension,
const Mesh & mesh, FEEngine & fe_engine,
const ID & id = "")
: ParentMaterial(model, spatial_dimension, mesh, fe_engine, id) {}
~PlaneStressToolbox() override = default;
protected:
void initialize();
public:
void computeAllCauchyStresses(GhostType ghost_type = _not_ghost) override {
ParentMaterial::computeAllCauchyStresses(ghost_type);
}
virtual void computeCauchyStressPlaneStress(ElementType /*el_type*/,
GhostType /*ghost_type*/) {
AKANTU_DEBUG_IN();
AKANTU_ERROR("The function \"computeCauchyStressPlaneStress\" can "
"only be used in 2D Plane stress problems, which means "
"that you made a mistake somewhere!! ");
AKANTU_DEBUG_OUT();
}
virtual void computeThirdAxisDeformation(ElementType, GhostType) {}
protected:
bool initialize_third_axis_deformation{false};
};
#define AKANTU_PLANE_STRESS_TOOL_SPEC(dim) \
template <> \
inline PlaneStressToolbox<dim, Material>::PlaneStressToolbox( \
SolidMechanicsModel & model, const ID & id) \
: Material(model, id) {}
AKANTU_PLANE_STRESS_TOOL_SPEC(1)
AKANTU_PLANE_STRESS_TOOL_SPEC(3)
} // namespace akantu
#include "plane_stress_toolbox_tmpl.hh"
#endif /* __AKANTU_PLANE_STRESS_TOOLBOX_HH__ */
diff --git a/src/model/solid_mechanics/materials/random_internal_field.hh b/src/model/solid_mechanics/materials/random_internal_field.hh
index a6511b6c9..6db5b663b 100644
--- a/src/model/solid_mechanics/materials/random_internal_field.hh
+++ b/src/model/solid_mechanics/materials/random_internal_field.hh
@@ -1,104 +1,104 @@
/**
* @file random_internal_field.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Random internal material parameter
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_random_generator.hh"
#include "internal_field.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_RANDOM_INTERNAL_FIELD_HH__
#define __AKANTU_RANDOM_INTERNAL_FIELD_HH__
namespace akantu {
/**
* class for the internal fields of materials with a random
* distribution
*/
template <typename T, template <typename> class BaseField = InternalField,
template <typename> class Generator = RandomGenerator>
class RandomInternalField : public BaseField<T> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
RandomInternalField(const ID & id, Material & material);
~RandomInternalField() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
RandomInternalField operator=(const RandomInternalField &) = delete;
public:
AKANTU_GET_MACRO(RandomParameter, random_parameter, const RandomParameter<T>);
/// initialize the field to a given number of component
void initialize(UInt nb_component) override;
/// set the field to a given value
void setDefaultValue(const T & value) override;
/// set the specified random distribution to a given parameter
void setRandomDistribution(const RandomParameter<T> & param);
/// print the content
void printself(std::ostream & stream, int indent = 0) const override;
protected:
void setArrayValues(T * begin, T * end) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
inline operator Real() const;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// random parameter containing the distribution and base value
RandomParameter<T> random_parameter;
};
/// standard output stream operator
template <typename T>
inline std::ostream & operator<<(std::ostream & stream,
const RandomInternalField<T> & _this) {
_this.printself(stream);
return stream;
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_RANDOM_INTERNAL_FIELD_HH__ */
diff --git a/src/model/solid_mechanics/materials/random_internal_field_tmpl.hh b/src/model/solid_mechanics/materials/random_internal_field_tmpl.hh
index 4f2769960..87f999af6 100644
--- a/src/model/solid_mechanics/materials/random_internal_field_tmpl.hh
+++ b/src/model/solid_mechanics/materials/random_internal_field_tmpl.hh
@@ -1,125 +1,125 @@
/**
* @file random_internal_field_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Thu Feb 08 2018
*
* @brief Random internal material parameter implementation
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_random_generator.hh"
#include "internal_field_tmpl.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_RANDOM_INTERNAL_FIELD_TMPL_HH__
#define __AKANTU_RANDOM_INTERNAL_FIELD_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
RandomInternalField<T, BaseField, Generator>::RandomInternalField(
const ID & id, Material & material)
: BaseField<T>(id, material), random_parameter(T()) {}
/* -------------------------------------------------------------------------- */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
RandomInternalField<T, BaseField, Generator>::~RandomInternalField() = default;
/* -------------------------------------------------------------------------- */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
void RandomInternalField<T, BaseField, Generator>::initialize(
UInt nb_component) {
this->internalInitialize(nb_component);
}
/* ------------------------------------------------------------------------ */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
void RandomInternalField<T, BaseField, Generator>::setDefaultValue(
const T & value) {
random_parameter.setBaseValue(value);
this->reset();
}
/* ------------------------------------------------------------------------ */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
void RandomInternalField<T, BaseField, Generator>::setRandomDistribution(
const RandomParameter<T> & param) {
random_parameter = param;
this->reset();
}
/* ------------------------------------------------------------------------ */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
void RandomInternalField<T, BaseField, Generator>::printself(
- std::ostream & stream, int indent[[gnu::unused]]) const {
+ std::ostream & stream, int indent [[gnu::unused]]) const {
stream << "RandomInternalField [ ";
random_parameter.printself(stream);
stream << " ]";
#if !defined(AKANTU_NDEBUG)
if (AKANTU_DEBUG_TEST(dblDump)) {
stream << std::endl;
InternalField<T>::printself(stream, indent);
}
#endif
}
/* -------------------------------------------------------------------------- */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
void RandomInternalField<T, BaseField, Generator>::setArrayValues(T * begin,
T * end) {
random_parameter.template setValues<Generator>(begin, end);
}
/* -------------------------------------------------------------------------- */
template <typename T, template <typename> class BaseField,
template <typename> class Generator>
inline RandomInternalField<T, BaseField, Generator>::operator Real() const {
return random_parameter.getBaseValue();
}
/* -------------------------------------------------------------------------- */
template <>
inline void ParameterTyped<RandomInternalField<Real>>::setAuto(
const ParserParameter & in_param) {
Parameter::setAuto(in_param);
RandomParameter<Real> r = in_param;
param.setRandomDistribution(r);
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_RANDOM_INTERNAL_FIELD_TMPL_HH__ */
diff --git a/src/model/solid_mechanics/materials/weight_functions/remove_damaged_with_damage_rate_weight_function.hh b/src/model/solid_mechanics/materials/weight_functions/remove_damaged_with_damage_rate_weight_function.hh
index fc956fa1a..1ac26e396 100644
--- a/src/model/solid_mechanics/materials/weight_functions/remove_damaged_with_damage_rate_weight_function.hh
+++ b/src/model/solid_mechanics/materials/weight_functions/remove_damaged_with_damage_rate_weight_function.hh
@@ -1,85 +1,85 @@
/**
* @file remove_damaged_with_damage_rate_weight_function.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Cyprien Wolff <cyprien.wolff@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Removed damaged weight function for non local materials
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "base_weight_function.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_REMOVE_DAMAGED_WITH_DAMAGE_RATE_WEIGHT_FUNCTION_HH__
#define __AKANTU_REMOVE_DAMAGED_WITH_DAMAGE_RATE_WEIGHT_FUNCTION_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Remove damaged with damage rate weight function */
/* -------------------------------------------------------------------------- */
class RemoveDamagedWithDamageRateWeightFunction : public BaseWeightFunction {
public:
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
RemoveDamagedWithDamageRateWeightFunction(NonLocalManager & manager)
: BaseWeightFunction(manager, "remove_damage_with_damage_rate"),
damage_with_damage_rate(nullptr) {
this->registerParam<Real>("damage_limit",
this->damage_limit_with_damage_rate, 1,
_pat_parsable, "Damage Threshold");
this->init();
}
/* --------------------------------------------------------------------------
*/
/* Base Weight Function inherited methods */
/* --------------------------------------------------------------------------
*/
inline Real operator()(Real r,
const __attribute__((unused)) IntegrationPoint & q1,
const IntegrationPoint & q2);
inline void init() override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// limit at which a point is considered as complitely broken
Real damage_limit_with_damage_rate;
/// internal pointer to the current damage vector
ElementTypeMapReal * damage_with_damage_rate;
};
#if defined(AKANTU_INCLUDE_INLINE_IMPL)
#include "remove_damaged_with_damage_rate_weight_function_inline_impl.cc"
#endif
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_REMOVE_DAMAGED_WITH_DAMAGE_WEIGHT_FUNCTION_HH__ */
diff --git a/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.cc b/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.cc
index e3913c320..330e0231b 100644
--- a/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.cc
+++ b/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.cc
@@ -1,123 +1,123 @@
/**
* @file stress_based_weight_function.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Aug 24 2015
* @date last modification: Tue Feb 20 2018
*
* @brief implementation of the stres based weight function classes
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "stress_based_weight_function.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
StressBasedWeightFunction::StressBasedWeightFunction(NonLocalManager & manager)
: BaseWeightFunction(manager, "stress_based")
// stress_diag("stress_diag", material), selected_stress_diag(NULL),
// stress_base("stress_base", material), selected_stress_base(NULL),
// characteristic_size("lc", material), selected_characteristic_size(NULL)
{
// this->registerParam("ft", this->ft, 0., _pat_parsable, "Tensile strength");
// stress_diag.initialize(spatial_dimension);
// stress_base.initialize(spatial_dimension * spatial_dimension);
// characteristic_size.initialize(1);
}
/* -------------------------------------------------------------------------- */
/// During intialization the characteristic sizes for all quadrature
/// points are computed
void StressBasedWeightFunction::init() {
// const Mesh & mesh = this->material.getModel().getFEEngine().getMesh();
// for (UInt g = _not_ghost; g <= _ghost; ++g) {
// GhostType gt = GhostType(g);
// Mesh::type_iterator it = mesh.firstType(spatial_dimension, gt);
// Mesh::type_iterator last_type = mesh.lastType(spatial_dimension, gt);
// for(; it != last_type; ++it) {
// UInt nb_quadrature_points =
// this->material.getModel().getFEEngine().getNbQuadraturePoints(*it, gt);
// const Array<UInt> & element_filter =
// this->material.getElementFilter(*it, gt);
// UInt nb_element = element_filter.size();
// Array<Real> ones(nb_element*nb_quadrature_points, 1, 1.);
// Array<Real> & lc = characteristic_size(*it, gt);
// this->material.getModel().getFEEngine().integrateOnQuadraturePoints(ones,
// lc,
// 1,
// *it,
// gt,
// element_filter);
// for (UInt q = 0; q < nb_quadrature_points * nb_element; q++) {
// lc(q) = pow(lc(q), 1./ Real(spatial_dimension));
// }
// }
// }
}
/* -------------------------------------------------------------------------- */
/// computation of principals stresses and principal directions
void StressBasedWeightFunction::updatePrincipalStress(__attribute__((unused))
GhostType ghost_type) {
// AKANTU_DEBUG_IN();
// const Mesh & mesh = this->material.getModel().getFEEngine().getMesh();
// Mesh::type_iterator it = mesh.firstType(spatial_dimension, ghost_type);
// Mesh::type_iterator last_type = mesh.lastType(spatial_dimension,
// ghost_type);
// for(; it != last_type; ++it) {
// Array<Real>::const_matrix_iterator sigma =
// this->material.getStress(*it, ghost_type).begin(spatial_dimension,
// spatial_dimension);
// auto eigenvalues =
// stress_diag(*it, ghost_type).begin(spatial_dimension);
// auto eigenvalues_end =
// stress_diag(*it, ghost_type).end(spatial_dimension);
// Array<Real>::matrix_iterator eigenvector =
// stress_base(*it, ghost_type).begin(spatial_dimension,
// spatial_dimension);
// #ifndef __trick__
// auto cl = characteristic_size(*it, ghost_type).begin();
// #endif
// UInt q = 0;
// for(;eigenvalues != eigenvalues_end; ++sigma, ++eigenvalues,
// ++eigenvector, ++cl, ++q) {
// sigma->eig(*eigenvalues, *eigenvector);
// *eigenvalues /= ft;
// #ifndef __trick__
// // specify a lower bound for principal stress based on the size of
// the element
// for (UInt i = 0; i < spatial_dimension; ++i) {
// (*eigenvalues)(i) = std::max(*cl / this->R, (*eigenvalues)(i));
// }
// #endif
// }
// }
// AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.hh b/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.hh
index 60897da5c..da05062e8 100644
--- a/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.hh
+++ b/src/model/solid_mechanics/materials/weight_functions/stress_based_weight_function.hh
@@ -1,101 +1,101 @@
/**
* @file stress_based_weight_function.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Cyprien Wolff <cyprien.wolff@epfl.ch>
*
* @date creation: Mon Aug 24 2015
* @date last modification: Wed Nov 08 2017
*
* @brief Removed damaged weight function for non local materials
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "base_weight_function.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_STRESS_BASED_WEIGHT_FUNCTION_HH__
#define __AKANTU_STRESS_BASED_WEIGHT_FUNCTION_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Stress Based Weight */
/* -------------------------------------------------------------------------- */
/// based on based on Giry et al.: Stress-based nonlocal damage model,
/// IJSS, 48, 2011
class StressBasedWeightFunction : public BaseWeightFunction {
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
StressBasedWeightFunction(NonLocalManager & manager);
/* --------------------------------------------------------------------------
*/
/* Base Weight Function inherited methods */
/* --------------------------------------------------------------------------
*/
void init() override;
inline void updateInternals() override;
void updatePrincipalStress(GhostType ghost_type);
inline void updateQuadraturePointsCoordinates(
ElementTypeMapArray<Real> & quadrature_points_coordinates);
inline Real operator()(Real r, const IntegrationPoint & q1,
const IntegrationPoint & q2);
/// computation of ellipsoid
inline Real computeRhoSquare(Real r, Vector<Real> & eigs,
Matrix<Real> & eigenvects, Vector<Real> & x_s);
protected:
inline void setInternal();
private:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
/// tensile strength
Real ft;
/// prinicipal stresses
ElementTypeMapReal * stress_diag;
/// for preselection of types (optimization)
ElementTypeMapReal * selected_stress_diag;
/// principal directions
ElementTypeMapReal * stress_base;
/// lenght intrinisic to the material
ElementTypeMapReal * characteristic_size;
};
#if defined(AKANTU_INCLUDE_INLINE_IMPL)
#include "stress_based_weight_function_inline_impl.cc"
#endif
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_STRESS_BASED_WEIGHT_FUNCTION_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model.cc b/src/model/solid_mechanics/solid_mechanics_model.cc
index e0d83b112..e9ba8becf 100644
--- a/src/model/solid_mechanics/solid_mechanics_model.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model.cc
@@ -1,1187 +1,1187 @@
/**
* @file solid_mechanics_model.cc
*
* @author Ramin Aghababaei <ramin.aghababaei@epfl.ch>
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue Jul 27 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Implementation of the SolidMechanicsModel class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model.hh"
#include "integrator_gauss.hh"
#include "shape_lagrange.hh"
#include "solid_mechanics_model_tmpl.hh"
#include "communicator.hh"
#include "element_synchronizer.hh"
#include "sparse_matrix.hh"
#include "synchronizer_registry.hh"
#include "dumpable_inline_impl.hh"
#ifdef AKANTU_USE_IOHELPER
#include "dumper_iohelper_paraview.hh"
#endif
#include "material_non_local.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/**
* A solid mechanics model need a mesh and a dimension to be created. the model
* by it self can not do a lot, the good init functions should be called in
* order to configure the model depending on what we want to do.
*
* @param mesh mesh representing the model we want to simulate
* @param dim spatial dimension of the problem, if dim = 0 (default value) the
* dimension of the problem is assumed to be the on of the mesh
* @param id an id to identify the model
*/
SolidMechanicsModel::SolidMechanicsModel(
Mesh & mesh, UInt dim, const ID & id, const MemoryID & memory_id,
std::shared_ptr<DOFManager> dof_manager, const ModelType model_type)
: Model(mesh, model_type, dof_manager, dim, id, memory_id),
BoundaryCondition<SolidMechanicsModel>(),
material_index("material index", id, memory_id),
material_local_numbering("material local numbering", id, memory_id) {
AKANTU_DEBUG_IN();
this->registerFEEngineObject<MyFEEngineType>("SolidMechanicsFEEngine", mesh,
Model::spatial_dimension);
#if defined(AKANTU_USE_IOHELPER)
this->mesh.registerDumper<DumperParaview>("paraview_all", id, true);
this->mesh.addDumpMesh(mesh, Model::spatial_dimension, _not_ghost,
_ek_regular);
#endif
material_selector = std::make_shared<DefaultMaterialSelector>(material_index);
this->registerDataAccessor(*this);
if (this->mesh.isDistributed()) {
auto & synchronizer = this->mesh.getElementSynchronizer();
this->registerSynchronizer(synchronizer, SynchronizationTag::_material_id);
this->registerSynchronizer(synchronizer, SynchronizationTag::_smm_mass);
this->registerSynchronizer(synchronizer, SynchronizationTag::_smm_stress);
this->registerSynchronizer(synchronizer, SynchronizationTag::_for_dump);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SolidMechanicsModel::~SolidMechanicsModel() {
AKANTU_DEBUG_IN();
for (auto & internal : this->registered_internals) {
delete internal.second;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::setTimeStep(Real time_step, const ID & solver_id) {
Model::setTimeStep(time_step, solver_id);
#if defined(AKANTU_USE_IOHELPER)
this->mesh.getDumper().setTimeStep(time_step);
#endif
}
/* -------------------------------------------------------------------------- */
/* Initialization */
/* -------------------------------------------------------------------------- */
/**
* This function groups many of the initialization in on function. For most of
* basics case the function should be enough. The functions initialize the
* model, the internal vectors, set them to 0, and depending on the parameters
* it also initialize the explicit or implicit solver.
*
* @param material_file the file containing the materials to use
* @param method the analysis method wanted. See the akantu::AnalysisMethod for
* the different possibilities
*/
void SolidMechanicsModel::initFullImpl(const ModelOptions & options) {
material_index.initialize(mesh, _element_kind = _ek_not_defined,
_default_value = UInt(-1), _with_nb_element = true);
material_local_numbering.initialize(mesh, _element_kind = _ek_not_defined,
_with_nb_element = true);
Model::initFullImpl(options);
// initialize the materials
if (this->parser.getLastParsedFile() != "") {
this->instantiateMaterials();
}
this->initMaterials();
this->initBC(*this, *displacement, *displacement_increment, *external_force);
}
/* -------------------------------------------------------------------------- */
TimeStepSolverType SolidMechanicsModel::getDefaultSolverType() const {
return TimeStepSolverType::_dynamic_lumped;
}
/* -------------------------------------------------------------------------- */
ModelSolverOptions SolidMechanicsModel::getDefaultSolverOptions(
const TimeStepSolverType & type) const {
ModelSolverOptions options;
switch (type) {
case TimeStepSolverType::_dynamic_lumped: {
options.non_linear_solver_type = NonLinearSolverType::_lumped;
options.integration_scheme_type["displacement"] =
IntegrationSchemeType::_central_difference;
options.solution_type["displacement"] = IntegrationScheme::_acceleration;
break;
}
case TimeStepSolverType::_static: {
options.non_linear_solver_type = NonLinearSolverType::_newton_raphson;
options.integration_scheme_type["displacement"] =
IntegrationSchemeType::_pseudo_time;
options.solution_type["displacement"] = IntegrationScheme::_not_defined;
break;
}
case TimeStepSolverType::_dynamic: {
if (this->method == _explicit_consistent_mass) {
options.non_linear_solver_type = NonLinearSolverType::_newton_raphson;
options.integration_scheme_type["displacement"] =
IntegrationSchemeType::_central_difference;
options.solution_type["displacement"] = IntegrationScheme::_acceleration;
} else {
options.non_linear_solver_type = NonLinearSolverType::_newton_raphson;
options.integration_scheme_type["displacement"] =
IntegrationSchemeType::_trapezoidal_rule_2;
options.solution_type["displacement"] = IntegrationScheme::_displacement;
}
break;
}
default:
AKANTU_EXCEPTION(type << " is not a valid time step solver type");
}
return options;
}
/* -------------------------------------------------------------------------- */
std::tuple<ID, TimeStepSolverType>
SolidMechanicsModel::getDefaultSolverID(const AnalysisMethod & method) {
switch (method) {
case _explicit_lumped_mass: {
return std::make_tuple("explicit_lumped",
TimeStepSolverType::_dynamic_lumped);
}
case _explicit_consistent_mass: {
return std::make_tuple("explicit", TimeStepSolverType::_dynamic);
}
case _static: {
return std::make_tuple("static", TimeStepSolverType::_static);
}
case _implicit_dynamic: {
return std::make_tuple("implicit", TimeStepSolverType::_dynamic);
}
default:
return std::make_tuple("unknown", TimeStepSolverType::_not_defined);
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::initSolver(TimeStepSolverType time_step_solver_type,
NonLinearSolverType) {
auto & dof_manager = this->getDOFManager();
/* ------------------------------------------------------------------------ */
// for alloc type of solvers
this->allocNodalField(this->displacement, spatial_dimension, "displacement");
this->allocNodalField(this->previous_displacement, spatial_dimension,
"previous_displacement");
this->allocNodalField(this->displacement_increment, spatial_dimension,
"displacement_increment");
this->allocNodalField(this->internal_force, spatial_dimension,
"internal_force");
this->allocNodalField(this->external_force, spatial_dimension,
"external_force");
this->allocNodalField(this->blocked_dofs, spatial_dimension, "blocked_dofs");
this->allocNodalField(this->current_position, spatial_dimension,
"current_position");
// initialize the current positions
this->current_position->copy(this->mesh.getNodes());
/* ------------------------------------------------------------------------ */
if (!dof_manager.hasDOFs("displacement")) {
dof_manager.registerDOFs("displacement", *this->displacement, _dst_nodal);
dof_manager.registerBlockedDOFs("displacement", *this->blocked_dofs);
dof_manager.registerDOFsIncrement("displacement",
*this->displacement_increment);
dof_manager.registerDOFsPrevious("displacement",
*this->previous_displacement);
}
/* ------------------------------------------------------------------------ */
// for dynamic
if (time_step_solver_type == TimeStepSolverType::_dynamic ||
time_step_solver_type == TimeStepSolverType::_dynamic_lumped) {
this->allocNodalField(this->velocity, spatial_dimension, "velocity");
this->allocNodalField(this->acceleration, spatial_dimension,
"acceleration");
if (!dof_manager.hasDOFsDerivatives("displacement", 1)) {
dof_manager.registerDOFsDerivative("displacement", 1, *this->velocity);
dof_manager.registerDOFsDerivative("displacement", 2,
*this->acceleration);
}
}
}
/* -------------------------------------------------------------------------- */
/**
* Initialize the model,basically it pre-compute the shapes, shapes derivatives
* and jacobian
*/
void SolidMechanicsModel::initModel() {
/// \todo add the current position as a parameter to initShapeFunctions for
/// large deformation
getFEEngine().initShapeFunctions(_not_ghost);
getFEEngine().initShapeFunctions(_ghost);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleResidual() {
AKANTU_DEBUG_IN();
/* ------------------------------------------------------------------------ */
// computes the internal forces
this->assembleInternalForces();
/* ------------------------------------------------------------------------ */
this->getDOFManager().assembleToResidual("displacement",
*this->external_force, 1);
this->getDOFManager().assembleToResidual("displacement",
*this->internal_force, 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleResidual(const ID & residual_part) {
AKANTU_DEBUG_IN();
if ("external" == residual_part) {
this->getDOFManager().assembleToResidual("displacement",
*this->external_force, 1);
AKANTU_DEBUG_OUT();
return;
}
if ("internal" == residual_part) {
this->getDOFManager().assembleToResidual("displacement",
*this->internal_force, 1);
AKANTU_DEBUG_OUT();
return;
}
AKANTU_CUSTOM_EXCEPTION(
debug::SolverCallbackResidualPartUnknown(residual_part));
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
MatrixType SolidMechanicsModel::getMatrixType(const ID & matrix_id) {
// \TODO check the materials to know what is the correct answer
if (matrix_id == "C")
return _mt_not_defined;
return _symmetric;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleMatrix(const ID & matrix_id) {
if (matrix_id == "K") {
this->assembleStiffnessMatrix();
} else if (matrix_id == "M") {
this->assembleMass();
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleLumpedMatrix(const ID & matrix_id) {
if (matrix_id == "M") {
this->assembleMassLumped();
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::beforeSolveStep() {
for (auto & material : materials)
material->beforeSolveStep();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::afterSolveStep() {
for (auto & material : materials)
material->afterSolveStep();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::predictor() { ++displacement_release; }
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::corrector() { ++displacement_release; }
/* -------------------------------------------------------------------------- */
/**
* This function computes the internal forces as F_{int} = \int_{\Omega} N
* \sigma d\Omega@f$
*/
void SolidMechanicsModel::assembleInternalForces() {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_INFO("Assemble the internal forces");
this->internal_force->clear();
// compute the stresses of local elements
AKANTU_DEBUG_INFO("Compute local stresses");
for (auto & material : materials) {
material->computeAllStresses(_not_ghost);
}
/* ------------------------------------------------------------------------ */
/* Computation of the non local part */
if (this->non_local_manager)
this->non_local_manager->computeAllNonLocalStresses();
// communicate the stresses
AKANTU_DEBUG_INFO("Send data for residual assembly");
this->asynchronousSynchronize(SynchronizationTag::_smm_stress);
// assemble the forces due to local stresses
AKANTU_DEBUG_INFO("Assemble residual for local elements");
for (auto & material : materials) {
material->assembleInternalForces(_not_ghost);
}
// finalize communications
AKANTU_DEBUG_INFO("Wait distant stresses");
this->waitEndSynchronize(SynchronizationTag::_smm_stress);
// assemble the stresses due to ghost elements
AKANTU_DEBUG_INFO("Assemble residual for ghost elements");
for (auto & material : materials) {
material->assembleInternalForces(_ghost);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleStiffnessMatrix() {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_INFO("Assemble the new stiffness matrix.");
// Check if materials need to recompute the matrix
bool need_to_reassemble = false;
for (auto & material : materials) {
need_to_reassemble |= material->hasStiffnessMatrixChanged();
}
if (need_to_reassemble) {
this->getDOFManager().getMatrix("K").clear();
// call compute stiffness matrix on each local elements
for (auto & material : materials) {
material->assembleStiffnessMatrix(_not_ghost);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::updateCurrentPosition() {
if (this->current_position_release == this->displacement_release)
return;
this->current_position->copy(this->mesh.getNodes());
auto cpos_it = this->current_position->begin(Model::spatial_dimension);
auto cpos_end = this->current_position->end(Model::spatial_dimension);
auto disp_it = this->displacement->begin(Model::spatial_dimension);
for (; cpos_it != cpos_end; ++cpos_it, ++disp_it) {
*cpos_it += *disp_it;
}
this->current_position_release = this->displacement_release;
}
/* -------------------------------------------------------------------------- */
const Array<Real> & SolidMechanicsModel::getCurrentPosition() {
this->updateCurrentPosition();
return *this->current_position;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::updateDataForNonLocalCriterion(
ElementTypeMapReal & criterion) {
const ID field_name = criterion.getName();
for (auto & material : materials) {
if (!material->isInternal<Real>(field_name, _ek_regular))
continue;
for (auto ghost_type : ghost_types) {
material->flattenInternal(field_name, criterion, ghost_type, _ek_regular);
}
}
}
/* -------------------------------------------------------------------------- */
/* Information */
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getStableTimeStep() {
AKANTU_DEBUG_IN();
Real min_dt = getStableTimeStep(_not_ghost);
/// reduction min over all processors
mesh.getCommunicator().allReduce(min_dt, SynchronizerOperation::_min);
AKANTU_DEBUG_OUT();
return min_dt;
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getStableTimeStep(const GhostType & ghost_type) {
AKANTU_DEBUG_IN();
Real min_dt = std::numeric_limits<Real>::max();
this->updateCurrentPosition();
Element elem;
elem.ghost_type = ghost_type;
for (auto type :
mesh.elementTypes(Model::spatial_dimension, ghost_type, _ek_regular)) {
elem.type = type;
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
UInt nb_element = mesh.getNbElement(type);
auto mat_indexes = material_index(type, ghost_type).begin();
auto mat_loc_num = material_local_numbering(type, ghost_type).begin();
Array<Real> X(0, nb_nodes_per_element * Model::spatial_dimension);
FEEngine::extractNodalToElementField(mesh, *current_position, X, type,
_not_ghost);
auto X_el = X.begin(Model::spatial_dimension, nb_nodes_per_element);
for (UInt el = 0; el < nb_element;
++el, ++X_el, ++mat_indexes, ++mat_loc_num) {
elem.element = *mat_loc_num;
Real el_h = getFEEngine().getElementInradius(*X_el, type);
Real el_c = this->materials[*mat_indexes]->getCelerity(elem);
Real el_dt = el_h / el_c;
min_dt = std::min(min_dt, el_dt);
}
}
AKANTU_DEBUG_OUT();
return min_dt;
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getKineticEnergy() {
AKANTU_DEBUG_IN();
Real ekin = 0.;
UInt nb_nodes = mesh.getNbNodes();
if (this->getDOFManager().hasLumpedMatrix("M")) {
auto m_it = this->mass->begin(Model::spatial_dimension);
auto m_end = this->mass->end(Model::spatial_dimension);
auto v_it = this->velocity->begin(Model::spatial_dimension);
for (UInt n = 0; m_it != m_end; ++n, ++m_it, ++v_it) {
const auto & v = *v_it;
const auto & m = *m_it;
Real mv2 = 0.;
auto is_local_node = mesh.isLocalOrMasterNode(n);
// bool is_not_pbc_slave_node = !isPBCSlaveNode(n);
auto count_node = is_local_node; // && is_not_pbc_slave_node;
if (count_node) {
for (UInt i = 0; i < Model::spatial_dimension; ++i) {
if (m(i) > std::numeric_limits<Real>::epsilon())
mv2 += v(i) * v(i) * m(i);
}
}
ekin += mv2;
}
} else if (this->getDOFManager().hasMatrix("M")) {
Array<Real> Mv(nb_nodes, Model::spatial_dimension);
this->getDOFManager().assembleMatMulVectToArray("displacement", "M",
*this->velocity, Mv);
for (auto && data : zip(arange(nb_nodes), make_view(Mv, spatial_dimension),
make_view(*this->velocity, spatial_dimension))) {
ekin += std::get<2>(data).dot(std::get<1>(data)) *
mesh.isLocalOrMasterNode(std::get<0>(data));
}
} else {
AKANTU_ERROR("No function called to assemble the mass matrix.");
}
mesh.getCommunicator().allReduce(ekin, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
return ekin * .5;
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getKineticEnergy(const ElementType & type,
UInt index) {
AKANTU_DEBUG_IN();
UInt nb_quadrature_points = getFEEngine().getNbIntegrationPoints(type);
Array<Real> vel_on_quad(nb_quadrature_points, Model::spatial_dimension);
Array<UInt> filter_element(1, 1, index);
getFEEngine().interpolateOnIntegrationPoints(*velocity, vel_on_quad,
Model::spatial_dimension, type,
_not_ghost, filter_element);
auto vit = vel_on_quad.begin(Model::spatial_dimension);
auto vend = vel_on_quad.end(Model::spatial_dimension);
Vector<Real> rho_v2(nb_quadrature_points);
Real rho = materials[material_index(type)(index)]->getRho();
for (UInt q = 0; vit != vend; ++vit, ++q) {
rho_v2(q) = rho * vit->dot(*vit);
}
AKANTU_DEBUG_OUT();
return .5 * getFEEngine().integrate(rho_v2, type, index);
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getExternalWork() {
AKANTU_DEBUG_IN();
auto ext_force_it = external_force->begin(Model::spatial_dimension);
auto int_force_it = internal_force->begin(Model::spatial_dimension);
auto boun_it = blocked_dofs->begin(Model::spatial_dimension);
decltype(ext_force_it) incr_or_velo_it;
if (this->method == _static) {
incr_or_velo_it =
this->displacement_increment->begin(Model::spatial_dimension);
} else {
incr_or_velo_it = this->velocity->begin(Model::spatial_dimension);
}
Real work = 0.;
UInt nb_nodes = this->mesh.getNbNodes();
for (UInt n = 0; n < nb_nodes;
++n, ++ext_force_it, ++int_force_it, ++boun_it, ++incr_or_velo_it) {
const auto & int_force = *int_force_it;
const auto & ext_force = *ext_force_it;
const auto & boun = *boun_it;
const auto & incr_or_velo = *incr_or_velo_it;
bool is_local_node = this->mesh.isLocalOrMasterNode(n);
// bool is_not_pbc_slave_node = !this->isPBCSlaveNode(n);
bool count_node = is_local_node; // && is_not_pbc_slave_node;
if (count_node) {
for (UInt i = 0; i < Model::spatial_dimension; ++i) {
if (boun(i))
work -= int_force(i) * incr_or_velo(i);
else
work += ext_force(i) * incr_or_velo(i);
}
}
}
mesh.getCommunicator().allReduce(work, SynchronizerOperation::_sum);
if (this->method != _static)
work *= this->getTimeStep();
AKANTU_DEBUG_OUT();
return work;
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getEnergy(const std::string & energy_id) {
AKANTU_DEBUG_IN();
if (energy_id == "kinetic") {
return getKineticEnergy();
} else if (energy_id == "external work") {
return getExternalWork();
}
Real energy = 0.;
for (auto & material : materials)
energy += material->getEnergy(energy_id);
/// reduction sum over all processors
mesh.getCommunicator().allReduce(energy, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
return energy;
}
/* -------------------------------------------------------------------------- */
Real SolidMechanicsModel::getEnergy(const std::string & energy_id,
const ElementType & type, UInt index) {
AKANTU_DEBUG_IN();
if (energy_id == "kinetic") {
return getKineticEnergy(type, index);
}
UInt mat_index = this->material_index(type, _not_ghost)(index);
UInt mat_loc_num = this->material_local_numbering(type, _not_ghost)(index);
Real energy =
this->materials[mat_index]->getEnergy(energy_id, type, mat_loc_num);
AKANTU_DEBUG_OUT();
return energy;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::onElementsAdded(const Array<Element> & element_list,
const NewElementsEvent & event) {
AKANTU_DEBUG_IN();
this->material_index.initialize(mesh, _element_kind = _ek_not_defined,
_with_nb_element = true,
_default_value = UInt(-1));
this->material_local_numbering.initialize(
mesh, _element_kind = _ek_not_defined, _with_nb_element = true,
_default_value = UInt(-1));
ElementTypeMapArray<UInt> filter("new_element_filter", this->getID(),
this->getMemoryID());
for (auto & elem : element_list) {
if (!filter.exists(elem.type, elem.ghost_type))
filter.alloc(0, 1, elem.type, elem.ghost_type);
filter(elem.type, elem.ghost_type).push_back(elem.element);
}
this->assignMaterialToElements(&filter);
for (auto & material : materials)
material->onElementsAdded(element_list, event);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::onElementsRemoved(
const Array<Element> & element_list,
const ElementTypeMapArray<UInt> & new_numbering,
const RemovedElementsEvent & event) {
for (auto & material : materials) {
material->onElementsRemoved(element_list, new_numbering, event);
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::onNodesAdded(const Array<UInt> & nodes_list,
const NewNodesEvent & event) {
AKANTU_DEBUG_IN();
UInt nb_nodes = mesh.getNbNodes();
if (displacement) {
displacement->resize(nb_nodes, 0.);
++displacement_release;
}
if (mass)
mass->resize(nb_nodes, 0.);
if (velocity)
velocity->resize(nb_nodes, 0.);
if (acceleration)
acceleration->resize(nb_nodes, 0.);
if (external_force)
external_force->resize(nb_nodes, 0.);
if (internal_force)
internal_force->resize(nb_nodes, 0.);
if (blocked_dofs)
blocked_dofs->resize(nb_nodes, 0.);
if (current_position)
current_position->resize(nb_nodes, 0.);
if (previous_displacement)
previous_displacement->resize(nb_nodes, 0.);
if (displacement_increment)
displacement_increment->resize(nb_nodes, 0.);
for (auto & material : materials) {
material->onNodesAdded(nodes_list, event);
}
need_to_reassemble_lumped_mass = true;
need_to_reassemble_mass = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::onNodesRemoved(const Array<UInt> & /*element_list*/,
const Array<UInt> & new_numbering,
const RemovedNodesEvent & /*event*/) {
if (displacement) {
mesh.removeNodesFromArray(*displacement, new_numbering);
++displacement_release;
}
if (mass)
mesh.removeNodesFromArray(*mass, new_numbering);
if (velocity)
mesh.removeNodesFromArray(*velocity, new_numbering);
if (acceleration)
mesh.removeNodesFromArray(*acceleration, new_numbering);
if (internal_force)
mesh.removeNodesFromArray(*internal_force, new_numbering);
if (external_force)
mesh.removeNodesFromArray(*external_force, new_numbering);
if (blocked_dofs)
mesh.removeNodesFromArray(*blocked_dofs, new_numbering);
// if (increment_acceleration)
// mesh.removeNodesFromArray(*increment_acceleration, new_numbering);
if (displacement_increment)
mesh.removeNodesFromArray(*displacement_increment, new_numbering);
if (previous_displacement)
mesh.removeNodesFromArray(*previous_displacement, new_numbering);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::printself(std::ostream & stream, int indent) const {
std::string space(indent, AKANTU_INDENT);
stream << space << "Solid Mechanics Model [" << std::endl;
stream << space << " + id : " << id << std::endl;
stream << space << " + spatial dimension : " << Model::spatial_dimension
<< std::endl;
stream << space << " + fem [" << std::endl;
getFEEngine().printself(stream, indent + 2);
stream << space << " ]" << std::endl;
stream << space << " + nodals information [" << std::endl;
displacement->printself(stream, indent + 2);
if (velocity)
velocity->printself(stream, indent + 2);
if (acceleration)
acceleration->printself(stream, indent + 2);
if (mass)
mass->printself(stream, indent + 2);
external_force->printself(stream, indent + 2);
internal_force->printself(stream, indent + 2);
blocked_dofs->printself(stream, indent + 2);
stream << space << " ]" << std::endl;
stream << space << " + material information [" << std::endl;
material_index.printself(stream, indent + 2);
stream << space << " ]" << std::endl;
stream << space << " + materials [" << std::endl;
for (auto & material : materials)
material->printself(stream, indent + 2);
stream << space << " ]" << std::endl;
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::initializeNonLocal() {
this->non_local_manager->synchronize(*this, SynchronizationTag::_material_id);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::insertIntegrationPointsInNeighborhoods(
const GhostType & ghost_type) {
for (auto & mat : materials) {
MaterialNonLocalInterface * mat_non_local;
if ((mat_non_local =
dynamic_cast<MaterialNonLocalInterface *>(mat.get())) == nullptr)
continue;
ElementTypeMapArray<Real> quadrature_points_coordinates(
"quadrature_points_coordinates_tmp_nl", this->id, this->memory_id);
quadrature_points_coordinates.initialize(this->getFEEngine(),
_nb_component = spatial_dimension,
_ghost_type = ghost_type);
for (auto & type : quadrature_points_coordinates.elementTypes(
Model::spatial_dimension, ghost_type)) {
this->getFEEngine().computeIntegrationPointsCoordinates(
quadrature_points_coordinates(type, ghost_type), type, ghost_type);
}
mat_non_local->initMaterialNonLocal();
mat_non_local->insertIntegrationPointsInNeighborhoods(
ghost_type, quadrature_points_coordinates);
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::computeNonLocalStresses(
const GhostType & ghost_type) {
for (auto & mat : materials) {
if (not aka::is_of_type<MaterialNonLocalInterface>(*mat))
continue;
auto & mat_non_local = dynamic_cast<MaterialNonLocalInterface &>(*mat);
mat_non_local.computeNonLocalStresses(ghost_type);
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::updateLocalInternal(
ElementTypeMapReal & internal_flat, const GhostType & ghost_type,
const ElementKind & kind) {
const ID field_name = internal_flat.getName();
for (auto & material : materials) {
if (material->isInternal<Real>(field_name, kind))
material->flattenInternal(field_name, internal_flat, ghost_type, kind);
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::updateNonLocalInternal(
ElementTypeMapReal & internal_flat, const GhostType & ghost_type,
const ElementKind & kind) {
const ID field_name = internal_flat.getName();
for (auto & mat : materials) {
if (not aka::is_of_type<MaterialNonLocalInterface>(*mat))
continue;
- auto & mat_non_local = dynamic_cast<MaterialNonLocalInterface&>(*mat);
+ auto & mat_non_local = dynamic_cast<MaterialNonLocalInterface &>(*mat);
mat_non_local.updateNonLocalInternals(internal_flat, field_name, ghost_type,
kind);
}
}
/* -------------------------------------------------------------------------- */
FEEngine & SolidMechanicsModel::getFEEngineBoundary(const ID & name) {
return getFEEngineClassBoundary<MyFEEngineType>(name);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::splitElementByMaterial(
const Array<Element> & elements,
std::vector<Array<Element>> & elements_per_mat) const {
for (const auto & el : elements) {
Element mat_el = el;
mat_el.element = this->material_local_numbering(el);
elements_per_mat[this->material_index(el)].push_back(mat_el);
}
}
/* -------------------------------------------------------------------------- */
UInt SolidMechanicsModel::getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
UInt nb_nodes_per_element = 0;
for (const Element & el : elements) {
nb_nodes_per_element += Mesh::getNbNodesPerElement(el.type);
}
switch (tag) {
case SynchronizationTag::_material_id: {
size += elements.size() * sizeof(UInt);
break;
}
case SynchronizationTag::_smm_mass: {
size += nb_nodes_per_element * sizeof(Real) *
Model::spatial_dimension; // mass vector
break;
}
case SynchronizationTag::_smm_for_gradu: {
size += nb_nodes_per_element * Model::spatial_dimension *
sizeof(Real); // displacement
break;
}
case SynchronizationTag::_smm_boundary: {
// force, displacement, boundary
size += nb_nodes_per_element * Model::spatial_dimension *
(2 * sizeof(Real) + sizeof(bool));
break;
}
case SynchronizationTag::_for_dump: {
// displacement, velocity, acceleration, residual, force
size += nb_nodes_per_element * Model::spatial_dimension * sizeof(Real) * 5;
break;
}
default: {}
}
if (tag != SynchronizationTag::_material_id) {
splitByMaterial(elements, [&](auto && mat, auto && elements) {
size += mat.getNbData(elements, tag);
});
}
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
switch (tag) {
case SynchronizationTag::_material_id: {
this->packElementalDataHelper(material_index, buffer, elements, false,
getFEEngine());
break;
}
case SynchronizationTag::_smm_mass: {
packNodalDataHelper(*mass, buffer, elements, mesh);
break;
}
case SynchronizationTag::_smm_for_gradu: {
packNodalDataHelper(*displacement, buffer, elements, mesh);
break;
}
case SynchronizationTag::_for_dump: {
packNodalDataHelper(*displacement, buffer, elements, mesh);
packNodalDataHelper(*velocity, buffer, elements, mesh);
packNodalDataHelper(*acceleration, buffer, elements, mesh);
packNodalDataHelper(*internal_force, buffer, elements, mesh);
packNodalDataHelper(*external_force, buffer, elements, mesh);
break;
}
case SynchronizationTag::_smm_boundary: {
packNodalDataHelper(*external_force, buffer, elements, mesh);
packNodalDataHelper(*velocity, buffer, elements, mesh);
packNodalDataHelper(*blocked_dofs, buffer, elements, mesh);
break;
}
default: {}
}
if (tag != SynchronizationTag::_material_id) {
splitByMaterial(elements, [&](auto && mat, auto && elements) {
mat.packData(buffer, elements, tag);
});
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
switch (tag) {
case SynchronizationTag::_material_id: {
for (auto && element : elements) {
UInt recv_mat_index;
buffer >> recv_mat_index;
UInt & mat_index = material_index(element);
if (mat_index != UInt(-1))
continue;
// add ghosts element to the correct material
mat_index = recv_mat_index;
UInt index = materials[mat_index]->addElement(element);
material_local_numbering(element) = index;
}
break;
}
case SynchronizationTag::_smm_mass: {
unpackNodalDataHelper(*mass, buffer, elements, mesh);
break;
}
case SynchronizationTag::_smm_for_gradu: {
unpackNodalDataHelper(*displacement, buffer, elements, mesh);
break;
}
case SynchronizationTag::_for_dump: {
unpackNodalDataHelper(*displacement, buffer, elements, mesh);
unpackNodalDataHelper(*velocity, buffer, elements, mesh);
unpackNodalDataHelper(*acceleration, buffer, elements, mesh);
unpackNodalDataHelper(*internal_force, buffer, elements, mesh);
unpackNodalDataHelper(*external_force, buffer, elements, mesh);
break;
}
case SynchronizationTag::_smm_boundary: {
unpackNodalDataHelper(*external_force, buffer, elements, mesh);
unpackNodalDataHelper(*velocity, buffer, elements, mesh);
unpackNodalDataHelper(*blocked_dofs, buffer, elements, mesh);
break;
}
default: {}
}
if (tag != SynchronizationTag::_material_id) {
splitByMaterial(elements, [&](auto && mat, auto && elements) {
mat.unpackData(buffer, elements, tag);
});
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
UInt SolidMechanicsModel::getNbData(const Array<UInt> & dofs,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
// UInt nb_nodes = mesh.getNbNodes();
switch (tag) {
case SynchronizationTag::_smm_uv: {
size += sizeof(Real) * Model::spatial_dimension * 2;
break;
}
case SynchronizationTag::_smm_res: {
size += sizeof(Real) * Model::spatial_dimension;
break;
}
case SynchronizationTag::_smm_mass: {
size += sizeof(Real) * Model::spatial_dimension;
break;
}
case SynchronizationTag::_for_dump: {
size += sizeof(Real) * Model::spatial_dimension * 5;
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
AKANTU_DEBUG_OUT();
return size * dofs.size();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::packData(CommunicationBuffer & buffer,
const Array<UInt> & dofs,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
switch (tag) {
case SynchronizationTag::_smm_uv: {
packDOFDataHelper(*displacement, buffer, dofs);
packDOFDataHelper(*velocity, buffer, dofs);
break;
}
case SynchronizationTag::_smm_res: {
packDOFDataHelper(*internal_force, buffer, dofs);
break;
}
case SynchronizationTag::_smm_mass: {
packDOFDataHelper(*mass, buffer, dofs);
break;
}
case SynchronizationTag::_for_dump: {
packDOFDataHelper(*displacement, buffer, dofs);
packDOFDataHelper(*velocity, buffer, dofs);
packDOFDataHelper(*acceleration, buffer, dofs);
packDOFDataHelper(*internal_force, buffer, dofs);
packDOFDataHelper(*external_force, buffer, dofs);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::unpackData(CommunicationBuffer & buffer,
const Array<UInt> & dofs,
const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
switch (tag) {
case SynchronizationTag::_smm_uv: {
unpackDOFDataHelper(*displacement, buffer, dofs);
unpackDOFDataHelper(*velocity, buffer, dofs);
break;
}
case SynchronizationTag::_smm_res: {
unpackDOFDataHelper(*internal_force, buffer, dofs);
break;
}
case SynchronizationTag::_smm_mass: {
unpackDOFDataHelper(*mass, buffer, dofs);
break;
}
case SynchronizationTag::_for_dump: {
unpackDOFDataHelper(*displacement, buffer, dofs);
unpackDOFDataHelper(*velocity, buffer, dofs);
unpackDOFDataHelper(*acceleration, buffer, dofs);
unpackDOFDataHelper(*internal_force, buffer, dofs);
unpackDOFDataHelper(*external_force, buffer, dofs);
break;
}
default: { AKANTU_ERROR("Unknown ghost synchronization tag : " << tag); }
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model.hh b/src/model/solid_mechanics/solid_mechanics_model.hh
index 851b621de..2161a7469 100644
--- a/src/model/solid_mechanics/solid_mechanics_model.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model.hh
@@ -1,567 +1,567 @@
/**
* @file solid_mechanics_model.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jul 27 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Model of Solid Mechanics
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "boundary_condition.hh"
#include "data_accessor.hh"
#include "fe_engine.hh"
#include "model.hh"
#include "non_local_manager_callback.hh"
#include "solid_mechanics_model_event_handler.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLID_MECHANICS_MODEL_HH__
#define __AKANTU_SOLID_MECHANICS_MODEL_HH__
namespace akantu {
class Material;
class MaterialSelector;
class DumperIOHelper;
class NonLocalManager;
template <ElementKind kind, class IntegrationOrderFunctor>
class IntegratorGauss;
template <ElementKind kind> class ShapeLagrange;
} // namespace akantu
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
class SolidMechanicsModel
: public Model,
public DataAccessor<Element>,
public DataAccessor<UInt>,
public BoundaryCondition<SolidMechanicsModel>,
public NonLocalManagerCallback,
public EventHandlerManager<SolidMechanicsModelEventHandler> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
class NewMaterialElementsEvent : public NewElementsEvent {
public:
AKANTU_GET_MACRO_NOT_CONST(MaterialList, material, Array<UInt> &);
AKANTU_GET_MACRO(MaterialList, material, const Array<UInt> &);
protected:
Array<UInt> material;
};
using MyFEEngineType = FEEngineTemplate<IntegratorGauss, ShapeLagrange>;
protected:
using EventManager = EventHandlerManager<SolidMechanicsModelEventHandler>;
public:
SolidMechanicsModel(
Mesh & mesh, UInt spatial_dimension = _all_dimensions,
const ID & id = "solid_mechanics_model", const MemoryID & memory_id = 0,
std::shared_ptr<DOFManager> dof_manager = nullptr,
const ModelType model_type = ModelType::_solid_mechanics_model);
~SolidMechanicsModel() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
protected:
/// initialize completely the model
void initFullImpl(
const ModelOptions & options = SolidMechanicsModelOptions()) override;
/// initialize all internal arrays for materials
virtual void initMaterials();
/// initialize the model
void initModel() override;
/// function to print the containt of the class
void printself(std::ostream & stream, int indent = 0) const override;
/// get some default values for derived classes
std::tuple<ID, TimeStepSolverType>
getDefaultSolverID(const AnalysisMethod & method) override;
/* ------------------------------------------------------------------------ */
/* Solver interface */
/* ------------------------------------------------------------------------ */
public:
/// assembles the stiffness matrix,
virtual void assembleStiffnessMatrix();
/// assembles the internal forces in the array internal_forces
virtual void assembleInternalForces();
protected:
/// callback for the solver, this adds f_{ext} - f_{int} to the residual
void assembleResidual() override;
/// callback for the solver, this adds f_{ext} or f_{int} to the residual
void assembleResidual(const ID & residual_part) override;
bool canSplitResidual() override { return true; }
/// get the type of matrix needed
MatrixType getMatrixType(const ID & matrix_id) override;
/// callback for the solver, this assembles different matrices
void assembleMatrix(const ID & matrix_id) override;
/// callback for the solver, this assembles the stiffness matrix
void assembleLumpedMatrix(const ID & matrix_id) override;
/// callback for the solver, this is called at beginning of solve
void predictor() override;
/// callback for the solver, this is called at end of solve
void corrector() override;
/// callback for the solver, this is called at beginning of solve
void beforeSolveStep() override;
/// callback for the solver, this is called at end of solve
void afterSolveStep() override;
/// Callback for the model to instantiate the matricees when needed
void initSolver(TimeStepSolverType time_step_solver_type,
NonLinearSolverType non_linear_solver_type) override;
protected:
/* ------------------------------------------------------------------------ */
TimeStepSolverType getDefaultSolverType() const override;
/* ------------------------------------------------------------------------ */
ModelSolverOptions
getDefaultSolverOptions(const TimeStepSolverType & type) const override;
public:
bool isDefaultSolverExplicit() {
return method == _explicit_lumped_mass ||
method == _explicit_consistent_mass;
}
protected:
/// update the current position vector
void updateCurrentPosition();
/* ------------------------------------------------------------------------ */
/* Materials (solid_mechanics_model_material.cc) */
/* ------------------------------------------------------------------------ */
public:
/// register an empty material of a given type
Material & registerNewMaterial(const ID & mat_name, const ID & mat_type,
const ID & opt_param);
/// reassigns materials depending on the material selector
virtual void reassignMaterial();
/// applya constant eigen_grad_u on all quadrature points of a given material
virtual void applyEigenGradU(const Matrix<Real> & prescribed_eigen_grad_u,
const ID & material_name,
const GhostType ghost_type = _not_ghost);
protected:
/// register a material in the dynamic database
Material & registerNewMaterial(const ParserSection & mat_section);
/// read the material files to instantiate all the materials
void instantiateMaterials();
/// set the element_id_by_material and add the elements to the good materials
virtual void
assignMaterialToElements(const ElementTypeMapArray<UInt> * filter = nullptr);
/* ------------------------------------------------------------------------ */
/* Mass (solid_mechanics_model_mass.cc) */
/* ------------------------------------------------------------------------ */
public:
/// assemble the lumped mass matrix
void assembleMassLumped();
/// assemble the mass matrix for consistent mass resolutions
void assembleMass();
public:
/// assemble the lumped mass matrix for local and ghost elements
void assembleMassLumped(GhostType ghost_type);
/// assemble the mass matrix for either _ghost or _not_ghost elements
void assembleMass(GhostType ghost_type);
protected:
/// fill a vector of rho
void computeRho(Array<Real> & rho, ElementType type, GhostType ghost_type);
/// compute the kinetic energy
Real getKineticEnergy();
Real getKineticEnergy(const ElementType & type, UInt index);
/// compute the external work (for impose displacement, the velocity should be
/// given too)
Real getExternalWork();
/* ------------------------------------------------------------------------ */
/* NonLocalManager inherited members */
/* ------------------------------------------------------------------------ */
protected:
void initializeNonLocal() override;
void updateDataForNonLocalCriterion(ElementTypeMapReal & criterion) override;
void computeNonLocalStresses(const GhostType & ghost_type) override;
void
insertIntegrationPointsInNeighborhoods(const GhostType & ghost_type) override;
/// update the values of the non local internal
void updateLocalInternal(ElementTypeMapReal & internal_flat,
const GhostType & ghost_type,
const ElementKind & kind) override;
/// copy the results of the averaging in the materials
void updateNonLocalInternal(ElementTypeMapReal & internal_flat,
const GhostType & ghost_type,
const ElementKind & kind) override;
/* ------------------------------------------------------------------------ */
/* Data Accessor inherited members */
/* ------------------------------------------------------------------------ */
public:
UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const override;
void packData(CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const override;
void unpackData(CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) override;
UInt getNbData(const Array<UInt> & dofs,
const SynchronizationTag & tag) const override;
void packData(CommunicationBuffer & buffer, const Array<UInt> & dofs,
const SynchronizationTag & tag) const override;
void unpackData(CommunicationBuffer & buffer, const Array<UInt> & dofs,
const SynchronizationTag & tag) override;
protected:
void
splitElementByMaterial(const Array<Element> & elements,
std::vector<Array<Element>> & elements_per_mat) const;
template <typename Operation>
void splitByMaterial(const Array<Element> & elements, Operation && op) const;
/* ------------------------------------------------------------------------ */
/* Mesh Event Handler inherited members */
/* ------------------------------------------------------------------------ */
protected:
void onNodesAdded(const Array<UInt> & nodes_list,
const NewNodesEvent & event) override;
void onNodesRemoved(const Array<UInt> & element_list,
const Array<UInt> & new_numbering,
const RemovedNodesEvent & event) override;
void onElementsAdded(const Array<Element> & nodes_list,
const NewElementsEvent & event) override;
void onElementsRemoved(const Array<Element> & element_list,
const ElementTypeMapArray<UInt> & new_numbering,
const RemovedElementsEvent & event) override;
void onElementsChanged(const Array<Element> &, const Array<Element> &,
const ElementTypeMapArray<UInt> &,
const ChangedElementsEvent &) override{};
/* ------------------------------------------------------------------------ */
/* Dumpable interface (kept for convenience) and dumper relative functions */
/* ------------------------------------------------------------------------ */
public:
virtual void onDump();
//! decide wether a field is a material internal or not
bool isInternal(const std::string & field_name,
const ElementKind & element_kind);
//! give the amount of data per element
virtual ElementTypeMap<UInt>
getInternalDataPerElem(const std::string & field_name,
const ElementKind & kind);
//! flatten a given material internal field
ElementTypeMapArray<Real> &
flattenInternal(const std::string & field_name, const ElementKind & kind,
const GhostType ghost_type = _not_ghost);
//! flatten all the registered material internals
void flattenAllRegisteredInternals(const ElementKind & kind);
std::shared_ptr<dumper::Field>
createNodalFieldReal(const std::string & field_name,
const std::string & group_name,
bool padding_flag) override;
std::shared_ptr<dumper::Field>
createNodalFieldBool(const std::string & field_name,
const std::string & group_name,
bool padding_flag) override;
std::shared_ptr<dumper::Field>
createElementalField(const std::string & field_name,
const std::string & group_name, bool padding_flag,
const UInt & spatial_dimension,
const ElementKind & kind) override;
virtual void dump(const std::string & dumper_name);
virtual void dump(const std::string & dumper_name, UInt step);
virtual void dump(const std::string & dumper_name, Real time, UInt step);
void dump() override;
virtual void dump(UInt step);
virtual void dump(Real time, UInt step);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// return the dimension of the system space
AKANTU_GET_MACRO(SpatialDimension, Model::spatial_dimension, UInt);
/// set the value of the time step
void setTimeStep(Real time_step, const ID & solver_id = "") override;
/// get the value of the conversion from forces/ mass to acceleration
AKANTU_GET_MACRO(F_M2A, f_m2a, Real);
/// set the value of the conversion from forces/ mass to acceleration
AKANTU_SET_MACRO(F_M2A, f_m2a, Real);
/// get the SolidMechanicsModel::displacement vector
AKANTU_GET_MACRO(Displacement, *displacement, Array<Real> &);
/// get the SolidMechanicsModel::previous_displacement vector
AKANTU_GET_MACRO(PreviousDisplacement, *previous_displacement, Array<Real> &);
/// get the SolidMechanicsModel::current_position vector \warn only consistent
/// after a call to SolidMechanicsModel::updateCurrentPosition
const Array<Real> & getCurrentPosition();
/// get the SolidMechanicsModel::increment vector \warn only consistent if
AKANTU_GET_MACRO(Increment, *displacement_increment, Array<Real> &);
/// get the lumped SolidMechanicsModel::mass vector
AKANTU_GET_MACRO(Mass, *mass, Array<Real> &);
/// get the SolidMechanicsModel::velocity vector
AKANTU_GET_MACRO(Velocity, *velocity, Array<Real> &);
/// get the SolidMechanicsModel::acceleration vector, updated by
/// SolidMechanicsModel::updateAcceleration
AKANTU_GET_MACRO(Acceleration, *acceleration, Array<Real> &);
/// get the SolidMechanicsModel::external_force vector (external forces)
AKANTU_GET_MACRO(ExternalForce, *external_force, Array<Real> &);
/// get the SolidMechanicsModel::force vector (external forces)
Array<Real> & getForce() {
AKANTU_DEBUG_WARNING("getForce was maintained for backward compatibility, "
"use getExternalForce instead");
return *external_force;
}
/// get the SolidMechanicsModel::internal_force vector (internal forces)
AKANTU_GET_MACRO(InternalForce, *internal_force, Array<Real> &);
/// get the SolidMechanicsModel::blocked_dofs vector
AKANTU_GET_MACRO(BlockedDOFs, *blocked_dofs, Array<bool> &);
/// get an iterable on the materials
inline decltype(auto) getMaterials();
/// get an iterable on the materials
inline decltype(auto) getMaterials() const;
-
+
/// get a particular material (by material index)
inline Material & getMaterial(UInt mat_index);
/// get a particular material (by material index)
inline const Material & getMaterial(UInt mat_index) const;
/// get a particular material (by material name)
inline Material & getMaterial(const std::string & name);
/// get a particular material (by material name)
inline const Material & getMaterial(const std::string & name) const;
/// get a particular material id from is name
inline UInt getMaterialIndex(const std::string & name) const;
/// give the number of materials
inline UInt getNbMaterials() const { return materials.size(); }
/// give the material internal index from its id
Int getInternalIndexFromID(const ID & id) const;
/// compute the stable time step
Real getStableTimeStep();
/// get the energies
Real getEnergy(const std::string & energy_id);
/// compute the energy for energy
Real getEnergy(const std::string & energy_id, const ElementType & type,
UInt index);
AKANTU_GET_MACRO(MaterialByElement, material_index,
const ElementTypeMapArray<UInt> &);
AKANTU_GET_MACRO(MaterialLocalNumbering, material_local_numbering,
const ElementTypeMapArray<UInt> &);
/// vectors containing local material element index for each global element
/// index
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(MaterialByElement, material_index,
UInt);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(MaterialByElement, material_index, UInt);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(MaterialLocalNumbering,
material_local_numbering, UInt);
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(MaterialLocalNumbering,
material_local_numbering, UInt);
AKANTU_GET_MACRO_NOT_CONST(MaterialSelector, *material_selector,
MaterialSelector &);
AKANTU_SET_MACRO(MaterialSelector, material_selector,
std::shared_ptr<MaterialSelector>);
/// Access the non_local_manager interface
AKANTU_GET_MACRO(NonLocalManager, *non_local_manager, NonLocalManager &);
/// get the FEEngine object to integrate or interpolate on the boundary
FEEngine & getFEEngineBoundary(const ID & name = "") override;
protected:
friend class Material;
protected:
/// compute the stable time step
Real getStableTimeStep(const GhostType & ghost_type);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// conversion coefficient form force/mass to acceleration
Real f_m2a{1.0};
/// displacements array
Array<Real> * displacement{nullptr};
UInt displacement_release{0};
/// displacements array at the previous time step (used in finite deformation)
Array<Real> * previous_displacement{nullptr};
/// increment of displacement
Array<Real> * displacement_increment{nullptr};
/// lumped mass array
Array<Real> * mass{nullptr};
/// Check if materials need to recompute the mass array
bool need_to_reassemble_lumped_mass{true};
/// Check if materials need to recompute the mass matrix
bool need_to_reassemble_mass{true};
/// velocities array
Array<Real> * velocity{nullptr};
/// accelerations array
Array<Real> * acceleration{nullptr};
/// external forces array
Array<Real> * external_force{nullptr};
/// internal forces array
Array<Real> * internal_force{nullptr};
/// array specifing if a degree of freedom is blocked or not
Array<bool> * blocked_dofs{nullptr};
/// array of current position used during update residual
Array<Real> * current_position{nullptr};
UInt current_position_release{0};
/// Arrays containing the material index for each element
ElementTypeMapArray<UInt> material_index;
/// Arrays containing the position in the element filter of the material
/// (material's local numbering)
ElementTypeMapArray<UInt> material_local_numbering;
/// list of used materials
std::vector<std::unique_ptr<Material>> materials;
/// mapping between material name and material internal id
std::map<std::string, UInt> materials_names_to_id;
/// class defining of to choose a material
std::shared_ptr<MaterialSelector> material_selector;
/// tells if the material are instantiated
bool are_materials_instantiated{false};
using flatten_internal_map = std::map<std::pair<std::string, ElementKind>,
ElementTypeMapArray<Real> *>;
/// map a registered internals to be flattened for dump purposes
flatten_internal_map registered_internals;
/// non local manager
std::unique_ptr<NonLocalManager> non_local_manager;
};
/* -------------------------------------------------------------------------- */
namespace BC {
namespace Neumann {
using FromStress = FromHigherDim;
using FromTraction = FromSameDim;
} // namespace Neumann
} // namespace BC
} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "material.hh"
#include "parser.hh"
#include "solid_mechanics_model_inline_impl.cc"
#include "solid_mechanics_model_tmpl.hh"
/* -------------------------------------------------------------------------- */
#endif /* __AKANTU_SOLID_MECHANICS_MODEL_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.cc
index 467249bf4..cfdafb670 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.cc
@@ -1,543 +1,543 @@
/**
* @file fragment_manager.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Thu Jan 23 2014
* @date last modification: Tue Feb 20 2018
*
* @brief Group manager to handle fragments
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fragment_manager.hh"
#include "aka_iterators.hh"
#include "communicator.hh"
#include "element_synchronizer.hh"
#include "material_cohesive.hh"
#include "mesh_iterators.hh"
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <functional>
#include <numeric>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
FragmentManager::FragmentManager(SolidMechanicsModelCohesive & model,
bool dump_data, const ID & id,
const MemoryID & memory_id)
: GroupManager(model.getMesh(), id, memory_id), model(model),
mass_center(0, model.getSpatialDimension(), "mass_center"),
mass(0, model.getSpatialDimension(), "mass"),
velocity(0, model.getSpatialDimension(), "velocity"),
inertia_moments(0, model.getSpatialDimension(), "inertia_moments"),
principal_directions(
0, model.getSpatialDimension() * model.getSpatialDimension(),
"principal_directions"),
quad_coordinates("quad_coordinates", id),
mass_density("mass_density", id),
nb_elements_per_fragment(0, 1, "nb_elements_per_fragment"),
dump_data(dump_data) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
/// compute quadrature points' coordinates
quad_coordinates.initialize(mesh, _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension,
_ghost_type = _not_ghost);
// mesh.initElementTypeMapArray(quad_coordinates, spatial_dimension,
// spatial_dimension, _not_ghost);
model.getFEEngine().interpolateOnIntegrationPoints(model.getMesh().getNodes(),
quad_coordinates);
/// store mass density per quadrature point
mass_density.initialize(mesh, _spatial_dimension = spatial_dimension,
_ghost_type = _not_ghost);
// mesh.initElementTypeMapArray(mass_density, 1, spatial_dimension,
// _not_ghost);
storeMassDensityPerIntegrationPoint();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
class CohesiveElementFilter : public GroupManager::ClusteringFilter {
public:
CohesiveElementFilter(const SolidMechanicsModelCohesive & model,
const Real max_damage = 1.)
: model(model), is_unbroken(max_damage) {}
bool operator()(const Element & el) const override {
if (Mesh::getKind(el.type) == _ek_regular)
return true;
const Array<UInt> & mat_indexes =
model.getMaterialByElement(el.type, el.ghost_type);
const Array<UInt> & mat_loc_num =
model.getMaterialLocalNumbering(el.type, el.ghost_type);
const auto & mat = static_cast<const MaterialCohesive &>(
model.getMaterial(mat_indexes(el.element)));
UInt el_index = mat_loc_num(el.element);
UInt nb_quad_per_element =
model.getFEEngine("CohesiveFEEngine")
.getNbIntegrationPoints(el.type, el.ghost_type);
const Array<Real> & damage_array = mat.getDamage(el.type, el.ghost_type);
AKANTU_DEBUG_ASSERT(nb_quad_per_element * el_index < damage_array.size(),
"This quadrature point is out of range");
const Real * element_damage =
damage_array.storage() + nb_quad_per_element * el_index;
UInt unbroken_quads = std::count_if(
element_damage, element_damage + nb_quad_per_element, is_unbroken);
if (unbroken_quads > 0)
return true;
return false;
}
private:
struct IsUnbrokenFunctor {
IsUnbrokenFunctor(const Real & max_damage) : max_damage(max_damage) {}
bool operator()(const Real & x) { return x < max_damage; }
const Real max_damage;
};
const SolidMechanicsModelCohesive & model;
const IsUnbrokenFunctor is_unbroken;
};
/* -------------------------------------------------------------------------- */
void FragmentManager::buildFragments(Real damage_limit) {
AKANTU_DEBUG_IN();
ElementSynchronizer * cohesive_synchronizer =
const_cast<ElementSynchronizer *>(&model.getCohesiveSynchronizer());
if (cohesive_synchronizer) {
cohesive_synchronizer->synchronize(model, SynchronizationTag::_smmc_damage);
}
auto & mesh_facets = const_cast<Mesh &>(mesh.getMeshFacets());
UInt spatial_dimension = model.getSpatialDimension();
std::string fragment_prefix("fragment");
/// generate fragments
global_nb_fragment =
createClusters(spatial_dimension, mesh_facets, fragment_prefix,
CohesiveElementFilter(model, damage_limit));
nb_fragment = getNbElementGroups(spatial_dimension);
fragment_index.resize(nb_fragment);
/// loop over fragments
for (auto && data : zip(iterateElementGroups(), fragment_index)) {
auto name = std::get<0>(data).getName();
/// get fragment index
std::string fragment_index_string = name.substr(fragment_prefix.size() + 1);
std::get<1>(data) = std::stoul(fragment_index_string);
}
/// compute fragments' mass
computeMass();
if (dump_data) {
createDumpDataArray(fragment_index, "fragments", true);
createDumpDataArray(mass, "fragments mass");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::computeMass() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
/// create a unit field per quadrature point, since to compute mass
/// it's neccessary to integrate only density
ElementTypeMapArray<Real> unit_field("unit_field", id);
unit_field.initialize(model.getFEEngine(), _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension,
_ghost_type = _not_ghost, _default_value = 1.);
integrateFieldOnFragments(unit_field, mass);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::computeCenterOfMass() {
AKANTU_DEBUG_IN();
/// integrate position multiplied by density
integrateFieldOnFragments(quad_coordinates, mass_center);
/// divide it by the fragments' mass
Real * mass_storage = mass.storage();
Real * mass_center_storage = mass_center.storage();
UInt total_components = mass_center.size() * mass_center.getNbComponent();
for (UInt i = 0; i < total_components; ++i)
mass_center_storage[i] /= mass_storage[i];
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::computeVelocity() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
/// compute velocity per quadrature point
ElementTypeMapArray<Real> velocity_field("velocity_field", id);
velocity_field.initialize(
model.getFEEngine(), _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension, _ghost_type = _not_ghost);
model.getFEEngine().interpolateOnIntegrationPoints(model.getVelocity(),
velocity_field);
/// integrate on fragments
integrateFieldOnFragments(velocity_field, velocity);
/// divide it by the fragments' mass
Real * mass_storage = mass.storage();
Real * velocity_storage = velocity.storage();
UInt total_components = velocity.size() * velocity.getNbComponent();
for (UInt i = 0; i < total_components; ++i)
velocity_storage[i] /= mass_storage[i];
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/**
* Given the distance @f$ \mathbf{r} @f$ between a quadrature point
* and its center of mass, the moment of inertia is computed as \f[
* I_\mathrm{CM} = \mathrm{tr}(\mathbf{r}\mathbf{r}^\mathrm{T})
* \mathbf{I} - \mathbf{r}\mathbf{r}^\mathrm{T} \f] for more
* information check Wikipedia
* (http://en.wikipedia.org/wiki/Moment_of_inertia#Identities_for_a_skew-symmetric_matrix)
*
*/
void FragmentManager::computeInertiaMoments() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
computeCenterOfMass();
/// compute local coordinates products with respect to the center of match
ElementTypeMapArray<Real> moments_coords("moments_coords", id);
moments_coords.initialize(model.getFEEngine(),
_nb_component =
spatial_dimension * spatial_dimension,
_spatial_dimension = spatial_dimension,
_ghost_type = _not_ghost, _default_value = 1.);
/// loop over fragments
for (auto && data :
zip(iterateElementGroups(), make_view(mass_center, spatial_dimension))) {
const auto & el_list = std::get<0>(data).getElements();
auto & mass_center = std::get<1>(data);
/// loop over elements of the fragment
for (auto type :
el_list.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
auto nb_quad_per_element =
model.getFEEngine().getNbIntegrationPoints(type);
auto & moments_coords_array = moments_coords(type);
const auto & quad_coordinates_array = quad_coordinates(type);
const auto & el_list_array = el_list(type);
auto moments_begin =
moments_coords_array.begin(spatial_dimension, spatial_dimension);
auto quad_coordinates_begin =
quad_coordinates_array.begin(spatial_dimension);
Vector<Real> relative_coords(spatial_dimension);
for (UInt el = 0; el < el_list_array.size(); ++el) {
UInt global_el = el_list_array(el);
/// loop over quadrature points
for (UInt q = 0; q < nb_quad_per_element; ++q) {
UInt global_q = global_el * nb_quad_per_element + q;
Matrix<Real> moments_matrix = moments_begin[global_q];
const Vector<Real> & quad_coord_vector =
quad_coordinates_begin[global_q];
/// to understand this read the documentation written just
/// before this function
relative_coords = quad_coord_vector;
relative_coords -= mass_center;
moments_matrix.outerProduct(relative_coords, relative_coords);
Real trace = moments_matrix.trace();
moments_matrix *= -1.;
moments_matrix += Matrix<Real>::eye(spatial_dimension, trace);
}
}
}
}
/// integrate moments
Array<Real> integrated_moments(global_nb_fragment,
spatial_dimension * spatial_dimension);
integrateFieldOnFragments(moments_coords, integrated_moments);
/// compute and store principal moments
inertia_moments.resize(global_nb_fragment);
principal_directions.resize(global_nb_fragment);
auto integrated_moments_it =
integrated_moments.begin(spatial_dimension, spatial_dimension);
auto inertia_moments_it = inertia_moments.begin(spatial_dimension);
auto principal_directions_it =
principal_directions.begin(spatial_dimension, spatial_dimension);
for (UInt frag = 0; frag < global_nb_fragment; ++frag,
++integrated_moments_it, ++inertia_moments_it,
++principal_directions_it) {
integrated_moments_it->eig(*inertia_moments_it, *principal_directions_it);
}
if (dump_data)
createDumpDataArray(inertia_moments, "moments of inertia");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::computeAllData() {
AKANTU_DEBUG_IN();
buildFragments();
computeVelocity();
computeInertiaMoments();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::storeMassDensityPerIntegrationPoint() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
for (auto type : mesh.elementTypes(_spatial_dimension = spatial_dimension,
_element_kind = _ek_regular)) {
Array<Real> & mass_density_array = mass_density(type);
UInt nb_element = mesh.getNbElement(type);
UInt nb_quad_per_element = model.getFEEngine().getNbIntegrationPoints(type);
mass_density_array.resize(nb_element * nb_quad_per_element);
const Array<UInt> & mat_indexes = model.getMaterialByElement(type);
Real * mass_density_it = mass_density_array.storage();
/// store mass_density for each element and quadrature point
for (UInt el = 0; el < nb_element; ++el) {
Material & mat = model.getMaterial(mat_indexes(el));
for (UInt q = 0; q < nb_quad_per_element; ++q, ++mass_density_it)
*mass_density_it = mat.getRho();
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::integrateFieldOnFragments(
ElementTypeMapArray<Real> & field, Array<Real> & output) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
UInt nb_component = output.getNbComponent();
/// integration part
output.resize(global_nb_fragment);
output.clear();
auto output_begin = output.begin(nb_component);
/// loop over fragments
for (auto && data : zip(iterateElementGroups(), fragment_index)) {
const auto & el_list = std::get<0>(data).getElements();
auto fragment_index = std::get<1>(data);
/// loop over elements of the fragment
for (auto type :
el_list.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
UInt nb_quad_per_element =
model.getFEEngine().getNbIntegrationPoints(type);
const Array<Real> & density_array = mass_density(type);
Array<Real> & field_array = field(type);
const Array<UInt> & elements = el_list(type);
/// generate array to be integrated by filtering fragment's elements
Array<Real> integration_array(elements.size() * nb_quad_per_element,
nb_component);
- auto field_array_begin =
- field_array.begin_reinterpret(nb_quad_per_element, nb_component,
- field_array.size() /
- nb_quad_per_element);
+ auto field_array_begin = field_array.begin_reinterpret(
+ nb_quad_per_element, nb_component,
+ field_array.size() / nb_quad_per_element);
auto density_array_begin = density_array.begin_reinterpret(
nb_quad_per_element, density_array.size() / nb_quad_per_element);
- for(auto && data : enumerate(make_view(integration_array, nb_quad_per_element, nb_component))) {
+ for (auto && data : enumerate(make_view(
+ integration_array, nb_quad_per_element, nb_component))) {
UInt global_el = elements(std::get<0>(data));
auto & int_array = std::get<1>(data);
int_array = field_array_begin[global_el];
/// multiply field by density
const Vector<Real> & density_vector = density_array_begin[global_el];
for (UInt i = 0; i < nb_quad_per_element; ++i) {
for (UInt j = 0; j < nb_component; ++j) {
int_array(i, j) *= density_vector(i);
}
}
}
/// integrate the field over the fragment
Array<Real> integrated_array(elements.size(), nb_component);
model.getFEEngine().integrate(integration_array, integrated_array,
nb_component, type, _not_ghost, elements);
/// sum over all elements and store the result
Vector<Real> output_tmp(output_begin[fragment_index]);
output_tmp += std::accumulate(integrated_array.begin(nb_component),
integrated_array.end(nb_component),
Vector<Real>(nb_component));
}
}
/// sum output over all processors
const Communicator & comm = mesh.getCommunicator();
comm.allReduce(output, SynchronizerOperation::_sum);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void FragmentManager::computeNbElementsPerFragment() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = model.getSpatialDimension();
nb_elements_per_fragment.resize(global_nb_fragment);
nb_elements_per_fragment.clear();
/// loop over fragments
for (auto && data : zip(iterateElementGroups(), fragment_index)) {
const auto & el_list = std::get<0>(data).getElements();
auto fragment_index = std::get<1>(data);
/// loop over elements of the fragment
for (auto type :
el_list.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
UInt nb_element = el_list(type).size();
nb_elements_per_fragment(fragment_index) += nb_element;
}
}
/// sum values over all processors
const auto & comm = mesh.getCommunicator();
comm.allReduce(nb_elements_per_fragment, SynchronizerOperation::_sum);
if (dump_data)
createDumpDataArray(nb_elements_per_fragment, "elements per fragment");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void FragmentManager::createDumpDataArray(Array<T> & data, std::string name,
bool fragment_index_output) {
AKANTU_DEBUG_IN();
if (data.size() == 0)
return;
auto & mesh_not_const = const_cast<Mesh &>(mesh);
auto && spatial_dimension = mesh.getSpatialDimension();
auto && nb_component = data.getNbComponent();
auto && data_begin = data.begin(nb_component);
-
+
/// loop over fragments
- for (auto && data : zip(iterateElementGroups(), fragment_index)) {
+ for (auto && data : zip(iterateElementGroups(), fragment_index)) {
const auto & fragment = std::get<0>(data);
auto fragment_idx = std::get<1>(data);
/// loop over cluster types
for (auto & type : fragment.elementTypes(spatial_dimension)) {
/// init mesh data
auto & mesh_data = mesh_not_const.getDataPointer<T>(
name, type, _not_ghost, nb_component);
auto mesh_data_begin = mesh_data.begin(nb_component);
/// fill mesh data
for (const auto & elem : fragment.getElements(type)) {
Vector<T> md_tmp = mesh_data_begin[elem];
if (fragment_index_output) {
md_tmp(0) = fragment_idx;
} else {
md_tmp = data_begin[fragment_idx];
}
}
}
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.hh
index eaf2025f7..29f56aa81 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/fragment_manager.hh
@@ -1,169 +1,169 @@
/**
* @file fragment_manager.hh
*
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Thu Jan 23 2014
* @date last modification: Thu Jul 06 2017
*
* @brief Group manager to handle fragments
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "group_manager.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_FRAGMENT_MANAGER_HH__
#define __AKANTU_FRAGMENT_MANAGER_HH__
namespace akantu {
class SolidMechanicsModelCohesive;
}
namespace akantu {
/* -------------------------------------------------------------------------- */
class FragmentManager : public GroupManager {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
FragmentManager(SolidMechanicsModelCohesive & model, bool dump_data = true,
const ID & id = "fragment_manager",
const MemoryID & memory_id = 0);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
private:
/// store mass density per integration point
void storeMassDensityPerIntegrationPoint();
/// integrate an elemental field multiplied by density on global
/// fragments
void integrateFieldOnFragments(ElementTypeMapArray<Real> & field,
Array<Real> & output);
/// compute fragments' mass
void computeMass();
/// create dump data for a single array
template <typename T>
void createDumpDataArray(Array<T> & data, std::string name,
bool fragment_index_output = false);
public:
/// build fragment list (cohesive elements are considered broken if
/// damage >= damage_limit)
void buildFragments(Real damage_limit = 1.);
/// compute fragments' center of mass
void computeCenterOfMass();
/// compute fragments' velocity
void computeVelocity();
/// computes principal moments of inertia with respect to the center
/// of mass of each fragment
void computeInertiaMoments();
/// compute all fragments' data
void computeAllData();
/// compute number of elements per fragment
void computeNbElementsPerFragment();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get number of fragments
AKANTU_GET_MACRO(NbFragment, global_nb_fragment, UInt);
/// get fragments' mass
AKANTU_GET_MACRO(Mass, mass, const Array<Real> &);
/// get fragments' center of mass
AKANTU_GET_MACRO(CenterOfMass, mass_center, const Array<Real> &);
/// get fragments' velocity
AKANTU_GET_MACRO(Velocity, velocity, const Array<Real> &);
/// get fragments' principal moments of inertia
AKANTU_GET_MACRO(MomentsOfInertia, inertia_moments, const Array<Real> &);
/// get fragments' principal directions
AKANTU_GET_MACRO(PrincipalDirections, principal_directions,
const Array<Real> &);
/// get number of elements per fragment
AKANTU_GET_MACRO(NbElementsPerFragment, nb_elements_per_fragment,
const Array<UInt> &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// local_fragment index
Array<UInt> fragment_index;
/// global number of fragments (parallel simulations)
UInt global_nb_fragment;
/// number of fragments
UInt nb_fragment;
/// cohesive solid mechanics model associated
SolidMechanicsModelCohesive & model;
/// fragments' center of mass
Array<Real> mass_center;
/// fragments' mass
Array<Real> mass;
/// fragments' velocity
Array<Real> velocity;
/// fragments' principal moments of inertia with respect to the
/// center of mass
Array<Real> inertia_moments;
/// fragments' principal directions
Array<Real> principal_directions;
/// quadrature points' coordinates
ElementTypeMapArray<Real> quad_coordinates;
/// mass density per quadrature point
ElementTypeMapArray<Real> mass_density;
/// fragment filter
Array<UInt> nb_elements_per_fragment;
/// dump data
bool dump_data;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_FRAGMENT_MANAGER_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/material_selector_cohesive.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/material_selector_cohesive.hh
index a6ef7c4ed..eb4951c54 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/material_selector_cohesive.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/material_selector_cohesive.hh
@@ -1,99 +1,99 @@
/**
* @file material_selector_cohesive.hh
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Dec 11 2015
* @date last modification: Mon Dec 18 2017
*
* @brief Material selectors for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_selector.hh"
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
namespace akantu {
class SolidMechanicsModelCohesive;
}
namespace akantu {
#ifndef __AKANTU_MATERIAL_SELECTOR_COHESIVE_HH__
#define __AKANTU_MATERIAL_SELECTOR_COHESIVE_HH__
/* -------------------------------------------------------------------------- */
/**
* class that assigns the first cohesive material by default to the
* cohesive elements
*/
class DefaultMaterialCohesiveSelector : public MaterialSelector {
public:
DefaultMaterialCohesiveSelector(const SolidMechanicsModelCohesive & model);
UInt operator()(const Element & element) override;
private:
const ElementTypeMapArray<UInt> & facet_material;
const Mesh & mesh;
};
/* -------------------------------------------------------------------------- */
/// To be used with intrinsic elements inserted along mesh physical surfaces
class MeshDataMaterialCohesiveSelector : public MaterialSelector {
public:
MeshDataMaterialCohesiveSelector(const SolidMechanicsModelCohesive & model);
UInt operator()(const Element & element) override;
protected:
const SolidMechanicsModelCohesive & model;
const Mesh & mesh_facets;
const ElementTypeMapArray<std::string> & material_index;
bool third_dimension;
};
/// bulk1, bulk2 -> cohesive
using MaterialCohesiveRules = std::map<std::pair<ID, ID>, ID>;
/* -------------------------------------------------------------------------- */
class MaterialCohesiveRulesSelector : public MaterialSelector {
public:
MaterialCohesiveRulesSelector(const SolidMechanicsModelCohesive & model,
const MaterialCohesiveRules & rules,
ID mesh_data_id = "physical_names");
UInt operator()(const Element & element);
private:
const SolidMechanicsModelCohesive & model;
ID mesh_data_id;
const Mesh & mesh;
const Mesh & mesh_facets;
UInt spatial_dimension;
MaterialCohesiveRules rules;
};
#endif /* __AKANTU_MATERIAL_SELECTOR_COHESIVE_HH__ */
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field.hh
index c67ea80fd..1ac12f425 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field.hh
@@ -1,67 +1,67 @@
/**
* @file cohesive_internal_field.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Internal field for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "internal_field.hh"
#ifndef __AKANTU_COHESIVE_INTERNAL_FIELD_HH__
#define __AKANTU_COHESIVE_INTERNAL_FIELD_HH__
namespace akantu {
/// internal field class for cohesive materials
template <typename T> class CohesiveInternalField : public InternalField<T> {
public:
CohesiveInternalField(const ID & id, Material & material);
~CohesiveInternalField() override;
/// initialize the field to a given number of component
void initialize(UInt nb_component) override;
private:
CohesiveInternalField operator=(__attribute__((unused))
const CohesiveInternalField & other){};
};
/* -------------------------------------------------------------------------- */
/* Facet Internal Field */
/* -------------------------------------------------------------------------- */
template <typename T> class FacetInternalField : public InternalField<T> {
public:
FacetInternalField(const ID & id, Material & material);
~FacetInternalField() override;
/// initialize the field to a given number of component
void initialize(UInt nb_component) override;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_COHESIVE_INTERNAL_FIELD_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field_tmpl.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field_tmpl.hh
index 85c0794e6..e652ba1d1 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field_tmpl.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/cohesive_internal_field_tmpl.hh
@@ -1,95 +1,95 @@
/**
* @file cohesive_internal_field_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Nov 13 2013
* @date last modification: Wed Nov 08 2017
*
* @brief implementation of the cohesive internal field
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COHESIVE_INTERNAL_FIELD_TMPL_HH__
#define __AKANTU_COHESIVE_INTERNAL_FIELD_TMPL_HH__
namespace akantu {
template <typename T>
CohesiveInternalField<T>::CohesiveInternalField(const ID & id,
Material & material)
: InternalField<T>(
id, material, material.getModel().getFEEngine("CohesiveFEEngine"),
aka::as_type<MaterialCohesive>(material).getElementFilter()) {
this->element_kind = _ek_cohesive;
}
template <typename T>
CohesiveInternalField<T>::~CohesiveInternalField() = default;
template <typename T>
void CohesiveInternalField<T>::initialize(UInt nb_component) {
this->internalInitialize(nb_component);
}
/* -------------------------------------------------------------------------- */
template <typename T>
FacetInternalField<T>::FacetInternalField(const ID & id, Material & material)
: InternalField<T>(
id, material, material.getModel().getFEEngine("FacetsFEEngine"),
aka::as_type<MaterialCohesive>(material).getFacetFilter()) {
this->spatial_dimension -= 1;
this->element_kind = _ek_regular;
}
template <typename T> FacetInternalField<T>::~FacetInternalField() = default;
template <typename T>
void FacetInternalField<T>::initialize(UInt nb_component) {
this->internalInitialize(nb_component);
}
/* -------------------------------------------------------------------------- */
template <>
inline void
ParameterTyped<RandomInternalField<Real, FacetInternalField>>::setAuto(
const ParserParameter & in_param) {
Parameter::setAuto(in_param);
RandomParameter<Real> r = in_param;
param.setRandomDistribution(r);
}
/* -------------------------------------------------------------------------- */
template <>
inline void
ParameterTyped<RandomInternalField<Real, CohesiveInternalField>>::setAuto(
const ParserParameter & in_param) {
Parameter::setAuto(in_param);
RandomParameter<Real> r = in_param;
param.setRandomDistribution(r);
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_COHESIVE_INTERNAL_FIELD_TMPL_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_bilinear.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_bilinear.hh
index 5653bf663..0e525c9ba 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_bilinear.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_bilinear.hh
@@ -1,105 +1,105 @@
/**
* @file material_cohesive_bilinear.hh
*
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Bilinear cohesive constitutive law
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear.hh"
#ifndef __AKANTU_MATERIAL_COHESIVE_BILINEAR_HH__
#define __AKANTU_MATERIAL_COHESIVE_BILINEAR_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* Cohesive material bilinear
*
* parameters in the material files :
* - delta_0 : elastic limit displacement (default: 0)
* - sigma_c : critical stress sigma_c (default: 0)
* - beta : weighting parameter for sliding and normal opening (default:
* 0)
* - G_cI : fracture energy for mode I (default: 0)
* - G_cII : fracture energy for mode II (default: 0)
* - penalty : stiffness in compression to prevent penetration
*/
template <UInt spatial_dimension>
class MaterialCohesiveBilinear
: public MaterialCohesiveLinear<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialCohesiveBilinear(SolidMechanicsModel & model, const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the material computed parameter
void initMaterial() override;
/// set material parameters for new elements
void onElementsAdded(const Array<Element> & element_list,
const NewElementsEvent & event) override;
protected:
/// constitutive law
void computeTraction(const Array<Real> & normal, ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/**
* Scale traction sigma_c according to the volume of the
* two elements surrounding an element
*/
void scaleTraction(const Element & el, Vector<Real> & sigma_c_vec);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// elastic limit displacement
Real delta_0;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
//#include "material_cohesive_elastic_inline_impl.cc"
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_COHESIVE_BILINEAR_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.cc
index eaa8b5163..ed0d96a8b 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.cc
@@ -1,338 +1,341 @@
/**
* @file material_cohesive_exponential.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Mon Jul 09 2012
* @date last modification: Tue Feb 20 2018
*
* @brief Exponential irreversible cohesive law of mixed mode loading
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_exponential.hh"
#include "dof_synchronizer.hh"
#include "solid_mechanics_model.hh"
#include "sparse_matrix.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialCohesiveExponential<spatial_dimension>::MaterialCohesiveExponential(
SolidMechanicsModel & model, const ID & id)
: MaterialCohesive(model, id) {
AKANTU_DEBUG_IN();
this->registerParam("beta", beta, Real(0.), _pat_parsable, "Beta parameter");
this->registerParam("exponential_penalty", exp_penalty, true, _pat_parsable,
"Is contact penalty following the exponential law?");
this->registerParam(
"contact_tangent", contact_tangent, Real(1.0), _pat_parsable,
"Ratio of contact tangent over the initial exponential tangent");
// this->initInternalArray(delta_max, 1, _ek_cohesive);
use_previous_delta_max = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
MaterialCohesive::initMaterial();
if ((exp_penalty) && (contact_tangent != 1)) {
contact_tangent = 1;
AKANTU_DEBUG_WARNING("The parsed paramter <contact_tangent> is forced to "
"1.0 when the contact penalty follows the exponential "
"law");
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::computeTraction(
const Array<Real> & normal, ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// define iterators
auto traction_it = tractions(el_type, ghost_type).begin(spatial_dimension);
auto opening_it = opening(el_type, ghost_type).begin(spatial_dimension);
auto normal_it = normal.begin(spatial_dimension);
auto traction_end = tractions(el_type, ghost_type).end(spatial_dimension);
auto delta_max_it = delta_max(el_type, ghost_type).begin();
auto delta_max_prev_it = delta_max.previous(el_type, ghost_type).begin();
/// compute scalars
Real beta2 = beta * beta;
/// loop on each quadrature point
for (; traction_it != traction_end; ++traction_it, ++opening_it, ++normal_it,
++delta_max_it, ++delta_max_prev_it) {
/// compute normal and tangential opening vectors
Real normal_opening_norm = opening_it->dot(*normal_it);
Vector<Real> normal_opening(spatial_dimension);
normal_opening = (*normal_it);
normal_opening *= normal_opening_norm;
Vector<Real> tangential_opening(spatial_dimension);
tangential_opening = *opening_it;
tangential_opening -= normal_opening;
Real tangential_opening_norm = tangential_opening.norm();
/**
* compute effective opening displacement
* @f$ \delta = \sqrt{
* \beta^2 \Delta_t^2 + \Delta_n^2 } @f$
*/
Real delta = tangential_opening_norm;
delta *= delta * beta2;
delta += normal_opening_norm * normal_opening_norm;
delta = sqrt(delta);
if ((normal_opening_norm < 0) &&
(std::abs(normal_opening_norm) > Math::getTolerance())) {
Vector<Real> op_n(*normal_it);
op_n *= normal_opening_norm;
Vector<Real> delta_s(*opening_it);
delta_s -= op_n;
delta = tangential_opening_norm * beta;
computeCoupledTraction(*traction_it, *normal_it, delta, delta_s,
*delta_max_it, *delta_max_prev_it);
computeCompressiveTraction(*traction_it, *normal_it, normal_opening_norm,
*opening_it);
} else
computeCoupledTraction(*traction_it, *normal_it, delta, *opening_it,
*delta_max_it, *delta_max_prev_it);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::computeCoupledTraction(
Vector<Real> & tract, const Vector<Real> & normal, Real delta,
const Vector<Real> & opening, Real & delta_max_new, Real delta_max) {
AKANTU_DEBUG_IN();
/// full damage case
if (std::abs(delta) < Math::getTolerance()) {
/// set traction to zero
tract.clear();
} else { /// element not fully damaged
/**
* Compute traction loading @f$ \mathbf{T} =
* e \sigma_c \frac{\delta}{\delta_c} e^{-\delta/ \delta_c}@f$
*/
/**
* Compute traction unloading @f$ \mathbf{T} =
* \frac{t_{max}}{\delta_{max}} \delta @f$
*/
Real beta2 = beta * beta;
Real normal_open_norm = opening.dot(normal);
Vector<Real> op_n_n(spatial_dimension);
op_n_n = normal;
op_n_n *= (1 - beta2);
op_n_n *= normal_open_norm;
tract = beta2 * opening;
tract += op_n_n;
delta_max_new = std::max(delta_max, delta);
- tract *= std::exp(1.) * sigma_c * std::exp(-delta_max_new / delta_c) / delta_c;
+ tract *=
+ std::exp(1.) * sigma_c * std::exp(-delta_max_new / delta_c) / delta_c;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::computeCompressiveTraction(
Vector<Real> & tract, const Vector<Real> & normal, Real delta_n,
__attribute__((unused)) const Vector<Real> & opening) {
Vector<Real> temp_tract(normal);
if (exp_penalty) {
- temp_tract *=
- delta_n * std::exp(1) * sigma_c * std::exp(-delta_n / delta_c) / delta_c;
+ temp_tract *= delta_n * std::exp(1) * sigma_c *
+ std::exp(-delta_n / delta_c) / delta_c;
} else {
- Real initial_tg = contact_tangent * std::exp(1.) * sigma_c * delta_n / delta_c;
+ Real initial_tg =
+ contact_tangent * std::exp(1.) * sigma_c * delta_n / delta_c;
temp_tract *= initial_tg;
}
tract += temp_tract;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::computeTangentTraction(
const ElementType & el_type, Array<Real> & tangent_matrix,
const Array<Real> & normal, GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto tangent_it = tangent_matrix.begin(spatial_dimension, spatial_dimension);
auto tangent_end = tangent_matrix.end(spatial_dimension, spatial_dimension);
auto normal_it = normal.begin(spatial_dimension);
auto opening_it = opening(el_type, ghost_type).begin(spatial_dimension);
auto delta_max_it = delta_max.previous(el_type, ghost_type).begin();
Real beta2 = beta * beta;
/**
* compute tangent matrix @f$ \frac{\partial \mathbf{t}}
* {\partial \delta} = \hat{\mathbf{t}} \otimes
* \frac{\partial (t/\delta)}{\partial \delta}
* \frac{\hat{\mathbf{t}}}{\delta}+ \frac{t}{\delta} [ \beta^2 \mathbf{I} +
* (1-\beta^2) (\mathbf{n} \otimes \mathbf{n})] @f$
**/
/**
* In which @f$
* \frac{\partial(t/ \delta)}{\partial \delta} =
* \left\{\begin{array} {l l}
* -e \frac{\sigma_c}{\delta_c^2 }e^{-\delta / \delta_c} & \quad if
* \delta \geq \delta_{max} \\
* 0 & \quad if \delta < \delta_{max}, \delta_n > 0
* \end{array}\right. @f$
**/
for (; tangent_it != tangent_end;
++tangent_it, ++normal_it, ++opening_it, ++delta_max_it) {
Real normal_opening_norm = opening_it->dot(*normal_it);
Vector<Real> normal_opening(spatial_dimension);
normal_opening = (*normal_it);
normal_opening *= normal_opening_norm;
Vector<Real> tangential_opening(spatial_dimension);
tangential_opening = *opening_it;
tangential_opening -= normal_opening;
Real tangential_opening_norm = tangential_opening.norm();
Real delta = tangential_opening_norm;
delta *= delta * beta2;
delta += normal_opening_norm * normal_opening_norm;
delta = sqrt(delta);
if ((normal_opening_norm < 0) &&
(std::abs(normal_opening_norm) > Math::getTolerance())) {
Vector<Real> op_n(*normal_it);
op_n *= normal_opening_norm;
Vector<Real> delta_s(*opening_it);
delta_s -= op_n;
delta = tangential_opening_norm * beta;
computeCoupledTangent(*tangent_it, *normal_it, delta, delta_s,
*delta_max_it);
computeCompressivePenalty(*tangent_it, *normal_it, normal_opening_norm);
} else
computeCoupledTangent(*tangent_it, *normal_it, delta, *opening_it,
*delta_max_it);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::computeCoupledTangent(
Matrix<Real> & tangent, const Vector<Real> & normal, Real delta,
const Vector<Real> & opening, Real) {
AKANTU_DEBUG_IN();
Real beta2 = beta * beta;
Matrix<Real> J(spatial_dimension, spatial_dimension);
J.eye(beta2);
if (std::abs(delta) < Math::getTolerance()) {
delta = Math::getTolerance();
}
Real opening_normal;
opening_normal = opening.dot(normal);
Vector<Real> delta_e(normal);
delta_e *= opening_normal;
delta_e *= (1. - beta2);
delta_e += (beta2 * opening);
Real exponent = std::exp(1. - delta / delta_c) * sigma_c / delta_c;
Matrix<Real> first_term(spatial_dimension, spatial_dimension);
first_term.outerProduct(normal, normal);
first_term *= (1. - beta2);
first_term += J;
Matrix<Real> second_term(spatial_dimension, spatial_dimension);
second_term.outerProduct(delta_e, delta_e);
second_term /= delta;
second_term /= delta_c;
Matrix<Real> diff(first_term);
diff -= second_term;
tangent = diff;
tangent *= exponent;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveExponential<spatial_dimension>::computeCompressivePenalty(
Matrix<Real> & tangent, const Vector<Real> & normal, Real delta_n) {
if (!exp_penalty)
delta_n = 0.;
Matrix<Real> n_outer_n(spatial_dimension, spatial_dimension);
n_outer_n.outerProduct(normal, normal);
Real normal_tg = contact_tangent * std::exp(1.) * sigma_c *
- std::exp(-delta_n / delta_c) * (1. - delta_n / delta_c) / delta_c;
+ std::exp(-delta_n / delta_c) * (1. - delta_n / delta_c) /
+ delta_c;
n_outer_n *= normal_tg;
tangent += n_outer_n;
}
INSTANTIATE_MATERIAL(cohesive_exponential, MaterialCohesiveExponential);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.hh
index 17e667827..5253904e3 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_exponential.hh
@@ -1,122 +1,122 @@
/**
* @file material_cohesive_exponential.hh
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Exponential irreversible cohesive law of mixed mode loading
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material_cohesive.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_COHESIVE_EXPONENTIAL_HH__
#define __AKANTU_MATERIAL_COHESIVE_EXPONENTIAL_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* Cohesive material Exponential damage
*
* parameters in the material files :
* - sigma_c : critical stress sigma_c (default: 0)
* - beta : weighting parameter for sliding and normal opening (default:
* 0)
* - delta_c : critical opening (default: 0)
*/
template <UInt spatial_dimension>
class MaterialCohesiveExponential : public MaterialCohesive {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialCohesiveExponential(SolidMechanicsModel & model, const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
protected:
/// Initialization
void initMaterial() override;
/// constitutive law
void computeTraction(const Array<Real> & normal, ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute the tangent stiffness matrix for an element type
void computeTangentTraction(const ElementType & el_type,
Array<Real> & tangent_matrix,
const Array<Real> & normal,
GhostType ghost_type = _not_ghost) override;
private:
void computeCoupledTraction(Vector<Real> & tract, const Vector<Real> & normal,
Real delta, const Vector<Real> & opening,
Real & delta_max_new, Real delta_max);
void computeCompressiveTraction(Vector<Real> & tract,
const Vector<Real> & normal, Real delta_n,
const Vector<Real> & opening);
void computeCoupledTangent(Matrix<Real> & tangent,
const Vector<Real> & normal, Real delta,
const Vector<Real> & opening, Real delta_max_new);
void computeCompressivePenalty(Matrix<Real> & tangent,
const Vector<Real> & normal, Real delta_n);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// beta parameter
Real beta;
/// contact penalty = initial slope ?
bool exp_penalty;
/// Ratio of contact tangent over the initial exponential tangent
Real contact_tangent;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
// #include "material_cohesive_exponential_inline_impl.cc"
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_COHESIVE_EXPONENTIAL_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.cc
index 76df8af09..c3f4c5a98 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.cc
@@ -1,422 +1,422 @@
/**
* @file material_cohesive_linear.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Feb 22 2012
* @date last modification: Wed Feb 21 2018
*
* @brief Linear irreversible cohesive law of mixed mode loading with
* random stress definition for extrinsic type
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
-#include "dof_synchronizer.hh"
#include "material_cohesive_linear.hh"
+#include "dof_synchronizer.hh"
#include "solid_mechanics_model_cohesive.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <numeric>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialCohesiveLinear<spatial_dimension>::MaterialCohesiveLinear(
SolidMechanicsModel & model, const ID & id)
: MaterialCohesive(model, id), sigma_c_eff("sigma_c_eff", *this),
delta_c_eff("delta_c_eff", *this),
insertion_stress("insertion_stress", *this) {
AKANTU_DEBUG_IN();
this->registerParam("beta", beta, Real(0.), _pat_parsable | _pat_readable,
"Beta parameter");
this->registerParam("G_c", G_c, Real(0.), _pat_parsable | _pat_readable,
"Mode I fracture energy");
this->registerParam("penalty", penalty, Real(0.),
_pat_parsable | _pat_readable, "Penalty coefficient");
this->registerParam("volume_s", volume_s, Real(0.),
_pat_parsable | _pat_readable,
"Reference volume for sigma_c scaling");
this->registerParam("m_s", m_s, Real(1.), _pat_parsable | _pat_readable,
"Weibull exponent for sigma_c scaling");
this->registerParam("kappa", kappa, Real(1.), _pat_parsable | _pat_readable,
"Kappa parameter");
this->registerParam(
"contact_after_breaking", contact_after_breaking, false,
_pat_parsable | _pat_readable,
"Activation of contact when the elements are fully damaged");
this->registerParam("max_quad_stress_insertion", max_quad_stress_insertion,
false, _pat_parsable | _pat_readable,
"Insertion of cohesive element when stress is high "
"enough just on one quadrature point");
this->registerParam("recompute", recompute, false,
_pat_parsable | _pat_modifiable, "recompute solution");
this->use_previous_delta_max = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinear<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
MaterialCohesive::initMaterial();
sigma_c_eff.initialize(1);
delta_c_eff.initialize(1);
insertion_stress.initialize(spatial_dimension);
if (not Math::are_float_equal(delta_c, 0.))
delta_c_eff.setDefaultValue(delta_c);
else
delta_c_eff.setDefaultValue(2 * G_c / sigma_c);
if (model->getIsExtrinsic())
scaleInsertionTraction();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinear<spatial_dimension>::updateInternalParameters() {
/// compute scalars
beta2_kappa2 = beta * beta / kappa / kappa;
beta2_kappa = beta * beta / kappa;
if (Math::are_float_equal(beta, 0))
beta2_inv = 0;
else
beta2_inv = 1. / beta / beta;
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinear<spatial_dimension>::scaleInsertionTraction() {
AKANTU_DEBUG_IN();
// do nothing if volume_s hasn't been specified by the user
if (Math::are_float_equal(volume_s, 0.))
return;
const Mesh & mesh_facets = model->getMeshFacets();
const auto & fe_engine = model->getFEEngine();
const auto & fe_engine_facet = model->getFEEngine("FacetsFEEngine");
Real base_sigma_c = sigma_c;
for (auto && type_facet : mesh_facets.elementTypes(spatial_dimension - 1)) {
const Array<std::vector<Element>> & facet_to_element =
mesh_facets.getElementToSubelement(type_facet);
UInt nb_facet = facet_to_element.size();
UInt nb_quad_per_facet = fe_engine_facet.getNbIntegrationPoints(type_facet);
// iterator to modify sigma_c for all the quadrature points of a facet
auto sigma_c_iterator =
sigma_c(type_facet).begin_reinterpret(nb_quad_per_facet, nb_facet);
for (UInt f = 0; f < nb_facet; ++f, ++sigma_c_iterator) {
const std::vector<Element> & element_list = facet_to_element(f);
// compute bounding volume
Real volume = 0;
auto elem = element_list.begin();
auto elem_end = element_list.end();
for (; elem != elem_end; ++elem) {
if (*elem == ElementNull)
continue;
// unit vector for integration in order to obtain the volume
UInt nb_quadrature_points =
fe_engine.getNbIntegrationPoints(elem->type);
Vector<Real> unit_vector(nb_quadrature_points, 1);
volume += fe_engine.integrate(unit_vector, elem->type, elem->element,
elem->ghost_type);
}
// scale sigma_c
*sigma_c_iterator -= base_sigma_c;
*sigma_c_iterator *= std::pow(volume_s / volume, 1. / m_s);
*sigma_c_iterator += base_sigma_c;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinear<spatial_dimension>::checkInsertion(
bool check_only) {
AKANTU_DEBUG_IN();
const Mesh & mesh_facets = model->getMeshFacets();
CohesiveElementInserter & inserter = model->getElementInserter();
for (auto && type_facet : mesh_facets.elementTypes(spatial_dimension - 1)) {
ElementType type_cohesive = FEEngine::getCohesiveElementType(type_facet);
const auto & facets_check = inserter.getCheckFacets(type_facet);
auto & f_insertion = inserter.getInsertionFacets(type_facet);
auto & f_filter = facet_filter(type_facet);
auto & sig_c_eff = sigma_c_eff(type_cohesive);
auto & del_c = delta_c_eff(type_cohesive);
auto & ins_stress = insertion_stress(type_cohesive);
auto & trac_old = tractions.previous(type_cohesive);
const auto & f_stress = model->getStressOnFacets(type_facet);
const auto & sigma_lim = sigma_c(type_facet);
UInt nb_quad_facet =
model->getFEEngine("FacetsFEEngine").getNbIntegrationPoints(type_facet);
#ifndef AKANTU_NDEBUG
UInt nb_quad_cohesive = model->getFEEngine("CohesiveFEEngine")
.getNbIntegrationPoints(type_cohesive);
AKANTU_DEBUG_ASSERT(nb_quad_cohesive == nb_quad_facet,
"The cohesive element and the corresponding facet do "
"not have the same numbers of integration points");
#endif
UInt nb_facet = f_filter.size();
// if (nb_facet == 0) continue;
auto sigma_lim_it = sigma_lim.begin();
Matrix<Real> stress_tmp(spatial_dimension, spatial_dimension);
Matrix<Real> normal_traction(spatial_dimension, nb_quad_facet);
Vector<Real> stress_check(nb_quad_facet);
UInt sp2 = spatial_dimension * spatial_dimension;
const auto & tangents = model->getTangents(type_facet);
const auto & normals = model->getFEEngine("FacetsFEEngine")
.getNormalsOnIntegrationPoints(type_facet);
auto normal_begin = normals.begin(spatial_dimension);
auto tangent_begin = tangents.begin(tangents.getNbComponent());
auto facet_stress_begin =
f_stress.begin(spatial_dimension, spatial_dimension * 2);
std::vector<Real> new_sigmas;
std::vector<Vector<Real>> new_normal_traction;
std::vector<Real> new_delta_c;
// loop over each facet belonging to this material
for (UInt f = 0; f < nb_facet; ++f, ++sigma_lim_it) {
UInt facet = f_filter(f);
// skip facets where check shouldn't be realized
if (!facets_check(facet))
continue;
// compute the effective norm on each quadrature point of the facet
for (UInt q = 0; q < nb_quad_facet; ++q) {
UInt current_quad = facet * nb_quad_facet + q;
const Vector<Real> & normal = normal_begin[current_quad];
const Vector<Real> & tangent = tangent_begin[current_quad];
const Matrix<Real> & facet_stress_it = facet_stress_begin[current_quad];
// compute average stress on the current quadrature point
Matrix<Real> stress_1(facet_stress_it.storage(), spatial_dimension,
spatial_dimension);
Matrix<Real> stress_2(facet_stress_it.storage() + sp2,
spatial_dimension, spatial_dimension);
stress_tmp.copy(stress_1);
stress_tmp += stress_2;
stress_tmp /= 2.;
Vector<Real> normal_traction_vec(normal_traction(q));
// compute normal and effective stress
stress_check(q) = computeEffectiveNorm(stress_tmp, normal, tangent,
normal_traction_vec);
}
// verify if the effective stress overcomes the threshold
Real final_stress = stress_check.mean();
if (max_quad_stress_insertion)
final_stress = *std::max_element(
stress_check.storage(), stress_check.storage() + nb_quad_facet);
if (final_stress > *sigma_lim_it) {
f_insertion(facet) = true;
if (check_only)
continue;
// store the new cohesive material parameters for each quadrature
// point
for (UInt q = 0; q < nb_quad_facet; ++q) {
Real new_sigma = stress_check(q);
Vector<Real> normal_traction_vec(normal_traction(q));
if (spatial_dimension != 3)
normal_traction_vec *= -1.;
new_sigmas.push_back(new_sigma);
new_normal_traction.push_back(normal_traction_vec);
Real new_delta;
// set delta_c in function of G_c or a given delta_c value
if (Math::are_float_equal(delta_c, 0.))
new_delta = 2 * G_c / new_sigma;
else
new_delta = (*sigma_lim_it) / new_sigma * delta_c;
new_delta_c.push_back(new_delta);
}
}
}
// update material data for the new elements
UInt old_nb_quad_points = sig_c_eff.size();
UInt new_nb_quad_points = new_sigmas.size();
sig_c_eff.resize(old_nb_quad_points + new_nb_quad_points);
ins_stress.resize(old_nb_quad_points + new_nb_quad_points);
trac_old.resize(old_nb_quad_points + new_nb_quad_points);
del_c.resize(old_nb_quad_points + new_nb_quad_points);
for (UInt q = 0; q < new_nb_quad_points; ++q) {
sig_c_eff(old_nb_quad_points + q) = new_sigmas[q];
del_c(old_nb_quad_points + q) = new_delta_c[q];
for (UInt dim = 0; dim < spatial_dimension; ++dim) {
ins_stress(old_nb_quad_points + q, dim) = new_normal_traction[q](dim);
trac_old(old_nb_quad_points + q, dim) = new_normal_traction[q](dim);
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinear<spatial_dimension>::computeTraction(
const Array<Real> & normal, ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// define iterators
auto traction_it = tractions(el_type, ghost_type).begin(spatial_dimension);
auto opening_it = opening(el_type, ghost_type).begin(spatial_dimension);
auto contact_traction_it =
contact_tractions(el_type, ghost_type).begin(spatial_dimension);
auto contact_opening_it =
contact_opening(el_type, ghost_type).begin(spatial_dimension);
auto normal_it = normal.begin(spatial_dimension);
auto traction_end = tractions(el_type, ghost_type).end(spatial_dimension);
auto sigma_c_it = sigma_c_eff(el_type, ghost_type).begin();
auto delta_max_it = delta_max(el_type, ghost_type).begin();
auto delta_c_it = delta_c_eff(el_type, ghost_type).begin();
auto damage_it = damage(el_type, ghost_type).begin();
auto insertion_stress_it =
insertion_stress(el_type, ghost_type).begin(spatial_dimension);
Vector<Real> normal_opening(spatial_dimension);
Vector<Real> tangential_opening(spatial_dimension);
/// loop on each quadrature point
for (; traction_it != traction_end;
++traction_it, ++opening_it, ++normal_it, ++sigma_c_it, ++delta_max_it,
++delta_c_it, ++damage_it, ++contact_traction_it, ++insertion_stress_it,
++contact_opening_it) {
Real normal_opening_norm, tangential_opening_norm;
bool penetration;
this->computeTractionOnQuad(
*traction_it, *opening_it, *normal_it, *delta_max_it, *delta_c_it,
*insertion_stress_it, *sigma_c_it, normal_opening, tangential_opening,
normal_opening_norm, tangential_opening_norm, *damage_it, penetration,
*contact_traction_it, *contact_opening_it);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinear<spatial_dimension>::computeTangentTraction(
const ElementType & el_type, Array<Real> & tangent_matrix,
const Array<Real> & normal, GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// define iterators
auto tangent_it = tangent_matrix.begin(spatial_dimension, spatial_dimension);
auto tangent_end = tangent_matrix.end(spatial_dimension, spatial_dimension);
auto normal_it = normal.begin(spatial_dimension);
auto opening_it = opening(el_type, ghost_type).begin(spatial_dimension);
/// NB: delta_max_it points on delta_max_previous, i.e. the
/// delta_max related to the solution of the previous incremental
/// step
auto delta_max_it = delta_max.previous(el_type, ghost_type).begin();
auto sigma_c_it = sigma_c_eff(el_type, ghost_type).begin();
auto delta_c_it = delta_c_eff(el_type, ghost_type).begin();
auto damage_it = damage(el_type, ghost_type).begin();
auto contact_opening_it =
contact_opening(el_type, ghost_type).begin(spatial_dimension);
Vector<Real> normal_opening(spatial_dimension);
Vector<Real> tangential_opening(spatial_dimension);
for (; tangent_it != tangent_end; ++tangent_it, ++normal_it, ++opening_it,
++delta_max_it, ++sigma_c_it, ++delta_c_it,
++damage_it, ++contact_opening_it) {
Real normal_opening_norm, tangential_opening_norm;
bool penetration;
this->computeTangentTractionOnQuad(
*tangent_it, *delta_max_it, *delta_c_it, *sigma_c_it, *opening_it,
*normal_it, normal_opening, tangential_opening, normal_opening_norm,
tangential_opening_norm, *damage_it, penetration, *contact_opening_it);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(cohesive_linear, MaterialCohesiveLinear);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.hh
index 6102277b5..a954a6953 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear.hh
@@ -1,188 +1,188 @@
/**
* @file material_cohesive_linear.hh
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Linear irreversible cohesive law of mixed mode loading with
* random stress definition for extrinsic type
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_COHESIVE_LINEAR_HH__
#define __AKANTU_MATERIAL_COHESIVE_LINEAR_HH__
namespace akantu {
/**
* Cohesive material linear damage for extrinsic case
*
* parameters in the material files :
* - sigma_c : critical stress sigma_c (default: 0)
* - beta : weighting parameter for sliding and normal opening (default:
* 0)
* - G_cI : fracture energy for mode I (default: 0)
* - G_cII : fracture energy for mode II (default: 0)
* - penalty : stiffness in compression to prevent penetration
*/
template <UInt spatial_dimension>
class MaterialCohesiveLinear : public MaterialCohesive {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialCohesiveLinear(SolidMechanicsModel & model, const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the material parameters
void initMaterial() override;
void updateInternalParameters() override;
/// check stress for cohesive elements' insertion
void checkInsertion(bool check_only = false) override;
/// compute effective stress norm for insertion check
Real computeEffectiveNorm(const Matrix<Real> & stress,
const Vector<Real> & normal,
const Vector<Real> & tangent,
Vector<Real> & normal_stress) const;
protected:
/// constitutive law
void computeTraction(const Array<Real> & normal, ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute tangent stiffness matrix
void computeTangentTraction(const ElementType & el_type,
Array<Real> & tangent_matrix,
const Array<Real> & normal,
GhostType ghost_type) override;
/**
* Scale insertion traction sigma_c according to the volume of the
* two elements surrounding a facet
*
* see the article: F. Zhou and J. F. Molinari "Dynamic crack
* propagation with cohesive elements: a methodology to address mesh
* dependency" International Journal for Numerical Methods in
* Engineering (2004)
*/
void scaleInsertionTraction();
/// compute the traction for a given quadrature point
inline void computeTractionOnQuad(
Vector<Real> & traction, Vector<Real> & opening,
const Vector<Real> & normal, Real & delta_max, const Real & delta_c,
const Vector<Real> & insertion_stress, const Real & sigma_c,
Vector<Real> & normal_opening, Vector<Real> & tangential_opening,
Real & normal_opening_norm, Real & tangential_opening_norm, Real & damage,
bool & penetration, Vector<Real> & contact_traction,
Vector<Real> & contact_opening);
inline void computeTangentTractionOnQuad(
Matrix<Real> & tangent, Real & delta_max, const Real & delta_c,
const Real & sigma_c, Vector<Real> & opening, const Vector<Real> & normal,
Vector<Real> & normal_opening, Vector<Real> & tangential_opening,
Real & normal_opening_norm, Real & tangential_opening_norm, Real & damage,
bool & penetration, Vector<Real> & contact_opening);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get sigma_c_eff
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(InsertionTraction, sigma_c_eff, Real);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// beta parameter
Real beta;
/// beta square inverse to compute effective norm
Real beta2_inv;
/// mode I fracture energy
Real G_c;
/// kappa parameter
Real kappa;
/// constitutive law scalar to compute delta
Real beta2_kappa2;
/// constitutive law scalar to compute traction
Real beta2_kappa;
/// penalty coefficient
Real penalty;
/// reference volume used to scale sigma_c
Real volume_s;
/// weibull exponent used to scale sigma_c
Real m_s;
/// variable defining if we are recomputing the last loading step
/// after load_reduction
bool recompute;
/// critical effective stress
RandomInternalField<Real, CohesiveInternalField> sigma_c_eff;
/// effective critical displacement (each element can have a
/// different value)
CohesiveInternalField<Real> delta_c_eff;
/// stress at insertion
CohesiveInternalField<Real> insertion_stress;
/// variable saying if there should be penalty contact also after
/// breaking the cohesive elements
bool contact_after_breaking;
/// insertion of cohesive element when stress is high enough just on
/// one quadrature point
bool max_quad_stress_insertion;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#include "material_cohesive_linear_inline_impl.cc"
#endif /* __AKANTU_MATERIAL_COHESIVE_LINEAR_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.cc
index 0f931e311..4aa7da688 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.cc
@@ -1,298 +1,298 @@
/**
* @file material_cohesive_linear_fatigue.cc
*
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Feb 20 2015
* @date last modification: Tue Feb 20 2018
*
* @brief See material_cohesive_linear_fatigue.hh for information
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear_fatigue.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialCohesiveLinearFatigue<spatial_dimension>::MaterialCohesiveLinearFatigue(
SolidMechanicsModel & model, const ID & id)
: MaterialCohesiveLinear<spatial_dimension>(model, id),
delta_prec("delta_prec", *this), K_plus("K_plus", *this),
K_minus("K_minus", *this), T_1d("T_1d", *this),
switches("switches", *this), delta_dot_prec("delta_dot_prec", *this),
normal_regime("normal_regime", *this) {
this->registerParam("delta_f", delta_f, Real(-1.),
_pat_parsable | _pat_readable, "delta_f");
this->registerParam("progressive_delta_f", progressive_delta_f, false,
_pat_parsable | _pat_readable,
"Whether or not delta_f is equal to delta_max");
this->registerParam("count_switches", count_switches, false,
_pat_parsable | _pat_readable,
"Count the opening/closing switches per element");
this->registerParam(
"fatigue_ratio", fatigue_ratio, Real(1.), _pat_parsable | _pat_readable,
"What portion of the cohesive law is subjected to fatigue");
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearFatigue<spatial_dimension>::initMaterial() {
MaterialCohesiveLinear<spatial_dimension>::initMaterial();
// check that delta_f has a proper value or assign a defaul value
if (delta_f < 0)
delta_f = this->delta_c_eff;
else if (delta_f < this->delta_c_eff)
AKANTU_ERROR("Delta_f must be greater or equal to delta_c");
delta_prec.initialize(1);
K_plus.initialize(1);
K_minus.initialize(1);
T_1d.initialize(1);
normal_regime.initialize(1);
if (count_switches) {
switches.initialize(1);
delta_dot_prec.initialize(1);
}
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearFatigue<spatial_dimension>::computeTraction(
const Array<Real> & normal, ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// define iterators
auto traction_it =
this->tractions(el_type, ghost_type).begin(spatial_dimension);
auto opening_it = this->opening(el_type, ghost_type).begin(spatial_dimension);
auto contact_traction_it =
this->contact_tractions(el_type, ghost_type).begin(spatial_dimension);
auto contact_opening_it =
this->contact_opening(el_type, ghost_type).begin(spatial_dimension);
auto normal_it = normal.begin(spatial_dimension);
auto traction_end =
this->tractions(el_type, ghost_type).end(spatial_dimension);
const Array<Real> & sigma_c_array = this->sigma_c_eff(el_type, ghost_type);
Array<Real> & delta_max_array = this->delta_max(el_type, ghost_type);
const Array<Real> & delta_c_array = this->delta_c_eff(el_type, ghost_type);
Array<Real> & damage_array = this->damage(el_type, ghost_type);
auto insertion_stress_it =
this->insertion_stress(el_type, ghost_type).begin(spatial_dimension);
Array<Real> & delta_prec_array = delta_prec(el_type, ghost_type);
Array<Real> & K_plus_array = K_plus(el_type, ghost_type);
Array<Real> & K_minus_array = K_minus(el_type, ghost_type);
Array<Real> & T_1d_array = T_1d(el_type, ghost_type);
Array<bool> & normal_regime_array = normal_regime(el_type, ghost_type);
Array<UInt> * switches_array = nullptr;
Array<Real> * delta_dot_prec_array = nullptr;
if (count_switches) {
switches_array = &switches(el_type, ghost_type);
delta_dot_prec_array = &delta_dot_prec(el_type, ghost_type);
}
auto * memory_space = new Real[2 * spatial_dimension];
Vector<Real> normal_opening(memory_space, spatial_dimension);
Vector<Real> tangential_opening(memory_space + spatial_dimension,
spatial_dimension);
Real tolerance = Math::getTolerance();
/// loop on each quadrature point
for (UInt q = 0; traction_it != traction_end; ++traction_it, ++opening_it,
++normal_it, ++contact_traction_it, ++insertion_stress_it,
++contact_opening_it, ++q) {
/// compute normal and tangential opening vectors
Real normal_opening_norm = opening_it->dot(*normal_it);
normal_opening = (*normal_it);
normal_opening *= normal_opening_norm;
tangential_opening = *opening_it;
tangential_opening -= normal_opening;
Real tangential_opening_norm = tangential_opening.norm();
/**
* compute effective opening displacement
* @f$ \delta = \sqrt{
* \frac{\beta^2}{\kappa^2} \Delta_t^2 + \Delta_n^2 } @f$
*/
Real delta =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
bool penetration = normal_opening_norm < -tolerance;
if (this->contact_after_breaking == false &&
Math::are_float_equal(damage_array(q), 1.))
penetration = false;
if (penetration) {
/// use penalty coefficient in case of penetration
*contact_traction_it = normal_opening;
*contact_traction_it *= this->penalty;
*contact_opening_it = normal_opening;
/// don't consider penetration contribution for delta
*opening_it = tangential_opening;
normal_opening.clear();
} else {
delta += normal_opening_norm * normal_opening_norm;
contact_traction_it->clear();
contact_opening_it->clear();
}
delta = std::sqrt(delta);
/**
* Compute traction @f$ \mathbf{T} = \left(
* \frac{\beta^2}{\kappa} \Delta_t \mathbf{t} + \Delta_n
* \mathbf{n} \right) \frac{\sigma_c}{\delta} \left( 1-
* \frac{\delta}{\delta_c} \right)@f$
*/
// update maximum displacement and damage
delta_max_array(q) = std::max(delta, delta_max_array(q));
damage_array(q) = std::min(delta_max_array(q) / delta_c_array(q), Real(1.));
Real delta_dot = delta - delta_prec_array(q);
// count switches if asked
if (count_switches) {
if ((delta_dot > 0. && (*delta_dot_prec_array)(q) <= 0.) ||
(delta_dot < 0. && (*delta_dot_prec_array)(q) >= 0.))
++((*switches_array)(q));
(*delta_dot_prec_array)(q) = delta_dot;
}
// set delta_f equal to delta_max if desired
if (progressive_delta_f)
delta_f = delta_max_array(q);
// broken element case
if (Math::are_float_equal(damage_array(q), 1.))
traction_it->clear();
// just inserted element case
else if (Math::are_float_equal(damage_array(q), 0.)) {
if (penetration)
traction_it->clear();
else
*traction_it = *insertion_stress_it;
// initialize the 1d traction to sigma_c
T_1d_array(q) = sigma_c_array(q);
}
// normal case
else {
// if element is closed then there are zero tractions
if (delta <= tolerance)
traction_it->clear();
// otherwise compute new tractions if the new delta is different
// than the previous one
else if (std::abs(delta_dot) > tolerance) {
// loading case
if (delta_dot > 0.) {
if (!normal_regime_array(q)) {
// equation (4) of the article
K_plus_array(q) *= 1. - delta_dot / delta_f;
// equivalent to equation (2) of the article
T_1d_array(q) += K_plus_array(q) * delta_dot;
// in case of reloading, traction must not exceed that of the
// envelop of the cohesive law
Real max_traction =
sigma_c_array(q) * (1 - delta / delta_c_array(q));
bool max_traction_exceeded = T_1d_array(q) > max_traction;
if (max_traction_exceeded)
T_1d_array(q) = max_traction;
// switch to standard linear cohesive law
if (delta_max_array(q) > fatigue_ratio * delta_c_array(q)) {
// reset delta_max to avoid big jumps in the traction
delta_max_array(q) =
sigma_c_array(q) /
(T_1d_array(q) / delta + sigma_c_array(q) / delta_c_array(q));
damage_array(q) =
std::min(delta_max_array(q) / delta_c_array(q), Real(1.));
K_minus_array(q) = sigma_c_array(q) / delta_max_array(q) *
(1. - damage_array(q));
normal_regime_array(q) = true;
} else {
// equation (3) of the article
K_minus_array(q) = T_1d_array(q) / delta;
// if the traction is following the cohesive envelop, then
// K_plus has to be reset
if (max_traction_exceeded)
K_plus_array(q) = K_minus_array(q);
}
} else {
// compute stiffness according to the standard law
K_minus_array(q) =
sigma_c_array(q) / delta_max_array(q) * (1. - damage_array(q));
}
}
// unloading case
else if (!normal_regime_array(q)) {
// equation (4) of the article
K_plus_array(q) +=
(K_plus_array(q) - K_minus_array(q)) * delta_dot / delta_f;
// equivalent to equation (2) of the article
T_1d_array(q) = K_minus_array(q) * delta;
}
// applying the actual stiffness
*traction_it = tangential_opening;
*traction_it *= this->beta2_kappa;
*traction_it += normal_opening;
*traction_it *= K_minus_array(q);
}
}
// update precendent delta
delta_prec_array(q) = delta;
}
delete[] memory_space;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(cohesive_linear_fatigue, MaterialCohesiveLinearFatigue);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.hh
index 7c204eadc..398287ece 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_fatigue.hh
@@ -1,132 +1,132 @@
/**
* @file material_cohesive_linear_fatigue.hh
*
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Linear irreversible cohesive law with dissipative
* unloading-reloading cycles
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_COHESIVE_LINEAR_FATIGUE_HH__
#define __AKANTU_MATERIAL_COHESIVE_LINEAR_FATIGUE_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* Linear irreversible cohesive law with dissipative
* unloading-reloading cycles
*
* This law uses two different stiffnesses during unloading and
* reloading. The implementation is based on the article entitled "A
* cohesive model for fatigue crack growth" by Nguyen, Repetto, Ortiz
* and Radovitzky (2001). This law is identical to the
* MaterialCohesiveLinear one except for the unloading-reloading
* phase.
*
* input parameter:
*
* - delta_f : it must be greater than delta_c and it is inversely
* proportional to the dissipation in the unloading-reloading
* cycles (default: delta_c)
*/
template <UInt spatial_dimension>
class MaterialCohesiveLinearFatigue
: public MaterialCohesiveLinear<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
MaterialCohesiveLinearFatigue(SolidMechanicsModel & model,
const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the material parameters
void initMaterial() override;
protected:
/// constitutive law
void computeTraction(const Array<Real> & normal, ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// get the switches
AKANTU_GET_MACRO_BY_ELEMENT_TYPE_CONST(Switches, switches, UInt);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// delta_f parameter
Real delta_f;
/// variable saying if delta_f is equal to delta_max for each
/// element when the traction is computed
bool progressive_delta_f;
/// count the opening/closing switches per element
bool count_switches;
/// delta of the previous step
CohesiveInternalField<Real> delta_prec;
/// stiffness for reloading
CohesiveInternalField<Real> K_plus;
/// stiffness for unloading
CohesiveInternalField<Real> K_minus;
/// 1D traction in the cohesive law
CohesiveInternalField<Real> T_1d;
/// Number of opening/closing switches
CohesiveInternalField<UInt> switches;
/// delta increment of the previous time step
CohesiveInternalField<Real> delta_dot_prec;
/// has the element passed to normal regime (not in fatigue anymore)
CohesiveInternalField<bool> normal_regime;
/// ratio indicating until what point fatigue is applied in the cohesive law
Real fatigue_ratio;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_COHESIVE_LINEAR_FATIGUE_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.cc
index 0379b2531..eec417b08 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.cc
@@ -1,277 +1,277 @@
/**
* @file material_cohesive_linear_friction.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
*
* @date creation: Tue Jan 12 2016
* @date last modification: Wed Feb 21 2018
*
* @brief Linear irreversible cohesive law of mixed mode loading with
* random stress definition for extrinsic type
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear_friction.hh"
#include "solid_mechanics_model_cohesive.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialCohesiveLinearFriction<spatial_dimension>::
MaterialCohesiveLinearFriction(SolidMechanicsModel & model, const ID & id)
: MaterialParent(model, id), residual_sliding("residual_sliding", *this),
friction_force("friction_force", *this) {
AKANTU_DEBUG_IN();
this->registerParam("mu", mu_max, Real(0.), _pat_parsable | _pat_readable,
"Maximum value of the friction coefficient");
this->registerParam("penalty_for_friction", friction_penalty, Real(0.),
_pat_parsable | _pat_readable,
"Penalty parameter for the friction behavior");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearFriction<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
MaterialParent::initMaterial();
friction_force.initialize(spatial_dimension);
residual_sliding.initialize(1);
residual_sliding.initializeHistory();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearFriction<spatial_dimension>::computeTraction(
__attribute__((unused)) const Array<Real> & normal, ElementType el_type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
residual_sliding.resize();
friction_force.resize();
/// define iterators
auto traction_it =
this->tractions(el_type, ghost_type).begin(spatial_dimension);
auto traction_end =
this->tractions(el_type, ghost_type).end(spatial_dimension);
auto opening_it = this->opening(el_type, ghost_type).begin(spatial_dimension);
auto previous_opening_it =
this->opening.previous(el_type, ghost_type).begin(spatial_dimension);
auto contact_traction_it =
this->contact_tractions(el_type, ghost_type).begin(spatial_dimension);
auto contact_opening_it =
this->contact_opening(el_type, ghost_type).begin(spatial_dimension);
auto normal_it = this->normal.begin(spatial_dimension);
auto sigma_c_it = this->sigma_c_eff(el_type, ghost_type).begin();
auto delta_max_it = this->delta_max(el_type, ghost_type).begin();
auto delta_max_prev_it =
this->delta_max.previous(el_type, ghost_type).begin();
auto delta_c_it = this->delta_c_eff(el_type, ghost_type).begin();
auto damage_it = this->damage(el_type, ghost_type).begin();
auto insertion_stress_it =
this->insertion_stress(el_type, ghost_type).begin(spatial_dimension);
auto res_sliding_it = this->residual_sliding(el_type, ghost_type).begin();
auto res_sliding_prev_it =
this->residual_sliding.previous(el_type, ghost_type).begin();
auto friction_force_it =
this->friction_force(el_type, ghost_type).begin(spatial_dimension);
Vector<Real> normal_opening(spatial_dimension);
Vector<Real> tangential_opening(spatial_dimension);
if (not this->model->isDefaultSolverExplicit())
this->delta_max(el_type, ghost_type)
.copy(this->delta_max.previous(el_type, ghost_type));
/// loop on each quadrature point
for (; traction_it != traction_end;
++traction_it, ++opening_it, ++normal_it, ++sigma_c_it, ++delta_max_it,
++delta_c_it, ++damage_it, ++contact_traction_it, ++insertion_stress_it,
++contact_opening_it, ++delta_max_prev_it, ++res_sliding_it,
++res_sliding_prev_it, ++friction_force_it, ++previous_opening_it) {
Real normal_opening_norm, tangential_opening_norm;
bool penetration;
this->computeTractionOnQuad(
*traction_it, *opening_it, *normal_it, *delta_max_it, *delta_c_it,
*insertion_stress_it, *sigma_c_it, normal_opening, tangential_opening,
normal_opening_norm, tangential_opening_norm, *damage_it, penetration,
*contact_traction_it, *contact_opening_it);
if (penetration) {
/// the friction coefficient mu increases with the damage. It
/// equals the maximum value when damage = 1.
// Real damage = std::min(*delta_max_prev_it / *delta_c_it,
// Real(1.));
Real mu = mu_max; // * damage;
/// the definition of tau_max refers to the opening
/// (penetration) of the previous incremental step
Real normal_opening_prev_norm =
std::min(previous_opening_it->dot(*normal_it), Real(0.));
// Vector<Real> normal_opening_prev = (*normal_it);
// normal_opening_prev *= normal_opening_prev_norm;
Real tau_max = mu * this->penalty * (std::abs(normal_opening_prev_norm));
Real delta_sliding_norm =
std::abs(tangential_opening_norm - *res_sliding_prev_it);
/// tau is the norm of the friction force, acting tangentially to the
/// surface
Real tau = std::min(friction_penalty * delta_sliding_norm, tau_max);
if ((tangential_opening_norm - *res_sliding_prev_it) < 0.0)
tau = -tau;
/// from tau get the x and y components of friction, to be added in the
/// force vector
Vector<Real> tangent_unit_vector(spatial_dimension);
tangent_unit_vector = tangential_opening / tangential_opening_norm;
*friction_force_it = tau * tangent_unit_vector;
/// update residual_sliding
*res_sliding_it =
tangential_opening_norm - (std::abs(tau) / friction_penalty);
} else {
friction_force_it->clear();
}
*traction_it += *friction_force_it;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearFriction<spatial_dimension>::computeTangentTraction(
const ElementType & el_type, Array<Real> & tangent_matrix,
__attribute__((unused)) const Array<Real> & normal, GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// define iterators
auto tangent_it = tangent_matrix.begin(spatial_dimension, spatial_dimension);
auto tangent_end = tangent_matrix.end(spatial_dimension, spatial_dimension);
auto normal_it = this->normal.begin(spatial_dimension);
auto opening_it = this->opening(el_type, ghost_type).begin(spatial_dimension);
auto previous_opening_it =
this->opening.previous(el_type, ghost_type).begin(spatial_dimension);
/**
* NB: delta_max_it points on delta_max_previous, i.e. the
* delta_max related to the solution of the previous incremental
* step
*/
auto delta_max_it = this->delta_max.previous(el_type, ghost_type).begin();
auto sigma_c_it = this->sigma_c_eff(el_type, ghost_type).begin();
auto delta_c_it = this->delta_c_eff(el_type, ghost_type).begin();
auto damage_it = this->damage(el_type, ghost_type).begin();
auto contact_opening_it =
this->contact_opening(el_type, ghost_type).begin(spatial_dimension);
auto res_sliding_prev_it =
this->residual_sliding.previous(el_type, ghost_type).begin();
Vector<Real> normal_opening(spatial_dimension);
Vector<Real> tangential_opening(spatial_dimension);
for (; tangent_it != tangent_end;
++tangent_it, ++normal_it, ++opening_it, ++previous_opening_it,
++delta_max_it, ++sigma_c_it, ++delta_c_it, ++damage_it,
++contact_opening_it, ++res_sliding_prev_it) {
Real normal_opening_norm, tangential_opening_norm;
bool penetration;
this->computeTangentTractionOnQuad(
*tangent_it, *delta_max_it, *delta_c_it, *sigma_c_it, *opening_it,
*normal_it, normal_opening, tangential_opening, normal_opening_norm,
tangential_opening_norm, *damage_it, penetration, *contact_opening_it);
if (penetration) {
// Real damage = std::min(*delta_max_it / *delta_c_it, Real(1.));
Real mu = mu_max; // * damage;
Real normal_opening_prev_norm =
std::min(previous_opening_it->dot(*normal_it), Real(0.));
// Vector<Real> normal_opening_prev = (*normal_it);
// normal_opening_prev *= normal_opening_prev_norm;
Real tau_max = mu * this->penalty * (std::abs(normal_opening_prev_norm));
Real delta_sliding_norm =
std::abs(tangential_opening_norm - *res_sliding_prev_it);
// tau is the norm of the friction force, acting tangentially to the
// surface
Real tau = std::min(friction_penalty * delta_sliding_norm, tau_max);
if (tau < tau_max && tau_max > Math::getTolerance()) {
Matrix<Real> I(spatial_dimension, spatial_dimension);
I.eye(1.);
Matrix<Real> n_outer_n(spatial_dimension, spatial_dimension);
n_outer_n.outerProduct(*normal_it, *normal_it);
Matrix<Real> nn(n_outer_n);
I -= nn;
*tangent_it += I * friction_penalty;
}
}
// check if the tangential stiffness matrix is symmetric
// for (UInt h = 0; h < spatial_dimension; ++h){
// for (UInt l = h; l < spatial_dimension; ++l){
// if (l > h){
// Real k_ls = (*tangent_it)[spatial_dimension*h+l];
// Real k_us = (*tangent_it)[spatial_dimension*l+h];
// // std::cout << "k_ls = " << k_ls << std::endl;
// // std::cout << "k_us = " << k_us << std::endl;
// if (std::abs(k_ls) > 1e-13 && std::abs(k_us) > 1e-13){
// Real error = std::abs((k_ls - k_us) / k_us);
// if (error > 1e-10){
// std::cout << "non symmetric cohesive matrix" << std::endl;
// // std::cout << "error " << error << std::endl;
// }
// }
// }
// }
// }
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(cohesive_linear_friction, MaterialCohesiveLinearFriction);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.hh
index 8df782f9c..780ce1922 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_friction.hh
@@ -1,105 +1,105 @@
/**
* @file material_cohesive_linear_friction.hh
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Linear irreversible cohesive law of mixed mode loading with
* random stress definition for extrinsic type
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_COHESIVE_LINEAR_FRICTION_HH__
#define __AKANTU_MATERIAL_COHESIVE_LINEAR_FRICTION_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* Cohesive material linear with friction force
*
* parameters in the material files :
* - mu : friction coefficient
* - penalty_for_friction : Penalty parameter for the friction behavior
*/
template <UInt spatial_dimension>
class MaterialCohesiveLinearFriction
: public MaterialCohesiveLinear<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
using MaterialParent = MaterialCohesiveLinear<spatial_dimension>;
public:
MaterialCohesiveLinearFriction(SolidMechanicsModel & model,
const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the material parameters
void initMaterial() override;
protected:
/// constitutive law
void computeTraction(const Array<Real> & normal, ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute tangent stiffness matrix
void computeTangentTraction(const ElementType & el_type,
Array<Real> & tangent_matrix,
const Array<Real> & normal,
GhostType ghost_type) override;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// maximum value of the friction coefficient
Real mu_max;
/// penalty parameter for the friction law
Real friction_penalty;
/// history parameter for the friction law
CohesiveInternalField<Real> residual_sliding;
/// friction force
CohesiveInternalField<Real> friction_force;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_COHESIVE_LINEAR_FRICTION_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_inline_impl.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_inline_impl.cc
index 448c63ea2..87c4ee528 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_inline_impl.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_inline_impl.cc
@@ -1,266 +1,266 @@
/**
* @file material_cohesive_linear_inline_impl.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Apr 22 2015
* @date last modification: Wed Feb 21 2018
*
* @brief Inline functions of the MaterialCohesiveLinear
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear.hh"
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_COHESIVE_LINEAR_INLINE_IMPL_CC__
#define __AKANTU_MATERIAL_COHESIVE_LINEAR_INLINE_IMPL_CC__
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline Real MaterialCohesiveLinear<dim>::computeEffectiveNorm(
const Matrix<Real> & stress, const Vector<Real> & normal,
const Vector<Real> & tangent, Vector<Real> & normal_traction) const {
normal_traction.mul<false>(stress, normal);
Real normal_contrib = normal_traction.dot(normal);
/// in 3D tangential components must be summed
Real tangent_contrib = 0;
if (dim == 2) {
Real tangent_contrib_tmp = normal_traction.dot(tangent);
tangent_contrib += tangent_contrib_tmp * tangent_contrib_tmp;
} else if (dim == 3) {
for (UInt s = 0; s < dim - 1; ++s) {
const Vector<Real> tangent_v(tangent.storage() + s * dim, dim);
Real tangent_contrib_tmp = normal_traction.dot(tangent_v);
tangent_contrib += tangent_contrib_tmp * tangent_contrib_tmp;
}
}
tangent_contrib = std::sqrt(tangent_contrib);
normal_contrib = std::max(Real(0.), normal_contrib);
return std::sqrt(normal_contrib * normal_contrib +
tangent_contrib * tangent_contrib * beta2_inv);
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialCohesiveLinear<dim>::computeTractionOnQuad(
Vector<Real> & traction, Vector<Real> & opening,
const Vector<Real> & normal, Real & delta_max, const Real & delta_c,
const Vector<Real> & insertion_stress, const Real & sigma_c,
Vector<Real> & normal_opening, Vector<Real> & tangential_opening,
Real & normal_opening_norm, Real & tangential_opening_norm, Real & damage,
bool & penetration, Vector<Real> & contact_traction,
Vector<Real> & contact_opening) {
/// compute normal and tangential opening vectors
normal_opening_norm = opening.dot(normal);
normal_opening = normal;
normal_opening *= normal_opening_norm;
tangential_opening = opening;
tangential_opening -= normal_opening;
tangential_opening_norm = tangential_opening.norm();
/**
* compute effective opening displacement
* @f$ \delta = \sqrt{
* \frac{\beta^2}{\kappa^2} \Delta_t^2 + \Delta_n^2 } @f$
*/
Real delta =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
penetration = normal_opening_norm / delta_c < -Math::getTolerance();
// penetration = normal_opening_norm < 0.;
if (this->contact_after_breaking == false &&
Math::are_float_equal(damage, 1.))
penetration = false;
if (penetration) {
/// use penalty coefficient in case of penetration
contact_traction = normal_opening;
contact_traction *= this->penalty;
contact_opening = normal_opening;
/// don't consider penetration contribution for delta
opening = tangential_opening;
normal_opening.clear();
} else {
delta += normal_opening_norm * normal_opening_norm;
contact_traction.clear();
contact_opening.clear();
}
delta = std::sqrt(delta);
/// update maximum displacement and damage
delta_max = std::max(delta_max, delta);
damage = std::min(delta_max / delta_c, Real(1.));
/**
* Compute traction @f$ \mathbf{T} = \left(
* \frac{\beta^2}{\kappa} \Delta_t \mathbf{t} + \Delta_n
* \mathbf{n} \right) \frac{\sigma_c}{\delta} \left( 1-
* \frac{\delta}{\delta_c} \right)@f$
*/
if (Math::are_float_equal(damage, 1.))
traction.clear();
else if (Math::are_float_equal(damage, 0.)) {
if (penetration)
traction.clear();
else
traction = insertion_stress;
} else {
traction = tangential_opening;
traction *= this->beta2_kappa;
traction += normal_opening;
AKANTU_DEBUG_ASSERT(delta_max != 0.,
"Division by zero, tolerance might be too low");
traction *= sigma_c / delta_max * (1. - damage);
}
}
/* -------------------------------------------------------------------------- */
template <UInt dim>
inline void MaterialCohesiveLinear<dim>::computeTangentTractionOnQuad(
Matrix<Real> & tangent, Real & delta_max, const Real & delta_c,
const Real & sigma_c, Vector<Real> & opening, const Vector<Real> & normal,
Vector<Real> & normal_opening, Vector<Real> & tangential_opening,
Real & normal_opening_norm, Real & tangential_opening_norm, Real & damage,
bool & penetration, Vector<Real> & contact_opening) {
/**
* During the update of the residual the interpenetrations are
* stored in the array "contact_opening", therefore, in the case
* of penetration, in the array "opening" there are only the
* tangential components.
*/
opening += contact_opening;
/// compute normal and tangential opening vectors
normal_opening_norm = opening.dot(normal);
normal_opening = normal;
normal_opening *= normal_opening_norm;
tangential_opening = opening;
tangential_opening -= normal_opening;
tangential_opening_norm = tangential_opening.norm();
Real delta =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
penetration = normal_opening_norm < 0.0;
if (this->contact_after_breaking == false &&
Math::are_float_equal(damage, 1.))
penetration = false;
Real derivative = 0; // derivative = d(t/delta)/ddelta
Real t = 0;
Matrix<Real> n_outer_n(spatial_dimension, spatial_dimension);
n_outer_n.outerProduct(normal, normal);
if (penetration) {
/// stiffness in compression given by the penalty parameter
tangent += n_outer_n;
tangent *= penalty;
opening = tangential_opening;
normal_opening_norm = opening.dot(normal);
normal_opening = normal;
normal_opening *= normal_opening_norm;
} else {
delta += normal_opening_norm * normal_opening_norm;
}
delta = std::sqrt(delta);
/**
* Delta has to be different from 0 to have finite values of
* tangential stiffness. At the element insertion, delta =
* 0. Therefore, a fictictious value is defined, for the
* evaluation of the first value of K.
*/
if (delta < Math::getTolerance())
delta = delta_c / 1000.;
if (delta >= delta_max) {
if (delta <= delta_c) {
derivative = -sigma_c / (delta * delta);
t = sigma_c * (1 - delta / delta_c);
} else {
derivative = 0.;
t = 0.;
}
} else if (delta < delta_max) {
Real tmax = sigma_c * (1 - delta_max / delta_c);
t = tmax / delta_max * delta;
}
/// computation of the derivative of the constitutive law (dT/ddelta)
Matrix<Real> I(spatial_dimension, spatial_dimension);
I.eye(this->beta2_kappa);
Matrix<Real> nn(n_outer_n);
nn *= (1. - this->beta2_kappa);
nn += I;
nn *= t / delta;
Vector<Real> t_tilde(normal_opening);
t_tilde *= (1. - this->beta2_kappa2);
Vector<Real> mm(opening);
mm *= this->beta2_kappa2;
t_tilde += mm;
Vector<Real> t_hat(normal_opening);
t_hat += this->beta2_kappa * tangential_opening;
Matrix<Real> prov(spatial_dimension, spatial_dimension);
prov.outerProduct(t_hat, t_tilde);
prov *= derivative / delta;
prov += nn;
Matrix<Real> prov_t = prov.transpose();
tangent += prov_t;
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
#endif //__AKANTU_MATERIAL_COHESIVE_LINEAR_INLINE_IMPL_CC__
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.cc
index 622b5e77b..4e9789757 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.cc
@@ -1,413 +1,413 @@
/**
* @file material_cohesive_linear_uncoupled.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
*
* @date creation: Mon Jul 25 2016
* @date last modification: Wed Feb 21 2018
*
* @brief Linear irreversible cohesive law of mixed mode loading with
* random stress definition for extrinsic type
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <numeric>
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear_uncoupled.hh"
#include "solid_mechanics_model_cohesive.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
MaterialCohesiveLinearUncoupled<spatial_dimension>::
MaterialCohesiveLinearUncoupled(SolidMechanicsModel & model, const ID & id)
: MaterialCohesiveLinear<spatial_dimension>(model, id),
delta_n_max("delta_n_max", *this), delta_t_max("delta_t_max", *this),
damage_n("damage_n", *this), damage_t("damage_t", *this) {
AKANTU_DEBUG_IN();
this->registerParam(
"roughness", R, Real(1.), _pat_parsable | _pat_readable,
"Roughness to define coupling between mode II and mode I");
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearUncoupled<spatial_dimension>::initMaterial() {
AKANTU_DEBUG_IN();
MaterialCohesiveLinear<spatial_dimension>::initMaterial();
delta_n_max.initialize(1);
delta_t_max.initialize(1);
damage_n.initialize(1);
damage_t.initialize(1);
delta_n_max.initializeHistory();
delta_t_max.initializeHistory();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearUncoupled<spatial_dimension>::computeTraction(
const Array<Real> &, ElementType el_type, GhostType ghost_type) {
AKANTU_DEBUG_IN();
delta_n_max.resize();
delta_t_max.resize();
damage_n.resize();
damage_t.resize();
/// define iterators
auto traction_it =
this->tractions(el_type, ghost_type).begin(spatial_dimension);
auto traction_end =
this->tractions(el_type, ghost_type).end(spatial_dimension);
auto opening_it = this->opening(el_type, ghost_type).begin(spatial_dimension);
auto contact_traction_it =
this->contact_tractions(el_type, ghost_type).begin(spatial_dimension);
auto contact_opening_it =
this->contact_opening(el_type, ghost_type).begin(spatial_dimension);
auto normal_it = this->normal.begin(spatial_dimension);
auto sigma_c_it = this->sigma_c_eff(el_type, ghost_type).begin();
auto delta_n_max_it = delta_n_max(el_type, ghost_type).begin();
auto delta_t_max_it = delta_t_max(el_type, ghost_type).begin();
auto delta_c_it = this->delta_c_eff(el_type, ghost_type).begin();
auto damage_n_it = damage_n(el_type, ghost_type).begin();
auto damage_t_it = damage_t(el_type, ghost_type).begin();
auto insertion_stress_it =
this->insertion_stress(el_type, ghost_type).begin(spatial_dimension);
Vector<Real> normal_opening(spatial_dimension);
Vector<Real> tangential_opening(spatial_dimension);
/// loop on each quadrature point
for (; traction_it != traction_end;
++traction_it, ++opening_it, ++contact_traction_it, ++contact_opening_it,
++normal_it, ++sigma_c_it, ++delta_n_max_it, ++delta_t_max_it,
++delta_c_it, ++damage_n_it, ++damage_t_it, ++insertion_stress_it) {
Real normal_opening_norm, tangential_opening_norm;
bool penetration;
Real delta_c2_R2 = *delta_c_it * (*delta_c_it) / R / R;
/// compute normal and tangential opening vectors
normal_opening_norm = opening_it->dot(*normal_it);
Vector<Real> normal_opening = *normal_it;
normal_opening *= normal_opening_norm;
// std::cout<< "normal_opening_norm = " << normal_opening_norm
// <<std::endl;
Vector<Real> tangential_opening = *opening_it;
tangential_opening -= normal_opening;
tangential_opening_norm = tangential_opening.norm();
/// compute effective opening displacement
Real delta_n =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
Real delta_t =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
penetration = normal_opening_norm < 0.0;
if (this->contact_after_breaking == false &&
Math::are_float_equal(*damage_n_it, 1.))
penetration = false;
if (penetration) {
/// use penalty coefficient in case of penetration
*contact_traction_it = normal_opening;
*contact_traction_it *= this->penalty;
*contact_opening_it = normal_opening;
/// don't consider penetration contribution for delta
//*opening_it = tangential_opening;
normal_opening.clear();
} else {
delta_n += normal_opening_norm * normal_opening_norm;
delta_t += normal_opening_norm * normal_opening_norm * delta_c2_R2;
contact_traction_it->clear();
contact_opening_it->clear();
}
delta_n = std::sqrt(delta_n);
delta_t = std::sqrt(delta_t);
/// update maximum displacement and damage
*delta_n_max_it = std::max(*delta_n_max_it, delta_n);
*damage_n_it = std::min(*delta_n_max_it / *delta_c_it, Real(1.));
*delta_t_max_it = std::max(*delta_t_max_it, delta_t);
*damage_t_it = std::min(*delta_t_max_it / *delta_c_it, Real(1.));
Vector<Real> normal_traction(spatial_dimension);
Vector<Real> shear_traction(spatial_dimension);
/// NORMAL TRACTIONS
if (Math::are_float_equal(*damage_n_it, 1.))
normal_traction.clear();
else if (Math::are_float_equal(*damage_n_it, 0.)) {
if (penetration)
normal_traction.clear();
else
normal_traction = *insertion_stress_it;
} else {
// the following formulation holds both in loading and in
// unloading-reloading
normal_traction = normal_opening;
AKANTU_DEBUG_ASSERT(*delta_n_max_it != 0.,
"Division by zero, tolerance might be too low");
normal_traction *= *sigma_c_it / (*delta_n_max_it) * (1. - *damage_n_it);
}
/// SHEAR TRACTIONS
if (Math::are_float_equal(*damage_t_it, 1.))
shear_traction.clear();
else if (Math::are_float_equal(*damage_t_it, 0.)) {
shear_traction.clear();
} else {
shear_traction = tangential_opening;
AKANTU_DEBUG_ASSERT(*delta_t_max_it != 0.,
"Division by zero, tolerance might be too low");
shear_traction *= this->beta2_kappa;
shear_traction *= *sigma_c_it / (*delta_t_max_it) * (1. - *damage_t_it);
}
*traction_it = normal_traction;
*traction_it += shear_traction;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <UInt spatial_dimension>
void MaterialCohesiveLinearUncoupled<spatial_dimension>::computeTangentTraction(
const ElementType & el_type, Array<Real> & tangent_matrix,
const Array<Real> &, GhostType ghost_type) {
AKANTU_DEBUG_IN();
/// define iterators
auto tangent_it = tangent_matrix.begin(spatial_dimension, spatial_dimension);
auto tangent_end = tangent_matrix.end(spatial_dimension, spatial_dimension);
auto normal_it = this->normal.begin(spatial_dimension);
auto opening_it = this->opening(el_type, ghost_type).begin(spatial_dimension);
/// NB: delta_max_it points on delta_max_previous, i.e. the
/// delta_max related to the solution of the previous incremental
/// step
auto delta_n_max_it = delta_n_max.previous(el_type, ghost_type).begin();
auto delta_t_max_it = delta_t_max.previous(el_type, ghost_type).begin();
auto sigma_c_it = this->sigma_c_eff(el_type, ghost_type).begin();
auto delta_c_it = this->delta_c_eff(el_type, ghost_type).begin();
auto damage_n_it = damage_n(el_type, ghost_type).begin();
auto contact_opening_it =
this->contact_opening(el_type, ghost_type).begin(spatial_dimension);
Vector<Real> normal_opening(spatial_dimension);
Vector<Real> tangential_opening(spatial_dimension);
for (; tangent_it != tangent_end; ++tangent_it, ++normal_it, ++opening_it,
++sigma_c_it, ++delta_c_it,
++delta_n_max_it, ++delta_t_max_it,
++damage_n_it, ++contact_opening_it) {
Real normal_opening_norm, tangential_opening_norm;
bool penetration;
Real delta_c2_R2 = *delta_c_it * (*delta_c_it) / R / R;
/**
* During the update of the residual the interpenetrations are
* stored in the array "contact_opening", therefore, in the case
* of penetration, in the array "opening" there are only the
* tangential components.
*/
*opening_it += *contact_opening_it;
/// compute normal and tangential opening vectors
normal_opening_norm = opening_it->dot(*normal_it);
Vector<Real> normal_opening = *normal_it;
normal_opening *= normal_opening_norm;
Vector<Real> tangential_opening = *opening_it;
tangential_opening -= normal_opening;
tangential_opening_norm = tangential_opening.norm();
Real delta_n =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
Real delta_t =
tangential_opening_norm * tangential_opening_norm * this->beta2_kappa2;
penetration = normal_opening_norm < 0.0;
if (this->contact_after_breaking == false &&
Math::are_float_equal(*damage_n_it, 1.))
penetration = false;
Real derivative = 0; // derivative = d(t/delta)/ddelta
Real T = 0;
/// TANGENT STIFFNESS FOR NORMAL TRACTIONS
Matrix<Real> n_outer_n(spatial_dimension, spatial_dimension);
n_outer_n.outerProduct(*normal_it, *normal_it);
if (penetration) {
/// stiffness in compression given by the penalty parameter
*tangent_it = n_outer_n;
*tangent_it *= this->penalty;
//*opening_it = tangential_opening;
normal_opening.clear();
} else {
delta_n += normal_opening_norm * normal_opening_norm;
delta_n = std::sqrt(delta_n);
delta_t += normal_opening_norm * normal_opening_norm * delta_c2_R2;
/**
* Delta has to be different from 0 to have finite values of
* tangential stiffness. At the element insertion, delta =
* 0. Therefore, a fictictious value is defined, for the
* evaluation of the first value of K.
*/
if (delta_n < Math::getTolerance())
delta_n = *delta_c_it / 1000.;
// loading
if (delta_n >= *delta_n_max_it) {
if (delta_n <= *delta_c_it) {
derivative = -(*sigma_c_it) / (delta_n * delta_n);
T = *sigma_c_it * (1 - delta_n / *delta_c_it);
} else {
derivative = 0.;
T = 0.;
}
// unloading-reloading
} else if (delta_n < *delta_n_max_it) {
Real T_max = *sigma_c_it * (1 - *delta_n_max_it / *delta_c_it);
derivative = 0.;
T = T_max / *delta_n_max_it * delta_n;
}
/// computation of the derivative of the constitutive law (dT/ddelta)
Matrix<Real> nn(n_outer_n);
nn *= T / delta_n;
Vector<Real> Delta_tilde(normal_opening);
Delta_tilde *= (1. - this->beta2_kappa2);
Vector<Real> mm(*opening_it);
mm *= this->beta2_kappa2;
Delta_tilde += mm;
const Vector<Real> & Delta_hat(normal_opening);
Matrix<Real> prov(spatial_dimension, spatial_dimension);
prov.outerProduct(Delta_hat, Delta_tilde);
prov *= derivative / delta_n;
prov += nn;
Matrix<Real> prov_t = prov.transpose();
*tangent_it = prov_t;
}
derivative = 0.;
T = 0.;
/// TANGENT STIFFNESS FOR SHEAR TRACTIONS
delta_t = std::sqrt(delta_t);
/**
* Delta has to be different from 0 to have finite values of
* tangential stiffness. At the element insertion, delta =
* 0. Therefore, a fictictious value is defined, for the
* evaluation of the first value of K.
*/
if (delta_t < Math::getTolerance())
delta_t = *delta_c_it / 1000.;
// loading
if (delta_t >= *delta_t_max_it) {
if (delta_t <= *delta_c_it) {
derivative = -(*sigma_c_it) / (delta_t * delta_t);
T = *sigma_c_it * (1 - delta_t / *delta_c_it);
} else {
derivative = 0.;
T = 0.;
}
// unloading-reloading
} else if (delta_t < *delta_t_max_it) {
Real T_max = *sigma_c_it * (1 - *delta_t_max_it / *delta_c_it);
derivative = 0.;
T = T_max / *delta_t_max_it * delta_t;
}
/// computation of the derivative of the constitutive law (dT/ddelta)
Matrix<Real> I(spatial_dimension, spatial_dimension);
I.eye();
Matrix<Real> nn(n_outer_n);
I -= nn;
I *= T / delta_t;
Vector<Real> Delta_tilde(normal_opening);
Delta_tilde *= (delta_c2_R2 - this->beta2_kappa2);
Vector<Real> mm(*opening_it);
mm *= this->beta2_kappa2;
Delta_tilde += mm;
Vector<Real> Delta_hat(tangential_opening);
Delta_hat *= this->beta2_kappa;
Matrix<Real> prov(spatial_dimension, spatial_dimension);
prov.outerProduct(Delta_hat, Delta_tilde);
prov *= derivative / delta_t;
prov += I;
Matrix<Real> prov_t = prov.transpose();
*tangent_it += prov_t;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
INSTANTIATE_MATERIAL(cohesive_linear_uncoupled,
MaterialCohesiveLinearUncoupled);
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.hh b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.hh
index 4a7d61404..ee3615ae6 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/constitutive_laws/material_cohesive_linear_uncoupled.hh
@@ -1,102 +1,102 @@
/**
* @file material_cohesive_linear_uncoupled.hh
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Feb 21 2018
*
* @brief Linear irreversible cohesive law of mixed mode loading with
* random stress definition for extrinsic type
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_MATERIAL_COHESIVE_LINEAR_UNCOUPLED_HH__
#define __AKANTU_MATERIAL_COHESIVE_LINEAR_UNCOUPLED_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* Cohesive material linear with two different laws for mode I and
* mode II, for extrinsic case
*
* parameters in the material files :
* - roughness : define the interaction between mode I and mode II (default: 0)
*/
template <UInt spatial_dimension>
class MaterialCohesiveLinearUncoupled
: public MaterialCohesiveLinear<spatial_dimension> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
// typedef MaterialCohesiveLinear<spatial_dimension> MaterialParent;
public:
MaterialCohesiveLinearUncoupled(SolidMechanicsModel & model,
const ID & id = "");
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the material parameters
void initMaterial() override;
protected:
/// constitutive law
void computeTraction(const Array<Real> & normal, ElementType el_type,
GhostType ghost_type = _not_ghost) override;
/// compute tangent stiffness matrix
void computeTangentTraction(const ElementType & el_type,
Array<Real> & tangent_matrix,
const Array<Real> & normal,
GhostType ghost_type) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// parameter to tune the interaction between mode II and mode I
Real R;
/// maximum normal displacement
CohesiveInternalField<Real> delta_n_max;
/// maximum tangential displacement
CohesiveInternalField<Real> delta_t_max;
/// damage associated to normal tractions
CohesiveInternalField<Real> damage_n;
/// damage associated to shear tractions
CohesiveInternalField<Real> damage_t;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_MATERIAL_COHESIVE_LINEAR_UNCOUPLED_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive.cc
index d25c7102f..1c31d8d0a 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive.cc
@@ -1,560 +1,558 @@
/**
* @file material_cohesive.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Seyedeh Mohadeseh Taheri Mousavi <mohadeseh.taherimousavi@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Feb 22 2012
* @date last modification: Mon Feb 19 2018
*
* @brief Specialization of the material class for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive.hh"
#include "aka_random_generator.hh"
#include "dof_synchronizer.hh"
#include "fe_engine_template.hh"
#include "integrator_gauss.hh"
#include "shape_cohesive.hh"
#include "solid_mechanics_model_cohesive.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
MaterialCohesive::MaterialCohesive(SolidMechanicsModel & model, const ID & id)
: Material(model, id),
facet_filter("facet_filter", id, this->getMemoryID()),
fem_cohesive(
model.getFEEngineClass<MyFEEngineCohesiveType>("CohesiveFEEngine")),
reversible_energy("reversible_energy", *this),
total_energy("total_energy", *this), opening("opening", *this),
tractions("tractions", *this),
contact_tractions("contact_tractions", *this),
contact_opening("contact_opening", *this), delta_max("delta max", *this),
use_previous_delta_max(false), use_previous_opening(false),
damage("damage", *this), sigma_c("sigma_c", *this),
normal(0, spatial_dimension, "normal") {
AKANTU_DEBUG_IN();
this->model = dynamic_cast<SolidMechanicsModelCohesive *>(&model);
this->registerParam("sigma_c", sigma_c, _pat_parsable | _pat_readable,
"Critical stress");
this->registerParam("delta_c", delta_c, Real(0.),
_pat_parsable | _pat_readable, "Critical displacement");
this->element_filter.initialize(this->model->getMesh(),
_spatial_dimension = spatial_dimension,
_element_kind = _ek_cohesive);
// this->model->getMesh().initElementTypeMapArray(
// this->element_filter, 1, spatial_dimension, false, _ek_cohesive);
if (this->model->getIsExtrinsic())
this->facet_filter.initialize(this->model->getMeshFacets(),
_spatial_dimension = spatial_dimension - 1,
_element_kind = _ek_regular);
// this->model->getMeshFacets().initElementTypeMapArray(facet_filter, 1,
// spatial_dimension -
// 1);
this->reversible_energy.initialize(1);
this->total_energy.initialize(1);
this->tractions.initialize(spatial_dimension);
this->tractions.initializeHistory();
this->contact_tractions.initialize(spatial_dimension);
this->contact_opening.initialize(spatial_dimension);
this->opening.initialize(spatial_dimension);
this->opening.initializeHistory();
this->delta_max.initialize(1);
this->damage.initialize(1);
if (this->model->getIsExtrinsic())
this->sigma_c.initialize(1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
MaterialCohesive::~MaterialCohesive() = default;
/* -------------------------------------------------------------------------- */
void MaterialCohesive::initMaterial() {
AKANTU_DEBUG_IN();
Material::initMaterial();
if (this->use_previous_delta_max)
this->delta_max.initializeHistory();
if (this->use_previous_opening)
this->opening.initializeHistory();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MaterialCohesive::assembleInternalForces(GhostType ghost_type) {
AKANTU_DEBUG_IN();
#if defined(AKANTU_DEBUG_TOOLS)
debug::element_manager.printData(debug::_dm_material_cohesive,
"Cohesive Tractions", tractions);
#endif
auto & internal_force = const_cast<Array<Real> &>(model->getInternalForce());
for (auto type : element_filter.elementTypes(spatial_dimension, ghost_type,
_ek_cohesive)) {
auto & elem_filter = element_filter(type, ghost_type);
UInt nb_element = elem_filter.size();
if (nb_element == 0)
continue;
const auto & shapes = fem_cohesive.getShapes(type, ghost_type);
auto & traction = tractions(type, ghost_type);
auto & contact_traction = contact_tractions(type, ghost_type);
UInt size_of_shapes = shapes.getNbComponent();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points =
fem_cohesive.getNbIntegrationPoints(type, ghost_type);
/// compute @f$t_i N_a@f$
Array<Real> * traction_cpy = new Array<Real>(
nb_element * nb_quadrature_points, spatial_dimension * size_of_shapes);
auto traction_it = traction.begin(spatial_dimension, 1);
auto contact_traction_it = contact_traction.begin(spatial_dimension, 1);
auto shapes_filtered_begin = shapes.begin(1, size_of_shapes);
auto traction_cpy_it =
traction_cpy->begin(spatial_dimension, size_of_shapes);
Matrix<Real> traction_tmp(spatial_dimension, 1);
for (UInt el = 0; el < nb_element; ++el) {
UInt current_quad = elem_filter(el) * nb_quadrature_points;
for (UInt q = 0; q < nb_quadrature_points; ++q, ++traction_it,
++contact_traction_it, ++current_quad, ++traction_cpy_it) {
const Matrix<Real> & shapes_filtered =
shapes_filtered_begin[current_quad];
traction_tmp.copy(*traction_it);
traction_tmp += *contact_traction_it;
traction_cpy_it->mul<false, false>(traction_tmp, shapes_filtered);
}
}
/**
* compute @f$\int t \cdot N\, dS@f$ by @f$ \sum_q \mathbf{N}^t
* \mathbf{t}_q \overline w_q J_q@f$
*/
Array<Real> * partial_int_t_N = new Array<Real>(
nb_element, spatial_dimension * size_of_shapes, "int_t_N");
fem_cohesive.integrate(*traction_cpy, *partial_int_t_N,
spatial_dimension * size_of_shapes, type, ghost_type,
elem_filter);
delete traction_cpy;
Array<Real> * int_t_N = new Array<Real>(
nb_element, 2 * spatial_dimension * size_of_shapes, "int_t_N");
Real * int_t_N_val = int_t_N->storage();
Real * partial_int_t_N_val = partial_int_t_N->storage();
for (UInt el = 0; el < nb_element; ++el) {
std::copy_n(partial_int_t_N_val, size_of_shapes * spatial_dimension,
int_t_N_val);
std::copy_n(partial_int_t_N_val, size_of_shapes * spatial_dimension,
int_t_N_val + size_of_shapes * spatial_dimension);
for (UInt n = 0; n < size_of_shapes * spatial_dimension; ++n)
int_t_N_val[n] *= -1.;
int_t_N_val += nb_nodes_per_element * spatial_dimension;
partial_int_t_N_val += size_of_shapes * spatial_dimension;
}
delete partial_int_t_N;
/// assemble
model->getDOFManager().assembleElementalArrayLocalArray(
*int_t_N, internal_force, type, ghost_type, 1, elem_filter);
delete int_t_N;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MaterialCohesive::assembleStiffnessMatrix(GhostType ghost_type) {
AKANTU_DEBUG_IN();
for (auto type : element_filter.elementTypes(spatial_dimension, ghost_type,
_ek_cohesive)) {
UInt nb_quadrature_points =
fem_cohesive.getNbIntegrationPoints(type, ghost_type);
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
const Array<Real> & shapes = fem_cohesive.getShapes(type, ghost_type);
Array<UInt> & elem_filter = element_filter(type, ghost_type);
UInt nb_element = elem_filter.size();
if (!nb_element)
continue;
UInt size_of_shapes = shapes.getNbComponent();
Array<Real> * shapes_filtered = new Array<Real>(
nb_element * nb_quadrature_points, size_of_shapes, "filtered shapes");
Real * shapes_filtered_val = shapes_filtered->storage();
UInt * elem_filter_val = elem_filter.storage();
for (UInt el = 0; el < nb_element; ++el) {
auto shapes_val = shapes.storage() + elem_filter_val[el] *
size_of_shapes *
nb_quadrature_points;
memcpy(shapes_filtered_val, shapes_val,
size_of_shapes * nb_quadrature_points * sizeof(Real));
shapes_filtered_val += size_of_shapes * nb_quadrature_points;
}
Matrix<Real> A(spatial_dimension * size_of_shapes,
spatial_dimension * nb_nodes_per_element);
for (UInt i = 0; i < spatial_dimension * size_of_shapes; ++i) {
A(i, i) = 1;
A(i, i + spatial_dimension * size_of_shapes) = -1;
}
/// get the tangent matrix @f$\frac{\partial{(t/\delta)}}{\partial{\delta}}
/// @f$
Array<Real> * tangent_stiffness_matrix = new Array<Real>(
nb_element * nb_quadrature_points,
spatial_dimension * spatial_dimension, "tangent_stiffness_matrix");
// Array<Real> * normal = new Array<Real>(nb_element *
// nb_quadrature_points, spatial_dimension, "normal");
normal.resize(nb_quadrature_points);
computeNormal(model->getCurrentPosition(), normal, type, ghost_type);
/// compute openings @f$\mathbf{\delta}@f$
// computeOpening(model->getDisplacement(), opening(type, ghost_type), type,
// ghost_type);
tangent_stiffness_matrix->clear();
computeTangentTraction(type, *tangent_stiffness_matrix, normal, ghost_type);
// delete normal;
UInt size_at_nt_d_n_a = spatial_dimension * nb_nodes_per_element *
spatial_dimension * nb_nodes_per_element;
Array<Real> * at_nt_d_n_a = new Array<Real>(
nb_element * nb_quadrature_points, size_at_nt_d_n_a, "A^t*N^t*D*N*A");
Array<Real>::iterator<Vector<Real>> shapes_filt_it =
shapes_filtered->begin(size_of_shapes);
Array<Real>::matrix_iterator D_it =
tangent_stiffness_matrix->begin(spatial_dimension, spatial_dimension);
Array<Real>::matrix_iterator At_Nt_D_N_A_it =
at_nt_d_n_a->begin(spatial_dimension * nb_nodes_per_element,
spatial_dimension * nb_nodes_per_element);
Array<Real>::matrix_iterator At_Nt_D_N_A_end =
at_nt_d_n_a->end(spatial_dimension * nb_nodes_per_element,
spatial_dimension * nb_nodes_per_element);
Matrix<Real> N(spatial_dimension, spatial_dimension * size_of_shapes);
Matrix<Real> N_A(spatial_dimension,
spatial_dimension * nb_nodes_per_element);
Matrix<Real> D_N_A(spatial_dimension,
spatial_dimension * nb_nodes_per_element);
for (; At_Nt_D_N_A_it != At_Nt_D_N_A_end;
++At_Nt_D_N_A_it, ++D_it, ++shapes_filt_it) {
N.clear();
/**
* store the shapes in voigt notations matrix @f$\mathbf{N} =
* \begin{array}{cccccc} N_0(\xi) & 0 & N_1(\xi) &0 & N_2(\xi) & 0 \\
* 0 & * N_0(\xi)& 0 &N_1(\xi)& 0 & N_2(\xi) \end{array} @f$
**/
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt n = 0; n < size_of_shapes; ++n)
N(i, i + spatial_dimension * n) = (*shapes_filt_it)(n);
/**
* compute stiffness matrix @f$ \mathbf{K} = \delta \mathbf{U}^T
* \int_{\Gamma_c} {\mathbf{P}^t \frac{\partial{\mathbf{t}}}
*{\partial{\delta}}
* \mathbf{P} d\Gamma \Delta \mathbf{U}} @f$
**/
N_A.mul<false, false>(N, A);
D_N_A.mul<false, false>(*D_it, N_A);
(*At_Nt_D_N_A_it).mul<true, false>(D_N_A, N_A);
}
delete tangent_stiffness_matrix;
delete shapes_filtered;
Array<Real> * K_e = new Array<Real>(nb_element, size_at_nt_d_n_a, "K_e");
fem_cohesive.integrate(*at_nt_d_n_a, *K_e, size_at_nt_d_n_a, type,
ghost_type, elem_filter);
delete at_nt_d_n_a;
model->getDOFManager().assembleElementalMatricesToMatrix(
"K", "displacement", *K_e, type, ghost_type, _unsymmetric, elem_filter);
delete K_e;
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- *
* Compute traction from displacements
*
* @param[in] ghost_type compute the residual for _ghost or _not_ghost element
*/
void MaterialCohesive::computeTraction(GhostType ghost_type) {
AKANTU_DEBUG_IN();
#if defined(AKANTU_DEBUG_TOOLS)
debug::element_manager.printData(debug::_dm_material_cohesive,
"Cohesive Openings", opening);
#endif
for (auto & type : element_filter.elementTypes(spatial_dimension, ghost_type,
_ek_cohesive)) {
Array<UInt> & elem_filter = element_filter(type, ghost_type);
UInt nb_element = elem_filter.size();
if (nb_element == 0)
continue;
UInt nb_quadrature_points =
nb_element * fem_cohesive.getNbIntegrationPoints(type, ghost_type);
normal.resize(nb_quadrature_points);
/// compute normals @f$\mathbf{n}@f$
computeNormal(model->getCurrentPosition(), normal, type, ghost_type);
/// compute openings @f$\mathbf{\delta}@f$
computeOpening(model->getDisplacement(), opening(type, ghost_type), type,
ghost_type);
/// compute traction @f$\mathbf{t}@f$
computeTraction(normal, type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MaterialCohesive::computeNormal(const Array<Real> & position,
Array<Real> & normal, ElementType type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto & fem_cohesive =
this->model->getFEEngineClass<MyFEEngineCohesiveType>("CohesiveFEEngine");
normal.clear();
-#define COMPUTE_NORMAL(type) \
+#define COMPUTE_NORMAL(type) \
fem_cohesive.getShapeFunctions() \
.computeNormalsOnIntegrationPoints<type, CohesiveReduceFunctionMean>( \
position, normal, ghost_type, element_filter(type, ghost_type));
AKANTU_BOOST_COHESIVE_ELEMENT_SWITCH(COMPUTE_NORMAL);
#undef COMPUTE_NORMAL
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MaterialCohesive::computeOpening(const Array<Real> & displacement,
Array<Real> & opening, ElementType type,
GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto & fem_cohesive =
this->model->getFEEngineClass<MyFEEngineCohesiveType>("CohesiveFEEngine");
#define COMPUTE_OPENING(type) \
fem_cohesive.getShapeFunctions() \
.interpolateOnIntegrationPoints<type, CohesiveReduceFunctionOpening>( \
displacement, opening, spatial_dimension, ghost_type, \
element_filter(type, ghost_type));
AKANTU_BOOST_COHESIVE_ELEMENT_SWITCH(COMPUTE_OPENING);
#undef COMPUTE_OPENING
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void MaterialCohesive::updateEnergies(ElementType type) {
AKANTU_DEBUG_IN();
if (Mesh::getKind(type) != _ek_cohesive)
return;
-
+
Vector<Real> b(spatial_dimension);
Vector<Real> h(spatial_dimension);
auto erev = reversible_energy(type).begin();
auto etot = total_energy(type).begin();
auto traction_it = tractions(type).begin(spatial_dimension);
- auto traction_old_it =
- tractions.previous(type).begin(spatial_dimension);
+ auto traction_old_it = tractions.previous(type).begin(spatial_dimension);
auto opening_it = opening(type).begin(spatial_dimension);
- auto opening_old_it =
- opening.previous(type).begin(spatial_dimension);
+ auto opening_old_it = opening.previous(type).begin(spatial_dimension);
auto traction_end = tractions(type).end(spatial_dimension);
/// loop on each quadrature point
for (; traction_it != traction_end; ++traction_it, ++traction_old_it,
++opening_it, ++opening_old_it, ++erev,
++etot) {
/// trapezoidal integration
b = *opening_it;
b -= *opening_old_it;
h = *traction_old_it;
h += *traction_it;
*etot += .5 * b.dot(h);
*erev = .5 * traction_it->dot(*opening_it);
}
/// update old values
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Real MaterialCohesive::getReversibleEnergy() {
AKANTU_DEBUG_IN();
Real erev = 0.;
/// integrate reversible energy for each type of elements
for (auto & type : element_filter.elementTypes(spatial_dimension, _not_ghost,
_ek_cohesive)) {
erev +=
fem_cohesive.integrate(reversible_energy(type, _not_ghost), type,
_not_ghost, element_filter(type, _not_ghost));
}
AKANTU_DEBUG_OUT();
return erev;
}
/* -------------------------------------------------------------------------- */
Real MaterialCohesive::getDissipatedEnergy() {
AKANTU_DEBUG_IN();
Real edis = 0.;
/// integrate dissipated energy for each type of elements
for (auto & type : element_filter.elementTypes(spatial_dimension, _not_ghost,
_ek_cohesive)) {
Array<Real> dissipated_energy(total_energy(type, _not_ghost));
dissipated_energy -= reversible_energy(type, _not_ghost);
edis += fem_cohesive.integrate(dissipated_energy, type, _not_ghost,
element_filter(type, _not_ghost));
}
AKANTU_DEBUG_OUT();
return edis;
}
/* -------------------------------------------------------------------------- */
Real MaterialCohesive::getContactEnergy() {
AKANTU_DEBUG_IN();
Real econ = 0.;
/// integrate contact energy for each type of elements
for (auto & type : element_filter.elementTypes(spatial_dimension, _not_ghost,
_ek_cohesive)) {
auto & el_filter = element_filter(type, _not_ghost);
UInt nb_quad_per_el = fem_cohesive.getNbIntegrationPoints(type, _not_ghost);
UInt nb_quad_points = el_filter.size() * nb_quad_per_el;
Array<Real> contact_energy(nb_quad_points);
auto contact_traction_it =
contact_tractions(type, _not_ghost).begin(spatial_dimension);
auto contact_opening_it =
contact_opening(type, _not_ghost).begin(spatial_dimension);
/// loop on each quadrature point
for (UInt q = 0; q < nb_quad_points;
++contact_traction_it, ++contact_opening_it, ++q) {
contact_energy(q) = .5 * contact_traction_it->dot(*contact_opening_it);
}
econ += fem_cohesive.integrate(contact_energy, type, _not_ghost, el_filter);
}
AKANTU_DEBUG_OUT();
return econ;
}
/* -------------------------------------------------------------------------- */
Real MaterialCohesive::getEnergy(const std::string & type) {
AKANTU_DEBUG_IN();
if (type == "reversible")
return getReversibleEnergy();
else if (type == "dissipated")
return getDissipatedEnergy();
else if (type == "cohesive contact")
return getContactEnergy();
AKANTU_DEBUG_OUT();
return 0.;
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive_inline_impl.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive_inline_impl.cc
index 92d32336d..31705313c 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive_inline_impl.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/materials/material_cohesive_inline_impl.cc
@@ -1,100 +1,99 @@
/**
* @file material_cohesive_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Mon Feb 19 2018
*
* @brief MaterialCohesive inline implementation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
inline UInt MaterialCohesive::addFacet(const Element & element) {
Array<UInt> & f_filter = facet_filter(element.type, element.ghost_type);
f_filter.push_back(element.element);
return f_filter.size() - 1;
}
/* -------------------------------------------------------------------------- */
template <ElementType type>
void MaterialCohesive::computeNormal(const Array<Real> & /*position*/,
Array<Real> & /*normal*/,
GhostType /*ghost_type*/) {}
/* -------------------------------------------------------------------------- */
inline UInt MaterialCohesive::getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const {
switch (tag) {
case SynchronizationTag::_smm_stress: {
return 2 * spatial_dimension * sizeof(Real) *
this->getModel().getNbIntegrationPoints(elements,
"CohesiveFEEngine");
}
case SynchronizationTag::_smmc_damage: {
- return sizeof(Real) *
- this->getModel().getNbIntegrationPoints(elements,
- "CohesiveFEEngine");
+ return sizeof(Real) * this->getModel().getNbIntegrationPoints(
+ elements, "CohesiveFEEngine");
}
default: {}
}
return 0;
}
/* -------------------------------------------------------------------------- */
inline void MaterialCohesive::packData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) const {
switch (tag) {
case SynchronizationTag::_smm_stress: {
packElementDataHelper(tractions, buffer, elements, "CohesiveFEEngine");
packElementDataHelper(contact_tractions, buffer, elements,
"CohesiveFEEngine");
break;
}
case SynchronizationTag::_smmc_damage:
packElementDataHelper(damage, buffer, elements, "CohesiveFEEngine");
break;
default: {}
}
}
/* -------------------------------------------------------------------------- */
inline void MaterialCohesive::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
switch (tag) {
case SynchronizationTag::_smm_stress: {
unpackElementDataHelper(tractions, buffer, elements, "CohesiveFEEngine");
unpackElementDataHelper(contact_tractions, buffer, elements,
"CohesiveFEEngine");
break;
}
case SynchronizationTag::_smmc_damage:
unpackElementDataHelper(damage, buffer, elements, "CohesiveFEEngine");
break;
default: {}
}
}
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive.cc
index 3c6f4e063..0b2abf154 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive.cc
@@ -1,703 +1,707 @@
/**
* @file solid_mechanics_model_cohesive.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Tue May 08 2012
* @date last modification: Wed Feb 21 2018
*
* @brief Solid mechanics model for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_cohesive.hh"
#include "aka_iterators.hh"
#include "cohesive_element_inserter.hh"
#include "element_synchronizer.hh"
#include "facet_synchronizer.hh"
#include "fe_engine_template.hh"
#include "global_ids_updater.hh"
#include "integrator_gauss.hh"
#include "material_cohesive.hh"
#include "mesh_accessor.hh"
#include "mesh_global_data_updater.hh"
#include "parser.hh"
#include "shape_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include "dumpable_inline_impl.hh"
#ifdef AKANTU_USE_IOHELPER
#include "dumper_iohelper_paraview.hh"
#endif
/* -------------------------------------------------------------------------- */
#include <algorithm>
/* -------------------------------------------------------------------------- */
namespace akantu {
class CohesiveMeshGlobalDataUpdater : public MeshGlobalDataUpdater {
public:
CohesiveMeshGlobalDataUpdater(SolidMechanicsModelCohesive & model)
: model(model), mesh(model.getMesh()),
global_ids_updater(model.getMesh(), *model.cohesive_synchronizer) {}
/* ------------------------------------------------------------------------ */
std::tuple<UInt, UInt>
updateData(NewNodesEvent & nodes_event,
NewElementsEvent & elements_event) override {
auto cohesive_nodes_event =
dynamic_cast<CohesiveNewNodesEvent *>(&nodes_event);
if (not cohesive_nodes_event)
return std::make_tuple(nodes_event.getList().size(),
elements_event.getList().size());
/// update nodes type
auto & new_nodes = cohesive_nodes_event->getList();
auto & old_nodes = cohesive_nodes_event->getOldNodesList();
auto local_nb_new_nodes = new_nodes.size();
auto nb_new_nodes = local_nb_new_nodes;
if (mesh.isDistributed()) {
MeshAccessor mesh_accessor(mesh);
auto & nodes_flags = mesh_accessor.getNodesFlags();
auto nb_old_nodes = nodes_flags.size();
nodes_flags.resize(nb_old_nodes + local_nb_new_nodes);
for (auto && data : zip(old_nodes, new_nodes)) {
UInt old_node, new_node;
std::tie(old_node, new_node) = data;
nodes_flags(new_node) = nodes_flags(old_node);
}
model.updateCohesiveSynchronizers();
nb_new_nodes = global_ids_updater.updateGlobalIDs(new_nodes.size());
}
Vector<UInt> nb_new_stuff = {nb_new_nodes, elements_event.getList().size()};
const auto & comm = mesh.getCommunicator();
comm.allReduce(nb_new_stuff, SynchronizerOperation::_sum);
if (nb_new_stuff(1) > 0) {
mesh.sendEvent(elements_event);
MeshUtils::resetFacetToDouble(mesh.getMeshFacets());
}
if (nb_new_stuff(0) > 0) {
mesh.sendEvent(nodes_event);
// mesh.sendEvent(global_ids_updater.getChangedNodeEvent());
}
return std::make_tuple(nb_new_stuff(0), nb_new_stuff(1));
}
private:
SolidMechanicsModelCohesive & model;
Mesh & mesh;
GlobalIdsUpdater global_ids_updater;
};
/* -------------------------------------------------------------------------- */
SolidMechanicsModelCohesive::SolidMechanicsModelCohesive(
Mesh & mesh, UInt dim, const ID & id, const MemoryID & memory_id,
std::shared_ptr<DOFManager> dof_manager)
: SolidMechanicsModel(mesh, dim, id, memory_id, dof_manager,
ModelType::_solid_mechanics_model_cohesive),
tangents("tangents", id), facet_stress("facet_stress", id),
facet_material("facet_material", id) {
AKANTU_DEBUG_IN();
registerFEEngineObject<MyFEEngineCohesiveType>("CohesiveFEEngine", mesh,
Model::spatial_dimension);
auto && tmp_material_selector =
std::make_shared<DefaultMaterialCohesiveSelector>(*this);
tmp_material_selector->setFallback(this->material_selector);
this->material_selector = tmp_material_selector;
#if defined(AKANTU_USE_IOHELPER)
this->mesh.registerDumper<DumperParaview>("cohesive elements", id);
this->mesh.addDumpMeshToDumper("cohesive elements", mesh,
Model::spatial_dimension, _not_ghost,
_ek_cohesive);
#endif
if (this->mesh.isDistributed()) {
/// create the distributed synchronizer for cohesive elements
this->cohesive_synchronizer = std::make_unique<ElementSynchronizer>(
mesh, "cohesive_distributed_synchronizer");
auto & synchronizer = mesh.getElementSynchronizer();
this->cohesive_synchronizer->split(synchronizer, [](auto && el) {
return Mesh::getKind(el.type) == _ek_cohesive;
});
- this->registerSynchronizer(*cohesive_synchronizer, SynchronizationTag::_material_id);
- this->registerSynchronizer(*cohesive_synchronizer, SynchronizationTag::_smm_stress);
- this->registerSynchronizer(*cohesive_synchronizer, SynchronizationTag::_smm_boundary);
+ this->registerSynchronizer(*cohesive_synchronizer,
+ SynchronizationTag::_material_id);
+ this->registerSynchronizer(*cohesive_synchronizer,
+ SynchronizationTag::_smm_stress);
+ this->registerSynchronizer(*cohesive_synchronizer,
+ SynchronizationTag::_smm_boundary);
}
this->inserter = std::make_unique<CohesiveElementInserter>(
this->mesh, id + ":cohesive_element_inserter");
registerFEEngineObject<MyFEEngineFacetType>(
"FacetsFEEngine", mesh.getMeshFacets(), Model::spatial_dimension - 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SolidMechanicsModelCohesive::~SolidMechanicsModelCohesive() = default;
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::setTimeStep(Real time_step,
const ID & solver_id) {
SolidMechanicsModel::setTimeStep(time_step, solver_id);
#if defined(AKANTU_USE_IOHELPER)
this->mesh.getDumper("cohesive elements").setTimeStep(time_step);
#endif
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::initFullImpl(const ModelOptions & options) {
AKANTU_DEBUG_IN();
const auto & smmc_options =
aka::as_type<SolidMechanicsModelCohesiveOptions>(options);
this->is_extrinsic = smmc_options.is_extrinsic;
inserter->setIsExtrinsic(is_extrinsic);
if (mesh.isDistributed()) {
auto & mesh_facets = inserter->getMeshFacets();
auto & synchronizer =
aka::as_type<FacetSynchronizer>(mesh_facets.getElementSynchronizer());
synchronizeGhostFacetsConnectivity();
/// create the facet synchronizer for extrinsic simulations
if (is_extrinsic) {
facet_stress_synchronizer = std::make_unique<ElementSynchronizer>(
synchronizer, id + ":facet_stress_synchronizer");
facet_stress_synchronizer->swapSendRecv();
this->registerSynchronizer(*facet_stress_synchronizer,
SynchronizationTag::_smmc_facets_stress);
}
}
MeshAccessor mesh_accessor(mesh);
mesh_accessor.registerGlobalDataUpdater(
std::make_unique<CohesiveMeshGlobalDataUpdater>(*this));
ParserSection section;
bool is_empty;
std::tie(section, is_empty) = this->getParserSection();
if (not is_empty) {
auto inserter_section =
section.getSubSections(ParserType::_cohesive_inserter);
if (inserter_section.begin() != inserter_section.end()) {
inserter->parseSection(*inserter_section.begin());
}
}
SolidMechanicsModel::initFullImpl(options);
AKANTU_DEBUG_OUT();
} // namespace akantu
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::initMaterials() {
AKANTU_DEBUG_IN();
// make sure the material are instantiated
if (!are_materials_instantiated)
instantiateMaterials();
/// find the first cohesive material
UInt cohesive_index = UInt(-1);
for (auto && material : enumerate(materials)) {
if (dynamic_cast<MaterialCohesive *>(std::get<1>(material).get())) {
cohesive_index = std::get<0>(material);
break;
}
}
if (cohesive_index == UInt(-1))
AKANTU_EXCEPTION("No cohesive materials in the material input file");
material_selector->setFallback(cohesive_index);
// set the facet information in the material in case of dynamic insertion
// to know what material to call for stress checks
const Mesh & mesh_facets = inserter->getMeshFacets();
facet_material.initialize(
mesh_facets, _spatial_dimension = spatial_dimension - 1,
_with_nb_element = true,
_default_value = material_selector->getFallbackValue());
for_each_element(
mesh_facets,
[&](auto && element) {
auto mat_index = (*material_selector)(element);
auto & mat = aka::as_type<MaterialCohesive>(*materials[mat_index]);
facet_material(element) = mat_index;
if (is_extrinsic) {
mat.addFacet(element);
}
},
_spatial_dimension = spatial_dimension - 1, _ghost_type = _not_ghost);
SolidMechanicsModel::initMaterials();
if (is_extrinsic) {
this->initAutomaticInsertion();
} else {
this->insertIntrinsicElements();
}
AKANTU_DEBUG_OUT();
} // namespace akantu
/* -------------------------------------------------------------------------- */
/**
* Initialize the model,basically it pre-compute the shapes, shapes derivatives
* and jacobian
*/
void SolidMechanicsModelCohesive::initModel() {
AKANTU_DEBUG_IN();
SolidMechanicsModel::initModel();
/// add cohesive type connectivity
ElementType type = _not_defined;
for (auto && type_ghost : ghost_types) {
for (const auto & tmp_type :
mesh.elementTypes(spatial_dimension, type_ghost)) {
const auto & connectivity = mesh.getConnectivity(tmp_type, type_ghost);
if (connectivity.size() == 0)
continue;
type = tmp_type;
auto type_facet = Mesh::getFacetType(type);
auto type_cohesive = FEEngine::getCohesiveElementType(type_facet);
mesh.addConnectivityType(type_cohesive, type_ghost);
}
}
AKANTU_DEBUG_ASSERT(type != _not_defined, "No elements in the mesh");
getFEEngine("CohesiveFEEngine").initShapeFunctions(_not_ghost);
getFEEngine("CohesiveFEEngine").initShapeFunctions(_ghost);
if (is_extrinsic) {
getFEEngine("FacetsFEEngine").initShapeFunctions(_not_ghost);
getFEEngine("FacetsFEEngine").initShapeFunctions(_ghost);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::insertIntrinsicElements() {
AKANTU_DEBUG_IN();
inserter->insertIntrinsicElements();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::initAutomaticInsertion() {
AKANTU_DEBUG_IN();
this->inserter->limitCheckFacets();
this->updateFacetStressSynchronizer();
this->resizeFacetStress();
/// compute normals on facets
this->computeNormals();
this->initStressInterpolation();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::updateAutomaticInsertion() {
AKANTU_DEBUG_IN();
this->inserter->limitCheckFacets();
this->updateFacetStressSynchronizer();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::initStressInterpolation() {
Mesh & mesh_facets = inserter->getMeshFacets();
/// compute quadrature points coordinates on facets
Array<Real> & position = mesh.getNodes();
ElementTypeMapArray<Real> quad_facets("quad_facets", id);
quad_facets.initialize(mesh_facets, _nb_component = Model::spatial_dimension,
_spatial_dimension = Model::spatial_dimension - 1);
// mesh_facets.initElementTypeMapArray(quad_facets, Model::spatial_dimension,
// Model::spatial_dimension - 1);
getFEEngine("FacetsFEEngine")
.interpolateOnIntegrationPoints(position, quad_facets);
/// compute elements quadrature point positions and build
/// element-facet quadrature points data structure
ElementTypeMapArray<Real> elements_quad_facets("elements_quad_facets", id);
elements_quad_facets.initialize(
mesh, _nb_component = Model::spatial_dimension,
_spatial_dimension = Model::spatial_dimension);
// mesh.initElementTypeMapArray(elements_quad_facets,
// Model::spatial_dimension,
// Model::spatial_dimension);
for (auto elem_gt : ghost_types) {
for (auto & type : mesh.elementTypes(Model::spatial_dimension, elem_gt)) {
UInt nb_element = mesh.getNbElement(type, elem_gt);
if (nb_element == 0)
continue;
/// compute elements' quadrature points and list of facet
/// quadrature points positions by element
const auto & facet_to_element =
mesh_facets.getSubelementToElement(type, elem_gt);
auto & el_q_facet = elements_quad_facets(type, elem_gt);
auto facet_type = Mesh::getFacetType(type);
auto nb_quad_per_facet =
getFEEngine("FacetsFEEngine").getNbIntegrationPoints(facet_type);
auto nb_facet_per_elem = facet_to_element.getNbComponent();
// small hack in the loop to skip boundary elements, they are silently
// initialized to NaN to see if this causes problems
el_q_facet.resize(nb_element * nb_facet_per_elem * nb_quad_per_facet,
std::numeric_limits<Real>::quiet_NaN());
for (auto && data :
zip(make_view(facet_to_element),
make_view(el_q_facet, spatial_dimension, nb_quad_per_facet))) {
const auto & global_facet = std::get<0>(data);
auto & el_q = std::get<1>(data);
if (global_facet == ElementNull)
continue;
Matrix<Real> quad_f =
make_view(quad_facets(global_facet.type, global_facet.ghost_type),
spatial_dimension, nb_quad_per_facet)
.begin()[global_facet.element];
el_q = quad_f;
// for (UInt q = 0; q < nb_quad_per_facet; ++q) {
// for (UInt s = 0; s < Model::spatial_dimension; ++s) {
// el_q_facet(el * nb_facet_per_elem * nb_quad_per_facet +
// f * nb_quad_per_facet + q,
// s) = quad_f(global_facet * nb_quad_per_facet + q,
// s);
// }
// }
//}
}
}
}
/// loop over non cohesive materials
for (auto && material : materials) {
if (dynamic_cast<MaterialCohesive *>(material.get()))
continue;
/// initialize the interpolation function
material->initElementalFieldInterpolation(elements_quad_facets);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::assembleInternalForces() {
AKANTU_DEBUG_IN();
// f_int += f_int_cohe
for (auto & material : this->materials) {
try {
auto & mat = aka::as_type<MaterialCohesive>(*material);
mat.computeTraction(_not_ghost);
} catch (std::bad_cast & bce) {
}
}
SolidMechanicsModel::assembleInternalForces();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::computeNormals() {
AKANTU_DEBUG_IN();
Mesh & mesh_facets = this->inserter->getMeshFacets();
this->getFEEngine("FacetsFEEngine")
.computeNormalsOnIntegrationPoints(_not_ghost);
/**
* @todo store tangents while computing normals instead of
* recomputing them as follows:
*/
/* ------------------------------------------------------------------------ */
UInt tangent_components =
Model::spatial_dimension * (Model::spatial_dimension - 1);
tangents.initialize(mesh_facets, _nb_component = tangent_components,
_spatial_dimension = Model::spatial_dimension - 1);
// mesh_facets.initElementTypeMapArray(tangents, tangent_components,
// Model::spatial_dimension - 1);
for (auto facet_type :
mesh_facets.elementTypes(Model::spatial_dimension - 1)) {
const Array<Real> & normals =
this->getFEEngine("FacetsFEEngine")
.getNormalsOnIntegrationPoints(facet_type);
Array<Real> & tangents = this->tangents(facet_type);
Math::compute_tangents(normals, tangents);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::interpolateStress() {
ElementTypeMapArray<Real> by_elem_result("temporary_stress_by_facets", id);
for (auto & material : materials) {
auto * mat = dynamic_cast<MaterialCohesive *>(material.get());
if (mat == nullptr)
/// interpolate stress on facet quadrature points positions
material->interpolateStressOnFacets(facet_stress, by_elem_result);
}
this->synchronize(SynchronizationTag::_smmc_facets_stress);
}
/* -------------------------------------------------------------------------- */
UInt SolidMechanicsModelCohesive::checkCohesiveStress() {
AKANTU_DEBUG_IN();
if (not is_extrinsic) {
AKANTU_EXCEPTION(
"This function can only be used for extrinsic cohesive elements");
}
interpolateStress();
for (auto & mat : materials) {
auto * mat_cohesive = dynamic_cast<MaterialCohesive *>(mat.get());
if (mat_cohesive) {
/// check which not ghost cohesive elements are to be created
mat_cohesive->checkInsertion();
}
}
/// communicate data among processors
// this->synchronize(SynchronizationTag::_smmc_facets);
/// insert cohesive elements
UInt nb_new_elements = inserter->insertElements();
// if (nb_new_elements > 0) {
// this->reinitializeSolver();
// }
AKANTU_DEBUG_OUT();
return nb_new_elements;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::onElementsAdded(
const Array<Element> & element_list, const NewElementsEvent & event) {
AKANTU_DEBUG_IN();
SolidMechanicsModel::onElementsAdded(element_list, event);
if (is_extrinsic)
resizeFacetStress();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::onNodesAdded(const Array<UInt> & new_nodes,
const NewNodesEvent & event) {
AKANTU_DEBUG_IN();
SolidMechanicsModel::onNodesAdded(new_nodes, event);
const CohesiveNewNodesEvent * cohesive_event;
if ((cohesive_event = dynamic_cast<const CohesiveNewNodesEvent *>(&event)) ==
nullptr)
return;
const auto & old_nodes = cohesive_event->getOldNodesList();
auto copy = [this, &new_nodes, &old_nodes](auto & arr) {
UInt new_node, old_node;
auto view = make_view(arr, spatial_dimension);
auto begin = view.begin();
for (auto && pair : zip(new_nodes, old_nodes)) {
std::tie(new_node, old_node) = pair;
auto old_ = begin + old_node;
auto new_ = begin + new_node;
*new_ = *old_;
}
};
copy(*displacement);
copy(*blocked_dofs);
if (velocity)
copy(*velocity);
if (acceleration)
copy(*acceleration);
if (current_position)
copy(*current_position);
if (previous_displacement)
copy(*previous_displacement);
// if (external_force)
// copy(*external_force);
// if (internal_force)
// copy(*internal_force);
if (displacement_increment)
copy(*displacement_increment);
copy(getDOFManager().getSolution("displacement"));
// this->assembleMassLumped();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::afterSolveStep() {
AKANTU_DEBUG_IN();
/*
* This is required because the Cauchy stress is the stress measure that
* is used to check the insertion of cohesive elements
*/
for (auto & mat : materials) {
if (mat->isFiniteDeformation())
mat->computeAllCauchyStresses(_not_ghost);
}
SolidMechanicsModel::afterSolveStep();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::printself(std::ostream & stream,
int indent) const {
std::string space(indent, AKANTU_INDENT);
- stream << space << "SolidMechanicsModelCohesive [" << "\n";
+ stream << space << "SolidMechanicsModelCohesive ["
+ << "\n";
SolidMechanicsModel::printself(stream, indent + 2);
stream << space << "]" << std::endl;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::resizeFacetStress() {
AKANTU_DEBUG_IN();
this->facet_stress.initialize(getFEEngine("FacetsFEEngine"),
_nb_component =
2 * spatial_dimension * spatial_dimension,
_spatial_dimension = spatial_dimension - 1);
// for (auto && ghost_type : ghost_types) {
// for (const auto & type :
// mesh_facets.elementTypes(spatial_dimension - 1, ghost_type)) {
// UInt nb_facet = mesh_facets.getNbElement(type, ghost_type);
// UInt nb_quadrature_points = getFEEngine("FacetsFEEngine")
// .getNbIntegrationPoints(type,
// ghost_type);
// UInt new_size = nb_facet * nb_quadrature_points;
// facet_stress(type, ghost_type).resize(new_size);
// }
// }
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::addDumpGroupFieldToDumper(
const std::string & dumper_name, const std::string & field_id,
const std::string & group_name, const ElementKind & element_kind,
bool padding_flag) {
AKANTU_DEBUG_IN();
UInt spatial_dimension = Model::spatial_dimension;
ElementKind _element_kind = element_kind;
if (dumper_name == "cohesive elements") {
_element_kind = _ek_cohesive;
} else if (dumper_name == "facets") {
spatial_dimension = Model::spatial_dimension - 1;
}
SolidMechanicsModel::addDumpGroupFieldToDumper(dumper_name, field_id,
group_name, spatial_dimension,
_element_kind, padding_flag);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::onDump() {
this->flattenAllRegisteredInternals(_ek_cohesive);
SolidMechanicsModel::onDump();
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_inline_impl.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_inline_impl.cc
index 5943fa349..91a2335ce 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_inline_impl.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_inline_impl.cc
@@ -1,306 +1,306 @@
/**
* @file solid_mechanics_model_cohesive_inline_impl.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Fri Jan 18 2013
* @date last modification: Tue Feb 20 2018
*
* @brief Implementation of inline functions for the Cohesive element model
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLID_MECHANICS_MODEL_COHESIVE_INLINE_IMPL_CC__
#define __AKANTU_SOLID_MECHANICS_MODEL_COHESIVE_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
// template <SolveConvergenceMethod cmethod, SolveConvergenceCriteria criteria>
// bool SolidMechanicsModelCohesive::solveStepCohesive(
// Real tolerance, Real & error, UInt max_iteration, bool load_reduction,
// Real tol_increase_factor, bool do_not_factorize) {
// // EventManager::sendEvent(
// // SolidMechanicsModelEvent::BeforeSolveStepEvent(method));
// // this->implicitPred();
// // bool insertion_new_element = true;
// // bool converged = false;
// // Array<Real> * displacement_tmp = NULL;
// // Array<Real> * velocity_tmp = NULL;
// // Array<Real> * acceleration_tmp = NULL;
// // StaticCommunicator & comm = StaticCommunicator::getStaticCommunicator();
// // Int prank = comm.whoAmI();
// // /// Loop for the insertion of new cohesive elements
// // while (insertion_new_element) {
// // if (is_extrinsic) {
// // /**
// // * If in extrinsic the solution of the previous incremental step
// // * is saved in temporary arrays created for displacements,
// // * velocities and accelerations. Such arrays are used to find
// // * the solution with the Newton-Raphson scheme (this is done by
// // * pointing the pointer "displacement" to displacement_tmp). In
// // * this way, inside the array "displacement" is kept the
// // * solution of the previous incremental step, and in
// // * "displacement_tmp" is saved the current solution.
// // */
// // if (!displacement_tmp)
// // displacement_tmp = new Array<Real>(0, spatial_dimension);
// // displacement_tmp->copy(*(this->displacement));
// // if (!velocity_tmp)
// // velocity_tmp = new Array<Real>(0, spatial_dimension);
// // velocity_tmp->copy(*(this->velocity));
// // if (!acceleration_tmp) {
// // acceleration_tmp = new Array<Real>(0, spatial_dimension);
// // }
// // acceleration_tmp->copy(*(this->acceleration));
// // std::swap(displacement, displacement_tmp);
// // std::swap(velocity, velocity_tmp);
// // std::swap(acceleration, acceleration_tmp);
// // }
// // this->updateResidual();
// // AKANTU_DEBUG_ASSERT(stiffness_matrix != NULL,
// // "You should first initialize the implicit solver and
// "
// // "assemble the stiffness matrix");
// // bool need_factorize = !do_not_factorize;
// // if (method == _implicit_dynamic) {
// // AKANTU_DEBUG_ASSERT(mass_matrix != NULL, "You should first initialize
// "
// // "the implicit solver and "
// // "assemble the mass matrix");
// // }
// // switch (cmethod) {
// // case _scm_newton_raphson_tangent:
// // case _scm_newton_raphson_tangent_not_computed:
// // break;
// // case _scm_newton_raphson_tangent_modified:
// // this->assembleStiffnessMatrix();
// // break;
// // default:
// // AKANTU_ERROR("The resolution method "
// // << cmethod << " has not been implemented!");
// // }
// // UInt iter = 0;
// // converged = false;
// // error = 0.;
// // if (criteria == SolveConvergenceCriteria::_residual) {
// // converged = this->testConvergence<criteria>(tolerance, error);
// // if (converged)
// // return converged;
// // }
// // /// Loop to solve the nonlinear system
// // do {
// // if (cmethod == _scm_newton_raphson_tangent)
// // this->assembleStiffnessMatrix();
// // solve<NewmarkBeta::_displacement_corrector>(*increment, 1.,
// // need_factorize);
// // this->implicitCorr();
// // this->updateResidual();
// // converged = this->testConvergence<criteria>(tolerance, error);
// // iter++;
// // AKANTU_DEBUG_INFO("[" << criteria << "] Convergence iteration "
// // << std::setw(std::log10(max_iteration)) << iter
// // << ": error " << error
// // << (converged ? " < " : " > ") << tolerance);
// // switch (cmethod) {
// // case _scm_newton_raphson_tangent:
// // need_factorize = true;
// // break;
// // case _scm_newton_raphson_tangent_not_computed:
// // case _scm_newton_raphson_tangent_modified:
// // need_factorize = false;
// // break;
// // default:
// // AKANTU_ERROR("The resolution method "
// // << cmethod << " has not been implemented!");
// // }
// // } while (!converged && iter < max_iteration);
// // /**
// // * This is to save the obtained result and proceed with the
// // * simulation even if the error is higher than the pre-fixed
// // * tolerance. This is done only after loading reduction
// // * (load_reduction = true).
// // */
// // // if (load_reduction && (error < tolerance * tol_increase_factor))
// // // converged = true;
// // if ((error < tolerance * tol_increase_factor))
// // converged = true;
// // if (converged) {
// // } else if (iter == max_iteration) {
// // if (prank == 0) {
// // AKANTU_DEBUG_WARNING(
// // "[" << criteria << "] Convergence not reached after "
// // << std::setw(std::log10(max_iteration)) << iter << "
// iteration"
// // << (iter == 1 ? "" : "s") << "!" << std::endl);
// // }
// // }
// // if (is_extrinsic) {
// // /**
// // * If is extrinsic the pointer "displacement" is moved back to
// // * the array displacement. In this way, the array displacement is
// // * correctly resized during the checkCohesiveStress function (in
// // * case new cohesive elements are added). This is possible
// // * because the procedure called by checkCohesiveStress does not
// // * use the displacement field (the correct one is now stored in
// // * displacement_tmp), but directly the stress field that is
// // * already computed.
// // */
// // Array<Real> * tmp_swap;
// // tmp_swap = displacement_tmp;
// // displacement_tmp = this->displacement;
// // this->displacement = tmp_swap;
// // tmp_swap = velocity_tmp;
// // velocity_tmp = this->velocity;
// // this->velocity = tmp_swap;
// // tmp_swap = acceleration_tmp;
// // acceleration_tmp = this->acceleration;
// // this->acceleration = tmp_swap;
// // /// If convergence is reached, call checkCohesiveStress in order
// // /// to check if cohesive elements have to be introduced
// // if (converged) {
// // UInt new_cohesive_elements = checkCohesiveStress();
// // if (new_cohesive_elements == 0) {
// // insertion_new_element = false;
// // } else {
// // insertion_new_element = true;
// // }
// // }
// // }
// // if (!converged && load_reduction)
// // insertion_new_element = false;
// // /**
// // * If convergence is not reached, there is the possibility to
// // * return back to the main file and reduce the load. Before doing
// // * this, a pre-fixed value as to be defined for the parameter
// // * delta_max of the cohesive elements introduced in the current
// // * incremental step. This is done by calling the function
// // * checkDeltaMax.
// // */
// // if (!converged) {
// // insertion_new_element = false;
// // for (UInt m = 0; m < materials.size(); ++m) {
// // try {
// // MaterialCohesive & mat =
// // aka::as_type<MaterialCohesive>(*materials[m]);
// // mat.checkDeltaMax(_not_ghost);
// // } catch (std::bad_cast &) {
// // }
// // }
// // }
// // } // end loop for the insertion of new cohesive elements
// // /**
// // * When the solution to the current incremental step is computed (no
// // * more cohesive elements have to be introduced), call the function
// // * to compute the energies.
// // */
// // if ((is_extrinsic && converged)) {
// // for (UInt m = 0; m < materials.size(); ++m) {
// // try {
// // MaterialCohesive & mat =
// // aka::as_type<MaterialCohesive>(*materials[m]);
// // mat.computeEnergies();
// // } catch (std::bad_cast & bce) {
// // }
// // }
// // EventManager::sendEvent(
// // SolidMechanicsModelEvent::AfterSolveStepEvent(method));
// // /**
// // * The function resetVariables is necessary to correctly set a
// // * variable that permit to decrease locally the penalty parameter
// // * for compression.
// // */
// // for (UInt m = 0; m < materials.size(); ++m) {
// // try {
// // MaterialCohesive & mat =
// // aka::as_type<MaterialCohesive>(*materials[m]);
// // mat.resetVariables(_not_ghost);
// // } catch (std::bad_cast &) {
// // }
// // }
// // /// The correct solution is saved
// // this->displacement->copy(*displacement_tmp);
// // this->velocity->copy(*velocity_tmp);
// // this->acceleration->copy(*acceleration_tmp);
// // }
// // delete displacement_tmp;
// // delete velocity_tmp;
// // delete acceleration_tmp;
// // return insertion_new_element;
//}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SOLID_MECHANICS_MODEL_COHESIVE_INLINE_IMPL_CC__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_parallel.cc b/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_parallel.cc
index fdc4ae287..144e626cd 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_parallel.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_cohesive/solid_mechanics_model_cohesive_parallel.cc
@@ -1,550 +1,553 @@
/**
* @file solid_mechanics_model_cohesive_parallel.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Nov 05 2014
* @date last modification: Tue Feb 20 2018
*
* @brief Functions for parallel cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "element_synchronizer.hh"
#include "material_cohesive.hh"
#include "solid_mechanics_model_cohesive.hh"
#include "solid_mechanics_model_tmpl.hh"
/* -------------------------------------------------------------------------- */
#include <type_traits>
/* -------------------------------------------------------------------------- */
namespace akantu {
class FacetGlobalConnectivityAccessor : public DataAccessor<Element> {
public:
FacetGlobalConnectivityAccessor(Mesh & mesh)
: global_connectivity("global_connectivity",
"facet_connectivity_synchronizer") {
global_connectivity.initialize(
mesh, _spatial_dimension = _all_dimensions, _with_nb_element = true,
_with_nb_nodes_per_element = true, _element_kind = _ek_regular);
mesh.getGlobalConnectivity(global_connectivity);
}
UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const {
UInt size = 0;
if (tag == SynchronizationTag::_smmc_facets_conn) {
UInt nb_nodes = Mesh::getNbNodesPerElementList(elements);
size += nb_nodes * sizeof(UInt);
}
return size;
}
void packData(CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const {
if (tag == SynchronizationTag::_smmc_facets_conn) {
for (const auto & element : elements) {
auto & conns = global_connectivity(element.type, element.ghost_type);
for (auto n : arange(conns.getNbComponent())) {
buffer << conns(element.element, n);
}
}
}
}
void unpackData(CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) {
if (tag == SynchronizationTag::_smmc_facets_conn) {
for (const auto & element : elements) {
auto & conns = global_connectivity(element.type, element.ghost_type);
for (auto n : arange(conns.getNbComponent())) {
buffer >> conns(element.element, n);
}
}
}
}
AKANTU_GET_MACRO(GlobalConnectivity, (global_connectivity), decltype(auto));
protected:
ElementTypeMapArray<UInt> global_connectivity;
};
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::synchronizeGhostFacetsConnectivity() {
AKANTU_DEBUG_IN();
const Communicator & comm = mesh.getCommunicator();
Int psize = comm.getNbProc();
if (psize == 1) {
AKANTU_DEBUG_OUT();
return;
}
/// get global connectivity for not ghost facets
auto & mesh_facets = inserter->getMeshFacets();
FacetGlobalConnectivityAccessor data_accessor(mesh_facets);
/// communicate
- mesh_facets.getElementSynchronizer().synchronizeOnce(data_accessor,
- SynchronizationTag::_smmc_facets_conn);
+ mesh_facets.getElementSynchronizer().synchronizeOnce(
+ data_accessor, SynchronizationTag::_smmc_facets_conn);
/// flip facets
MeshUtils::flipFacets(mesh_facets, data_accessor.getGlobalConnectivity(),
_ghost);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::updateCohesiveSynchronizers() {
/// update synchronizers if needed
if (not mesh.isDistributed())
return;
auto & mesh_facets = inserter->getMeshFacets();
auto & facet_synchronizer = mesh_facets.getElementSynchronizer();
const auto & cfacet_synchronizer = facet_synchronizer;
// update the cohesive element synchronizer
cohesive_synchronizer->updateSchemes([&](auto && scheme, auto && proc,
auto && direction) {
auto & facet_scheme =
cfacet_synchronizer.getCommunications().getScheme(proc, direction);
for (auto && facet : facet_scheme) {
const auto & cohesive_element = const_cast<const Mesh &>(mesh_facets)
.getElementToSubelement(facet)[1];
if (cohesive_element == ElementNull or
cohesive_element.kind() != _ek_cohesive)
continue;
auto && cohesive_type = FEEngine::getCohesiveElementType(facet.type);
auto old_nb_cohesive_elements =
mesh.getNbElement(cohesive_type, facet.ghost_type);
old_nb_cohesive_elements -=
mesh_facets
.getData<UInt>("facet_to_double", facet.type, facet.ghost_type)
.size();
if (cohesive_element.element >= old_nb_cohesive_elements) {
scheme.push_back(cohesive_element);
}
}
});
if (not facet_stress_synchronizer)
return;
const auto & element_synchronizer = mesh.getElementSynchronizer();
const auto & comm = mesh.getCommunicator();
auto && my_rank = comm.whoAmI();
// update the facet stress synchronizer
facet_stress_synchronizer->updateSchemes([&](auto && scheme, auto && proc,
auto && /*direction*/) {
auto it_element = scheme.begin();
for (auto && element : scheme) {
auto && facet_check = inserter->getCheckFacets(
element.type, element.ghost_type)(element.element); // slow access
// here
if (facet_check) {
auto && connected_elements = mesh_facets.getElementToSubelement(
element.type, element.ghost_type)(element.element); // slow access
// here
auto && rank_left = element_synchronizer.getRank(connected_elements[0]);
auto && rank_right =
element_synchronizer.getRank(connected_elements[1]);
// keep element if the element is still a boundary element between two
// processors
if ((rank_left == Int(proc) and rank_right == my_rank) or
(rank_left == my_rank and rank_right == Int(proc))) {
*it_element = element;
++it_element;
}
}
}
scheme.resize(it_element - scheme.begin());
});
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::updateFacetStressSynchronizer() {
if (facet_stress_synchronizer != nullptr) {
const auto & rank_to_element =
mesh.getElementSynchronizer().getElementToRank();
const auto & facet_checks = inserter->getCheckFacets();
const auto & mesh_facets = inserter->getMeshFacets();
const auto & element_to_facet = mesh_facets.getElementToSubelement();
UInt rank = mesh.getCommunicator().whoAmI();
facet_stress_synchronizer->updateSchemes(
[&](auto & scheme, auto & proc, auto & /*direction*/) {
UInt el = 0;
for (auto && element : scheme) {
if (not facet_checks(element))
continue;
const auto & next_el = element_to_facet(element);
UInt rank_left = rank_to_element(next_el[0]);
UInt rank_right = rank_to_element(next_el[1]);
if ((rank_left == rank and rank_right == proc) or
(rank_left == proc and rank_right == rank)) {
scheme[el] = element;
++el;
}
}
scheme.resize(el);
});
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SolidMechanicsModelCohesive::packFacetStressDataHelper(
const ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer,
const Array<Element> & elements) const {
packUnpackFacetStressDataHelper<T, true>(
const_cast<ElementTypeMapArray<T> &>(data_to_pack), buffer, elements);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void SolidMechanicsModelCohesive::unpackFacetStressDataHelper(
ElementTypeMapArray<T> & data_to_unpack, CommunicationBuffer & buffer,
const Array<Element> & elements) const {
packUnpackFacetStressDataHelper<T, false>(data_to_unpack, buffer, elements);
}
/* -------------------------------------------------------------------------- */
template <typename T, bool pack_helper>
void SolidMechanicsModelCohesive::packUnpackFacetStressDataHelper(
ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer,
const Array<Element> & elements) const {
ElementType current_element_type = _not_defined;
GhostType current_ghost_type = _casper;
UInt nb_quad_per_elem = 0;
UInt sp2 = spatial_dimension * spatial_dimension;
UInt nb_component = sp2 * 2;
bool element_rank = false;
Mesh & mesh_facets = inserter->getMeshFacets();
Array<T> * vect = nullptr;
Array<std::vector<Element>> * element_to_facet = nullptr;
auto & fe_engine = this->getFEEngine("FacetsFEEngine");
for (auto && el : elements) {
if (el.type == _not_defined)
AKANTU_EXCEPTION(
"packUnpackFacetStressDataHelper called with wrong inputs");
if (el.type != current_element_type ||
el.ghost_type != current_ghost_type) {
current_element_type = el.type;
current_ghost_type = el.ghost_type;
vect = &data_to_pack(el.type, el.ghost_type);
element_to_facet =
&(mesh_facets.getElementToSubelement(el.type, el.ghost_type));
nb_quad_per_elem =
fe_engine.getNbIntegrationPoints(el.type, el.ghost_type);
}
if (pack_helper)
element_rank =
(*element_to_facet)(el.element)[0].ghost_type != _not_ghost;
else
element_rank =
(*element_to_facet)(el.element)[0].ghost_type == _not_ghost;
for (UInt q = 0; q < nb_quad_per_elem; ++q) {
Vector<T> data(vect->storage() +
(el.element * nb_quad_per_elem + q) * nb_component +
element_rank * sp2,
sp2);
if (pack_helper)
buffer << data;
else
buffer >> data;
}
}
}
/* -------------------------------------------------------------------------- */
UInt SolidMechanicsModelCohesive::getNbQuadsForFacetCheck(
const Array<Element> & elements) const {
UInt nb_quads = 0;
UInt nb_quad_per_facet = 0;
ElementType current_element_type = _not_defined;
GhostType current_ghost_type = _casper;
auto & fe_engine = this->getFEEngine("FacetsFEEngine");
for (auto & el : elements) {
if (el.type != current_element_type ||
el.ghost_type != current_ghost_type) {
current_element_type = el.type;
current_ghost_type = el.ghost_type;
nb_quad_per_facet =
fe_engine.getNbIntegrationPoints(el.type, el.ghost_type);
}
nb_quads += nb_quad_per_facet;
}
return nb_quads;
}
/* -------------------------------------------------------------------------- */
UInt SolidMechanicsModelCohesive::getNbData(
const Array<Element> & elements, const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
UInt size = 0;
if (elements.size() == 0)
return 0;
/// regular element case
if (elements(0).kind() == _ek_regular) {
switch (tag) {
// case SynchronizationTag::_smmc_facets: {
// size += elements.size() * sizeof(bool);
// break;
// }
case SynchronizationTag::_smmc_facets_stress: {
UInt nb_quads = getNbQuadsForFacetCheck(elements);
size += nb_quads * spatial_dimension * spatial_dimension * sizeof(Real);
break;
}
case SynchronizationTag::_material_id: {
for (auto && element : elements) {
if (Mesh::getSpatialDimension(element.type) == (spatial_dimension - 1))
size += sizeof(UInt);
}
size += SolidMechanicsModel::getNbData(elements, tag);
break;
}
default: { size += SolidMechanicsModel::getNbData(elements, tag); }
}
}
/// cohesive element case
else if (elements(0).kind() == _ek_cohesive) {
switch (tag) {
case SynchronizationTag::_material_id: {
size += elements.size() * sizeof(UInt);
break;
}
case SynchronizationTag::_smm_boundary: {
UInt nb_nodes_per_element = 0;
for (auto && el : elements) {
nb_nodes_per_element += Mesh::getNbNodesPerElement(el.type);
}
// force, displacement, boundary
size += nb_nodes_per_element * spatial_dimension *
(2 * sizeof(Real) + sizeof(bool));
break;
}
default:
break;
}
- if (tag != SynchronizationTag::_material_id && tag != SynchronizationTag::_smmc_facets) {
+ if (tag != SynchronizationTag::_material_id &&
+ tag != SynchronizationTag::_smmc_facets) {
splitByMaterial(elements, [&](auto && mat, auto && elements) {
size += mat.getNbData(elements, tag);
});
}
}
AKANTU_DEBUG_OUT();
return size;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::packData(
CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const {
AKANTU_DEBUG_IN();
if (elements.size() == 0)
return;
if (elements(0).kind() == _ek_regular) {
switch (tag) {
// case SynchronizationTag::_smmc_facets: {
// packElementalDataHelper(inserter->getInsertionFacetsByElement(),
// buffer,
// elements, false, getFEEngine());
// break;
// }
case SynchronizationTag::_smmc_facets_stress: {
packFacetStressDataHelper(facet_stress, buffer, elements);
break;
}
case SynchronizationTag::_material_id: {
for (auto && element : elements) {
if (Mesh::getSpatialDimension(element.type) != (spatial_dimension - 1))
continue;
buffer << material_index(element);
}
SolidMechanicsModel::packData(buffer, elements, tag);
break;
}
default: { SolidMechanicsModel::packData(buffer, elements, tag); }
}
AKANTU_DEBUG_OUT();
return;
}
if (elements(0).kind() == _ek_cohesive) {
switch (tag) {
case SynchronizationTag::_material_id: {
packElementalDataHelper(material_index, buffer, elements, false,
getFEEngine("CohesiveFEEngine"));
break;
}
case SynchronizationTag::_smm_boundary: {
packNodalDataHelper(*internal_force, buffer, elements, mesh);
packNodalDataHelper(*velocity, buffer, elements, mesh);
packNodalDataHelper(*blocked_dofs, buffer, elements, mesh);
break;
}
default: {}
}
- if (tag != SynchronizationTag::_material_id && tag != SynchronizationTag::_smmc_facets) {
+ if (tag != SynchronizationTag::_material_id &&
+ tag != SynchronizationTag::_smmc_facets) {
splitByMaterial(elements, [&](auto && mat, auto && elements) {
mat.packData(buffer, elements, tag);
});
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModelCohesive::unpackData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag) {
AKANTU_DEBUG_IN();
if (elements.size() == 0)
return;
if (elements(0).kind() == _ek_regular) {
switch (tag) {
// case SynchronizationTag::_smmc_facets: {
// unpackElementalDataHelper(inserter->getInsertionFacetsByElement(),
// buffer,
// elements, false, getFEEngine());
// break;
// }
case SynchronizationTag::_smmc_facets_stress: {
unpackFacetStressDataHelper(facet_stress, buffer, elements);
break;
}
case SynchronizationTag::_material_id: {
for (auto && element : elements) {
if (Mesh::getSpatialDimension(element.type) != (spatial_dimension - 1))
continue;
UInt recv_mat_index;
buffer >> recv_mat_index;
UInt & mat_index = material_index(element);
if (mat_index != UInt(-1))
continue;
// add ghosts element to the correct material
mat_index = recv_mat_index;
auto & mat = aka::as_type<MaterialCohesive>(*materials[mat_index]);
if (is_extrinsic) {
mat.addFacet(element);
}
facet_material(element) = recv_mat_index;
}
SolidMechanicsModel::unpackData(buffer, elements, tag);
break;
}
default: { SolidMechanicsModel::unpackData(buffer, elements, tag); }
}
AKANTU_DEBUG_OUT();
return;
}
if (elements(0).kind() == _ek_cohesive) {
switch (tag) {
case SynchronizationTag::_material_id: {
for (auto && element : elements) {
UInt recv_mat_index;
buffer >> recv_mat_index;
UInt & mat_index = material_index(element);
if (mat_index != UInt(-1))
continue;
// add ghosts element to the correct material
mat_index = recv_mat_index;
UInt index = materials[mat_index]->addElement(element);
material_local_numbering(element) = index;
}
break;
}
case SynchronizationTag::_smm_boundary: {
unpackNodalDataHelper(*internal_force, buffer, elements, mesh);
unpackNodalDataHelper(*velocity, buffer, elements, mesh);
unpackNodalDataHelper(*blocked_dofs, buffer, elements, mesh);
break;
}
default: {}
}
- if (tag != SynchronizationTag::_material_id && tag != SynchronizationTag::_smmc_facets) {
+ if (tag != SynchronizationTag::_material_id &&
+ tag != SynchronizationTag::_smmc_facets) {
splitByMaterial(elements, [&](auto && mat, auto && elements) {
mat.unpackData(buffer, elements, tag);
});
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_intersector.hh b/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_intersector.hh
index 9552e178b..7288a6c4c 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_intersector.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_intersector.hh
@@ -1,98 +1,98 @@
/**
* @file embedded_interface_intersector.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri May 01 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Class that loads the interface from mesh and computes intersections
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_EMBEDDED_INTERFACE_INTERSECTOR_HH__
#define __AKANTU_EMBEDDED_INTERFACE_INTERSECTOR_HH__
#include "aka_common.hh"
#include "mesh_geom_abstract.hh"
#include "mesh_geom_common.hh"
#include "mesh_segment_intersector.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
namespace {
using K = cgal::Cartesian;
}
/**
* @brief Computes the intersections of the reinforcements defined in the
* primitive mesh
*
* The purpose of this class is to look for reinforcements in the primitive
* mesh, which
* should be defined by physical groups with the same names as the reinforcement
* materials
* in the model.
*
* It then constructs the CGAL primitives from the elements of those
* reinforcements
* and computes the intersections with the background mesh, to create an
* `interface_mesh`,
* which is in turn used by the EmbeddedInterfaceModel.
*
* @see MeshSegmentIntersector, MeshGeomAbstract
* @see EmbeddedInterfaceModel
*/
class EmbeddedInterfaceIntersector : public MeshGeomAbstract {
public:
/// Construct from mesh and a reinforcement mesh
explicit EmbeddedInterfaceIntersector(Mesh & mesh,
const Mesh & primitive_mesh);
/// Destructor
virtual ~EmbeddedInterfaceIntersector();
public:
/// Generate the interface mesh
virtual void constructData(GhostType ghost_type = _not_ghost);
/// Create a segment with an element connectivity
K::Segment_3 createSegment(const Vector<UInt> & connectivity);
/// Getter for interface mesh
AKANTU_GET_MACRO_NOT_CONST(InterfaceMesh, interface_mesh, Mesh &);
protected:
/// Resulting mesh of intersection
Mesh interface_mesh;
/// Mesh used for primitive construction
const Mesh & primitive_mesh;
};
-} // akantu
+} // namespace akantu
#endif // __AKANTU_EMBEDDED_INTERFACE_INTERSECTOR_HH__
diff --git a/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.cc b/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.cc
index c12013d76..b4ab928ee 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.cc
@@ -1,173 +1,173 @@
/**
* @file embedded_interface_model.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Mar 13 2015
* @date last modification: Wed Feb 14 2018
*
* @brief Model of Solid Mechanics with embedded interfaces
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "embedded_interface_model.hh"
#include "integrator_gauss.hh"
#include "material_elastic.hh"
#include "material_reinforcement.hh"
#include "mesh_iterators.hh"
#include "shape_lagrange.hh"
#ifdef AKANTU_USE_IOHELPER
#include "dumpable_inline_impl.hh"
#include "dumper_iohelper_paraview.hh"
#endif
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
EmbeddedInterfaceModel::EmbeddedInterfaceModel(Mesh & mesh,
Mesh & primitive_mesh,
UInt spatial_dimension,
const ID & id,
const MemoryID & memory_id)
: SolidMechanicsModel(mesh, spatial_dimension, id, memory_id),
intersector(mesh, primitive_mesh), interface_mesh(nullptr),
primitive_mesh(primitive_mesh), interface_material_selector(nullptr) {
this->model_type = ModelType::_embedded_model;
// This pointer should be deleted by ~SolidMechanicsModel()
auto mat_sel_pointer =
std::make_shared<MeshDataMaterialSelector<std::string>>("physical_names",
*this);
this->setMaterialSelector(mat_sel_pointer);
interface_mesh = &(intersector.getInterfaceMesh());
// Create 1D FEEngine on the interface mesh
registerFEEngineObject<MyFEEngineType>("EmbeddedInterfaceFEEngine",
*interface_mesh, 1);
// Registering allocator for material reinforcement
MaterialFactory::getInstance().registerAllocator(
"reinforcement",
[&](UInt dim, const ID & constitutive, SolidMechanicsModel &,
const ID & id) -> std::unique_ptr<Material> {
if (constitutive == "elastic") {
using mat = MaterialElastic<1>;
switch (dim) {
case 2:
return std::make_unique<MaterialReinforcement<mat, 2>>(*this, id);
case 3:
return std::make_unique<MaterialReinforcement<mat, 3>>(*this, id);
default:
AKANTU_EXCEPTION("Dimension 1 is invalid for reinforcements");
}
} else {
AKANTU_EXCEPTION("Reinforcement type" << constitutive
<< " is not recognized");
}
});
}
/* -------------------------------------------------------------------------- */
EmbeddedInterfaceModel::~EmbeddedInterfaceModel() {
delete interface_material_selector;
}
/* -------------------------------------------------------------------------- */
void EmbeddedInterfaceModel::initFullImpl(const ModelOptions & options) {
const auto & eim_options =
aka::as_type<EmbeddedInterfaceModelOptions>(options);
// Do no initialize interface_mesh if told so
if (eim_options.has_intersections)
intersector.constructData();
SolidMechanicsModel::initFullImpl(options);
#if defined(AKANTU_USE_IOHELPER)
this->mesh.registerDumper<DumperParaview>("reinforcement", id);
this->mesh.addDumpMeshToDumper("reinforcement", *interface_mesh, 1,
_not_ghost, _ek_regular);
#endif
}
void EmbeddedInterfaceModel::initModel() {
// Initialize interface FEEngine
SolidMechanicsModel::initModel();
FEEngine & engine = getFEEngine("EmbeddedInterfaceFEEngine");
engine.initShapeFunctions(_not_ghost);
engine.initShapeFunctions(_ghost);
}
/* -------------------------------------------------------------------------- */
void EmbeddedInterfaceModel::assignMaterialToElements(
const ElementTypeMapArray<UInt> * filter) {
delete interface_material_selector;
interface_material_selector =
new InterfaceMeshDataMaterialSelector<std::string>("physical_names",
*this);
for_each_element(getInterfaceMesh(),
[&](auto && element) {
auto mat_index = (*interface_material_selector)(element);
// material_index(element) = mat_index;
materials[mat_index]->addElement(element);
// this->material_local_numbering(element) = index;
},
_element_filter = filter, _spatial_dimension = 1);
SolidMechanicsModel::assignMaterialToElements(filter);
}
/* -------------------------------------------------------------------------- */
void EmbeddedInterfaceModel::addDumpGroupFieldToDumper(
const std::string & dumper_name, const std::string & field_id,
const std::string & group_name, const ElementKind & element_kind,
bool padding_flag) {
#ifdef AKANTU_USE_IOHELPER
std::shared_ptr<dumper::Field> field;
// If dumper is reinforcement, create a 1D elemental field
if (dumper_name == "reinforcement")
field = this->createElementalField(field_id, group_name, padding_flag, 1,
element_kind);
else {
try {
SolidMechanicsModel::addDumpGroupFieldToDumper(
dumper_name, field_id, group_name, element_kind, padding_flag);
} catch (...) {
}
}
if (field) {
DumperIOHelper & dumper = mesh.getGroupDumper(dumper_name, group_name);
Model::addDumpGroupFieldToDumper(field_id, field, dumper);
}
#endif
}
-} // akantu
+} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.hh b/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.hh
index 42db35d34..3ea97d6e1 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_embedded_interface/embedded_interface_model.hh
@@ -1,153 +1,153 @@
/**
* @file embedded_interface_model.hh
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 31 2018
*
* @brief Model of Solid Mechanics with embedded interfaces
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_EMBEDDED_INTERFACE_MODEL_HH__
#define __AKANTU_EMBEDDED_INTERFACE_MODEL_HH__
#include "aka_common.hh"
#include "mesh.hh"
#include "solid_mechanics_model.hh"
#include "embedded_interface_intersector.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/**
* @brief Solid mechanics model using the embedded model.
*
* This SolidMechanicsModel subclass implements the embedded model,
* a method used to represent 1D elements in a finite elements model
* (eg. reinforcements in concrete).
*
* In addition to the SolidMechanicsModel properties, this model has
* a mesh of the 1D elements embedded in the model, and an instance of the
* EmbeddedInterfaceIntersector class for the computation of the intersections
* of the
* 1D elements with the background (bulk) mesh.
*
* @see MaterialReinforcement
*/
class EmbeddedInterfaceModel : public SolidMechanicsModel {
using MyFEEngineType = SolidMechanicsModel::MyFEEngineType;
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
/**
* @brief Constructor
*
* @param mesh main mesh (concrete)
* @param primitive_mesh mesh of the embedded reinforcement
*/
EmbeddedInterfaceModel(Mesh & mesh, Mesh & primitive_mesh,
UInt spatial_dimension = _all_dimensions,
const ID & id = "embedded_interface_model",
const MemoryID & memory_id = 0);
/// Destructor
~EmbeddedInterfaceModel() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// Initialise the model
void initFullImpl(
const ModelOptions & options = EmbeddedInterfaceModelOptions()) override;
/// Initialise the materials
void
assignMaterialToElements(const ElementTypeMapArray<UInt> * filter) override;
/// Initialize the embedded shape functions
void initModel() override;
/// Allows filtering of dump fields which need to be dumpes on interface mesh
void addDumpGroupFieldToDumper(const std::string & dumper_name,
const std::string & field_id,
const std::string & group_name,
const ElementKind & element_kind,
bool padding_flag) override;
// virtual ElementTypeMap<UInt> getInternalDataPerElem(const std::string &
// field_name,
// const ElementKind &
// kind);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// Get interface mesh
AKANTU_GET_MACRO(InterfaceMesh, *interface_mesh, Mesh &);
/// Get associated elements
AKANTU_GET_MACRO_BY_ELEMENT_TYPE(
InterfaceAssociatedElements,
interface_mesh->getData<Element>("associated_element"), Element);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// Intersector object to build the interface mesh
EmbeddedInterfaceIntersector intersector;
/// Interface mesh (weak reference)
Mesh * interface_mesh;
/// Mesh used to create the CGAL primitives for intersections
Mesh & primitive_mesh;
/// Material selector for interface
MaterialSelector * interface_material_selector;
};
/// Material selector based on mesh data for interface elements
template <typename T>
class InterfaceMeshDataMaterialSelector
: public ElementDataMaterialSelector<T> {
public:
InterfaceMeshDataMaterialSelector(const std::string & name,
const EmbeddedInterfaceModel & model,
UInt first_index = 1)
: ElementDataMaterialSelector<T>(
model.getInterfaceMesh().getData<T>(name), model, first_index) {}
};
-} // akantu
+} // namespace akantu
#endif // __AKANTU_EMBEDDED_INTERFACE_MODEL_HH__
diff --git a/src/model/solid_mechanics/solid_mechanics_model_event_handler.hh b/src/model/solid_mechanics/solid_mechanics_model_event_handler.hh
index 6f1214c96..9693d90be 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_event_handler.hh
+++ b/src/model/solid_mechanics/solid_mechanics_model_event_handler.hh
@@ -1,126 +1,126 @@
/**
* @file solid_mechanics_model_event_handler.hh
*
* @author Daniel Pino Muñoz <daniel.pinomunoz@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief EventHandler implementation for SolidMechanicsEvents
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLID_MECHANICS_MODEL_EVENT_HANDLER_HH__
#define __AKANTU_SOLID_MECHANICS_MODEL_EVENT_HANDLER_HH__
namespace akantu {
/// akantu::SolidMechanicsModelEvent is the base event for model
namespace SolidMechanicsModelEvent {
struct BeforeSolveStepEvent {
BeforeSolveStepEvent(AnalysisMethod & method) : method(method) {}
AnalysisMethod method;
};
struct AfterSolveStepEvent {
AfterSolveStepEvent(AnalysisMethod & method) : method(method) {}
AnalysisMethod method;
};
struct BeforeDumpEvent {
BeforeDumpEvent() = default;
};
struct BeginningOfDamageIterationEvent {
BeginningOfDamageIterationEvent() = default;
};
struct AfterDamageEvent {
AfterDamageEvent() = default;
};
-}
+} // namespace SolidMechanicsModelEvent
/// akantu::SolidMechanicsModelEvent
class SolidMechanicsModelEventHandler {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
virtual ~SolidMechanicsModelEventHandler() = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
protected:
/// Send what is before the solve step to the beginning of solve step through
/// EventManager
inline void
sendEvent(const SolidMechanicsModelEvent::BeforeSolveStepEvent & event) {
onBeginningSolveStep(event.method);
}
/// Send what is after the solve step to the end of solve step through
/// EventManager
inline void
sendEvent(const SolidMechanicsModelEvent::AfterSolveStepEvent & event) {
onEndSolveStep(event.method);
}
/// Send what is before dump to current dump through EventManager
inline void
sendEvent(__attribute__((unused))
const SolidMechanicsModelEvent::BeforeDumpEvent & event) {
onDump();
}
/// Send what is at the beginning of damage iteration to Damage iteration
/// through EventManager
inline void sendEvent(
__attribute__((unused))
const SolidMechanicsModelEvent::BeginningOfDamageIterationEvent & event) {
onDamageIteration();
}
/// Send what is after damage for the damage update through EventManager
inline void
sendEvent(__attribute__((unused))
const SolidMechanicsModelEvent::AfterDamageEvent & event) {
onDamageUpdate();
}
template <class EventHandler> friend class EventHandlerManager;
/* ------------------------------------------------------------------------ */
/* Interface */
/* ------------------------------------------------------------------------ */
public:
/// function to implement to react on akantu::BeforeSolveStepEvent
virtual void onBeginningSolveStep(__attribute__((unused))
const AnalysisMethod & method) {}
/// function to implement to react on akantu::AfterSolveStepEvent
virtual void onEndSolveStep(__attribute__((unused))
const AnalysisMethod & method) {}
/// function to implement to react on akantu::BeforeDumpEvent
virtual void onDump() {}
/// function to implement to react on akantu::BeginningOfDamageIterationEvent
virtual void onDamageIteration() {}
/// function to implement to react on akantu::AfterDamageEvent
virtual void onDamageUpdate() {}
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SOLID_MECHANICS_MODEL_EVENT_HANDLER_HH__ */
diff --git a/src/model/solid_mechanics/solid_mechanics_model_io.cc b/src/model/solid_mechanics/solid_mechanics_model_io.cc
index ebe86604e..dd373933d 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_io.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_io.cc
@@ -1,328 +1,329 @@
/**
* @file solid_mechanics_model_io.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sun Jul 09 2017
* @date last modification: Sun Dec 03 2017
*
* @brief Dumpable part of the SolidMechnicsModel
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model.hh"
#include "group_manager_inline_impl.cc"
#include "dumpable_inline_impl.hh"
#ifdef AKANTU_USE_IOHELPER
#include "dumper_element_partition.hh"
#include "dumper_elemental_field.hh"
#include "dumper_field.hh"
#include "dumper_homogenizing_field.hh"
#include "dumper_internal_material_field.hh"
#include "dumper_iohelper.hh"
#include "dumper_material_padders.hh"
#include "dumper_paraview.hh"
#endif
namespace akantu {
/* -------------------------------------------------------------------------- */
bool SolidMechanicsModel::isInternal(const std::string & field_name,
const ElementKind & element_kind) {
/// check if at least one material contains field_id as an internal
for (auto & material : materials) {
bool is_internal = material->isInternal<Real>(field_name, element_kind);
if (is_internal)
return true;
}
return false;
}
/* -------------------------------------------------------------------------- */
ElementTypeMap<UInt>
SolidMechanicsModel::getInternalDataPerElem(const std::string & field_name,
const ElementKind & element_kind) {
if (!(this->isInternal(field_name, element_kind)))
AKANTU_EXCEPTION("unknown internal " << field_name);
for (auto & material : materials) {
if (material->isInternal<Real>(field_name, element_kind))
return material->getInternalDataPerElem<Real>(field_name, element_kind);
}
return ElementTypeMap<UInt>();
}
/* -------------------------------------------------------------------------- */
ElementTypeMapArray<Real> &
SolidMechanicsModel::flattenInternal(const std::string & field_name,
const ElementKind & kind,
const GhostType ghost_type) {
std::pair<std::string, ElementKind> key(field_name, kind);
if (this->registered_internals.count(key) == 0) {
this->registered_internals[key] =
new ElementTypeMapArray<Real>(field_name, this->id, this->memory_id);
}
ElementTypeMapArray<Real> * internal_flat = this->registered_internals[key];
for (auto type :
mesh.elementTypes(Model::spatial_dimension, ghost_type, kind)) {
if (internal_flat->exists(type, ghost_type)) {
auto & internal = (*internal_flat)(type, ghost_type);
// internal.clear();
internal.resize(0);
}
}
for (auto & material : materials) {
if (material->isInternal<Real>(field_name, kind))
material->flattenInternal(field_name, *internal_flat, ghost_type, kind);
}
return *internal_flat;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::flattenAllRegisteredInternals(
const ElementKind & kind) {
ElementKind _kind;
ID _id;
for (auto & internal : this->registered_internals) {
std::tie(_id, _kind) = internal.first;
if (kind == _kind)
this->flattenInternal(_id, kind);
}
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::onDump() {
this->flattenAllRegisteredInternals(_ek_regular);
}
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
std::shared_ptr<dumper::Field> SolidMechanicsModel::createElementalField(
const std::string & field_name, const std::string & group_name,
bool padding_flag, const UInt & spatial_dimension,
const ElementKind & kind) {
std::shared_ptr<dumper::Field> field;
if (field_name == "partitions")
field = mesh.createElementalField<UInt, dumper::ElementPartitionField>(
mesh.getConnectivities(), group_name, spatial_dimension, kind);
else if (field_name == "material_index")
field = mesh.createElementalField<UInt, Vector, dumper::ElementalField>(
material_index, group_name, spatial_dimension, kind);
else {
// this copy of field_name is used to compute derivated data such as
// strain and von mises stress that are based on grad_u and stress
std::string field_name_copy(field_name);
if (field_name == "strain" || field_name == "Green strain" ||
field_name == "principal strain" ||
field_name == "principal Green strain")
field_name_copy = "grad_u";
else if (field_name == "Von Mises stress")
field_name_copy = "stress";
bool is_internal = this->isInternal(field_name_copy, kind);
if (is_internal) {
auto nb_data_per_elem =
this->getInternalDataPerElem(field_name_copy, kind);
auto & internal_flat = this->flattenInternal(field_name_copy, kind);
field = mesh.createElementalField<Real, dumper::InternalMaterialField>(
internal_flat, group_name, spatial_dimension, kind, nb_data_per_elem);
std::unique_ptr<dumper::ComputeFunctorInterface> func;
if (field_name == "strain") {
func = std::make_unique<dumper::ComputeStrain<false>>(*this);
} else if (field_name == "Von Mises stress") {
func = std::make_unique<dumper::ComputeVonMisesStress>(*this);
} else if (field_name == "Green strain") {
func = std::make_unique<dumper::ComputeStrain<true>>(*this);
} else if (field_name == "principal strain") {
func = std::make_unique<dumper::ComputePrincipalStrain<false>>(*this);
} else if (field_name == "principal Green strain") {
func = std::make_unique<dumper::ComputePrincipalStrain<true>>(*this);
}
if (func) {
field = dumper::FieldComputeProxy::createFieldCompute(field,
std::move(func));
}
// treat the paddings
if (padding_flag) {
if (field_name == "stress") {
if (spatial_dimension == 2) {
auto foo = std::make_unique<dumper::StressPadder<2>>(*this);
field = dumper::FieldComputeProxy::createFieldCompute(
field, std::move(foo));
}
} else if (field_name == "strain" || field_name == "Green strain") {
if (spatial_dimension == 2) {
auto foo = std::make_unique<dumper::StrainPadder<2>>(*this);
field = dumper::FieldComputeProxy::createFieldCompute(
field, std::move(foo));
}
}
}
// homogenize the field
auto foo = dumper::HomogenizerProxy::createHomogenizer(*field);
- field = dumper::FieldComputeProxy::createFieldCompute(field, std::move(foo));
+ field =
+ dumper::FieldComputeProxy::createFieldCompute(field, std::move(foo));
}
}
return field;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field>
SolidMechanicsModel::createNodalFieldReal(const std::string & field_name,
const std::string & group_name,
bool padding_flag) {
std::map<std::string, Array<Real> *> real_nodal_fields;
real_nodal_fields["displacement"] = this->displacement;
real_nodal_fields["mass"] = this->mass;
real_nodal_fields["velocity"] = this->velocity;
real_nodal_fields["acceleration"] = this->acceleration;
real_nodal_fields["external_force"] = this->external_force;
real_nodal_fields["internal_force"] = this->internal_force;
real_nodal_fields["increment"] = this->displacement_increment;
if (field_name == "force") {
AKANTU_EXCEPTION("The 'force' field has been renamed in 'external_force'");
} else if (field_name == "residual") {
AKANTU_EXCEPTION(
"The 'residual' field has been replaced by 'internal_force'");
}
std::shared_ptr<dumper::Field> field;
if (padding_flag)
field = this->mesh.createNodalField(real_nodal_fields[field_name],
group_name, 3);
else
field =
this->mesh.createNodalField(real_nodal_fields[field_name], group_name);
return field;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> SolidMechanicsModel::createNodalFieldBool(
const std::string & field_name, const std::string & group_name,
__attribute__((unused)) bool padding_flag) {
std::map<std::string, Array<bool> *> uint_nodal_fields;
uint_nodal_fields["blocked_dofs"] = blocked_dofs;
std::shared_ptr<dumper::Field> field;
field = mesh.createNodalField(uint_nodal_fields[field_name], group_name);
return field;
}
/* -------------------------------------------------------------------------- */
#else
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field>
SolidMechanicsModel::createElementalField(const std::string &,
const std::string &, bool,
const UInt &, const ElementKind &) {
return nullptr;
}
/* --------------------------------------------------------------------------
*/
std::shaed_ptr<dumper::Field>
SolidMechanicsModel::createNodalFieldReal(const std::string &,
const std::string &, bool) {
return nullptr;
}
/* --------------------------------------------------------------------------
*/
std::shared_ptr<dumper::Field>
SolidMechanicsModel::createNodalFieldBool(const std::string &,
const std::string &, bool) {
return nullptr;
}
#endif
/* --------------------------------------------------------------------------
*/
void SolidMechanicsModel::dump(const std::string & dumper_name) {
this->onDump();
EventManager::sendEvent(SolidMechanicsModelEvent::BeforeDumpEvent());
mesh.dump(dumper_name);
}
/* --------------------------------------------------------------------------
*/
void SolidMechanicsModel::dump(const std::string & dumper_name, UInt step) {
this->onDump();
EventManager::sendEvent(SolidMechanicsModelEvent::BeforeDumpEvent());
mesh.dump(dumper_name, step);
}
/* -------------------------------------------------------------------------
*/
void SolidMechanicsModel::dump(const std::string & dumper_name, Real time,
UInt step) {
this->onDump();
EventManager::sendEvent(SolidMechanicsModelEvent::BeforeDumpEvent());
mesh.dump(dumper_name, time, step);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::dump() {
this->onDump();
EventManager::sendEvent(SolidMechanicsModelEvent::BeforeDumpEvent());
mesh.dump();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::dump(UInt step) {
this->onDump();
EventManager::sendEvent(SolidMechanicsModelEvent::BeforeDumpEvent());
mesh.dump(step);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::dump(Real time, UInt step) {
this->onDump();
EventManager::sendEvent(SolidMechanicsModelEvent::BeforeDumpEvent());
mesh.dump(time, step);
}
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_mass.cc b/src/model/solid_mechanics/solid_mechanics_model_mass.cc
index b0e944cc3..4fb9161bd 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_mass.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_mass.cc
@@ -1,150 +1,152 @@
/**
* @file solid_mechanics_model_mass.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Oct 05 2010
* @date last modification: Wed Nov 08 2017
*
* @brief function handling mass computation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "integrator_gauss.hh"
#include "material.hh"
#include "model_solver.hh"
#include "shape_lagrange.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class ComputeRhoFunctor {
public:
explicit ComputeRhoFunctor(const SolidMechanicsModel & model)
: model(model){};
void operator()(Matrix<Real> & rho, const Element & element) const {
const Array<UInt> & mat_indexes =
model.getMaterialByElement(element.type, element.ghost_type);
Real mat_rho =
model.getMaterial(mat_indexes(element.element)).getParam("rho");
rho.set(mat_rho);
}
private:
const SolidMechanicsModel & model;
};
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleMassLumped() {
AKANTU_DEBUG_IN();
if (not need_to_reassemble_lumped_mass)
return;
this->allocNodalField(this->mass, spatial_dimension, "mass");
mass->clear();
if (!this->getDOFManager().hasLumpedMatrix("M")) {
this->getDOFManager().getNewLumpedMatrix("M");
}
this->getDOFManager().clearLumpedMatrix("M");
assembleMassLumped(_not_ghost);
assembleMassLumped(_ghost);
this->getDOFManager().getLumpedMatrixPerDOFs("displacement", "M",
*(this->mass));
/// for not connected nodes put mass to one in order to avoid
#if !defined(AKANTU_NDEBUG)
bool has_unconnected_nodes = false;
auto mass_it = mass->begin_reinterpret(mass->size() * mass->getNbComponent());
auto mass_end = mass->end_reinterpret(mass->size() * mass->getNbComponent());
for (; mass_it != mass_end; ++mass_it) {
if (std::abs(*mass_it) < std::numeric_limits<Real>::epsilon() ||
Math::isnan(*mass_it)) {
has_unconnected_nodes = true;
break;
}
}
if (has_unconnected_nodes)
AKANTU_DEBUG_WARNING("There are nodes that seem to not be connected to any "
"elements, beware that they have lumped mass of 0.");
#endif
this->synchronize(SynchronizationTag::_smm_mass);
need_to_reassemble_lumped_mass = false;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleMass() {
AKANTU_DEBUG_IN();
if (not need_to_reassemble_mass)
return;
this->getDOFManager().clearMatrix("M");
assembleMass(_not_ghost);
need_to_reassemble_mass = false;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleMassLumped(GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto & fem = getFEEngineClass<MyFEEngineType>();
ComputeRhoFunctor compute_rho(*this);
- for (auto type : mesh.elementTypes(Model::spatial_dimension, ghost_type, _ek_regular)) {
+ for (auto type :
+ mesh.elementTypes(Model::spatial_dimension, ghost_type, _ek_regular)) {
fem.assembleFieldLumped(compute_rho, "M", "displacement",
this->getDOFManager(), type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assembleMass(GhostType ghost_type) {
AKANTU_DEBUG_IN();
auto & fem = getFEEngineClass<MyFEEngineType>();
ComputeRhoFunctor compute_rho(*this);
- for (auto type : mesh.elementTypes(Model::spatial_dimension, ghost_type, _ek_regular)) {
+ for (auto type :
+ mesh.elementTypes(Model::spatial_dimension, ghost_type, _ek_regular)) {
fem.assembleFieldMatrix(compute_rho, "M", "displacement",
this->getDOFManager(), type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
} // namespace akantu
diff --git a/src/model/solid_mechanics/solid_mechanics_model_material.cc b/src/model/solid_mechanics/solid_mechanics_model_material.cc
index ba79ab110..f6e7bbf12 100644
--- a/src/model/solid_mechanics/solid_mechanics_model_material.cc
+++ b/src/model/solid_mechanics/solid_mechanics_model_material.cc
@@ -1,255 +1,254 @@
/**
* @file solid_mechanics_model_material.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Nov 26 2010
* @date last modification: Tue Feb 20 2018
*
* @brief instatiation of materials
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_factory.hh"
#include "aka_math.hh"
#include "material_non_local.hh"
#include "mesh_iterators.hh"
#include "non_local_manager.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
Material &
SolidMechanicsModel::registerNewMaterial(const ParserSection & section) {
std::string mat_name;
std::string mat_type = section.getName();
std::string opt_param = section.getOption();
try {
std::string tmp = section.getParameter("name");
mat_name = tmp; /** this can seam weird, but there is an ambiguous operator
* overload that i couldn't solve. @todo remove the
* weirdness of this code
*/
} catch (debug::Exception &) {
AKANTU_ERROR("A material of type \'"
<< mat_type
<< "\' in the input file has been defined without a name!");
}
Material & mat = this->registerNewMaterial(mat_name, mat_type, opt_param);
mat.parseSection(section);
return mat;
}
/* -------------------------------------------------------------------------- */
Material & SolidMechanicsModel::registerNewMaterial(const ID & mat_name,
const ID & mat_type,
const ID & opt_param) {
AKANTU_DEBUG_ASSERT(materials_names_to_id.find(mat_name) ==
materials_names_to_id.end(),
"A material with this name '"
<< mat_name << "' has already been registered. "
<< "Please use unique names for materials");
UInt mat_count = materials.size();
materials_names_to_id[mat_name] = mat_count;
std::stringstream sstr_mat;
sstr_mat << this->id << ":" << mat_count << ":" << mat_type;
ID mat_id = sstr_mat.str();
std::unique_ptr<Material> material = MaterialFactory::getInstance().allocate(
mat_type, spatial_dimension, opt_param, *this, mat_id);
materials.push_back(std::move(material));
return *(materials.back());
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::instantiateMaterials() {
ParserSection model_section;
bool is_empty;
std::tie(model_section, is_empty) = this->getParserSection();
if (not is_empty) {
auto model_materials = model_section.getSubSections(ParserType::_material);
for (const auto & section : model_materials) {
this->registerNewMaterial(section);
}
}
auto sub_sections = this->parser.getSubSections(ParserType::_material);
for (const auto & section : sub_sections) {
this->registerNewMaterial(section);
}
#ifdef AKANTU_DAMAGE_NON_LOCAL
for (auto & material : materials) {
if (dynamic_cast<MaterialNonLocalInterface *>(material.get()) == nullptr)
continue;
this->non_local_manager = std::make_unique<NonLocalManager>(
*this, *this, id + ":non_local_manager", memory_id);
break;
}
#endif
if (materials.empty())
AKANTU_EXCEPTION("No materials where instantiated for the model"
<< getID());
are_materials_instantiated = true;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::assignMaterialToElements(
const ElementTypeMapArray<UInt> * filter) {
for_each_element(
mesh,
[&](auto && element) {
UInt mat_index = (*material_selector)(element);
AKANTU_DEBUG_ASSERT(
mat_index < materials.size(),
"The material selector returned an index that does not exists");
material_index(element) = mat_index;
},
_element_filter = filter, _ghost_type = _not_ghost);
-
if (non_local_manager)
non_local_manager->synchronize(*this, SynchronizationTag::_material_id);
for_each_element(mesh,
[&](auto && element) {
auto mat_index = material_index(element);
auto index = materials[mat_index]->addElement(element);
material_local_numbering(element) = index;
},
_element_filter = filter, _ghost_type = _not_ghost);
// synchronize the element material arrays
this->synchronize(SynchronizationTag::_material_id);
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::initMaterials() {
AKANTU_DEBUG_ASSERT(materials.size() != 0, "No material to initialize !");
if (!are_materials_instantiated)
instantiateMaterials();
this->assignMaterialToElements();
for (auto & material : materials) {
/// init internals properties
material->initMaterial();
}
this->synchronize(SynchronizationTag::_smm_init_mat);
if (this->non_local_manager) {
this->non_local_manager->initialize();
}
}
/* -------------------------------------------------------------------------- */
Int SolidMechanicsModel::getInternalIndexFromID(const ID & id) const {
AKANTU_DEBUG_IN();
auto it = materials.begin();
auto end = materials.end();
for (; it != end; ++it)
if ((*it)->getID() == id) {
AKANTU_DEBUG_OUT();
return (it - materials.begin());
}
AKANTU_DEBUG_OUT();
return -1;
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::reassignMaterial() {
AKANTU_DEBUG_IN();
std::vector<Array<Element>> element_to_add(materials.size());
std::vector<Array<Element>> element_to_remove(materials.size());
Element element;
for (auto ghost_type : ghost_types) {
element.ghost_type = ghost_type;
for (auto type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_not_defined)) {
element.type = type;
UInt nb_element = mesh.getNbElement(type, ghost_type);
Array<UInt> & mat_indexes = material_index(type, ghost_type);
for (UInt el = 0; el < nb_element; ++el) {
element.element = el;
UInt old_material = mat_indexes(el);
UInt new_material = (*material_selector)(element);
if (old_material != new_material) {
element_to_add[new_material].push_back(element);
element_to_remove[old_material].push_back(element);
}
}
}
}
UInt mat_index = 0;
for (auto mat_it = materials.begin(); mat_it != materials.end();
++mat_it, ++mat_index) {
(*mat_it)->removeElements(element_to_remove[mat_index]);
(*mat_it)->addElements(element_to_add[mat_index]);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SolidMechanicsModel::applyEigenGradU(
const Matrix<Real> & prescribed_eigen_grad_u, const ID & material_name,
const GhostType ghost_type) {
AKANTU_DEBUG_ASSERT(prescribed_eigen_grad_u.size() ==
spatial_dimension * spatial_dimension,
"The prescribed grad_u is not of the good size");
for (auto & material : materials) {
if (material->getName() == material_name)
material->applyEigenGradU(prescribed_eigen_grad_u, ghost_type);
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/structural_mechanics/structural_elements/structural_element_bernoulli_beam_3.hh b/src/model/structural_mechanics/structural_elements/structural_element_bernoulli_beam_3.hh
index b00cbd1cd..26cf6467f 100644
--- a/src/model/structural_mechanics/structural_elements/structural_element_bernoulli_beam_3.hh
+++ b/src/model/structural_mechanics/structural_elements/structural_element_bernoulli_beam_3.hh
@@ -1,190 +1,190 @@
/**
* @file structural_element_bernoulli_beam_3.hh
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Sébastien Hartmann <sebastien.hartmann@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Damien Spielmann <damien.spielmann@epfl.ch>
*
* @date creation: Wed Oct 11 2017
* @date last modification: Tue Feb 20 2018
*
* @brief Specific functions for bernoulli beam 3d
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_STRUCTURAL_ELEMENT_BERNOULLI_BEAM_3_HH__
#define __AKANTU_STRUCTURAL_ELEMENT_BERNOULLI_BEAM_3_HH__
#include "structural_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <>
inline void StructuralMechanicsModel::assembleMass<_bernoulli_beam_3>() {
AKANTU_DEBUG_IN();
#if 0
GhostType ghost_type = _not_ghost;
ElementType type = _bernoulli_beam_3;
MyFEEngineType & fem = getFEEngineClass<MyFEEngineType>();
UInt nb_element = getFEEngine().getMesh().getNbElement(type);
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_quadrature_points = getFEEngine().getNbIntegrationPoints(type);
UInt nb_fields_to_interpolate =
getTangentStiffnessVoigtSize<_bernoulli_beam_3>();
UInt nt_n_field_size = nb_degree_of_freedom * nb_nodes_per_element;
Array<Real> * n =
new Array<Real>(nb_element * nb_quadrature_points,
nb_fields_to_interpolate * nt_n_field_size, "N");
n->clear();
Array<Real> * rho_field =
new Array<Real>(nb_element * nb_quadrature_points, "Rho");
rho_field->clear();
computeRho(*rho_field, type, _not_ghost);
/* --------------------------------------------------------------------------
*/
fem.computeShapesMatrix(type, nb_degree_of_freedom, nb_nodes_per_element, n,
0, 0, 0, true, ghost_type); // Ni ui -> u
fem.computeShapesMatrix(type, nb_degree_of_freedom, nb_nodes_per_element, n,
1, 1, 1, true, ghost_type); // Mi vi -> v
fem.computeShapesMatrix(type, nb_degree_of_freedom, nb_nodes_per_element, n,
2, 5, 1, true, ghost_type); // Li Theta_z_i -> v
fem.computeShapesMatrix(type, nb_degree_of_freedom, nb_nodes_per_element, n,
1, 2, 2, true, ghost_type); // Mi wi -> w
fem.computeShapesMatrix(type, nb_degree_of_freedom, nb_nodes_per_element, n,
2, 4, 2, false, ghost_type); // -Li Theta_y_i -> w
fem.computeShapesMatrix(type, nb_degree_of_freedom, nb_nodes_per_element, n,
0, 3, 3, true, ghost_type); // Ni Theta_x_i->Theta_x
/* --------------------------------------------------------------------------
*/
fem.assembleFieldMatrix(*rho_field, nb_degree_of_freedom, *mass_matrix, n,
rotation_matrix, type, ghost_type);
delete n;
delete rho_field;
#endif
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <>
void StructuralMechanicsModel::computeRotationMatrix<_bernoulli_beam_3>(
Array<Real> & rotations) {
ElementType type = _bernoulli_beam_3;
Mesh & mesh = getFEEngine().getMesh();
UInt nb_element = mesh.getNbElement(type);
auto n_it = mesh.getNormals(type).begin(spatial_dimension);
Array<UInt>::iterator<Vector<UInt>> connec_it =
mesh.getConnectivity(type).begin(2);
auto nodes_it = mesh.getNodes().begin(spatial_dimension);
Matrix<Real> Pe(spatial_dimension, spatial_dimension);
Matrix<Real> Pg(spatial_dimension, spatial_dimension);
Matrix<Real> inv_Pg(spatial_dimension, spatial_dimension);
Vector<Real> x_n(spatial_dimension); // x vect n
Array<Real>::matrix_iterator R_it =
rotations.begin(nb_degree_of_freedom, nb_degree_of_freedom);
for (UInt e = 0; e < nb_element; ++e, ++n_it, ++connec_it, ++R_it) {
Vector<Real> & n = *n_it;
Matrix<Real> & R = *R_it;
Vector<UInt> & connec = *connec_it;
Vector<Real> x;
x = nodes_it[connec(1)]; // X2
Vector<Real> y;
y = nodes_it[connec(0)]; // X1
Real l = x.distance(y);
x -= y; // X2 - X1
x_n.crossProduct(x, n);
Pe.eye();
Pe(0, 0) *= l;
Pe(1, 1) *= -l;
Pg(0, 0) = x(0);
Pg(0, 1) = x_n(0);
Pg(0, 2) = n(0);
Pg(1, 0) = x(1);
Pg(1, 1) = x_n(1);
Pg(1, 2) = n(1);
Pg(2, 0) = x(2);
Pg(2, 1) = x_n(2);
Pg(2, 2) = n(2);
inv_Pg.inverse(Pg);
Pe *= inv_Pg;
for (UInt i = 0; i < spatial_dimension; ++i) {
for (UInt j = 0; j < spatial_dimension; ++j) {
R(i, j) = Pe(i, j);
R(i + spatial_dimension, j + spatial_dimension) = Pe(i, j);
}
}
}
}
/* -------------------------------------------------------------------------- */
template <>
void StructuralMechanicsModel::computeTangentModuli<_bernoulli_beam_3>(
Array<Real> & tangent_moduli) {
UInt nb_element = getFEEngine().getMesh().getNbElement(_bernoulli_beam_3);
UInt nb_quadrature_points =
getFEEngine().getNbIntegrationPoints(_bernoulli_beam_3);
UInt tangent_size = 4;
tangent_moduli.clear();
Array<Real>::matrix_iterator D_it =
tangent_moduli.begin(tangent_size, tangent_size);
for (UInt e = 0; e < nb_element; ++e) {
UInt mat = element_material(_bernoulli_beam_3, _not_ghost)(e);
Real E = materials[mat].E;
Real A = materials[mat].A;
Real Iz = materials[mat].Iz;
Real Iy = materials[mat].Iy;
Real GJ = materials[mat].GJ;
for (UInt q = 0; q < nb_quadrature_points; ++q, ++D_it) {
Matrix<Real> & D = *D_it;
D(0, 0) = E * A;
D(1, 1) = E * Iz;
D(2, 2) = E * Iy;
D(3, 3) = GJ;
}
}
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_STRUCTURAL_ELEMENT_BERNOULLI_BEAM_3_HH__ */
diff --git a/src/model/structural_mechanics/structural_elements/structural_element_kirchhoff_shell.hh b/src/model/structural_mechanics/structural_elements/structural_element_kirchhoff_shell.hh
index e5559a345..62349cc8c 100644
--- a/src/model/structural_mechanics/structural_elements/structural_element_kirchhoff_shell.hh
+++ b/src/model/structural_mechanics/structural_elements/structural_element_kirchhoff_shell.hh
@@ -1,80 +1,80 @@
/**
* @file structural_element_kirchhoff_shell.hh
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Sébastien Hartmann <sebastien.hartmann@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Damien Spielmann <damien.spielmann@epfl.ch>
*
* @date creation: Wed Oct 11 2017
* @date last modification: Wed Feb 21 2018
*
* @brief Specific functions for bernoulli kirchhoff shell
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_STRUCTURAL_ELEMENT_BERNOULLI_KIRCHHOFF_SHELL_HH__
#define __AKANTU_STRUCTURAL_ELEMENT_BERNOULLI_KIRCHHOFF_SHELL_HH__
#include "structural_mechanics_model.hh"
namespace akantu {
/* -------------------------------------------------------------------------- */
template <>
inline void
StructuralMechanicsModel::assembleMass<_discrete_kirchhoff_triangle_18>() {
AKANTU_TO_IMPLEMENT();
}
/* -------------------------------------------------------------------------- */
template <>
void StructuralMechanicsModel::computeTangentModuli<
_discrete_kirchhoff_triangle_18>(Array<Real> & tangent_moduli) {
auto tangent_size =
ElementClass<_discrete_kirchhoff_triangle_18>::getNbStressComponents();
auto nb_quad =
getFEEngine().getNbIntegrationPoints(_discrete_kirchhoff_triangle_18);
auto H_it = tangent_moduli.begin(tangent_size, tangent_size);
for (UInt mat :
element_material(_discrete_kirchhoff_triangle_18, _not_ghost)) {
auto & m = materials[mat];
for (UInt q = 0; q < nb_quad; ++q, ++H_it) {
auto & H = *H_it;
H.clear();
Matrix<Real> D = {{1, m.nu, 0}, {m.nu, 1, 0}, {0, 0, (1 - m.nu) / 2}};
D *= m.E * m.t / (1 - m.nu * m.nu);
H.block(D, 0, 0); // in plane membrane behavior
H.block(D * Math::pow<3>(m.t) / 12., 3, 3); // bending behavior
}
}
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_STRUCTURAL_ELEMENT_BERNOULLI_DISCRETE_KIRCHHOFF_TRIANGLE_18_HH__ \
- */
+ */
diff --git a/src/model/structural_mechanics/structural_mechanics_model.cc b/src/model/structural_mechanics/structural_mechanics_model.cc
index 6a6c36546..56db49cba 100644
--- a/src/model/structural_mechanics/structural_mechanics_model.cc
+++ b/src/model/structural_mechanics/structural_mechanics_model.cc
@@ -1,455 +1,456 @@
/**
* @file structural_mechanics_model.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Sébastien Hartmann <sebastien.hartmann@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Damien Spielmann <damien.spielmann@epfl.ch>
*
* @date creation: Fri Jul 15 2011
* @date last modification: Wed Feb 21 2018
*
* @brief Model implementation for StucturalMechanics elements
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "structural_mechanics_model.hh"
#include "dof_manager.hh"
#include "integrator_gauss.hh"
#include "mesh.hh"
#include "shape_structural.hh"
#include "sparse_matrix.hh"
#include "time_step_solver.hh"
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
#include "dumpable_inline_impl.hh"
#include "dumper_elemental_field.hh"
#include "dumper_iohelper_paraview.hh"
#include "group_manager_inline_impl.cc"
#endif
/* -------------------------------------------------------------------------- */
#include "structural_mechanics_model_inline_impl.cc"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
StructuralMechanicsModel::StructuralMechanicsModel(Mesh & mesh, UInt dim,
const ID & id,
const MemoryID & memory_id)
: Model(mesh, ModelType::_structural_mechanics_model, dim, id, memory_id),
time_step(NAN), f_m2a(1.0), stress("stress", id, memory_id),
element_material("element_material", id, memory_id),
set_ID("beam sets", id, memory_id),
rotation_matrix("rotation_matices", id, memory_id) {
AKANTU_DEBUG_IN();
registerFEEngineObject<MyFEEngineType>("StructuralMechanicsFEEngine", mesh,
spatial_dimension);
if (spatial_dimension == 2)
nb_degree_of_freedom = 3;
else if (spatial_dimension == 3)
nb_degree_of_freedom = 6;
else {
AKANTU_TO_IMPLEMENT();
}
#ifdef AKANTU_USE_IOHELPER
this->mesh.registerDumper<DumperParaview>("paraview_all", id, true);
#endif
this->mesh.addDumpMesh(mesh, spatial_dimension, _not_ghost, _ek_structural);
this->initDOFManager();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
StructuralMechanicsModel::~StructuralMechanicsModel() = default;
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::initFullImpl(const ModelOptions & options) {
// <<<< This is the SolidMechanicsModel implementation for future ref >>>>
// material_index.initialize(mesh, _element_kind = _ek_not_defined,
// _default_value = UInt(-1), _with_nb_element =
// true);
// material_local_numbering.initialize(mesh, _element_kind = _ek_not_defined,
// _with_nb_element = true);
// Model::initFullImpl(options);
// // initialize pbc
// if (this->pbc_pair.size() != 0)
// this->initPBC();
// // initialize the materials
// if (this->parser.getLastParsedFile() != "") {
// this->instantiateMaterials();
// }
// this->initMaterials();
// this->initBC(*this, *displacement, *displacement_increment,
// *external_force);
// <<<< END >>>>
Model::initFullImpl(options);
// Initializing stresses
ElementTypeMap<UInt> stress_components;
/// TODO this is ugly af, maybe add a function to FEEngine
for (auto & type : mesh.elementTypes(_spatial_dimension = _all_dimensions,
_element_kind = _ek_structural)) {
UInt nb_components = 0;
// Getting number of components for each element type
#define GET_(type) nb_components = ElementClass<type>::getNbStressComponents()
AKANTU_BOOST_STRUCTURAL_ELEMENT_SWITCH(GET_);
#undef GET_
stress_components(nb_components, type);
}
stress.initialize(
getFEEngine(), _spatial_dimension = _all_dimensions,
_element_kind = _ek_structural, _all_ghost_types = true,
_nb_component = [&stress_components](const ElementType & type,
const GhostType &) -> UInt {
return stress_components(type);
});
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::initFEEngineBoundary() {
/// TODO: this function should not be reimplemented
/// we're just avoiding a call to Model::initFEEngineBoundary()
}
/* -------------------------------------------------------------------------- */
// void StructuralMechanicsModel::setTimeStep(Real time_step) {
// this->time_step = time_step;
// #if defined(AKANTU_USE_IOHELPER)
// this->mesh.getDumper().setTimeStep(time_step);
// #endif
// }
/* -------------------------------------------------------------------------- */
/* Initialisation */
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::initSolver(
TimeStepSolverType time_step_solver_type, NonLinearSolverType) {
AKANTU_DEBUG_IN();
this->allocNodalField(displacement_rotation, nb_degree_of_freedom,
"displacement");
this->allocNodalField(external_force, nb_degree_of_freedom, "external_force");
this->allocNodalField(internal_force, nb_degree_of_freedom, "internal_force");
this->allocNodalField(blocked_dofs, nb_degree_of_freedom, "blocked_dofs");
auto & dof_manager = this->getDOFManager();
if (!dof_manager.hasDOFs("displacement")) {
dof_manager.registerDOFs("displacement", *displacement_rotation,
_dst_nodal);
dof_manager.registerBlockedDOFs("displacement", *this->blocked_dofs);
}
if (time_step_solver_type == TimeStepSolverType::_dynamic ||
time_step_solver_type == TimeStepSolverType::_dynamic_lumped) {
this->allocNodalField(velocity, spatial_dimension, "velocity");
this->allocNodalField(acceleration, spatial_dimension, "acceleration");
if (!dof_manager.hasDOFsDerivatives("displacement", 1)) {
dof_manager.registerDOFsDerivative("displacement", 1, *this->velocity);
dof_manager.registerDOFsDerivative("displacement", 2,
*this->acceleration);
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::initModel() {
for (auto && type : mesh.elementTypes(_element_kind = _ek_structural)) {
// computeRotationMatrix(type);
element_material.alloc(mesh.getNbElement(type), 1, type);
}
getFEEngine().initShapeFunctions(_not_ghost);
getFEEngine().initShapeFunctions(_ghost);
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::assembleStiffnessMatrix() {
AKANTU_DEBUG_IN();
getDOFManager().getMatrix("K").clear();
for (auto & type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_structural)) {
#define ASSEMBLE_STIFFNESS_MATRIX(type) assembleStiffnessMatrix<type>();
AKANTU_BOOST_STRUCTURAL_ELEMENT_SWITCH(ASSEMBLE_STIFFNESS_MATRIX);
#undef ASSEMBLE_STIFFNESS_MATRIX
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::computeStresses() {
AKANTU_DEBUG_IN();
for (auto & type :
mesh.elementTypes(spatial_dimension, _not_ghost, _ek_structural)) {
#define COMPUTE_STRESS_ON_QUAD(type) computeStressOnQuad<type>();
AKANTU_BOOST_STRUCTURAL_ELEMENT_SWITCH(COMPUTE_STRESS_ON_QUAD);
#undef COMPUTE_STRESS_ON_QUAD
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::computeRotationMatrix(const ElementType & type) {
Mesh & mesh = getFEEngine().getMesh();
UInt nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
UInt nb_element = mesh.getNbElement(type);
if (!rotation_matrix.exists(type)) {
rotation_matrix.alloc(nb_element,
nb_degree_of_freedom * nb_nodes_per_element *
nb_degree_of_freedom * nb_nodes_per_element,
type);
} else {
rotation_matrix(type).resize(nb_element);
}
rotation_matrix(type).clear();
Array<Real> rotations(nb_element,
nb_degree_of_freedom * nb_degree_of_freedom);
rotations.clear();
#define COMPUTE_ROTATION_MATRIX(type) computeRotationMatrix<type>(rotations);
AKANTU_BOOST_STRUCTURAL_ELEMENT_SWITCH(COMPUTE_ROTATION_MATRIX);
#undef COMPUTE_ROTATION_MATRIX
auto R_it = rotations.begin(nb_degree_of_freedom, nb_degree_of_freedom);
auto T_it =
rotation_matrix(type).begin(nb_degree_of_freedom * nb_nodes_per_element,
nb_degree_of_freedom * nb_nodes_per_element);
for (UInt el = 0; el < nb_element; ++el, ++R_it, ++T_it) {
auto & T = *T_it;
auto & R = *R_it;
for (UInt k = 0; k < nb_nodes_per_element; ++k) {
for (UInt i = 0; i < nb_degree_of_freedom; ++i)
for (UInt j = 0; j < nb_degree_of_freedom; ++j)
T(k * nb_degree_of_freedom + i, k * nb_degree_of_freedom + j) =
R(i, j);
}
}
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> StructuralMechanicsModel::createNodalFieldBool(
const std::string & field_name, const std::string & group_name,
__attribute__((unused)) bool padding_flag) {
std::map<std::string, Array<bool> *> uint_nodal_fields;
uint_nodal_fields["blocked_dofs"] = blocked_dofs;
return mesh.createNodalField(uint_nodal_fields[field_name], group_name);
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field>
StructuralMechanicsModel::createNodalFieldReal(const std::string & field_name,
const std::string & group_name,
bool padding_flag) {
UInt n;
if (spatial_dimension == 2) {
n = 2;
} else {
n = 3;
}
if (field_name == "displacement") {
return mesh.createStridedNodalField(displacement_rotation, group_name, n, 0,
padding_flag);
}
if (field_name == "rotation") {
return mesh.createStridedNodalField(displacement_rotation, group_name,
nb_degree_of_freedom - n, n,
padding_flag);
}
if (field_name == "force") {
return mesh.createStridedNodalField(external_force, group_name, n, 0,
padding_flag);
}
if (field_name == "momentum") {
return mesh.createStridedNodalField(
external_force, group_name, nb_degree_of_freedom - n, n, padding_flag);
}
if (field_name == "internal_force") {
return mesh.createStridedNodalField(internal_force, group_name, n, 0,
padding_flag);
}
if (field_name == "internal_momentum") {
return mesh.createStridedNodalField(
internal_force, group_name, nb_degree_of_freedom - n, n, padding_flag);
}
return nullptr;
}
/* -------------------------------------------------------------------------- */
std::shared_ptr<dumper::Field> StructuralMechanicsModel::createElementalField(
const std::string & field_name, const std::string & group_name, bool,
const UInt & spatial_dimension, const ElementKind & kind) {
std::shared_ptr<dumper::Field> field;
if (field_name == "element_index_by_material")
field = mesh.createElementalField<UInt, Vector, dumper::ElementalField>(
field_name, group_name, spatial_dimension, kind);
return field;
}
/* -------------------------------------------------------------------------- */
/* Virtual methods from SolverCallback */
/* -------------------------------------------------------------------------- */
/// get the type of matrix needed
MatrixType StructuralMechanicsModel::getMatrixType(const ID & /*id*/) {
return _symmetric;
}
/// callback to assemble a Matrix
void StructuralMechanicsModel::assembleMatrix(const ID & id) {
if (id == "K")
assembleStiffnessMatrix();
}
/// callback to assemble a lumped Matrix
void StructuralMechanicsModel::assembleLumpedMatrix(const ID & /*id*/) {}
/// callback to assemble the residual StructuralMechanicsModel::(rhs)
void StructuralMechanicsModel::assembleResidual() {
AKANTU_DEBUG_IN();
auto & dof_manager = getDOFManager();
internal_force->clear();
computeStresses();
assembleInternalForce();
dof_manager.assembleToResidual("displacement", *internal_force, -1);
dof_manager.assembleToResidual("displacement", *external_force, 1);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/* Virtual methods from Model */
/* -------------------------------------------------------------------------- */
/// get some default values for derived classes
std::tuple<ID, TimeStepSolverType>
StructuralMechanicsModel::getDefaultSolverID(const AnalysisMethod & method) {
switch (method) {
case _static: {
return std::make_tuple("static", TimeStepSolverType::_static);
}
case _implicit_dynamic: {
return std::make_tuple("implicit", TimeStepSolverType::_dynamic);
}
default:
return std::make_tuple("unknown", TimeStepSolverType::_not_defined);
}
}
/* ------------------------------------------------------------------------ */
ModelSolverOptions StructuralMechanicsModel::getDefaultSolverOptions(
const TimeStepSolverType & type) const {
ModelSolverOptions options;
switch (type) {
case TimeStepSolverType::_static: {
options.non_linear_solver_type = NonLinearSolverType::_linear;
- options.integration_scheme_type["displacement"] = IntegrationSchemeType::_pseudo_time;
+ options.integration_scheme_type["displacement"] =
+ IntegrationSchemeType::_pseudo_time;
options.solution_type["displacement"] = IntegrationScheme::_not_defined;
break;
}
default:
AKANTU_EXCEPTION(type << " is not a valid time step solver type");
}
return options;
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::assembleInternalForce() {
for (auto type : mesh.elementTypes(_spatial_dimension = _all_dimensions,
_element_kind = _ek_structural)) {
assembleInternalForce(type, _not_ghost);
// assembleInternalForce(type, _ghost);
}
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::assembleInternalForce(const ElementType & type,
GhostType gt) {
auto & fem = getFEEngine();
auto & sigma = stress(type, gt);
auto ndof = getNbDegreeOfFreedom(type);
auto nb_nodes = mesh.getNbNodesPerElement(type);
auto ndof_per_elem = ndof * nb_nodes;
Array<Real> BtSigma(fem.getNbIntegrationPoints(type) *
mesh.getNbElement(type),
ndof_per_elem, "BtSigma");
fem.computeBtD(sigma, BtSigma, type, gt);
Array<Real> intBtSigma(0, ndof_per_elem, "intBtSigma");
fem.integrate(BtSigma, intBtSigma, ndof_per_elem, type, gt);
BtSigma.resize(0);
getDOFManager().assembleElementalArrayLocalArray(intBtSigma, *internal_force,
type, gt, 1);
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/model/structural_mechanics/structural_mechanics_model_boundary.cc b/src/model/structural_mechanics/structural_mechanics_model_boundary.cc
index 8ed826ad6..d9490980f 100644
--- a/src/model/structural_mechanics/structural_mechanics_model_boundary.cc
+++ b/src/model/structural_mechanics/structural_mechanics_model_boundary.cc
@@ -1,46 +1,46 @@
/**
* @file structural_mechanics_model_boundary.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Damien Spielmann <damien.spielmann@epfl.ch>
*
* @date creation: Fri Jul 15 2011
* @date last modification: Fri Oct 13 2017
*
* @brief Implementation of the boundary conditions for
* StructuralMechanicsModel
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "integrator_gauss.hh"
#include "model.hh"
#include "shape_structural.hh"
#include "structural_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/model/structural_mechanics/structural_mechanics_model_mass.cc b/src/model/structural_mechanics/structural_mechanics_model_mass.cc
index d26224be8..9d54cf9ec 100644
--- a/src/model/structural_mechanics/structural_mechanics_model_mass.cc
+++ b/src/model/structural_mechanics/structural_mechanics_model_mass.cc
@@ -1,79 +1,79 @@
/**
* @file structural_mechanics_model_mass.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Sébastien Hartmann <sebastien.hartmann@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jul 07 2014
* @date last modification: Fri Dec 15 2017
*
* @brief function handling mass computation
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "integrator_gauss.hh"
#include "material.hh"
#include "shape_structural.hh"
#include "structural_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class ComputeRhoFunctorStruct {
public:
explicit ComputeRhoFunctorStruct(const StructuralMechanicsModel & model)
: model(model){};
void operator()(Matrix<Real> & rho, const Element & element) const {
Real mat_rho = model.getMaterial(element).rho;
rho.set(mat_rho);
}
private:
const StructuralMechanicsModel & model;
};
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::assembleMass() {
AKANTU_DEBUG_IN();
assembleMass(_not_ghost);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void StructuralMechanicsModel::assembleMass(GhostType ghost_type) {
AKANTU_DEBUG_IN();
MyFEEngineType & fem = getFEEngineClass<MyFEEngineType>();
ComputeRhoFunctorStruct compute_rho(*this);
for (auto type :
mesh.elementTypes(spatial_dimension, ghost_type, _ek_structural)) {
fem.assembleFieldMatrix(compute_rho, "M", "displacement",
this->getDOFManager(), type, ghost_type);
}
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
diff --git a/src/solver/petsc_wrapper.hh b/src/solver/petsc_wrapper.hh
index 4be454b4f..5d683578a 100644
--- a/src/solver/petsc_wrapper.hh
+++ b/src/solver/petsc_wrapper.hh
@@ -1,80 +1,80 @@
/**
* @file petsc_wrapper.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Feb 21 2013
* @date last modification: Sat Feb 03 2018
*
* @brief Wrapper of PETSc structures
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PETSC_WRAPPER_HH__
#define __AKANTU_PETSC_WRAPPER_HH__
/* -------------------------------------------------------------------------- */
#include <mpi.h>
#include <petscao.h>
#include <petscis.h>
#include <petscksp.h>
#include <petscmat.h>
#include <petscvec.h>
namespace akantu {
/* -------------------------------------------------------------------------- */
struct PETScMatrixWrapper {
Mat mat;
AO ao;
ISLocalToGlobalMapping mapping;
/// MPI communicator for PETSc commands
MPI_Comm communicator;
};
/* -------------------------------------------------------------------------- */
struct PETScSolverWrapper {
KSP ksp;
Vec solution;
Vec rhs;
// MPI communicator for PETSc commands
MPI_Comm communicator;
};
#if not defined(PETSC_CLANGUAGE_CXX)
extern int aka_PETScError(int ierr);
#define CHKERRXX(x) \
do { \
int error = aka_PETScError(x); \
if (error != 0) { \
AKANTU_EXCEPTION("Error in PETSC"); \
} \
} while (0)
#endif
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_PETSC_WRAPPER_HH__ */
diff --git a/src/solver/solver_petsc.hh b/src/solver/solver_petsc.hh
index 9be424428..933a5e514 100644
--- a/src/solver/solver_petsc.hh
+++ b/src/solver/solver_petsc.hh
@@ -1,178 +1,178 @@
/**
* @file solver_petsc.hh
*
* @author Alejandro M. Aragón <alejandro.aragon@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue May 13 2014
* @date last modification: Mon Jun 19 2017
*
* @brief Solver class interface for the petsc solver
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "sparse_solver.hh"
/* -------------------------------------------------------------------------- */
#include <petscksp.h>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_PETSC_HH__
#define __AKANTU_SOLVER_PETSC_HH__
namespace akantu {
class SparseMatrixPETSc;
class DOFManagerPETSc;
-}
+} // namespace akantu
namespace akantu {
class SolverPETSc : public SparseSolver {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SolverPETSc(DOFManagerPETSc & dof_manager, const ID & matrix_id,
const ID & id = "solver_petsc", const MemoryID & memory_id = 0);
virtual ~SolverPETSc();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// create the solver context and set the matrices
virtual void setOperators();
virtual void solve();
private:
/// DOFManager correctly typed
DOFManagerPETSc & dof_manager;
/// PETSc linear solver
KSP ksp;
/// Matrix defining the system of equations
SparseMatrixPETSc & matrix;
/// specify if the petsc_data is initialized or not
bool is_petsc_data_initialized;
};
// SolverPETSc(int argc, char *argv[]) : allocated_(false) {
// /*
// Set linear solver defaults for this problem (optional).
// - By extracting the KSP and PC contexts from the KSP context,
// we can then directly call any KSP and PC routines to set
// various options.
// - The following four statements are optional; all of these
// parameters could alternatively be specified at runtime via
// KSPSetFromOptions();
// */
// // ierr = KSPGetPC(ksp_,&pc);CHKERRCONTINUE(ierr);
// // ierr = PCSetType(pc,PCILU);CHKERRCONTINUE(ierr);
// // ierr = PCSetType(pc,PCJACOBI);CHKERRCONTINUE(ierr);
// ierr =
// KSPSetTolerances(ksp_,1.e-5,PETSC_DEFAULT,PETSC_DEFAULT,PETSC_DEFAULT);CHKERRCONTINUE(ierr);
// }
// //! Overload operator() to solve system of linear equations
// sparse_vector_type operator()(const sparse_matrix_type& AA, const
// sparse_vector_type& bb);
// //! Overload operator() to obtain reaction vector
// sparse_vector_type operator()(const sparse_matrix_type& Kpf, const
// sparse_matrix_type& Kpp, const sparse_vector_type& Up);
// //! Overload operator() to obtain the addition two vectors
// sparse_vector_type operator()(const sparse_vector_type& aa, const
// sparse_vector_type& bb);
// value_type norm(const sparse_matrix_type& aa, Element_insertion_type it =
// Add_t);
// value_type norm(const sparse_vector_type& aa, Element_insertion_type it =
// Add_t);
// // NOTE: the destructor will return an error if it is called after
// MPI_Finalize is
// // called because it uses collect communication to free-up allocated
// memory.
// ~SolverPETSc() {
// static bool exit = false;
// if (!exit) {
// // add finalize PETSc function at exit
// atexit(finalize);
// exit = true;
// }
// if (allocated_) {
// PetscErrorCode ierr = MatDestroy(&A_);CHKERRCONTINUE(ierr);
// ierr = VecDestroy(&x_);CHKERRCONTINUE(ierr);
// ierr = KSPDestroy(&ksp_);CHKERRCONTINUE(ierr);
// }
// }
// /* from the PETSc library, these are the options that can be passed
// to the command line
// Options Database Keys
// -options_table - Calls PetscOptionsView()
// -options_left - Prints unused options that remain in
// the
// database
// -objects_left - Prints list of all objects that have not
// been freed
// -mpidump - Calls PetscMPIDump()
// -malloc_dump - Calls PetscMallocDump()
// -malloc_info - Prints total memory usage
// -malloc_log - Prints summary of memory usage
// Options Database Keys for Profiling
// -log_summary [filename] - Prints summary of flop and timing
// information to screen.
// If the filename is specified the summary is written to the file. See
// PetscLogView().
// -log_summary_python [filename] - Prints data on of flop and timing
// usage
// to a file or screen.
// -log_all [filename] - Logs extensive profiling information
// See
// PetscLogDump().
// -log [filename] - Logs basic profiline information See
// PetscLogDump().
// -log_sync - Log the synchronization in scatters,
// inner products and norms
// -log_mpe [filename] - Creates a logfile viewable by the utility
// Upshot/Nupshot (in MPICH distribution)
// }
// }
// };
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SOLVER_PETSC_HH__ */
diff --git a/src/solver/solver_vector.hh b/src/solver/solver_vector.hh
index 53e19a2e4..dbe8b174b 100644
--- a/src/solver/solver_vector.hh
+++ b/src/solver/solver_vector.hh
@@ -1,87 +1,87 @@
/**
* @file solver_vector.hh
*
* @author Nicolas Richart
*
* @date creation Tue Jan 01 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_VECTOR_HH__
#define __AKANTU_SOLVER_VECTOR_HH__
namespace akantu {
class DOFManager;
}
namespace akantu {
class SolverVector {
public:
SolverVector(DOFManager & dof_manager, const ID & id = "solver_vector")
: id(id), _dof_manager(dof_manager) {}
SolverVector(const SolverVector & vector, const ID & id = "solver_vector")
: id(id), _dof_manager(vector._dof_manager) {}
virtual ~SolverVector() = default;
// resize the vector to the size of the problem
virtual void resize() = 0;
// clear the vector
virtual void clear() = 0;
virtual operator const Array<Real> &() const = 0;
virtual Int size() const = 0;
virtual Int localSize() const = 0;
virtual SolverVector & operator+(const SolverVector & y) = 0;
virtual SolverVector & operator=(const SolverVector & y) = 0;
-
+
UInt & release() { return release_; }
UInt release() const { return release_; }
virtual void printself(std::ostream & stream, int indent = 0) const = 0;
-
+
protected:
ID id;
/// Underlying dof manager
DOFManager & _dof_manager;
UInt release_{0};
};
inline std::ostream & operator<<(std::ostream & stream, SolverVector & _this) {
_this.printself(stream);
return stream;
}
} // namespace akantu
#endif /* __AKANTU_SOLVER_VECTOR_HH__ */
diff --git a/src/solver/solver_vector_default.cc b/src/solver/solver_vector_default.cc
index 4aaaa77cf..b9f35a506 100644
--- a/src/solver/solver_vector_default.cc
+++ b/src/solver/solver_vector_default.cc
@@ -1,37 +1,34 @@
/**
* @file solver_vector.cc
*
* @author Nicolas Richart
*
* @date creation Tue Jan 01 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solver_vector_default.hh"
#include "dof_manager_default.hh"
/* -------------------------------------------------------------------------- */
-namespace akantu {
-
-
-} // namespace akantu
+namespace akantu {} // namespace akantu
diff --git a/src/solver/solver_vector_default.hh b/src/solver/solver_vector_default.hh
index f664ceb08..bbc3b0e42 100644
--- a/src/solver/solver_vector_default.hh
+++ b/src/solver/solver_vector_default.hh
@@ -1,140 +1,141 @@
/**
* @file solver_vector_default.hh
*
* @author Nicolas Richart
*
* @date creation Tue Jan 01 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solver_vector.hh"
/* -------------------------------------------------------------------------- */
#include <utility>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_VECTOR_DEFAULT_HH__
#define __AKANTU_SOLVER_VECTOR_DEFAULT_HH__
namespace akantu {
class DOFManagerDefault;
} // namespace akantu
namespace akantu {
class SolverVectorArray : public SolverVector {
public:
SolverVectorArray(DOFManagerDefault & dof_manager, const ID & id);
SolverVectorArray(const SolverVectorArray & vector, const ID & id);
virtual ~SolverVectorArray() = default;
virtual Array<Real> & getVector() = 0;
virtual const Array<Real> & getVector() const = 0;
- void printself(std::ostream & stream, int indent = 0) const override{
+ void printself(std::ostream & stream, int indent = 0) const override {
std::string space(indent, AKANTU_INDENT);
stream << space << "SolverVectorArray [" << std::endl;
stream << space << " + id: " << id << std::endl;
this->getVector().printself(stream, indent + 1);
stream << space << "]" << std::endl;
}
};
/* -------------------------------------------------------------------------- */
template <class Array_> class SolverVectorArrayTmpl : public SolverVectorArray {
public:
SolverVectorArrayTmpl(DOFManagerDefault & dof_manager, Array_ & vector,
const ID & id = "solver_vector_default")
: SolverVectorArray(dof_manager, id), dof_manager(dof_manager),
vector(vector) {}
template <class A = Array_,
std::enable_if_t<not std::is_reference<A>::value> * = nullptr>
SolverVectorArrayTmpl(DOFManagerDefault & dof_manager,
const ID & id = "solver_vector_default")
: SolverVectorArray(dof_manager, id), dof_manager(dof_manager),
vector(0, 1, id + ":vector") {}
SolverVectorArrayTmpl(const SolverVectorArrayTmpl & vector,
const ID & id = "solver_vector_default")
- : SolverVectorArray(vector, id), dof_manager(vector.dof_manager), vector(vector.vector) {}
+ : SolverVectorArray(vector, id), dof_manager(vector.dof_manager),
+ vector(vector.vector) {}
operator const Array<Real> &() const override { return getVector(); };
virtual operator Array<Real> &() { return getVector(); };
SolverVector & operator+(const SolverVector & y) override;
SolverVector & operator=(const SolverVector & y) override;
void resize() override {
static_assert(not std::is_const<std::remove_reference_t<Array_>>::value,
"Cannot resize a const Array");
this->vector.resize(this->localSize(), 0.);
++this->release_;
}
void clear() override {
static_assert(not std::is_const<std::remove_reference_t<Array_>>::value,
"Cannot clear a const Array");
this->vector.clear();
++this->release_;
}
public:
Array<Real> & getVector() override { return vector; }
const Array<Real> & getVector() const override { return vector; }
Int size() const override;
Int localSize() const override;
virtual Array<Real> & getGlobalVector() { return this->vector; }
virtual void setGlobalVector(const Array<Real> & solution) {
this->vector.copy(solution);
}
protected:
DOFManagerDefault & dof_manager;
Array_ vector;
template <class A> friend class SolverVectorArrayTmpl;
};
/* -------------------------------------------------------------------------- */
using SolverVectorDefault = SolverVectorArrayTmpl<Array<Real>>;
/* -------------------------------------------------------------------------- */
template <class Array>
using SolverVectorDefaultWrap = SolverVectorArrayTmpl<Array &>;
template <class Array>
decltype(auto) make_solver_vector_default_wrap(DOFManagerDefault & dof_manager,
Array & vector) {
return SolverVectorDefaultWrap<Array>(dof_manager, vector);
}
} // namespace akantu
/* -------------------------------------------------------------------------- */
#include "solver_vector_default_tmpl.hh"
/* -------------------------------------------------------------------------- */
#endif /* __AKANTU_SOLVER_VECTOR_DEFAULT_HH__ */
diff --git a/src/solver/solver_vector_default_tmpl.hh b/src/solver/solver_vector_default_tmpl.hh
index f721de957..3cd7fb3e6 100644
--- a/src/solver/solver_vector_default_tmpl.hh
+++ b/src/solver/solver_vector_default_tmpl.hh
@@ -1,81 +1,84 @@
/**
* @file solver_vector_default_tmpl.hh
*
* @author Nicolas Richart
*
* @date creation Tue Jan 01 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager_default.hh"
#include "solver_vector_default.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_VECTOR_DEFAULT_TMPL_HH__
#define __AKANTU_SOLVER_VECTOR_DEFAULT_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
-inline SolverVectorArray::SolverVectorArray(DOFManagerDefault & dof_manager, const ID & id)
+inline SolverVectorArray::SolverVectorArray(DOFManagerDefault & dof_manager,
+ const ID & id)
: SolverVector(dof_manager, id) {}
/* -------------------------------------------------------------------------- */
-inline SolverVectorArray::SolverVectorArray(const SolverVectorArray & vector, const ID & id)
- : SolverVector(vector, id) {}
+inline SolverVectorArray::SolverVectorArray(const SolverVectorArray & vector,
+ const ID & id)
+ : SolverVector(vector, id) {}
/* -------------------------------------------------------------------------- */
template <class Array_>
SolverVector & SolverVectorArrayTmpl<Array_>::
operator+(const SolverVector & y) {
const auto & y_ = aka::as_type<SolverVectorArray>(y);
this->vector += y_.getVector();
++this->release_;
return *this;
}
/* -------------------------------------------------------------------------- */
template <class Array_>
SolverVector & SolverVectorArrayTmpl<Array_>::
operator=(const SolverVector & y) {
const auto & y_ = aka::as_type<SolverVectorArray>(y);
this->vector.copy(y_.getVector());
this->release_ = y.release();
return *this;
}
/* -------------------------------------------------------------------------- */
template <class Array_> inline Int SolverVectorArrayTmpl<Array_>::size() const {
return this->dof_manager.getSystemSize();
}
/* -------------------------------------------------------------------------- */
-template <class Array_> inline Int SolverVectorArrayTmpl<Array_>::localSize() const {
+template <class Array_>
+inline Int SolverVectorArrayTmpl<Array_>::localSize() const {
return dof_manager.getLocalSystemSize();
}
} // namespace akantu
#endif /* __AKANTU_SOLVER_VECTOR_DEFAULT_TMPL_HH__ */
diff --git a/src/solver/solver_vector_petsc.hh b/src/solver/solver_vector_petsc.hh
index b18f302de..19b351413 100644
--- a/src/solver/solver_vector_petsc.hh
+++ b/src/solver/solver_vector_petsc.hh
@@ -1,205 +1,205 @@
/**
* @file solver_vector_petsc.hh
*
* @author Nicolas Richart
*
* @date creation Tue Jan 01 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager_petsc.hh"
#include "solver_vector.hh"
/* -------------------------------------------------------------------------- */
#include <petscvec.h>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_VECTOR_PETSC_HH__
#define __AKANTU_SOLVER_VECTOR_PETSC_HH__
namespace akantu {
class DOFManagerPETSc;
} // namespace akantu
namespace akantu {
/* -------------------------------------------------------------------------- */
namespace internal {
/* ------------------------------------------------------------------------ */
class PETScVector {
public:
virtual ~PETScVector() = default;
- operator Vec&() { return x; }
- operator const Vec&() const { return x; }
-
+ operator Vec &() { return x; }
+ operator const Vec &() const { return x; }
+
Int size() const {
PetscInt n;
PETSc_call(VecGetSize, x, &n);
return n;
}
Int local_size() const {
PetscInt n;
PETSc_call(VecGetLocalSize, x, &n);
return n;
}
AKANTU_GET_MACRO_NOT_CONST(Vec, x, auto &);
AKANTU_GET_MACRO(Vec, x, const auto &);
protected:
Vec x{nullptr};
};
} // namespace internal
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
class SolverVectorPETSc : public SolverVector, public internal::PETScVector {
public:
SolverVectorPETSc(DOFManagerPETSc & dof_manager,
const ID & id = "solver_vector_petsc");
SolverVectorPETSc(const SolverVectorPETSc & vector,
const ID & id = "solver_vector_petsc");
SolverVectorPETSc(Vec vec, DOFManagerPETSc & dof_manager,
const ID & id = "solver_vector_petsc");
~SolverVectorPETSc() override;
// resize the vector to the size of the problem
void resize() override;
void clear() override;
operator const Array<Real> &() const override;
-
+
SolverVector & operator+(const SolverVector & y) override;
SolverVector & operator=(const SolverVector & y) override;
SolverVectorPETSc & operator=(const SolverVectorPETSc & y);
-
+
/// get values using processors global indexes
void getValues(const Array<Int> & idx, Array<Real> & values) const;
/// get values using processors local indexes
void getValuesLocal(const Array<Int> & idx, Array<Real> & values) const;
/// adding values to the vector using the global indices
void addValues(const Array<Int> & gidx, const Array<Real> & values,
Real scale_factor = 1.);
/// adding values to the vector using the local indices
void addValuesLocal(const Array<Int> & lidx, const Array<Real> & values,
Real scale_factor = 1.);
Int size() const override { return internal::PETScVector::size(); }
Int localSize() const override { return internal::PETScVector::local_size(); }
void printself(std::ostream & stream, int indent = 0) const override;
-
+
protected:
void applyModifications();
void updateGhost();
protected:
DOFManagerPETSc & dof_manager;
// used for the conversion operator
Array<Real> cache;
};
/* -------------------------------------------------------------------------- */
namespace internal {
/* ------------------------------------------------------------------------ */
template <class Array> class PETScWrapedVector : public PETScVector {
public:
PETScWrapedVector(Array && array) : array(array) {
PETSc_call(VecCreateSeqWithArray, PETSC_COMM_SELF, 1, array.size(),
array.storage(), &x);
}
~PETScWrapedVector() { PETSc_call(VecDestroy, &x); }
private:
Array array;
};
/* ------------------------------------------------------------------------ */
template <bool read_only> class PETScLocalVector : public PETScVector {
public:
PETScLocalVector(const Vec & g) : g(g) {
PETSc_call(VecGetLocalVectorRead, g, x);
}
PETScLocalVector(const SolverVectorPETSc & g)
: PETScLocalVector(g.getVec()) {}
~PETScLocalVector() {
PETSc_call(VecRestoreLocalVectorRead, g, x);
PETSc_call(VecDestroy, &x);
}
private:
const Vec & g;
};
template <> class PETScLocalVector<false> : public PETScVector {
public:
PETScLocalVector(Vec & g) : g(g) {
PETSc_call(VecGetLocalVectorRead, g, x);
}
PETScLocalVector(SolverVectorPETSc & g) : PETScLocalVector(g.getVec()) {}
~PETScLocalVector() {
PETSc_call(VecRestoreLocalVectorRead, g, x);
PETSc_call(VecDestroy, &x);
}
private:
Vec & g;
};
/* ------------------------------------------------------------------------ */
template <class Array>
decltype(auto) make_petsc_wraped_vector(Array && array) {
return PETScWrapedVector<Array>(std::forward<Array>(array));
}
template <
typename V,
std::enable_if_t<std::is_same<Vec, std::decay_t<V>>::value> * = nullptr>
decltype(auto) make_petsc_local_vector(V && vec) {
constexpr auto read_only = std::is_const<std::remove_reference_t<V>>::value;
return PETScLocalVector<read_only>(vec);
}
template <typename V, std::enable_if_t<std::is_base_of<
SolverVector, std::decay_t<V>>::value> * = nullptr>
decltype(auto) make_petsc_local_vector(V && vec) {
constexpr auto read_only = std::is_const<std::remove_reference_t<V>>::value;
return PETScLocalVector<read_only>(
dynamic_cast<std::conditional_t<read_only, const SolverVectorPETSc,
SolverVectorPETSc> &>(vec));
}
} // namespace internal
} // namespace akantu
#endif /* __AKANTU_SOLVER_VECTOR_PETSC_HH__ */
diff --git a/src/solver/sparse_matrix.cc b/src/solver/sparse_matrix.cc
index 8d8bbd3af..8c6183ee7 100644
--- a/src/solver/sparse_matrix.cc
+++ b/src/solver/sparse_matrix.cc
@@ -1,79 +1,79 @@
/**
* @file sparse_matrix.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Wed Nov 08 2017
*
* @brief implementation of the SparseMatrix class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "dof_manager.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
SparseMatrix::SparseMatrix(DOFManager & dof_manager,
const MatrixType & matrix_type, const ID & id)
: id(id), _dof_manager(dof_manager), matrix_type(matrix_type),
size_(dof_manager.getSystemSize()), nb_non_zero(0) {
AKANTU_DEBUG_IN();
const auto & comm = _dof_manager.getCommunicator();
this->nb_proc = comm.getNbProc();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SparseMatrix::SparseMatrix(const SparseMatrix & matrix, const ID & id)
: SparseMatrix(matrix._dof_manager, matrix.matrix_type, id) {
nb_non_zero = matrix.nb_non_zero;
}
/* -------------------------------------------------------------------------- */
SparseMatrix::~SparseMatrix() = default;
-// /* -------------------------------------------------------------------------- */
-// Array<Real> & operator*=(SolverVector & vect, const SparseMatrix & mat) {
+// /* --------------------------------------------------------------------------
+// */ Array<Real> & operator*=(SolverVector & vect, const SparseMatrix & mat) {
// Array<Real> tmp(vect.size(), vect.getNbComponent(), 0.);
// mat.matVecMul(vect, tmp);
// vect.copy(tmp);
// return vect;
// }
/* -------------------------------------------------------------------------- */
void SparseMatrix::add(const SparseMatrix & B, Real alpha) {
B.addMeTo(*this, alpha);
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/solver/sparse_matrix.hh b/src/solver/sparse_matrix.hh
index db3c82470..ee2f2be7f 100644
--- a/src/solver/sparse_matrix.hh
+++ b/src/solver/sparse_matrix.hh
@@ -1,164 +1,164 @@
/**
* @file sparse_matrix.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Tue Feb 20 2018
*
* @brief sparse matrix storage class (distributed assembled matrix)
* This is a COO format (Coordinate List)
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SPARSE_MATRIX_HH__
#define __AKANTU_SPARSE_MATRIX_HH__
/* -------------------------------------------------------------------------- */
namespace akantu {
class DOFManager;
class TermsToAssemble;
class SolverVector;
-}
+} // namespace akantu
namespace akantu {
class SparseMatrix {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SparseMatrix(DOFManager & dof_manager, const MatrixType & matrix_type,
const ID & id = "sparse_matrix");
SparseMatrix(const SparseMatrix & matrix, const ID & id = "sparse_matrix");
virtual ~SparseMatrix();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// remove the existing profile
virtual void clearProfile();
/// set the matrix to 0
virtual void clear() = 0;
/// add a non-zero element to the profile
virtual UInt add(UInt i, UInt j) = 0;
/// assemble a local matrix in the sparse one
virtual void add(UInt i, UInt j, Real value) = 0;
/// save the profil in a file using the MatrixMarket file format
virtual void saveProfile(__attribute__((unused)) const std::string &) const {
AKANTU_TO_IMPLEMENT();
}
/// save the matrix in a file using the MatrixMarket file format
virtual void saveMatrix(__attribute__((unused)) const std::string &) const {
AKANTU_TO_IMPLEMENT();
};
/// multiply the matrix by a coefficient
virtual void mul(Real alpha) = 0;
/// add matrices
virtual void add(const SparseMatrix & matrix, Real alpha = 1.);
/// Equivalent of *gemv in blas
virtual void matVecMul(const SolverVector & x, SolverVector & y,
Real alpha = 1., Real beta = 0.) const = 0;
/// modify the matrix to "remove" the blocked dof
virtual void applyBoundary(Real block_val = 1.) = 0;
/// copy the profile of another matrix
virtual void copyProfile(const SparseMatrix & other) = 0;
-
+
/// operator *=
SparseMatrix & operator*=(Real alpha) {
this->mul(alpha);
return *this;
}
protected:
/// This is the revert of add B += \alpha * *this;
virtual void addMeTo(SparseMatrix & B, Real alpha) const = 0;
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// return the values at potition i, j
virtual inline Real operator()(__attribute__((unused)) UInt i,
__attribute__((unused)) UInt j) const {
AKANTU_TO_IMPLEMENT();
}
/// return the values at potition i, j
virtual inline Real & operator()(__attribute__((unused)) UInt i,
__attribute__((unused)) UInt j) {
AKANTU_TO_IMPLEMENT();
}
AKANTU_GET_MACRO(NbNonZero, nb_non_zero, UInt);
UInt size() const { return size_; }
AKANTU_GET_MACRO(MatrixType, matrix_type, const MatrixType &);
virtual UInt getRelease() const = 0;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
ID id;
/// Underlying dof manager
DOFManager & _dof_manager;
/// sparce matrix type
MatrixType matrix_type;
/// Size of the matrix
UInt size_;
/// number of processors
UInt nb_proc;
/// number of non zero element
UInt nb_non_zero;
};
-//Array<Real> & operator*=(Array<Real> & vect, const SparseMatrix & mat);
+// Array<Real> & operator*=(Array<Real> & vect, const SparseMatrix & mat);
-} // akantu
+} // namespace akantu
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#include "sparse_matrix_inline_impl.cc"
#endif /* __AKANTU_SPARSE_MATRIX_HH__ */
diff --git a/src/solver/sparse_matrix_aij_inline_impl.cc b/src/solver/sparse_matrix_aij_inline_impl.cc
index c78fae335..f48042e16 100644
--- a/src/solver/sparse_matrix_aij_inline_impl.cc
+++ b/src/solver/sparse_matrix_aij_inline_impl.cc
@@ -1,188 +1,189 @@
/**
* @file sparse_matrix_aij_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Aug 21 2015
* @date last modification: Wed Nov 08 2017
*
* @brief Implementation of inline functions of SparseMatrixAIJ
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "sparse_matrix_aij.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SPARSE_MATRIX_AIJ_INLINE_IMPL_CC__
#define __AKANTU_SPARSE_MATRIX_AIJ_INLINE_IMPL_CC__
namespace akantu {
inline UInt SparseMatrixAIJ::add(UInt i, UInt j) {
KeyCOO jcn_irn = this->key(i, j);
auto it = this->irn_jcn_k.find(jcn_irn);
if (!(it == this->irn_jcn_k.end()))
return it->second;
if (i + 1 > this->size_)
this->size_ = i + 1;
if (j + 1 > this->size_)
this->size_ = j + 1;
this->irn.push_back(i + 1);
this->jcn.push_back(j + 1);
this->a.push_back(0.);
this->irn_jcn_k[jcn_irn] = this->nb_non_zero;
(this->nb_non_zero)++;
this->profile_release++;
this->value_release++;
return (this->nb_non_zero - 1);
}
/* -------------------------------------------------------------------------- */
inline void SparseMatrixAIJ::clearProfile() {
SparseMatrix::clearProfile();
this->irn_jcn_k.clear();
this->irn.resize(0);
this->jcn.resize(0);
this->a.resize(0);
this->size_ = 0;
this->nb_non_zero = 0;
-
+
this->profile_release++;
this->value_release++;
}
/* -------------------------------------------------------------------------- */
inline void SparseMatrixAIJ::add(UInt i, UInt j, Real value) {
UInt idx = this->add(i, j);
this->a(idx) += value;
this->value_release++;
}
/* -------------------------------------------------------------------------- */
inline Real SparseMatrixAIJ::operator()(UInt i, UInt j) const {
KeyCOO jcn_irn = this->key(i, j);
auto irn_jcn_k_it = this->irn_jcn_k.find(jcn_irn);
if (irn_jcn_k_it == this->irn_jcn_k.end())
return 0.;
return this->a(irn_jcn_k_it->second);
}
/* -------------------------------------------------------------------------- */
inline Real & SparseMatrixAIJ::operator()(UInt i, UInt j) {
KeyCOO jcn_irn = this->key(i, j);
auto irn_jcn_k_it = this->irn_jcn_k.find(jcn_irn);
AKANTU_DEBUG_ASSERT(irn_jcn_k_it != this->irn_jcn_k.end(),
"Couple (i,j) = (" << i << "," << j
<< ") does not exist in the profile");
// it may change the profile so it is considered as a change
this->value_release++;
return this->a(irn_jcn_k_it->second);
}
/* -------------------------------------------------------------------------- */
inline void
SparseMatrixAIJ::addSymmetricValuesToSymmetric(const Vector<Int> & is,
- const Vector<Int> & js,
- const Matrix<Real> & values) {
+ const Vector<Int> & js,
+ const Matrix<Real> & values) {
for (UInt i = 0; i < values.rows(); ++i) {
UInt c_irn = is(i);
if (c_irn < size_) {
for (UInt j = i; j < values.cols(); ++j) {
UInt c_jcn = js(j);
if (c_jcn < size_) {
operator()(c_irn, c_jcn) += values(i, j);
}
}
}
}
}
/* -------------------------------------------------------------------------- */
-inline void SparseMatrixAIJ::addUnsymmetricValuesToSymmetric(
- const Vector<Int> & is, const Vector<Int> & js,
- const Matrix<Real> & values) {
+inline void
+SparseMatrixAIJ::addUnsymmetricValuesToSymmetric(const Vector<Int> & is,
+ const Vector<Int> & js,
+ const Matrix<Real> & values) {
for (UInt i = 0; i < values.rows(); ++i) {
UInt c_irn = is(i);
if (c_irn < size_) {
for (UInt j = 0; j < values.cols(); ++j) {
UInt c_jcn = js(j);
if (c_jcn < size_) {
if (c_jcn >= c_irn) {
operator()(c_irn, c_jcn) += values(i, j);
}
}
}
}
}
}
/* -------------------------------------------------------------------------- */
inline void
SparseMatrixAIJ::addValuesToUnsymmetric(const Vector<Int> & is,
- const Vector<Int> & js,
- const Matrix<Real> & values) {
+ const Vector<Int> & js,
+ const Matrix<Real> & values) {
for (UInt i = 0; i < values.rows(); ++i) {
UInt c_irn = is(i);
if (c_irn < size_) {
for (UInt j = 0; j < values.cols(); ++j) {
UInt c_jcn = js(j);
if (c_jcn < size_) {
operator()(c_irn, c_jcn) += values(i, j);
}
}
}
}
}
/* -------------------------------------------------------------------------- */
inline void SparseMatrixAIJ::addValues(const Vector<Int> & is,
const Vector<Int> & js,
const Matrix<Real> & values,
MatrixType values_type) {
if (getMatrixType() == _symmetric)
if (values_type == _symmetric)
this->addSymmetricValuesToSymmetric(is, js, values);
else
this->addUnsymmetricValuesToSymmetric(is, js, values);
else
this->addValuesToUnsymmetric(is, js, values);
}
} // namespace akantu
#endif /* __AKANTU_SPARSE_MATRIX_AIJ_INLINE_IMPL_CC__ */
diff --git a/src/solver/sparse_matrix_inline_impl.cc b/src/solver/sparse_matrix_inline_impl.cc
index 81da7d999..f91c22e29 100644
--- a/src/solver/sparse_matrix_inline_impl.cc
+++ b/src/solver/sparse_matrix_inline_impl.cc
@@ -1,35 +1,35 @@
/**
* @file sparse_matrix_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Mon Jun 19 2017
*
* @brief implementation of inline methods of the SparseMatrix class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
namespace akantu {
inline void SparseMatrix::clearProfile() { this->nb_non_zero = 0; }
-} // akantu
+} // namespace akantu
diff --git a/src/solver/sparse_matrix_petsc.cc b/src/solver/sparse_matrix_petsc.cc
index 513e072ee..c6c59454e 100644
--- a/src/solver/sparse_matrix_petsc.cc
+++ b/src/solver/sparse_matrix_petsc.cc
@@ -1,291 +1,290 @@
/**
* @file sparse_matrix_petsc.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Sat Feb 03 2018
*
* @brief Implementation of PETSc matrix class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "sparse_matrix_petsc.hh"
#include "dof_manager_petsc.hh"
#include "mpi_communicator_data.hh"
#include "solver_vector_petsc.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
SparseMatrixPETSc::SparseMatrixPETSc(DOFManagerPETSc & dof_manager,
const MatrixType & matrix_type,
const ID & id)
: SparseMatrix(dof_manager, matrix_type, id), dof_manager(dof_manager) {
AKANTU_DEBUG_IN();
auto mpi_comm = dof_manager.getMPIComm();
PETSc_call(MatCreate, mpi_comm, &mat);
detail::PETScSetName(mat, id);
-
+
resize();
PETSc_call(MatSetFromOptions, mat);
-
+
PETSc_call(MatSetUp, mat);
PETSc_call(MatSetOption, mat, MAT_ROW_ORIENTED, PETSC_TRUE);
PETSc_call(MatSetOption, mat, MAT_NEW_NONZERO_LOCATIONS, PETSC_TRUE);
if (matrix_type == _symmetric)
PETSc_call(MatSetOption, mat, MAT_SYMMETRIC, PETSC_TRUE);
-
+
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SparseMatrixPETSc::SparseMatrixPETSc(const SparseMatrixPETSc & matrix,
const ID & id)
: SparseMatrix(matrix, id), dof_manager(matrix.dof_manager) {
PETSc_call(MatDuplicate, matrix.mat, MAT_COPY_VALUES, &mat);
detail::PETScSetName(mat, id);
}
/* -------------------------------------------------------------------------- */
SparseMatrixPETSc::~SparseMatrixPETSc() {
AKANTU_DEBUG_IN();
if (mat)
PETSc_call(MatDestroy, &mat);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::resize() {
auto local_size = dof_manager.getPureLocalSystemSize();
PETSc_call(MatSetSizes, mat, local_size, local_size, size_, size_);
auto & is_ltog_mapping = dof_manager.getISLocalToGlobalMapping();
PETSc_call(MatSetLocalToGlobalMapping, mat, is_ltog_mapping, is_ltog_mapping);
}
/* -------------------------------------------------------------------------- */
/**
* Method to save the nonzero pattern and the values stored at each position
* @param filename name of the file in which the information will be stored
*/
void SparseMatrixPETSc::saveMatrix(const std::string & filename) const {
AKANTU_DEBUG_IN();
auto mpi_comm = dof_manager.getMPIComm();
/// create Petsc viewer
PetscViewer viewer;
PETSc_call(PetscViewerASCIIOpen, mpi_comm, filename.c_str(), &viewer);
PETSc_call(PetscViewerPushFormat, viewer, PETSC_VIEWER_ASCII_MATRIXMARKET);
PETSc_call(MatView, mat, viewer);
PETSc_call(PetscViewerPopFormat, viewer);
PETSc_call(PetscViewerDestroy, &viewer);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/// Equivalent of *gemv in blas
void SparseMatrixPETSc::matVecMul(const SolverVector & _x, SolverVector & _y,
Real alpha, Real beta) const {
auto & x = aka::as_type<SolverVectorPETSc>(_x);
auto & y = aka::as_type<SolverVectorPETSc>(_y);
// y = alpha A x + beta y
SolverVectorPETSc w(x, this->id + ":tmp");
// w = A x
if (release == 0) {
PETSc_call(VecZeroEntries, w);
} else {
PETSc_call(MatMult, mat, x, w);
}
-
+
if (alpha != 1.) {
// w = alpha w
PETSc_call(VecScale, w, alpha);
}
// y = w + beta y
PETSc_call(VecAYPX, y, beta, w);
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::addMeToImpl(SparseMatrixPETSc & B, Real alpha) const {
PETSc_call(MatAXPY, B.mat, alpha, mat, SAME_NONZERO_PATTERN);
-
+
B.release++;
}
/* -------------------------------------------------------------------------- */
/**
* Method to add another PETSc matrix to this PETSc matrix
* @param matrix PETSc matrix to be added
* @param alpha the factor specifying how many times the matrix should be added
*/
void SparseMatrixPETSc::addMeTo(SparseMatrix & B, Real alpha) const {
if (aka::is_of_type<SparseMatrixPETSc>(B)) {
auto & B_petsc = aka::as_type<SparseMatrixPETSc>(B);
this->addMeToImpl(B_petsc, alpha);
} else {
AKANTU_TO_IMPLEMENT();
// this->addMeToTemplated<SparseMatrix>(*this, alpha);
}
}
/* -------------------------------------------------------------------------- */
/**
* MatSetValues() generally caches the values. The matrix is ready to
* use only after MatAssemblyBegin() and MatAssemblyEnd() have been
* called. (http://www.mcs.anl.gov/petsc/)
*/
void SparseMatrixPETSc::applyModifications() {
this->beginAssembly();
this->endAssembly();
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::beginAssembly() {
PETSc_call(MatAssemblyBegin, mat, MAT_FINAL_ASSEMBLY);
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::endAssembly() {
PETSc_call(MatAssemblyEnd, mat, MAT_FINAL_ASSEMBLY);
PETSc_call(MatSetOption, mat, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
this->release++;
}
/* -------------------------------------------------------------------------- */
-void SparseMatrixPETSc::copyProfile(const SparseMatrix & other) {
+void SparseMatrixPETSc::copyProfile(const SparseMatrix & other) {
auto & A = aka::as_type<SparseMatrixPETSc>(other);
-
+
MatDestroy(&mat);
MatDuplicate(A.mat, MAT_DO_NOT_COPY_VALUES, &mat);
}
-
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::applyBoundary(Real block_val) {
AKANTU_DEBUG_IN();
const auto & blocked_dofs = this->dof_manager.getGlobalBlockedDOFs();
// std::vector<PetscInt> rows;
// for (auto && data : enumerate(blocked)) {
// if (std::get<1>(data)) {
// rows.push_back(std::get<0>(data));
// }
// }
- //applyModifications();
+ // applyModifications();
static int c = 0;
-
+
saveMatrix("before_blocked_" + std::to_string(c) + ".mtx");
-
+
PETSc_call(MatZeroRowsColumnsLocal, mat, blocked_dofs.size(),
blocked_dofs.storage(), block_val, nullptr, nullptr);
saveMatrix("after_blocked_" + std::to_string(c) + ".mtx");
++c;
-
+
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::mul(Real alpha) {
PETSc_call(MatScale, mat, alpha);
this->release++;
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::clear() {
PETSc_call(MatZeroEntries, mat);
this->release++;
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::clearProfile() {
SparseMatrix::clearProfile();
PETSc_call(MatResetPreallocation, mat);
PETSc_call(MatSetOption, mat, MAT_NEW_NONZERO_LOCATIONS, PETSC_TRUE);
-// PETSc_call(MatSetOption, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
-// PETSc_call(MatSetOption, MAT_NEW_NONZERO_ALLOCATIONS, PETSC_TRUE);
-// PETSc_call(MatSetOption, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE);
+ // PETSc_call(MatSetOption, MAT_KEEP_NONZERO_PATTERN, PETSC_TRUE);
+ // PETSc_call(MatSetOption, MAT_NEW_NONZERO_ALLOCATIONS, PETSC_TRUE);
+ // PETSc_call(MatSetOption, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_TRUE);
clear();
}
/* -------------------------------------------------------------------------- */
UInt SparseMatrixPETSc::add(UInt i, UInt j) {
PETSc_call(MatSetValue, mat, i, j, 0, ADD_VALUES);
return 0;
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::add(UInt i, UInt j, Real val) {
PETSc_call(MatSetValue, mat, i, j, val, ADD_VALUES);
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::addLocal(UInt i, UInt j) {
PETSc_call(MatSetValueLocal, mat, i, j, 0, ADD_VALUES);
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::addLocal(UInt i, UInt j, Real val) {
PETSc_call(MatSetValueLocal, mat, i, j, val, ADD_VALUES);
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::addLocal(const Vector<Int> & rows,
const Vector<Int> & cols,
const Matrix<Real> & vals) {
PETSc_call(MatSetValuesLocal, mat, rows.size(), rows.storage(), cols.size(),
cols.storage(), vals.storage(), ADD_VALUES);
}
/* -------------------------------------------------------------------------- */
void SparseMatrixPETSc::addValues(const Vector<Int> & rows,
const Vector<Int> & cols,
const Matrix<Real> & vals, MatrixType type) {
if (type == _unsymmetric and matrix_type == _symmetric) {
PETSc_call(MatSetOption, mat, MAT_SYMMETRIC, PETSC_FALSE);
PETSc_call(MatSetOption, mat, MAT_STRUCTURALLY_SYMMETRIC, PETSC_FALSE);
}
PETSc_call(MatSetValues, mat, rows.size(), rows.storage(), cols.size(),
cols.storage(), vals.storage(), ADD_VALUES);
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/solver/sparse_matrix_petsc.hh b/src/solver/sparse_matrix_petsc.hh
index 1c5b62a7d..57813631e 100644
--- a/src/solver/sparse_matrix_petsc.hh
+++ b/src/solver/sparse_matrix_petsc.hh
@@ -1,159 +1,160 @@
/**
* @file sparse_matrix_petsc.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 06 2018
*
* @brief Interface for PETSc matrices
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PETSC_MATRIX_HH__
#define __AKANTU_PETSC_MATRIX_HH__
/* -------------------------------------------------------------------------- */
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
#include <petscmat.h>
/* -------------------------------------------------------------------------- */
namespace akantu {
class DOFManagerPETSc;
}
namespace akantu {
class SparseMatrixPETSc : public SparseMatrix {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SparseMatrixPETSc(DOFManagerPETSc & dof_manager,
const MatrixType & matrix_type,
const ID & id = "sparse_matrix_petsc");
SparseMatrixPETSc(const SparseMatrixPETSc & matrix,
const ID & id = "sparse_matrix_petsc");
virtual ~SparseMatrixPETSc();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// set the matrix to 0
void clear() override;
void clearProfile() override;
/// add a non-zero element to the profile
UInt add(UInt i, UInt j) override;
/// assemble a local matrix in the sparse one
void add(UInt i, UInt j, Real value) override;
void addLocal(UInt i, UInt j);
void addLocal(UInt i, UInt j, Real val);
void addLocal(const Vector<Int> & rows, const Vector<Int> & cols,
const Matrix<Real> & vals);
/// add a block of values
void addValues(const Vector<Int> & is, const Vector<Int> & js,
const Matrix<Real> & values, MatrixType values_type);
/// save the profil in a file using the MatrixMarket file format
// void saveProfile(__attribute__((unused)) const std::string &) const
// override {
// AKANTU_DEBUG_TO_IMPLEMENT();
// }
/// save the matrix in a file using the MatrixMarket file format
void saveMatrix(const std::string & filename) const override;
/// multiply the matrix by a coefficient
void mul(Real alpha) override;
/// Equivalent of *gemv in blas
void matVecMul(const SolverVector & x, SolverVector & y, Real alpha = 1.,
Real beta = 0.) const override;
/// modify the matrix to "remove" the blocked dof
void applyBoundary(Real block_val = 1.) override;
/// copy the profile of a matrix
void copyProfile(const SparseMatrix & other) override;
-
+
void applyModifications();
void resize();
+
protected:
/// This is the revert of add B += \alpha * *this;
void addMeTo(SparseMatrix & B, Real alpha) const override;
/// This is the specific implementation
void addMeToImpl(SparseMatrixPETSc & B, Real alpha) const;
void beginAssembly();
void endAssembly();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
/// return the values at potition i, j
virtual inline Real operator()(__attribute__((unused)) UInt i,
__attribute__((unused)) UInt j) const {
AKANTU_TO_IMPLEMENT();
}
/// return the values at potition i, j
virtual inline Real & operator()(__attribute__((unused)) UInt i,
__attribute__((unused)) UInt j) {
AKANTU_TO_IMPLEMENT();
}
virtual UInt getRelease() const override { return release; };
operator Mat &() { return mat; }
operator const Mat &() const { return mat; }
AKANTU_GET_MACRO(Mat, mat, const Mat &);
AKANTU_GET_MACRO_NOT_CONST(Mat, mat, Mat &);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
// DOFManagerPETSc that contains the numbering for petsc
DOFManagerPETSc & dof_manager;
/// store the PETSc matrix
Mat mat;
/// matrix release
UInt release{0};
};
} // namespace akantu
#endif /* __AKANTU_PETSC_MATRIX_HH__ */
diff --git a/src/solver/sparse_solver.cc b/src/solver/sparse_solver.cc
index 9fe6be43a..e7f7eaa85 100644
--- a/src/solver/sparse_solver.cc
+++ b/src/solver/sparse_solver.cc
@@ -1,84 +1,84 @@
/**
* @file sparse_solver.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Fri Dec 08 2017
*
* @brief Solver interface class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "sparse_solver.hh"
#include "communicator.hh"
#include "dof_manager.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
SparseSolver::SparseSolver(DOFManager & dof_manager, const ID & matrix_id,
const ID & id, const MemoryID & memory_id)
: Memory(id, memory_id), Parsable(ParserType::_solver, id),
_dof_manager(dof_manager), matrix_id(matrix_id),
communicator(dof_manager.getCommunicator()) {
AKANTU_DEBUG_IN();
// OK this is fishy...
this->communicator.registerEventHandler(*this);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SparseSolver::~SparseSolver() {
AKANTU_DEBUG_IN();
// this->destroyInternalData();
this->communicator.unregisterEventHandler(*this);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolver::beforeStaticSolverDestroy() {
AKANTU_DEBUG_IN();
try {
this->destroyInternalData();
} catch (...) {
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolver::createSynchronizerRegistry() {
// this->synch_registry = new SynchronizerRegistry(this);
}
void SparseSolver::onCommunicatorFinalize() { this->destroyInternalData(); }
-} // akantu
+} // namespace akantu
diff --git a/src/solver/sparse_solver.hh b/src/solver/sparse_solver.hh
index 5b042f3c3..c7afe6304 100644
--- a/src/solver/sparse_solver.hh
+++ b/src/solver/sparse_solver.hh
@@ -1,130 +1,130 @@
/**
* @file sparse_solver.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Jan 24 2018
*
* @brief interface for solvers
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_memory.hh"
#include "communicator_event_handler.hh"
#include "parsable.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_HH__
#define __AKANTU_SOLVER_HH__
namespace akantu {
enum SolverParallelMethod {
_not_parallel,
_fully_distributed,
_master_slave_distributed
};
class DOFManager;
-}
+} // namespace akantu
namespace akantu {
class SparseSolver : protected Memory,
public Parsable,
public CommunicatorEventHandler {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SparseSolver(DOFManager & dof_manager, const ID & matrix_id,
const ID & id = "solver", const MemoryID & memory_id = 0);
~SparseSolver() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// initialize the solver
virtual void initialize() = 0;
virtual void analysis(){};
virtual void factorize(){};
virtual void solve(){};
protected:
virtual void destroyInternalData(){};
public:
virtual void beforeStaticSolverDestroy();
void createSynchronizerRegistry();
/* ------------------------------------------------------------------------ */
/* Data Accessor inherited members */
/* ------------------------------------------------------------------------ */
public:
void onCommunicatorFinalize() override;
// inline virtual UInt getNbDataForDOFs(const Array<UInt> & dofs,
// SynchronizationTag tag) const;
// inline virtual void packDOFData(CommunicationBuffer & buffer,
// const Array<UInt> & dofs,
// SynchronizationTag tag) const;
// inline virtual void unpackDOFData(CommunicationBuffer & buffer,
// const Array<UInt> & dofs,
// SynchronizationTag tag);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
protected:
/// manager handling the dofs for this SparseMatrix solver
DOFManager & _dof_manager;
/// The id of the associated matrix
ID matrix_id;
/// How to parallelize the solve
SolverParallelMethod parallel_method;
/// Communicator used by the solver
Communicator & communicator;
};
namespace debug {
class SingularMatrixException : public Exception {
public:
SingularMatrixException(const SparseMatrix & matrix)
: Exception("Solver encountered singular matrix"), matrix(matrix) {}
const SparseMatrix & matrix;
};
-}
+} // namespace debug
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SOLVER_HH__ */
diff --git a/src/solver/sparse_solver_mumps.cc b/src/solver/sparse_solver_mumps.cc
index 8ff89a39c..ac7f10dcc 100644
--- a/src/solver/sparse_solver_mumps.cc
+++ b/src/solver/sparse_solver_mumps.cc
@@ -1,454 +1,454 @@
/**
* @file sparse_solver_mumps.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Dec 13 2010
* @date last modification: Tue Feb 20 2018
*
* @brief implem of SparseSolverMumps class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section DESCRIPTION
*
* @subsection Ctrl_param Control parameters
*
* ICNTL(1),
* ICNTL(2),
* ICNTL(3) : output streams for error, diagnostics, and global messages
*
* ICNTL(4) : verbose level : 0 no message - 4 all messages
*
* ICNTL(5) : type of matrix, 0 assembled, 1 elementary
*
* ICNTL(6) : control the permutation and scaling(default 7) see mumps doc for
* more information
*
* ICNTL(7) : determine the pivot order (default 7) see mumps doc for more
* information
*
* ICNTL(8) : describe the scaling method used
*
* ICNTL(9) : 1 solve A x = b, 0 solve At x = b
*
* ICNTL(10) : number of iterative refinement when NRHS = 1
*
* ICNTL(11) : > 0 return statistics
*
* ICNTL(12) : only used for SYM = 2, ordering strategy
*
* ICNTL(13) :
*
* ICNTL(14) : percentage of increase of the estimated working space
*
* ICNTL(15-17) : not used
*
* ICNTL(18) : only used if ICNTL(5) = 0, 0 matrix centralized, 1 structure on
* host and mumps give the mapping, 2 structure on host and distributed matrix
* for facto, 3 distributed matrix
*
* ICNTL(19) : > 0, Shur complement returned
*
* ICNTL(20) : 0 rhs dense, 1 rhs sparse
*
* ICNTL(21) : 0 solution in rhs, 1 solution distributed in ISOL_loc and SOL_loc
* allocated by user
*
* ICNTL(22) : 0 in-core, 1 out-of-core
*
* ICNTL(23) : maximum memory allocatable by mumps pre proc
*
* ICNTL(24) : controls the detection of "null pivot rows"
*
* ICNTL(25) :
*
* ICNTL(26) :
*
* ICNTL(27) :
*
* ICNTL(28) : 0 automatic choice, 1 sequential analysis, 2 parallel analysis
*
* ICNTL(29) : 0 automatic choice, 1 PT-Scotch, 2 ParMetis
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "dof_manager_default.hh"
#include "dof_synchronizer.hh"
-#include "sparse_matrix_aij.hh"
#include "solver_vector_default.hh"
+#include "sparse_matrix_aij.hh"
#if defined(AKANTU_USE_MPI)
#include "mpi_communicator_data.hh"
#endif
#include "sparse_solver_mumps.hh"
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
// static std::ostream & operator <<(std::ostream & stream, const DMUMPS_STRUC_C
// & _this) {
// stream << "DMUMPS Data [" << std::endl;
// stream << " + job : " << _this.job << std::endl;
// stream << " + par : " << _this.par << std::endl;
// stream << " + sym : " << _this.sym << std::endl;
// stream << " + comm_fortran : " << _this.comm_fortran << std::endl;
// stream << " + nz : " << _this.nz << std::endl;
// stream << " + irn : " << _this.irn << std::endl;
// stream << " + jcn : " << _this.jcn << std::endl;
// stream << " + nz_loc : " << _this.nz_loc << std::endl;
// stream << " + irn_loc : " << _this.irn_loc << std::endl;
// stream << " + jcn_loc : " << _this.jcn_loc << std::endl;
// stream << "]";
// return stream;
// }
namespace akantu {
/* -------------------------------------------------------------------------- */
SparseSolverMumps::SparseSolverMumps(DOFManagerDefault & dof_manager,
const ID & matrix_id, const ID & id,
const MemoryID & memory_id)
: SparseSolver(dof_manager, matrix_id, id, memory_id),
dof_manager(dof_manager), master_rhs_solution(0, 1) {
AKANTU_DEBUG_IN();
this->prank = communicator.whoAmI();
#ifdef AKANTU_USE_MPI
this->parallel_method = _fully_distributed;
#else // AKANTU_USE_MPI
this->parallel_method = _not_parallel;
#endif // AKANTU_USE_MPI
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SparseSolverMumps::~SparseSolverMumps() {
AKANTU_DEBUG_IN();
mumpsDataDestroy();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::mumpsDataDestroy() {
#ifdef AKANTU_USE_MPI
int finalized = 0;
MPI_Finalized(&finalized);
if (finalized) // Da fuck !?
return;
#endif
if (this->is_initialized) {
this->mumps_data.job = _smj_destroy; // destroy
dmumps_c(&this->mumps_data);
this->is_initialized = false;
}
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::destroyInternalData() { mumpsDataDestroy(); }
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::checkInitialized() {
if (this->is_initialized)
return;
this->initialize();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::setOutputLevel() {
// Output setup
icntl(1) = 0; // error output
icntl(2) = 0; // diagnostics output
icntl(3) = 0; // information
icntl(4) = 0;
#if !defined(AKANTU_NDEBUG)
DebugLevel dbg_lvl = debug::debugger.getDebugLevel();
if (AKANTU_DEBUG_TEST(dblDump)) {
strcpy(this->mumps_data.write_problem, "mumps_matrix.mtx");
}
// clang-format off
icntl(1) = (dbg_lvl >= dblWarning) ? 6 : 0;
icntl(3) = (dbg_lvl >= dblInfo) ? 6 : 0;
icntl(2) = (dbg_lvl >= dblTrace) ? 6 : 0;
icntl(4) =
dbg_lvl >= dblDump ? 4 :
dbg_lvl >= dblTrace ? 3 :
dbg_lvl >= dblInfo ? 2 :
dbg_lvl >= dblWarning ? 1 :
0;
// clang-format on
#endif
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::initMumpsData() {
auto & A = dof_manager.getMatrix(matrix_id);
// Default Scaling
icntl(8) = 77;
// Assembled matrix
icntl(5) = 0;
/// Default centralized dense second member
icntl(20) = 0;
icntl(21) = 0;
// automatic choice for analysis
icntl(28) = 0;
UInt size = A.size();
if (prank == 0) {
this->master_rhs_solution.resize(size);
}
this->mumps_data.nz_alloc = 0;
this->mumps_data.n = size;
switch (this->parallel_method) {
case _fully_distributed:
icntl(18) = 3; // fully distributed
this->mumps_data.nz_loc = A.getNbNonZero();
this->mumps_data.irn_loc = A.getIRN().storage();
this->mumps_data.jcn_loc = A.getJCN().storage();
break;
case _not_parallel:
case _master_slave_distributed:
icntl(18) = 0; // centralized
if (prank == 0) {
this->mumps_data.nz = A.getNbNonZero();
this->mumps_data.irn = A.getIRN().storage();
this->mumps_data.jcn = A.getJCN().storage();
} else {
this->mumps_data.nz = 0;
this->mumps_data.irn = nullptr;
this->mumps_data.jcn = nullptr;
}
break;
default:
AKANTU_ERROR("This case should not happen!!");
}
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::initialize() {
AKANTU_DEBUG_IN();
this->mumps_data.par = 1; // The host is part of computations
switch (this->parallel_method) {
case _not_parallel:
break;
case _master_slave_distributed:
this->mumps_data.par = 0; // The host is not part of the computations
/* FALLTHRU */
/* [[fallthrough]]; un-comment when compiler will get it */
case _fully_distributed:
#ifdef AKANTU_USE_MPI
- const auto & mpi_data = aka::as_type<MPICommunicatorData>(
- communicator.getCommunicatorData());
+ const auto & mpi_data =
+ aka::as_type<MPICommunicatorData>(communicator.getCommunicatorData());
MPI_Comm mpi_comm = mpi_data.getMPICommunicator();
this->mumps_data.comm_fortran = MPI_Comm_c2f(mpi_comm);
#else
AKANTU_ERROR(
"You cannot use parallel method to solve without activating MPI");
#endif
break;
}
const auto & A = dof_manager.getMatrix(matrix_id);
this->mumps_data.sym = 2 * (A.getMatrixType() == _symmetric);
this->prank = communicator.whoAmI();
this->setOutputLevel();
this->mumps_data.job = _smj_initialize; // initialize
dmumps_c(&this->mumps_data);
this->setOutputLevel();
this->is_initialized = true;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::analysis() {
AKANTU_DEBUG_IN();
initMumpsData();
this->mumps_data.job = _smj_analyze; // analyze
dmumps_c(&this->mumps_data);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::factorize() {
AKANTU_DEBUG_IN();
auto & A = dof_manager.getMatrix(matrix_id);
if (parallel_method == _fully_distributed)
this->mumps_data.a_loc = A.getA().storage();
else {
if (prank == 0)
this->mumps_data.a = A.getA().storage();
}
this->mumps_data.job = _smj_factorize; // factorize
dmumps_c(&this->mumps_data);
this->printError();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::solve(Array<Real> & x, const Array<Real> & b) {
auto & synch = this->dof_manager.getSynchronizer();
if (this->prank == 0) {
this->master_rhs_solution.resize(this->dof_manager.getSystemSize());
synch.gather(b, this->master_rhs_solution);
} else {
synch.gather(b);
}
this->solveInternal();
if (this->prank == 0) {
synch.scatter(x, this->master_rhs_solution);
} else {
synch.scatter(x);
}
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::solve() {
this->master_rhs_solution.copy(
aka::as_type<SolverVectorDefault>(this->dof_manager.getResidual())
.getGlobalVector());
this->solveInternal();
aka::as_type<SolverVectorDefault>(this->dof_manager.getSolution())
.setGlobalVector(this->master_rhs_solution);
this->dof_manager.splitSolutionPerDOFs();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::solveInternal() {
AKANTU_DEBUG_IN();
this->checkInitialized();
const auto & A = dof_manager.getMatrix(matrix_id);
this->setOutputLevel();
if (this->last_profile_release != A.getProfileRelease()) {
this->analysis();
this->last_profile_release = A.getProfileRelease();
}
if (AKANTU_DEBUG_TEST(dblDump)) {
A.saveMatrix("solver_mumps" + std::to_string(prank) + ".mtx");
}
if (this->last_value_release != A.getValueRelease()) {
this->factorize();
this->last_value_release = A.getValueRelease();
}
if (prank == 0) {
this->mumps_data.rhs = this->master_rhs_solution.storage();
}
this->mumps_data.job = _smj_solve; // solve
dmumps_c(&this->mumps_data);
this->printError();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SparseSolverMumps::printError() {
Vector<Int> _info_v(2);
_info_v[0] = info(1); // to get errors
_info_v[1] = -info(1); // to get warnings
dof_manager.getCommunicator().allReduce(_info_v, SynchronizerOperation::_min);
_info_v[1] = -_info_v[1];
if (_info_v[0] < 0) { // < 0 is an error
switch (_info_v[0]) {
case -10: {
AKANTU_CUSTOM_EXCEPTION(
debug::SingularMatrixException(dof_manager.getMatrix(matrix_id)));
break;
}
case -9: {
icntl(14) += 10;
if (icntl(14) != 90) {
// std::cout << "Dynamic memory increase of 10%" << std::endl;
AKANTU_DEBUG_WARNING("MUMPS dynamic memory is insufficient it will be "
"increased allowed to use 10% more");
// change releases to force a recompute
this->last_value_release--;
this->last_profile_release--;
this->solve();
} else {
AKANTU_ERROR("The MUMPS workarray is too small INFO(2)="
<< info(2) << "No further increase possible");
}
break;
}
default:
AKANTU_ERROR("Error in mumps during solve process, check mumps "
"user guide INFO(1) = "
<< _info_v[1]);
}
} else if (_info_v[1] > 0) {
AKANTU_DEBUG_WARNING("Warning in mumps during solve process, check mumps "
"user guide INFO(1) = "
<< _info_v[1]);
}
}
} // namespace akantu
diff --git a/src/solver/sparse_solver_mumps.hh b/src/solver/sparse_solver_mumps.hh
index af401c7e1..a4a221133 100644
--- a/src/solver/sparse_solver_mumps.hh
+++ b/src/solver/sparse_solver_mumps.hh
@@ -1,157 +1,157 @@
/**
* @file sparse_solver_mumps.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Solver class implementation for the mumps solver
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "sparse_solver.hh"
/* -------------------------------------------------------------------------- */
#include <dmumps_c.h>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SOLVER_MUMPS_HH__
#define __AKANTU_SOLVER_MUMPS_HH__
namespace akantu {
class DOFManagerDefault;
class SparseMatrixAIJ;
-}
+} // namespace akantu
namespace akantu {
class SparseSolverMumps : public SparseSolver {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SparseSolverMumps(DOFManagerDefault & dof_manager, const ID & matrix_id,
const ID & id = "sparse_solver_mumps",
const MemoryID & memory_id = 0);
~SparseSolverMumps() override;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// build the profile and do the analysis part
void initialize() override;
/// analysis (symbolic facto + permutations)
void analysis() override;
/// factorize the matrix
void factorize() override;
/// solve the system
virtual void solve(Array<Real> & x, const Array<Real> & b);
/// solve using residual and solution from the dof_manager
void solve() override;
private:
/// print the error if any happened in mumps
void printError();
/// solve the system with master_rhs_solution as b and x
void solveInternal();
/// set internal values;
void initMumpsData();
/// set the level of verbosity of mumps based on the debug level of akantu
void setOutputLevel();
protected:
/// de-initialize the internal data
void destroyInternalData() override;
/// check if initialized and except if it is not the case
void checkInitialized();
private:
void mumpsDataDestroy();
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
private:
/// access the control variable
inline Int & icntl(UInt i) { return mumps_data.icntl[i - 1]; }
/// access the results info
inline Int & info(UInt i) { return mumps_data.info[i - 1]; }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// DOFManager used by the Mumps implementation of the SparseSolver
DOFManagerDefault & dof_manager;
/// Full right hand side on the master processors and solution after solve
Array<Real> master_rhs_solution;
/// mumps data
DMUMPS_STRUC_C mumps_data;
/// Rank of the current process
UInt prank;
/// matrix release at last solve
UInt last_profile_release{UInt(-1)};
/// matrix release at last solve
UInt last_value_release{UInt(-1)};
/// check if the solver data are initialized
bool is_initialized{false};
/* ------------------------------------------------------------------------ */
/* Local types */
/* ------------------------------------------------------------------------ */
private:
SolverParallelMethod parallel_method;
// bool rhs_is_local;
enum SolverMumpsJob {
_smj_initialize = -1,
_smj_analyze = 1,
_smj_factorize = 2,
_smj_solve = 3,
_smj_analyze_factorize = 4,
_smj_factorize_solve = 5,
_smj_complete = 6, // analyze, factorize, solve
_smj_destroy = -2
};
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SOLVER_MUMPS_HH__ */
diff --git a/src/solver/terms_to_assemble.hh b/src/solver/terms_to_assemble.hh
index 4b4d834ff..78717cd27 100644
--- a/src/solver/terms_to_assemble.hh
+++ b/src/solver/terms_to_assemble.hh
@@ -1,100 +1,100 @@
/**
* @file terms_to_assemble.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief List of terms to assemble to a matrix
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#include <vector>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TERMS_TO_ASSEMBLE_HH__
#define __AKANTU_TERMS_TO_ASSEMBLE_HH__
namespace akantu {
class TermsToAssemble {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
TermsToAssemble() = default;
virtual ~TermsToAssemble() = default;
class TermToAssemble {
public:
TermToAssemble(UInt i, UInt j) : _i(i), _j(j), val(0.) {}
inline TermToAssemble & operator=(Real val) {
this->val = val;
return *this;
}
inline TermToAssemble operator+=(Real val) {
this->val += val;
return *this;
}
inline operator Real() const { return val; }
inline UInt i() const { return _i; }
inline UInt j() const { return _j; }
private:
UInt _i, _j;
Real val;
};
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
inline TermToAssemble & operator()(UInt i, UInt j) {
terms.emplace_back(i, j);
return terms.back();
}
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
private:
using TermsContainer = std::vector<TermToAssemble>;
public:
using const_terms_iterator = TermsContainer::const_iterator;
const_terms_iterator begin() const { return terms.begin(); }
const_terms_iterator end() const { return terms.end(); }
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
TermsContainer terms;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_TERMS_TO_ASSEMBLE_HH__ */
diff --git a/src/synchronizer/communication_buffer.hh b/src/synchronizer/communication_buffer.hh
index 03822eae9..3f9a180cf 100644
--- a/src/synchronizer/communication_buffer.hh
+++ b/src/synchronizer/communication_buffer.hh
@@ -1,182 +1,181 @@
/**
* @file communication_buffer.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 08 2017
*
* @brief Buffer for packing and unpacking data
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
#include "element.hh"
#ifndef __AKANTU_COMMUNICATION_BUFFER_HH__
#define __AKANTU_COMMUNICATION_BUFFER_HH__
namespace akantu {
template <bool is_static = true> class CommunicationBufferTemplated {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
- explicit CommunicationBufferTemplated(UInt size)
- : buffer(size, 1, char()) {
+ explicit CommunicationBufferTemplated(UInt size) : buffer(size, 1, char()) {
ptr_pack = buffer.storage();
ptr_unpack = buffer.storage();
};
CommunicationBufferTemplated() : CommunicationBufferTemplated(0) {}
- CommunicationBufferTemplated(const CommunicationBufferTemplated & other) = delete;
+ CommunicationBufferTemplated(const CommunicationBufferTemplated & other) =
+ delete;
CommunicationBufferTemplated &
operator=(const CommunicationBufferTemplated & other) = delete;
-
CommunicationBufferTemplated(CommunicationBufferTemplated && other) = default;
virtual ~CommunicationBufferTemplated() = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// reset to "empty"
inline void reset();
/// resize the internal buffer do not allocate on dynamic buffers
inline void resize(UInt size);
/// resize the internal buffer allocate always
inline void reserve(UInt size);
/// clear buffer context
inline void clear();
private:
inline void packResize(UInt size);
/* ------------------------------------------------------------------------ */
/* Accessors */
/* ------------------------------------------------------------------------ */
public:
inline char * storage() { return buffer.storage(); };
inline const char * storage() const { return buffer.storage(); };
/* ------------------------------------------------------------------------ */
/* Operators */
/* ------------------------------------------------------------------------ */
public:
/// printing tool
template <typename T> inline std::string extractStream(UInt packet_size);
/// packing data
template <typename T>
inline CommunicationBufferTemplated & operator<<(const T & to_pack);
template <typename T>
inline CommunicationBufferTemplated & operator<<(const Vector<T> & to_pack);
template <typename T>
inline CommunicationBufferTemplated & operator<<(const Matrix<T> & to_pack);
template <typename T>
inline CommunicationBufferTemplated &
operator<<(const std::vector<T> & to_pack);
/// unpacking data
template <typename T>
inline CommunicationBufferTemplated & operator>>(T & to_unpack);
template <typename T>
inline CommunicationBufferTemplated & operator>>(Vector<T> & to_unpack);
template <typename T>
inline CommunicationBufferTemplated & operator>>(Matrix<T> & to_unpack);
template <typename T>
inline CommunicationBufferTemplated & operator>>(std::vector<T> & to_unpack);
inline CommunicationBufferTemplated & operator<<(const std::string & to_pack);
inline CommunicationBufferTemplated & operator>>(std::string & to_unpack);
private:
template <typename T> inline void packIterable(T & to_pack);
template <typename T> inline void unpackIterable(T & to_pack);
/* ------------------------------------------------------------------------ */
/* Accessor */
/* ------------------------------------------------------------------------ */
public:
template <typename T> static inline UInt sizeInBuffer(const T & data);
template <typename T> static inline UInt sizeInBuffer(const Vector<T> & data);
template <typename T> static inline UInt sizeInBuffer(const Matrix<T> & data);
template <typename T>
static inline UInt sizeInBuffer(const std::vector<T> & data);
static inline UInt sizeInBuffer(const std::string & data);
/// return the size in bytes of the stored values
inline UInt getPackedSize() const { return ptr_pack - buffer.storage(); };
/// return the size in bytes of data left to be unpacked
inline UInt getLeftToUnpack() const {
return buffer.size() - (ptr_unpack - buffer.storage());
};
/// return the global size allocated
inline UInt size() const { return buffer.size(); };
/// is the buffer empty
inline bool empty() const {
return (getPackedSize() == 0) and (getLeftToUnpack() == 0);
}
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
/// current position for packing
char * ptr_pack;
/// current position for unpacking
char * ptr_unpack;
/// storing buffer
Array<char> buffer;
};
/* -------------------------------------------------------------------------- */
/* inline functions */
/* -------------------------------------------------------------------------- */
#if defined(AKANTU_INCLUDE_INLINE_IMPL)
#include "communication_buffer_inline_impl.cc"
#endif
using CommunicationBuffer = CommunicationBufferTemplated<true>;
using DynamicCommunicationBuffer = CommunicationBufferTemplated<false>;
} // namespace akantu
#endif /* __AKANTU_COMMUNICATION_BUFFER_HH__ */
diff --git a/src/synchronizer/communication_buffer_inline_impl.cc b/src/synchronizer/communication_buffer_inline_impl.cc
index 3b3b8ef2e..80e091f9c 100644
--- a/src/synchronizer/communication_buffer_inline_impl.cc
+++ b/src/synchronizer/communication_buffer_inline_impl.cc
@@ -1,333 +1,334 @@
/**
* @file communication_buffer_inline_impl.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Apr 14 2011
* @date last modification: Wed Nov 08 2017
*
* @brief CommunicationBuffer inline implementation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline UInt CommunicationBufferTemplated<is_static>::sizeInBuffer(const T &) {
return sizeof(T);
}
template <bool is_static>
template <typename T>
inline UInt
CommunicationBufferTemplated<is_static>::sizeInBuffer(const Vector<T> & data) {
UInt size = data.size() * sizeof(T);
return size;
}
template <bool is_static>
template <typename T>
inline UInt
CommunicationBufferTemplated<is_static>::sizeInBuffer(const Matrix<T> & data) {
UInt size = data.size() * sizeof(T);
return size;
}
template <bool is_static>
template <typename T>
inline UInt CommunicationBufferTemplated<is_static>::sizeInBuffer(
const std::vector<T> & data) {
UInt size = data.size() * sizeof(T) + sizeof(size_t);
return size;
}
template <bool is_static>
inline UInt CommunicationBufferTemplated<is_static>::sizeInBuffer(
const std::string & data) {
UInt size = data.size() * sizeof(std::string::value_type) + sizeof(size_t);
return size;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline void CommunicationBufferTemplated<is_static>::packResize(UInt size) {
if (not is_static) {
char * values = buffer.storage();
auto nb_packed = ptr_pack - values;
- if(buffer.size() > nb_packed + size) return;
+ if (buffer.size() > nb_packed + size)
+ return;
buffer.resize(nb_packed + size);
ptr_pack = buffer.storage() + nb_packed;
ptr_unpack = buffer.storage() + (ptr_unpack - values);
}
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator<<(const T & to_pack) {
UInt size = sizeInBuffer(to_pack);
packResize(size);
AKANTU_DEBUG_ASSERT(
(buffer.storage() + buffer.size()) >= (ptr_pack + size),
"Packing too much data in the CommunicationBufferTemplated");
memcpy(ptr_pack, reinterpret_cast<const char *>(&to_pack), size);
ptr_pack += size;
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator>>(T & to_unpack) {
UInt size = sizeInBuffer(to_unpack);
alignas(alignof(T)) std::array<char, sizeof(T)> aligned_ptr;
memcpy(aligned_ptr.data(), ptr_unpack, size);
auto * tmp = reinterpret_cast<T *>(aligned_ptr.data());
AKANTU_DEBUG_ASSERT(
(buffer.storage() + buffer.size()) >= (ptr_unpack + size),
"Unpacking too much data in the CommunicationBufferTemplated");
to_unpack = *tmp;
// memcpy(reinterpret_cast<char *>(&to_unpack), ptr_unpack, size);
ptr_unpack += size;
return *this;
}
/* -------------------------------------------------------------------------- */
/* Specialization */
/* -------------------------------------------------------------------------- */
/**
* Vector
*/
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator<<(const Vector<T> & to_pack) {
UInt size = sizeInBuffer(to_pack);
packResize(size);
AKANTU_DEBUG_ASSERT(
(buffer.storage() + buffer.size()) >= (ptr_pack + size),
"Packing too much data in the CommunicationBufferTemplated");
memcpy(ptr_pack, to_pack.storage(), size);
ptr_pack += size;
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator>>(Vector<T> & to_unpack) {
UInt size = sizeInBuffer(to_unpack);
AKANTU_DEBUG_ASSERT(
(buffer.storage() + buffer.size()) >= (ptr_unpack + size),
"Unpacking too much data in the CommunicationBufferTemplated");
memcpy(to_unpack.storage(), ptr_unpack, size);
ptr_unpack += size;
return *this;
}
/**
* Matrix
*/
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator<<(const Matrix<T> & to_pack) {
UInt size = sizeInBuffer(to_pack);
packResize(size);
AKANTU_DEBUG_ASSERT(
(buffer.storage() + buffer.size()) >= (ptr_pack + size),
"Packing too much data in the CommunicationBufferTemplated");
memcpy(ptr_pack, to_pack.storage(), size);
ptr_pack += size;
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator>>(Matrix<T> & to_unpack) {
UInt size = sizeInBuffer(to_unpack);
AKANTU_DEBUG_ASSERT(
(buffer.storage() + buffer.size()) >= (ptr_unpack + size),
"Unpacking too much data in the CommunicationBufferTemplated");
memcpy(to_unpack.storage(), ptr_unpack, size);
ptr_unpack += size;
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline void CommunicationBufferTemplated<is_static>::packIterable(T & to_pack) {
operator<<(size_t(to_pack.size()));
auto it = to_pack.begin();
auto end = to_pack.end();
for (; it != end; ++it)
operator<<(*it);
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline void
CommunicationBufferTemplated<is_static>::unpackIterable(T & to_unpack) {
size_t size;
operator>>(size);
to_unpack.resize(size);
auto it = to_unpack.begin();
auto end = to_unpack.end();
for (; it != end; ++it)
operator>>(*it);
}
/**
* std::vector<T>
*/
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::
operator<<(const std::vector<T> & to_pack) {
packIterable(to_pack);
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::
operator>>(std::vector<T> & to_unpack) {
unpackIterable(to_unpack);
return *this;
}
/**
* std::string
*/
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::
operator<<(const std::string & to_pack) {
packIterable(to_pack);
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline CommunicationBufferTemplated<is_static> &
CommunicationBufferTemplated<is_static>::operator>>(std::string & to_unpack) {
unpackIterable(to_unpack);
return *this;
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
template <typename T>
inline std::string
CommunicationBufferTemplated<is_static>::extractStream(UInt block_size) {
std::stringstream str;
auto * ptr = reinterpret_cast<T *>(buffer.storage());
UInt sz = buffer.size() / sizeof(T);
UInt sz_block = block_size / sizeof(T);
UInt n_block = 0;
for (UInt i = 0; i < sz; ++i) {
if (i % sz_block == 0) {
str << std::endl << n_block << " ";
++n_block;
}
str << *ptr << " ";
++ptr;
}
return str.str();
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline void CommunicationBufferTemplated<is_static>::resize(UInt size) {
if (!is_static) {
buffer.resize(0, 0);
} else {
buffer.resize(size, 0);
}
reset();
#ifndef AKANTU_NDEBUG
clear();
#endif
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline void CommunicationBufferTemplated<is_static>::reserve(UInt size) {
char * values = buffer.storage();
auto nb_packed = ptr_pack - values;
buffer.resize(size);
ptr_pack = buffer.storage() + nb_packed;
ptr_unpack = buffer.storage() + (ptr_unpack - values);
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline void CommunicationBufferTemplated<is_static>::clear() {
buffer.clear();
}
/* -------------------------------------------------------------------------- */
template <bool is_static>
inline void CommunicationBufferTemplated<is_static>::reset() {
ptr_pack = buffer.storage();
ptr_unpack = buffer.storage();
}
/* -------------------------------------------------------------------------- */
// template<bool is_static>
// inline CommunicationBufferTemplated<is_static> &
// CommunicationBufferTemplated<is_static>::packMeshData (const MeshData &
// to_pack, const ElementType & type) {
// UInt size = to_pack.size();
// operator<<(size);
// typename std::vector<T>::iterator it = to_pack.begin();
// typename std::vector<T>::iterator end = to_pack.end();
// for(;it != end; ++it) operator<<(*it);
// return *this;
//}
diff --git a/src/synchronizer/communication_descriptor_tmpl.hh b/src/synchronizer/communication_descriptor_tmpl.hh
index 92044ef1a..107334666 100644
--- a/src/synchronizer/communication_descriptor_tmpl.hh
+++ b/src/synchronizer/communication_descriptor_tmpl.hh
@@ -1,152 +1,152 @@
/**
* @file communication_descriptor_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 07 2016
* @date last modification: Thu Jan 25 2018
*
* @brief implementation of CommunicationDescriptor
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communication_descriptor.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COMMUNICATION_DESCRIPTOR_TMPL_HH__
#define __AKANTU_COMMUNICATION_DESCRIPTOR_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
/* Implementations */
/* -------------------------------------------------------------------------- */
template <class Entity>
CommunicationDescriptor<Entity>::CommunicationDescriptor(
Communication & communication, Array<Entity> & scheme,
Communications<Entity> & communications, const SynchronizationTag & tag,
UInt proc)
: communication(communication), scheme(scheme),
communications(communications), tag(tag), proc(proc),
rank(communications.getCommunicator().whoAmI()) {
counter = communications.getCounter(tag);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
CommunicationBuffer & CommunicationDescriptor<Entity>::getBuffer() {
return communication.buffer();
}
/* -------------------------------------------------------------------------- */
template <class Entity>
CommunicationRequest & CommunicationDescriptor<Entity>::getRequest() {
return communication.request();
}
/* -------------------------------------------------------------------------- */
template <class Entity> void CommunicationDescriptor<Entity>::freeRequest() {
const auto & comm = communications.getCommunicator();
// comm.test(communication.request());
comm.freeCommunicationRequest(communication.request());
communications.decrementPending(tag, communication.type());
}
/* -------------------------------------------------------------------------- */
template <class Entity>
const Array<Entity> & CommunicationDescriptor<Entity>::getScheme() {
return scheme;
}
template <class Entity> void CommunicationDescriptor<Entity>::resetBuffer() {
this->communication.buffer().reset();
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void CommunicationDescriptor<Entity>::packData(
const DataAccessor<Entity> & accessor) {
AKANTU_DEBUG_ASSERT(
communication.type() == _send,
"Cannot pack data on communication that is not of type _send");
accessor.packData(communication.buffer(), scheme, tag);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void CommunicationDescriptor<Entity>::unpackData(
DataAccessor<Entity> & accessor) {
AKANTU_DEBUG_ASSERT(
communication.type() == _recv,
"Cannot unpack data from communication that is not of type _recv");
accessor.unpackData(communication.buffer(), scheme, tag);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void CommunicationDescriptor<Entity>::postSend(int hash_id) {
AKANTU_DEBUG_ASSERT(communication.type() == _send,
"Cannot send a communication that is not of type _send");
Tag comm_tag = Tag::genTag(rank, counter, tag, hash_id);
AKANTU_DEBUG_ASSERT(communication.buffer().getPackedSize() ==
communication.size(),
"a problem have been introduced with "
<< "false sent sizes declaration "
<< communication.buffer().getPackedSize()
<< " != " << communication.size());
AKANTU_DEBUG_INFO("Posting send to proc " << proc << " (tag: " << tag << " - "
<< communication.size()
<< " data to send) "
<< " [ " << comm_tag << " ]");
CommunicationRequest & request = communication.request();
request = communications.getCommunicator().asyncSend(communication.buffer(),
proc, comm_tag);
communications.incrementPending(tag, communication.type());
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void CommunicationDescriptor<Entity>::postRecv(int hash_id) {
AKANTU_DEBUG_ASSERT(communication.type() == _recv,
"Cannot receive data for communication ("
<< communication.type()
<< ")that is not of type _recv");
Tag comm_tag = Tag::genTag(proc, counter, tag, hash_id);
AKANTU_DEBUG_INFO("Posting receive from proc "
<< proc << " (tag: " << tag << " - " << communication.size()
<< " data to receive) "
<< " [ " << comm_tag << " ]");
CommunicationRequest & request = communication.request();
request = communications.getCommunicator().asyncReceive(
communication.buffer(), proc, comm_tag);
communications.incrementPending(tag, communication.type());
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_COMMUNICATION_DESCRIPTOR_TMPL_HH__ */
diff --git a/src/synchronizer/communication_request.hh b/src/synchronizer/communication_request.hh
index 73b83e0ec..b723be3a8 100644
--- a/src/synchronizer/communication_request.hh
+++ b/src/synchronizer/communication_request.hh
@@ -1,112 +1,112 @@
/**
* @file communication_request.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jun 14 2010
* @date last modification: Wed Nov 08 2017
*
* @brief empty class just for inheritance
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#include <memory>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_REAL_STATIC_COMMUNICATOR_HH__
#define __AKANTU_REAL_STATIC_COMMUNICATOR_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
class InternalCommunicationRequest {
public:
InternalCommunicationRequest(UInt source, UInt dest);
virtual ~InternalCommunicationRequest();
virtual void printself(std::ostream & stream, int indent = 0) const;
AKANTU_GET_MACRO(Source, source, UInt);
AKANTU_GET_MACRO(Destination, destination, UInt);
private:
UInt source;
UInt destination;
UInt id;
static UInt counter;
};
/* -------------------------------------------------------------------------- */
class CommunicationRequest {
public:
CommunicationRequest(
std::shared_ptr<InternalCommunicationRequest> request = nullptr)
: request(std::move(request)) {}
virtual ~CommunicationRequest() = default;
virtual void free() { request.reset(); }
void printself(std::ostream & stream, int indent = 0) const {
request->printself(stream, indent);
};
UInt getSource() const { return request->getSource(); }
UInt getDestination() const { return request->getDestination(); }
bool isFreed() const { return request.get() == nullptr; }
InternalCommunicationRequest & getInternal() { return *request; }
private:
std::shared_ptr<InternalCommunicationRequest> request;
};
/* -------------------------------------------------------------------------- */
class CommunicationStatus {
public:
AKANTU_GET_MACRO(Source, source, Int);
UInt size() const { return size_; }
AKANTU_GET_MACRO(Tag, tag, Int);
AKANTU_SET_MACRO(Source, source, Int);
AKANTU_SET_MACRO(Size, size_, UInt);
AKANTU_SET_MACRO(Tag, tag, Int);
private:
Int source{0};
UInt size_{0};
Int tag{0};
};
/* -------------------------------------------------------------------------- */
/// Datatype to pack pairs for MPI_{MIN,MAX}LOC
template <typename T1, typename T2> struct SCMinMaxLoc {
T1 min_max;
T2 loc;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_REAL_STATIC_COMMUNICATOR_HH__ */
diff --git a/src/synchronizer/communication_tag.hh b/src/synchronizer/communication_tag.hh
index ff5eb6568..35cbb0a13 100644
--- a/src/synchronizer/communication_tag.hh
+++ b/src/synchronizer/communication_tag.hh
@@ -1,124 +1,124 @@
/**
* @file communication_tag.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 07 2016
* @date last modification: Wed Nov 08 2017
*
* @brief Description of the communication tags
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COMMUNICATION_TAG_HH__
#define __AKANTU_COMMUNICATION_TAG_HH__
namespace akantu {
/**
* tag = |__________20_________|___8____|_4_|
* | proc | num mes| ct|
*/
class Tag {
public:
Tag() = default;
Tag(int val) : tag(val) {}
Tag(int val, int hash) : tag(val), hash(hash) {}
operator int() const {
return int(max_tag == 0 ? tag : (uint32_t(tag) % max_tag));
}
/// generates a tag
template <typename CommTag>
static inline Tag genTag(int proc, UInt msg_count, CommTag tag) {
int _tag = ((((proc & 0xFFFFF) << 12) + ((msg_count & 0xFF) << 4) +
((int)tag & 0xF)));
Tag t(_tag);
return t;
}
/// generates a tag and hashes it
template <typename CommTag>
static inline Tag genTag(int proc, UInt msg_count, CommTag tag, int hash) {
Tag t = genTag(proc, msg_count, tag);
t.tag = t.tag ^ hash;
t.hash = hash;
return t;
}
virtual void printself(std::ostream & stream, int) const {
int t = tag;
stream << "TAG(";
if (hash != 0)
t = t ^ hash;
stream << (t >> 12) << ":" << (t >> 4 & 0xFF) << ":" << (t & 0xF) << " -> "
<< std::hex << "0x" << int(*this);
if (hash != 0)
stream << " {hash: 0x" << hash << "}";
stream << " [0x" << this->max_tag << "]";
stream << ")" << std::dec;
}
enum CommTags : int {
_SIZES = 1,
_CONNECTIVITY = 2,
_DATA = 3,
_PARTITIONS = 4,
_NB_NODES = 5,
_NODES = 6,
_COORDINATES = 7,
_NODES_TYPE = 8,
_MESH_DATA = 9,
_ELEMENT_GROUP = 10,
_NODE_GROUP = 11,
_MODIFY_SCHEME = 12,
_GATHER_INITIALIZATION = 1,
_GATHER = 2,
_SCATTER = 3,
_SYNCHRONIZE = 15,
_REDUCE,
_PERIODIC_SLAVES,
_PERIODIC_NODES,
};
private:
static void setMaxTag(int _max_tag) { max_tag = _max_tag; }
friend void initialize(const std::string &, int &, char **&);
private:
int tag{0};
int hash{0};
static int max_tag;
};
/* -------------------------------------------------------------------------- */
inline std::ostream & operator<<(std::ostream & stream, const Tag & _this) {
_this.printself(stream, 0);
return stream;
}
/* -------------------------------------------------------------------------- */
-}
+} // namespace akantu
#endif /* __AKANTU_COMMUNICATION_TAG_HH__ */
diff --git a/src/synchronizer/communications_tmpl.hh b/src/synchronizer/communications_tmpl.hh
index fd4c2c566..6fee91288 100644
--- a/src/synchronizer/communications_tmpl.hh
+++ b/src/synchronizer/communications_tmpl.hh
@@ -1,557 +1,556 @@
/**
* @file communications_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 07 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Implementation of Communications
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communications.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COMMUNICATIONS_TMPL_HH__
#define __AKANTU_COMMUNICATIONS_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class Entity>
Communications<Entity>::Communications(const Communicator & communicator)
: communicator(communicator) {}
/* -------------------------------------------------------------------------- */
template <class Entity>
Communications<Entity>::Communications(const Communications & other)
: communicator(other.communicator) {
for (auto sr : iterate_send_recv) {
for (const auto & scheme_pair : other.iterateSchemes(sr)) {
auto proc = scheme_pair.first;
auto & other_scheme = scheme_pair.second;
auto & scheme = this->createScheme(proc, sr);
scheme.copy(other_scheme);
}
}
this->invalidateSizes();
}
/* -------------------------------------------------------------------------- */
-template <class Entity>
-void Communications<Entity>::swapSendRecv() {
+template <class Entity> void Communications<Entity>::swapSendRecv() {
std::swap(schemes[_send], schemes[_recv]);
}
/* -------------------------------------------------------------------------- */
template <class Entity> class Communications<Entity>::iterator {
using communication_iterator =
typename std::map<UInt, Communication>::iterator;
public:
iterator() : communications(nullptr) {}
iterator(scheme_iterator scheme_it, communication_iterator comm_it,
Communications<Entity> & communications,
const SynchronizationTag & tag)
: scheme_it(scheme_it), comm_it(comm_it), communications(&communications),
tag(tag) {}
iterator & operator=(const iterator & other) {
if (this != &other) {
this->scheme_it = other.scheme_it;
this->comm_it = other.comm_it;
this->communications = other.communications;
this->tag = other.tag;
}
return *this;
}
iterator & operator++() {
++scheme_it;
++comm_it;
return *this;
}
CommunicationDescriptor<Entity> operator*() {
AKANTU_DEBUG_ASSERT(
scheme_it->first == comm_it->first,
"The two iterators are not in phase, something wrong"
<< " happened, time to take out your favorite debugger ("
<< scheme_it->first << " != " << comm_it->first << ")");
return CommunicationDescriptor<Entity>(comm_it->second, scheme_it->second,
*communications, tag,
scheme_it->first);
}
bool operator==(const iterator & other) const {
return scheme_it == other.scheme_it && comm_it == other.comm_it;
}
bool operator!=(const iterator & other) const {
return scheme_it != other.scheme_it || comm_it != other.comm_it;
}
private:
scheme_iterator scheme_it;
communication_iterator comm_it;
Communications<Entity> * communications;
SynchronizationTag tag;
};
/* -------------------------------------------------------------------------- */
template <class Entity> class Communications<Entity>::tag_iterator {
using internal_iterator = std::map<SynchronizationTag, UInt>::const_iterator;
public:
tag_iterator(const internal_iterator & it) : it(it) {}
tag_iterator & operator++() {
++it;
return *this;
}
SynchronizationTag operator*() { return it->first; }
bool operator==(const tag_iterator & other) const { return it == other.it; }
bool operator!=(const tag_iterator & other) const { return it != other.it; }
private:
internal_iterator it;
};
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::CommunicationPerProcs &
Communications<Entity>::getCommunications(const SynchronizationTag & tag,
const CommunicationSendRecv & sr) {
auto comm_it = this->communications[sr].find(tag);
if (comm_it == this->communications[sr].end())
AKANTU_CUSTOM_EXCEPTION_INFO(
debug::CommunicationException(),
"No known communications for the tag: " << tag);
return comm_it->second;
}
/* ---------------------------------------------------------------------- */
template <class Entity>
UInt Communications<Entity>::getPending(
const SynchronizationTag & tag, const CommunicationSendRecv & sr) const {
const std::map<SynchronizationTag, UInt> & pending =
pending_communications[sr];
auto it = pending.find(tag);
if (it == pending.end())
return 0;
return it->second;
}
/* -------------------------------------------------------------------------- */
template <class Entity>
bool Communications<Entity>::hasPending(
const SynchronizationTag & tag, const CommunicationSendRecv & sr) const {
return this->hasCommunication(tag) && (this->getPending(tag, sr) != 0);
}
/* ---------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::iterator
Communications<Entity>::begin(const SynchronizationTag & tag,
const CommunicationSendRecv & sr) {
auto & comms = this->getCommunications(tag, sr);
return iterator(this->schemes[sr].begin(), comms.begin(), *this, tag);
}
template <class Entity>
typename Communications<Entity>::iterator
Communications<Entity>::end(const SynchronizationTag & tag,
const CommunicationSendRecv & sr) {
auto & comms = this->getCommunications(tag, sr);
return iterator(this->schemes[sr].end(), comms.end(), *this, tag);
}
/* ---------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::iterator
Communications<Entity>::waitAny(const SynchronizationTag & tag,
const CommunicationSendRecv & sr) {
auto & comms = this->getCommunications(tag, sr);
auto it = comms.begin();
auto end = comms.end();
std::vector<CommunicationRequest> requests;
for (; it != end; ++it) {
auto & request = it->second.request();
if (!request.isFreed())
requests.push_back(request);
}
UInt req_id = communicator.waitAny(requests);
if (req_id != UInt(-1)) {
auto & request = requests[req_id];
UInt proc = sr == _recv ? request.getSource() : request.getDestination();
return iterator(this->schemes[sr].find(proc), comms.find(proc), *this, tag);
} else {
return this->end(tag, sr);
}
}
/* ---------------------------------------------------------------------- */
template <class Entity>
void Communications<Entity>::waitAll(const SynchronizationTag & tag,
const CommunicationSendRecv & sr) {
auto & comms = this->getCommunications(tag, sr);
auto it = comms.begin();
auto end = comms.end();
std::vector<CommunicationRequest> requests;
for (; it != end; ++it) {
requests.push_back(it->second.request());
}
communicator.waitAll(requests);
}
template <class Entity>
void Communications<Entity>::incrementPending(
const SynchronizationTag & tag, const CommunicationSendRecv & sr) {
++(pending_communications[sr][tag]);
}
template <class Entity>
void Communications<Entity>::decrementPending(
const SynchronizationTag & tag, const CommunicationSendRecv & sr) {
--(pending_communications[sr][tag]);
}
template <class Entity>
void Communications<Entity>::freeRequests(const SynchronizationTag & tag,
const CommunicationSendRecv & sr) {
iterator it = this->begin(tag, sr);
iterator end = this->end(tag, sr);
for (; it != end; ++it) {
(*it).freeRequest();
}
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::Scheme &
Communications<Entity>::createScheme(UInt proc,
const CommunicationSendRecv & sr) {
// scheme_iterator it = schemes[sr].find(proc);
// if (it != schemes[sr].end()) {
// AKANTU_CUSTOM_EXCEPTION_INFO(debug::CommunicationException(),
// "Communication scheme("
// << sr
// << ") already created for proc: " <<
// proc);
// }
return schemes[sr][proc];
}
template <class Entity>
void Communications<Entity>::resetSchemes(const CommunicationSendRecv & sr) {
auto it = this->schemes[sr].begin();
auto end = this->schemes[sr].end();
for (; it != end; ++it) {
it->second.resize(0);
}
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void Communications<Entity>::setCommunicationSize(
const SynchronizationTag & tag, UInt proc, UInt size,
const CommunicationSendRecv & sr) {
// accessor that fails if it does not exists
comm_size_computed[tag] = true; // TODO: need perhaps to be split based on sr
auto & comms = this->communications[sr];
auto & comms_per_tag = comms.at(tag);
comms_per_tag.at(proc).resize(size);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void Communications<Entity>::initializeCommunications(
const SynchronizationTag & tag) {
for (auto t = send_recv_t::begin(); t != send_recv_t::end(); ++t) {
pending_communications[*t].insert(std::make_pair(tag, 0));
auto & comms = this->communications[*t];
auto & comms_per_tag =
comms.insert(std::make_pair(tag, CommunicationPerProcs()))
.first->second;
for (auto pair : this->schemes[*t]) {
comms_per_tag.emplace(std::piecewise_construct,
std::forward_as_tuple(pair.first),
std::forward_as_tuple(*t));
}
}
comm_counter.insert(std::make_pair(tag, 0));
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::tag_iterator
Communications<Entity>::begin_tag() {
return tag_iterator(comm_counter.begin());
}
template <class Entity>
typename Communications<Entity>::tag_iterator
Communications<Entity>::end_tag() {
return tag_iterator(comm_counter.end());
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::scheme_iterator
Communications<Entity>::begin_scheme(const CommunicationSendRecv & sr) {
return this->schemes[sr].begin();
}
template <class Entity>
typename Communications<Entity>::scheme_iterator
Communications<Entity>::end_scheme(const CommunicationSendRecv & sr) {
return this->schemes[sr].end();
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::const_scheme_iterator
Communications<Entity>::begin_scheme(const CommunicationSendRecv & sr) const {
return this->schemes[sr].begin();
}
template <class Entity>
typename Communications<Entity>::const_scheme_iterator
Communications<Entity>::end_scheme(const CommunicationSendRecv & sr) const {
return this->schemes[sr].end();
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::scheme_iterator
Communications<Entity>::begin_send_scheme() {
return this->begin_scheme(_send);
}
template <class Entity>
typename Communications<Entity>::scheme_iterator
Communications<Entity>::end_send_scheme() {
return this->end_scheme(_send);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::const_scheme_iterator
Communications<Entity>::begin_send_scheme() const {
return this->begin_scheme(_send);
}
template <class Entity>
typename Communications<Entity>::const_scheme_iterator
Communications<Entity>::end_send_scheme() const {
return this->end_scheme(_send);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::scheme_iterator
Communications<Entity>::begin_recv_scheme() {
return this->begin_scheme(_recv);
}
template <class Entity>
typename Communications<Entity>::scheme_iterator
Communications<Entity>::end_recv_scheme() {
return this->end_scheme(_recv);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::const_scheme_iterator
Communications<Entity>::begin_recv_scheme() const {
return this->begin_scheme(_recv);
}
template <class Entity>
typename Communications<Entity>::const_scheme_iterator
Communications<Entity>::end_recv_scheme() const {
return this->end_scheme(_recv);
}
/* ------------------------------------------------------------------------ */
template <class Entity>
bool Communications<Entity>::hasCommunication(
const SynchronizationTag & tag) const {
return (communications[_send].find(tag) != communications[_send].end());
}
template <class Entity>
void Communications<Entity>::incrementCounter(const SynchronizationTag & tag) {
auto it = comm_counter.find(tag);
if (it == comm_counter.end()) {
AKANTU_CUSTOM_EXCEPTION_INFO(
debug::CommunicationException(),
"No counter initialized in communications for the tags: " << tag);
}
++(it->second);
}
template <class Entity>
UInt Communications<Entity>::getCounter(const SynchronizationTag & tag) const {
auto it = comm_counter.find(tag);
if (it == comm_counter.end()) {
AKANTU_CUSTOM_EXCEPTION_INFO(
debug::CommunicationException(),
"No counter initialized in communications for the tags: " << tag);
}
return it->second;
}
template <class Entity>
bool Communications<Entity>::hasCommunicationSize(
const SynchronizationTag & tag) const {
auto it = comm_size_computed.find(tag);
if (it == comm_size_computed.end()) {
return false;
}
return it->second;
}
template <class Entity> void Communications<Entity>::invalidateSizes() {
for (auto && pair : comm_size_computed) {
pair.second = false;
}
}
template <class Entity>
bool Communications<Entity>::hasPendingRecv(
const SynchronizationTag & tag) const {
return this->hasPending(tag, _recv);
}
template <class Entity>
bool Communications<Entity>::hasPendingSend(
const SynchronizationTag & tag) const {
return this->hasPending(tag, _send);
}
template <class Entity>
const auto & Communications<Entity>::getCommunicator() const {
return communicator;
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::iterator
Communications<Entity>::waitAnyRecv(const SynchronizationTag & tag) {
return this->waitAny(tag, _recv);
}
template <class Entity>
typename Communications<Entity>::iterator
Communications<Entity>::waitAnySend(const SynchronizationTag & tag) {
return this->waitAny(tag, _send);
}
template <class Entity>
void Communications<Entity>::waitAllRecv(const SynchronizationTag & tag) {
this->waitAll(tag, _recv);
}
template <class Entity>
void Communications<Entity>::waitAllSend(const SynchronizationTag & tag) {
this->waitAll(tag, _send);
}
template <class Entity>
void Communications<Entity>::freeSendRequests(const SynchronizationTag & tag) {
this->freeRequests(tag, _send);
}
template <class Entity>
void Communications<Entity>::freeRecvRequests(const SynchronizationTag & tag) {
this->freeRequests(tag, _recv);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::Scheme &
Communications<Entity>::createSendScheme(UInt proc) {
return createScheme(proc, _send);
}
template <class Entity>
typename Communications<Entity>::Scheme &
Communications<Entity>::createRecvScheme(UInt proc) {
return createScheme(proc, _recv);
}
/* -------------------------------------------------------------------------- */
template <class Entity> void Communications<Entity>::resetSchemes() {
resetSchemes(_send);
resetSchemes(_recv);
}
/* -------------------------------------------------------------------------- */
template <class Entity>
typename Communications<Entity>::Scheme &
Communications<Entity>::getScheme(UInt proc, const CommunicationSendRecv & sr) {
return this->schemes[sr].find(proc)->second;
}
/* -------------------------------------------------------------------------- */
template <class Entity>
const typename Communications<Entity>::Scheme &
Communications<Entity>::getScheme(UInt proc,
const CommunicationSendRecv & sr) const {
return this->schemes[sr].find(proc)->second;
}
/* -------------------------------------------------------------------------- */
template <class Entity>
void Communications<Entity>::setSendCommunicationSize(
const SynchronizationTag & tag, UInt proc, UInt size) {
this->setCommunicationSize(tag, proc, size, _send);
}
template <class Entity>
void Communications<Entity>::setRecvCommunicationSize(
const SynchronizationTag & tag, UInt proc, UInt size) {
this->setCommunicationSize(tag, proc, size, _recv);
}
} // namespace akantu
#endif /* __AKANTU_COMMUNICATIONS_TMPL_HH__ */
diff --git a/src/synchronizer/communicator_dummy_inline_impl.cc b/src/synchronizer/communicator_dummy_inline_impl.cc
index d5ee44523..24322d851 100644
--- a/src/synchronizer/communicator_dummy_inline_impl.cc
+++ b/src/synchronizer/communicator_dummy_inline_impl.cc
@@ -1,133 +1,130 @@
/**
* @file communicator_dummy_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Nov 07 2017
* @date last modification: Fri Nov 10 2017
*
* @brief Dummy communicator to make everything work im sequential
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
/* -------------------------------------------------------------------------- */
#include <cstring>
#include <type_traits>
#include <vector>
/* -------------------------------------------------------------------------- */
namespace akantu {
Communicator::Communicator(int & /*argc*/, char **& /*argv*/,
const private_member & /*unused*/) {}
template <typename T>
void Communicator::sendImpl(const T *, Int, Int, Int,
const CommunicationMode &) const {}
template <typename T>
void Communicator::receiveImpl(T *, Int, Int, Int) const {}
template <typename T>
CommunicationRequest
Communicator::asyncSendImpl(const T *, Int, Int, Int,
const CommunicationMode &) const {
return std::shared_ptr<InternalCommunicationRequest>(
new InternalCommunicationRequest(0, 0));
}
template <typename T>
CommunicationRequest Communicator::asyncReceiveImpl(T *, Int, Int, Int) const {
return std::shared_ptr<InternalCommunicationRequest>(
new InternalCommunicationRequest(0, 0));
}
template <typename T>
void Communicator::probe(Int, Int, CommunicationStatus &) const {}
template <typename T>
bool Communicator::asyncProbe(Int, Int, CommunicationStatus &) const {
return true;
}
bool Communicator::test(CommunicationRequest &) const { return true; }
bool Communicator::testAll(std::vector<CommunicationRequest> &) const {
return true;
}
void Communicator::wait(CommunicationRequest &) const {}
void Communicator::waitAll(std::vector<CommunicationRequest> &) const {}
UInt Communicator::waitAny(std::vector<CommunicationRequest> &) const {
return UInt(-1);
}
void Communicator::barrier() const {}
CommunicationRequest Communicator::asyncBarrier() const {
return std::shared_ptr<InternalCommunicationRequest>(
new InternalCommunicationRequest(0, 0));
}
template <typename T>
void Communicator::reduceImpl(T *, int, SynchronizerOperation, int) const {}
template <typename T>
void Communicator::allReduceImpl(T *, int, SynchronizerOperation) const {}
template <typename T>
void Communicator::scanImpl(T * values, T * result, int n,
SynchronizerOperation) const {
if (values == result)
return;
std::copy_n(values, n, result);
}
template <typename T>
-void Communicator::exclusiveScanImpl(T * values, T * result, int n,
+void Communicator::exclusiveScanImpl(T * /*values*/, T * result, int n,
SynchronizerOperation) const {
- if (values == result)
- return;
-
- std::copy_n(values, n, result);
+ std::fill_n(result, n, T());
}
template <typename T> inline void Communicator::allGatherImpl(T *, int) const {}
template <typename T>
inline void Communicator::allGatherVImpl(T *, int *) const {}
template <typename T>
inline void Communicator::gatherImpl(T *, int, int) const {}
template <typename T>
void Communicator::gatherImpl(T * values, int nb_values, T * gathered,
int) const {
static_assert(std::is_trivially_copyable<T>{},
"Cannot send this type of data");
std::memcpy(gathered, values, nb_values);
}
template <typename T>
inline void Communicator::gatherVImpl(T *, int *, int) const {}
template <typename T>
inline void Communicator::broadcastImpl(T *, int, int) const {}
int Communicator::getMaxTag() const { return std::numeric_limits<int>::max(); }
int Communicator::getMinTag() const { return 0; }
} // namespace akantu
diff --git a/src/synchronizer/communicator_event_handler.hh b/src/synchronizer/communicator_event_handler.hh
index f740ed40e..c8a5c4f4d 100644
--- a/src/synchronizer/communicator_event_handler.hh
+++ b/src/synchronizer/communicator_event_handler.hh
@@ -1,61 +1,61 @@
/**
* @file communicator_event_handler.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 15 2017
*
* @brief Event handler of the communicator
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_COMMUNICATOR_EVENT_HANDLER_HH__
#define __AKANTU_COMMUNICATOR_EVENT_HANDLER_HH__
namespace akantu {
class Communicator;
struct FinalizeCommunicatorEvent {
explicit FinalizeCommunicatorEvent(const Communicator & comm)
: communicator(comm) {}
const Communicator & communicator;
};
class CommunicatorEventHandler {
public:
virtual ~CommunicatorEventHandler() = default;
virtual void onCommunicatorFinalize() = 0;
private:
inline void sendEvent(const FinalizeCommunicatorEvent &) {
this->onCommunicatorFinalize();
}
template <class EventHandler> friend class EventHandlerManager;
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_COMMUNICATOR_EVENT_HANDLER_HH__ */
diff --git a/src/synchronizer/communicator_mpi_inline_impl.cc b/src/synchronizer/communicator_mpi_inline_impl.cc
index 9ebc835e5..9680efdba 100644
--- a/src/synchronizer/communicator_mpi_inline_impl.cc
+++ b/src/synchronizer/communicator_mpi_inline_impl.cc
@@ -1,492 +1,495 @@
/**
* @file communicator_mpi_inline_impl.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Nov 07 2017
* @date last modification: Mon Dec 18 2017
*
* @brief StaticCommunicatorMPI implementation
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_iterators.hh"
#include "communicator.hh"
#include "mpi_communicator_data.hh"
/* -------------------------------------------------------------------------- */
#include <memory>
#include <type_traits>
#include <unordered_map>
#include <vector>
/* -------------------------------------------------------------------------- */
#include <mpi.h>
/* -------------------------------------------------------------------------- */
#if (defined(__GNUC__) || defined(__GNUG__))
#if AKA_GCC_VERSION < 60000
namespace std {
template <> struct hash<akantu::SynchronizerOperation> {
using argument_type = akantu::SynchronizerOperation;
size_t operator()(const argument_type & e) const noexcept {
auto ue = underlying_type_t<argument_type>(e);
return uh(ue);
}
private:
const hash<underlying_type_t<argument_type>> uh{};
};
} // namespace std
#endif
#endif
namespace akantu {
class CommunicationRequestMPI : public InternalCommunicationRequest {
public:
CommunicationRequestMPI(UInt source, UInt dest)
: InternalCommunicationRequest(source, dest),
request(std::make_unique<MPI_Request>()) {}
MPI_Request & getMPIRequest() { return *request; };
private:
std::unique_ptr<MPI_Request> request;
};
namespace {
template <typename T> inline MPI_Datatype getMPIDatatype();
MPI_Op getMPISynchronizerOperation(SynchronizerOperation op) {
std::unordered_map<SynchronizerOperation, MPI_Op> _operations{
{SynchronizerOperation::_sum, MPI_SUM},
{SynchronizerOperation::_min, MPI_MIN},
{SynchronizerOperation::_max, MPI_MAX},
{SynchronizerOperation::_prod, MPI_PROD},
{SynchronizerOperation::_land, MPI_LAND},
{SynchronizerOperation::_band, MPI_BAND},
{SynchronizerOperation::_lor, MPI_LOR},
{SynchronizerOperation::_bor, MPI_BOR},
{SynchronizerOperation::_lxor, MPI_LXOR},
{SynchronizerOperation::_bxor, MPI_BXOR},
{SynchronizerOperation::_min_loc, MPI_MINLOC},
{SynchronizerOperation::_max_loc, MPI_MAXLOC},
{SynchronizerOperation::_null, MPI_OP_NULL}};
return _operations[op];
}
template <typename T> MPI_Datatype inline getMPIDatatype() {
return MPI_DATATYPE_NULL;
}
#define SPECIALIZE_MPI_DATATYPE(type, mpi_type) \
template <> MPI_Datatype inline getMPIDatatype<type>() { return mpi_type; }
#define COMMA ,
SPECIALIZE_MPI_DATATYPE(char, MPI_CHAR)
SPECIALIZE_MPI_DATATYPE(std::uint8_t, MPI_UINT8_T)
SPECIALIZE_MPI_DATATYPE(float, MPI_FLOAT)
SPECIALIZE_MPI_DATATYPE(double, MPI_DOUBLE)
SPECIALIZE_MPI_DATATYPE(long double, MPI_LONG_DOUBLE)
SPECIALIZE_MPI_DATATYPE(signed int, MPI_INT)
SPECIALIZE_MPI_DATATYPE(unsigned int, MPI_UNSIGNED)
SPECIALIZE_MPI_DATATYPE(signed long int, MPI_LONG)
SPECIALIZE_MPI_DATATYPE(unsigned long int, MPI_UNSIGNED_LONG)
SPECIALIZE_MPI_DATATYPE(signed long long int, MPI_LONG_LONG)
SPECIALIZE_MPI_DATATYPE(unsigned long long int, MPI_UNSIGNED_LONG_LONG)
SPECIALIZE_MPI_DATATYPE(SCMinMaxLoc<double COMMA int>, MPI_DOUBLE_INT)
SPECIALIZE_MPI_DATATYPE(SCMinMaxLoc<float COMMA int>, MPI_FLOAT_INT)
SPECIALIZE_MPI_DATATYPE(bool, MPI_CXX_BOOL)
template <> MPI_Datatype inline getMPIDatatype<NodeFlag>() {
return getMPIDatatype<std::underlying_type_t<NodeFlag>>();
}
inline int getMPISource(int src) {
if (src == _any_source)
return MPI_ANY_SOURCE;
return src;
}
decltype(auto) convertRequests(std::vector<CommunicationRequest> & requests) {
std::vector<MPI_Request> mpi_requests(requests.size());
for (auto && request_pair : zip(requests, mpi_requests)) {
auto && req = std::get<0>(request_pair);
auto && mpi_req = std::get<1>(request_pair);
mpi_req = aka::as_type<CommunicationRequestMPI>(req.getInternal())
.getMPIRequest();
}
return mpi_requests;
}
} // namespace
// this is ugly but shorten the code a lot
#define MPIDATA \
(*reinterpret_cast<MPICommunicatorData *>(communicator_data.get()))
/* -------------------------------------------------------------------------- */
/* Implementation */
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
Communicator::Communicator(int & /*argc*/, char **& /*argv*/,
const private_member & /*unused*/)
: communicator_data(std::make_unique<MPICommunicatorData>()) {
prank = MPIDATA.rank();
psize = MPIDATA.size();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::sendImpl(const T * buffer, Int size, Int receiver, Int tag,
const CommunicationMode & mode) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
switch (mode) {
case CommunicationMode::_auto:
MPI_Send(buffer, size, type, receiver, tag, communicator);
break;
case CommunicationMode::_synchronous:
MPI_Ssend(buffer, size, type, receiver, tag, communicator);
break;
case CommunicationMode::_ready:
MPI_Rsend(buffer, size, type, receiver, tag, communicator);
break;
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::receiveImpl(T * buffer, Int size, Int sender,
Int tag) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Status status;
MPI_Datatype type = getMPIDatatype<T>();
MPI_Recv(buffer, size, type, getMPISource(sender), tag, communicator,
&status);
}
/* -------------------------------------------------------------------------- */
template <typename T>
CommunicationRequest
Communicator::asyncSendImpl(const T * buffer, Int size, Int receiver, Int tag,
const CommunicationMode & mode) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
auto * request = new CommunicationRequestMPI(prank, receiver);
MPI_Request & req = request->getMPIRequest();
MPI_Datatype type = getMPIDatatype<T>();
switch (mode) {
case CommunicationMode::_auto:
MPI_Isend(buffer, size, type, receiver, tag, communicator, &req);
break;
case CommunicationMode::_synchronous:
MPI_Issend(buffer, size, type, receiver, tag, communicator, &req);
break;
case CommunicationMode::_ready:
MPI_Irsend(buffer, size, type, receiver, tag, communicator, &req);
break;
}
return std::shared_ptr<InternalCommunicationRequest>(request);
}
/* -------------------------------------------------------------------------- */
template <typename T>
CommunicationRequest Communicator::asyncReceiveImpl(T * buffer, Int size,
Int sender, Int tag) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
auto * request = new CommunicationRequestMPI(sender, prank);
MPI_Datatype type = getMPIDatatype<T>();
MPI_Request & req = request->getMPIRequest();
MPI_Irecv(buffer, size, type, getMPISource(sender), tag, communicator, &req);
return std::shared_ptr<InternalCommunicationRequest>(request);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::probe(Int sender, Int tag,
CommunicationStatus & status) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Status mpi_status;
MPI_Probe(getMPISource(sender), tag, communicator, &mpi_status);
MPI_Datatype type = getMPIDatatype<T>();
int count;
MPI_Get_count(&mpi_status, type, &count);
status.setSource(mpi_status.MPI_SOURCE);
status.setTag(mpi_status.MPI_TAG);
status.setSize(count);
}
/* -------------------------------------------------------------------------- */
template <typename T>
bool Communicator::asyncProbe(Int sender, Int tag,
CommunicationStatus & status) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Status mpi_status;
int test;
MPI_Iprobe(getMPISource(sender), tag, communicator, &test, &mpi_status);
if (not test)
return false;
MPI_Datatype type = getMPIDatatype<T>();
int count;
MPI_Get_count(&mpi_status, type, &count);
status.setSource(mpi_status.MPI_SOURCE);
status.setTag(mpi_status.MPI_TAG);
status.setSize(count);
return true;
}
/* -------------------------------------------------------------------------- */
bool Communicator::test(CommunicationRequest & request) const {
MPI_Status status;
int flag;
- auto & req_mpi =
- aka::as_type<CommunicationRequestMPI>(request.getInternal());
+ auto & req_mpi = aka::as_type<CommunicationRequestMPI>(request.getInternal());
MPI_Request & req = req_mpi.getMPIRequest();
MPI_Test(&req, &flag, &status);
return flag;
}
/* -------------------------------------------------------------------------- */
bool Communicator::testAll(std::vector<CommunicationRequest> & requests) const {
- //int are_finished;
- //auto && mpi_requests = convertRequests(requests);
- //MPI_Testall(mpi_requests.size(), mpi_requests.data(), &are_finished,
+ // int are_finished;
+ // auto && mpi_requests = convertRequests(requests);
+ // MPI_Testall(mpi_requests.size(), mpi_requests.data(), &are_finished,
// MPI_STATUSES_IGNORE);
- //return are_finished;
- for(auto & request : requests) {
- if(not test(request)) return false;
+ // return are_finished;
+ for (auto & request : requests) {
+ if (not test(request))
+ return false;
}
return true;
}
/* -------------------------------------------------------------------------- */
void Communicator::wait(CommunicationRequest & request) const {
MPI_Status status;
- auto & req_mpi =
- aka::as_type<CommunicationRequestMPI>(request.getInternal());
+ auto & req_mpi = aka::as_type<CommunicationRequestMPI>(request.getInternal());
MPI_Request & req = req_mpi.getMPIRequest();
MPI_Wait(&req, &status);
}
/* -------------------------------------------------------------------------- */
void Communicator::waitAll(std::vector<CommunicationRequest> & requests) const {
auto && mpi_requests = convertRequests(requests);
MPI_Waitall(mpi_requests.size(), mpi_requests.data(), MPI_STATUSES_IGNORE);
}
/* -------------------------------------------------------------------------- */
UInt Communicator::waitAny(std::vector<CommunicationRequest> & requests) const {
auto && mpi_requests = convertRequests(requests);
int pos;
MPI_Waitany(mpi_requests.size(), mpi_requests.data(), &pos,
MPI_STATUSES_IGNORE);
if (pos != MPI_UNDEFINED) {
return pos;
} else {
return UInt(-1);
}
}
/* -------------------------------------------------------------------------- */
void Communicator::barrier() const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Barrier(communicator);
}
/* -------------------------------------------------------------------------- */
CommunicationRequest Communicator::asyncBarrier() const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
auto * request = new CommunicationRequestMPI(0, 0);
MPI_Request & req = request->getMPIRequest();
MPI_Ibarrier(communicator, &req);
return std::shared_ptr<InternalCommunicationRequest>(request);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::reduceImpl(T * values, int nb_values,
SynchronizerOperation op, int root) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
MPI_Reduce(MPI_IN_PLACE, values, nb_values, type,
getMPISynchronizerOperation(op), root, communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::allReduceImpl(T * values, int nb_values,
SynchronizerOperation op) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
MPI_Allreduce(MPI_IN_PLACE, values, nb_values, type,
getMPISynchronizerOperation(op), communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::scanImpl(T * values, T * result, int nb_values,
SynchronizerOperation op) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
- if(values == result) {
- values = reinterpret_cast<T*>(MPI_IN_PLACE);
+ if (values == result) {
+ values = reinterpret_cast<T *>(MPI_IN_PLACE);
}
-
- MPI_Scan(values, result, nb_values, type,
- getMPISynchronizerOperation(op), communicator);
+
+ MPI_Scan(values, result, nb_values, type, getMPISynchronizerOperation(op),
+ communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::exclusiveScanImpl(T * values, T * result, int nb_values,
SynchronizerOperation op) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
- if(values == result) {
- values = reinterpret_cast<T*>(MPI_IN_PLACE);
+ if (values == result) {
+ values = reinterpret_cast<T *>(MPI_IN_PLACE);
+ }
+
+ MPI_Exscan(values, result, nb_values, type, getMPISynchronizerOperation(op),
+ communicator);
+
+ if (prank == 0) {
+ result[0] = T();
}
-
- MPI_Exscan(values, result, nb_values, type,
- getMPISynchronizerOperation(op), communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::allGatherImpl(T * values, int nb_values) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
MPI_Allgather(MPI_IN_PLACE, nb_values, type, values, nb_values, type,
communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::allGatherVImpl(T * values, int * nb_values) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
std::vector<int> displs(psize);
displs[0] = 0;
for (int i = 1; i < psize; ++i) {
displs[i] = displs[i - 1] + nb_values[i - 1];
}
MPI_Datatype type = getMPIDatatype<T>();
MPI_Allgatherv(MPI_IN_PLACE, *nb_values, type, values, nb_values,
displs.data(), type, communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::gatherImpl(T * values, int nb_values, int root) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
T *send_buf = nullptr, *recv_buf = nullptr;
if (prank == root) {
send_buf = (T *)MPI_IN_PLACE;
recv_buf = values;
} else {
send_buf = values;
}
MPI_Datatype type = getMPIDatatype<T>();
MPI_Gather(send_buf, nb_values, type, recv_buf, nb_values, type, root,
communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::gatherImpl(T * values, int nb_values, T * gathered,
int nb_gathered) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
T * send_buf = values;
T * recv_buf = gathered;
if (nb_gathered == 0)
nb_gathered = nb_values;
MPI_Datatype type = getMPIDatatype<T>();
MPI_Gather(send_buf, nb_values, type, recv_buf, nb_gathered, type,
this->prank, communicator);
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::gatherVImpl(T * values, int * nb_values, int root) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
int * displs = nullptr;
if (prank == root) {
displs = new int[psize];
displs[0] = 0;
for (int i = 1; i < psize; ++i) {
displs[i] = displs[i - 1] + nb_values[i - 1];
}
}
T *send_buf = nullptr, *recv_buf = nullptr;
if (prank == root) {
send_buf = (T *)MPI_IN_PLACE;
recv_buf = values;
} else
send_buf = values;
MPI_Datatype type = getMPIDatatype<T>();
MPI_Gatherv(send_buf, *nb_values, type, recv_buf, nb_values, displs, type,
root, communicator);
if (prank == root) {
delete[] displs;
}
}
/* -------------------------------------------------------------------------- */
template <typename T>
void Communicator::broadcastImpl(T * values, int nb_values, int root) const {
MPI_Comm communicator = MPIDATA.getMPICommunicator();
MPI_Datatype type = getMPIDatatype<T>();
MPI_Bcast(values, nb_values, type, root, communicator);
}
/* -------------------------------------------------------------------------- */
int Communicator::getMaxTag() const { return MPIDATA.getMaxTag(); }
int Communicator::getMinTag() const { return 0; }
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/synchronizer/data_accessor.cc b/src/synchronizer/data_accessor.cc
index e80b72ce3..2ea3d3882 100644
--- a/src/synchronizer/data_accessor.cc
+++ b/src/synchronizer/data_accessor.cc
@@ -1,154 +1,154 @@
/**
* @file data_accessor.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Tue Feb 20 2018
*
* @brief data accessors constructor functions
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "data_accessor.hh"
#include "fe_engine.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T, bool pack_helper>
void DataAccessor<Element>::packUnpackNodalDataHelper(
Array<T> & data, CommunicationBuffer & buffer,
const Array<Element> & elements, const Mesh & mesh) {
UInt nb_component = data.getNbComponent();
UInt nb_nodes_per_element = 0;
ElementType current_element_type = _not_defined;
GhostType current_ghost_type = _casper;
UInt * conn = nullptr;
for (auto & el : elements) {
if (el.type != current_element_type ||
el.ghost_type != current_ghost_type) {
current_element_type = el.type;
current_ghost_type = el.ghost_type;
conn = mesh.getConnectivity(el.type, el.ghost_type).storage();
nb_nodes_per_element = Mesh::getNbNodesPerElement(el.type);
}
UInt el_offset = el.element * nb_nodes_per_element;
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
UInt offset_conn = conn[el_offset + n];
Vector<T> data_vect(data.storage() + offset_conn * nb_component,
nb_component);
if (pack_helper)
buffer << data_vect;
else
buffer >> data_vect;
}
}
}
/* ------------------------------------------------------------------------ */
template <typename T, bool pack_helper>
void DataAccessor<Element>::packUnpackElementalDataHelper(
ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer,
const Array<Element> & element, bool per_quadrature_point_data,
const FEEngine & fem) {
ElementType current_element_type = _not_defined;
GhostType current_ghost_type = _casper;
UInt nb_quad_per_elem = 0;
UInt nb_component = 0;
Array<T> * vect = nullptr;
for (auto & el : element) {
if (el.type != current_element_type ||
el.ghost_type != current_ghost_type) {
current_element_type = el.type;
current_ghost_type = el.ghost_type;
vect = &data_to_pack(el.type, el.ghost_type);
nb_quad_per_elem =
per_quadrature_point_data
? fem.getNbIntegrationPoints(el.type, el.ghost_type)
: 1;
nb_component = vect->getNbComponent();
}
Vector<T> data(vect->storage() +
el.element * nb_component * nb_quad_per_elem,
nb_component * nb_quad_per_elem);
if (pack_helper)
buffer << data;
else
buffer >> data;
}
}
/* -------------------------------------------------------------------------- */
template <typename T, bool pack_helper>
void DataAccessor<UInt>::packUnpackDOFDataHelper(Array<T> & data,
CommunicationBuffer & buffer,
const Array<UInt> & dofs) {
T * data_ptr = data.storage();
for (const auto & dof : dofs) {
if (pack_helper)
buffer << data_ptr[dof];
else
buffer >> data_ptr[dof];
}
}
/* -------------------------------------------------------------------------- */
#define DECLARE_HELPERS(T) \
template void DataAccessor<Element>::packUnpackNodalDataHelper<T, false>( \
Array<T> & data, CommunicationBuffer & buffer, \
const Array<Element> & elements, const Mesh & mesh); \
template void DataAccessor<Element>::packUnpackNodalDataHelper<T, true>( \
Array<T> & data, CommunicationBuffer & buffer, \
const Array<Element> & elements, const Mesh & mesh); \
template void \
DataAccessor<Element>::packUnpackElementalDataHelper<T, false>( \
ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer, \
const Array<Element> & element, bool per_quadrature_point_data, \
const FEEngine & fem); \
template void DataAccessor<Element>::packUnpackElementalDataHelper<T, true>( \
ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer, \
const Array<Element> & element, bool per_quadrature_point_data, \
const FEEngine & fem); \
template void DataAccessor<UInt>::packUnpackDOFDataHelper<T, true>( \
Array<T> & data, CommunicationBuffer & buffer, \
const Array<UInt> & dofs); \
template void DataAccessor<UInt>::packUnpackDOFDataHelper<T, false>( \
Array<T> & data, CommunicationBuffer & buffer, const Array<UInt> & dofs)
/* -------------------------------------------------------------------------- */
DECLARE_HELPERS(Real);
DECLARE_HELPERS(UInt);
DECLARE_HELPERS(bool);
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
diff --git a/src/synchronizer/data_accessor.hh b/src/synchronizer/data_accessor.hh
index 6f2fd7377..3f09ad3ed 100644
--- a/src/synchronizer/data_accessor.hh
+++ b/src/synchronizer/data_accessor.hh
@@ -1,278 +1,278 @@
/**
* @file data_accessor.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 01 2010
* @date last modification: Sun Feb 04 2018
*
* @brief Interface of accessors for pack_unpack system
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "communication_buffer.hh"
#include "element.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DATA_ACCESSOR_HH__
#define __AKANTU_DATA_ACCESSOR_HH__
namespace akantu {
class FEEngine;
-} // akantu
+} // namespace akantu
namespace akantu {
class DataAccessorBase {
public:
DataAccessorBase() = default;
virtual ~DataAccessorBase() = default;
};
template <class T> class DataAccessor : public virtual DataAccessorBase {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DataAccessor() = default;
~DataAccessor() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/**
* @brief get the number of data to exchange for a given array of T
* (elements or dofs) and a given akantu::SynchronizationTag
*/
virtual UInt getNbData(const Array<T> & elements,
const SynchronizationTag & tag) const = 0;
/**
* @brief pack the data for a given array of T (elements or dofs) and a given
* akantu::SynchronizationTag
*/
virtual void packData(CommunicationBuffer & buffer, const Array<T> & element,
const SynchronizationTag & tag) const = 0;
/**
* @brief unpack the data for a given array of T (elements or dofs) and a
* given akantu::SynchronizationTag
*/
virtual void unpackData(CommunicationBuffer & buffer,
const Array<T> & element,
const SynchronizationTag & tag) = 0;
};
/* -------------------------------------------------------------------------- */
/* Specialization */
/* -------------------------------------------------------------------------- */
template <> class DataAccessor<Element> : public virtual DataAccessorBase {
public:
DataAccessor() = default;
~DataAccessor() override = default;
virtual UInt getNbData(const Array<Element> & elements,
const SynchronizationTag & tag) const = 0;
virtual void packData(CommunicationBuffer & buffer,
const Array<Element> & element,
const SynchronizationTag & tag) const = 0;
virtual void unpackData(CommunicationBuffer & buffer,
const Array<Element> & element,
const SynchronizationTag & tag) = 0;
/* ------------------------------------------------------------------------ */
public:
template <typename T, bool pack_helper>
static void
packUnpackNodalDataHelper(Array<T> & data, CommunicationBuffer & buffer,
const Array<Element> & elements, const Mesh & mesh);
/* ------------------------------------------------------------------------ */
template <typename T, bool pack_helper>
static void packUnpackElementalDataHelper(
ElementTypeMapArray<T> & data_to_pack, CommunicationBuffer & buffer,
const Array<Element> & element, bool per_quadrature_point_data,
const FEEngine & fem);
/* ------------------------------------------------------------------------ */
template <typename T>
static void
packNodalDataHelper(const Array<T> & data, CommunicationBuffer & buffer,
const Array<Element> & elements, const Mesh & mesh) {
packUnpackNodalDataHelper<T, true>(const_cast<Array<T> &>(data), buffer,
elements, mesh);
}
template <typename T>
static inline void
unpackNodalDataHelper(Array<T> & data, CommunicationBuffer & buffer,
const Array<Element> & elements, const Mesh & mesh) {
packUnpackNodalDataHelper<T, false>(data, buffer, elements, mesh);
}
/* ------------------------------------------------------------------------ */
template <typename T>
static inline void
packElementalDataHelper(const ElementTypeMapArray<T> & data_to_pack,
CommunicationBuffer & buffer,
const Array<Element> & elements,
bool per_quadrature_point, const FEEngine & fem) {
packUnpackElementalDataHelper<T, true>(
const_cast<ElementTypeMapArray<T> &>(data_to_pack), buffer, elements,
per_quadrature_point, fem);
}
template <typename T>
static inline void
unpackElementalDataHelper(ElementTypeMapArray<T> & data_to_unpack,
CommunicationBuffer & buffer,
const Array<Element> & elements,
bool per_quadrature_point, const FEEngine & fem) {
packUnpackElementalDataHelper<T, false>(data_to_unpack, buffer, elements,
per_quadrature_point, fem);
}
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <> class DataAccessor<UInt> : public virtual DataAccessorBase {
public:
DataAccessor() = default;
~DataAccessor() override = default;
virtual UInt getNbData(const Array<UInt> & elements,
const SynchronizationTag & tag) const = 0;
virtual void packData(CommunicationBuffer & buffer,
const Array<UInt> & element,
const SynchronizationTag & tag) const = 0;
virtual void unpackData(CommunicationBuffer & buffer,
const Array<UInt> & element,
const SynchronizationTag & tag) = 0;
/* ------------------------------------------------------------------------ */
public:
template <typename T, bool pack_helper>
static void packUnpackDOFDataHelper(Array<T> & data,
CommunicationBuffer & buffer,
const Array<UInt> & dofs);
template <typename T>
static inline void packDOFDataHelper(const Array<T> & data_to_pack,
CommunicationBuffer & buffer,
const Array<UInt> & dofs) {
packUnpackDOFDataHelper<T, true>(const_cast<Array<T> &>(data_to_pack),
buffer, dofs);
}
template <typename T>
static inline void unpackDOFDataHelper(Array<T> & data_to_unpack,
CommunicationBuffer & buffer,
const Array<UInt> & dofs) {
packUnpackDOFDataHelper<T, false>(data_to_unpack, buffer, dofs);
}
};
/* -------------------------------------------------------------------------- */
template <typename T> class AddOperation {
public:
inline T operator()(T & a, T & b) { return a + b; };
};
template <typename T> class IdentityOperation {
public:
inline T & operator()(T &, T & b) { return b; };
};
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <class Entity, template <class> class Op, class T>
class ReduceDataAccessor : public virtual DataAccessor<Entity> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
ReduceDataAccessor(Array<T> & data, const SynchronizationTag & tag)
: data(data), tag(tag) {}
~ReduceDataAccessor() override = default;
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/* ------------------------------------------------------------------------ */
UInt getNbData(const Array<Entity> & entities,
const SynchronizationTag & tag) const override {
if (tag != this->tag)
return 0;
Vector<T> tmp(data.getNbComponent());
return entities.size() * CommunicationBuffer::sizeInBuffer(tmp);
}
/* ------------------------------------------------------------------------ */
void packData(CommunicationBuffer & buffer, const Array<Entity> & entities,
const SynchronizationTag & tag) const override {
if (tag != this->tag)
return;
auto data_it = data.begin(data.getNbComponent());
for (auto el : entities) {
buffer << Vector<T>(data_it[el]);
}
}
/* ------------------------------------------------------------------------ */
void unpackData(CommunicationBuffer & buffer, const Array<Entity> & entities,
const SynchronizationTag & tag) override {
if (tag != this->tag)
return;
auto data_it = data.begin(data.getNbComponent());
for (auto el : entities) {
Vector<T> unpacked(data.getNbComponent());
Vector<T> vect(data_it[el]);
buffer >> unpacked;
vect = oper(vect, unpacked);
}
}
protected:
/// data to (un)pack
Array<T> & data;
/// Tag to consider
SynchronizationTag tag;
/// reduction operator
Op<Vector<T>> oper;
};
/* -------------------------------------------------------------------------- */
template <class T>
using SimpleUIntDataAccessor = ReduceDataAccessor<UInt, IdentityOperation, T>;
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DATA_ACCESSOR_HH__ */
diff --git a/src/synchronizer/dof_synchronizer.cc b/src/synchronizer/dof_synchronizer.cc
index c0f3dbb38..aec54d44a 100644
--- a/src/synchronizer/dof_synchronizer.cc
+++ b/src/synchronizer/dof_synchronizer.cc
@@ -1,282 +1,283 @@
/**
* @file dof_synchronizer.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 17 2011
* @date last modification: Tue Feb 06 2018
*
* @brief DOF synchronizing object implementation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_synchronizer.hh"
#include "aka_iterators.hh"
#include "dof_manager_default.hh"
#include "mesh.hh"
#include "node_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
/**
* A DOFSynchronizer needs a mesh and the number of degrees of freedom
* per node to be created. In the constructor computes the local and global dof
* number for each dof. The member
* proc_informations (std vector) is resized with the number of mpi
* processes. Each entry in the vector is a PerProcInformations object
* that contains the interactions of the current mpi process (prank) with the
* mpi process corresponding to the position of that entry. Every
* ProcInformations object contains one array with the dofs that have
* to be sent to prank and a second one with dofs that willl be received form
* prank.
* This information is needed for the asychronous communications. The
* constructor sets up this information.
*/
DOFSynchronizer::DOFSynchronizer(DOFManagerDefault & dof_manager, const ID & id,
MemoryID memory_id)
: SynchronizerImpl<UInt>(dof_manager.getCommunicator(), id, memory_id),
root(0), dof_manager(dof_manager),
root_dofs(0, 1, "dofs-to-receive-from-master"), dof_changed(true) {
std::vector<ID> dof_ids = dof_manager.getDOFIDs();
// Transfers nodes to global equation numbers in new schemes
for (const ID & dof_id : dof_ids) {
registerDOFs(dof_id);
}
this->initScatterGatherCommunicationScheme();
}
/* -------------------------------------------------------------------------- */
DOFSynchronizer::~DOFSynchronizer() = default;
/* -------------------------------------------------------------------------- */
void DOFSynchronizer::registerDOFs(const ID & dof_id) {
if (this->nb_proc == 1)
return;
if (dof_manager.getSupportType(dof_id) != _dst_nodal)
return;
const auto & equation_numbers = dof_manager.getLocalEquationsNumbers(dof_id);
const auto & associated_nodes = dof_manager.getDOFsAssociatedNodes(dof_id);
const auto & node_synchronizer = dof_manager.getMesh().getNodeSynchronizer();
const auto & node_communications = node_synchronizer.getCommunications();
auto transcode_node_to_global_dof_scheme =
- [this, &associated_nodes,
- &equation_numbers](auto && it, auto && end,
- const CommunicationSendRecv & sr) -> void {
+ [this, &associated_nodes, &equation_numbers](
+ auto && it, auto && end, const CommunicationSendRecv & sr) -> void {
for (; it != end; ++it) {
auto & scheme = communications.createScheme(it->first, sr);
const auto & node_scheme = it->second;
for (auto & node : node_scheme) {
auto an_begin = associated_nodes.begin();
auto an_it = an_begin;
auto an_end = associated_nodes.end();
std::vector<UInt> global_dofs_per_node;
while ((an_it = std::find(an_it, an_end, node)) != an_end) {
UInt pos = an_it - an_begin;
UInt local_eq_num = equation_numbers(pos);
UInt global_eq_num =
dof_manager.localToGlobalEquationNumber(local_eq_num);
global_dofs_per_node.push_back(global_eq_num);
++an_it;
}
std::sort(global_dofs_per_node.begin(), global_dofs_per_node.end());
std::transform(global_dofs_per_node.begin(), global_dofs_per_node.end(),
global_dofs_per_node.begin(), [this](UInt g) -> UInt {
UInt l = dof_manager.globalToLocalEquationNumber(g);
return l;
});
for (auto & leqnum : global_dofs_per_node) {
scheme.push_back(leqnum);
}
}
}
};
for (auto sr_it = send_recv_t::begin(); sr_it != send_recv_t::end();
++sr_it) {
auto ncs_it = node_communications.begin_scheme(*sr_it);
auto ncs_end = node_communications.end_scheme(*sr_it);
transcode_node_to_global_dof_scheme(ncs_it, ncs_end, *sr_it);
}
dof_changed = true;
}
/* -------------------------------------------------------------------------- */
void DOFSynchronizer::initScatterGatherCommunicationScheme() {
AKANTU_DEBUG_IN();
if (this->nb_proc == 1) {
dof_changed = false;
AKANTU_DEBUG_OUT();
return;
}
UInt nb_dofs = dof_manager.getLocalSystemSize();
this->root_dofs.clear();
this->master_receive_dofs.clear();
Array<UInt> dofs_to_send;
for (UInt n = 0; n < nb_dofs; ++n) {
if (dof_manager.isLocalOrMasterDOF(n)) {
auto & receive_per_proc = master_receive_dofs[this->root];
UInt global_dof = dof_manager.localToGlobalEquationNumber(n);
root_dofs.push_back(n);
receive_per_proc.push_back(global_dof);
dofs_to_send.push_back(global_dof);
}
}
if (this->rank == UInt(this->root)) {
Array<UInt> nb_dof_per_proc(this->nb_proc);
communicator.gather(dofs_to_send.size(), nb_dof_per_proc);
std::vector<CommunicationRequest> requests;
for (UInt p = 0; p < nb_proc; ++p) {
if (p == UInt(this->root))
continue;
auto & receive_per_proc = master_receive_dofs[p];
receive_per_proc.resize(nb_dof_per_proc(p));
if (nb_dof_per_proc(p) != 0)
requests.push_back(communicator.asyncReceive(
receive_per_proc, p,
Tag::genTag(p, 0, Tag::_GATHER_INITIALIZATION, this->hash_id)));
}
communicator.waitAll(requests);
communicator.freeCommunicationRequest(requests);
} else {
communicator.gather(dofs_to_send.size(), this->root);
- AKANTU_DEBUG(dblDebug,
- "I have " << nb_dofs << " dofs (" << dofs_to_send.size()
- << " to send to master proc");
+ AKANTU_DEBUG(dblDebug, "I have " << nb_dofs << " dofs ("
+ << dofs_to_send.size()
+ << " to send to master proc");
if (dofs_to_send.size() != 0)
communicator.send(dofs_to_send, this->root,
Tag::genTag(this->rank, 0, Tag::_GATHER_INITIALIZATION,
this->hash_id));
}
dof_changed = false;
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
bool DOFSynchronizer::hasChanged() {
communicator.allReduce(dof_changed, SynchronizerOperation::_lor);
return dof_changed;
}
/* -------------------------------------------------------------------------- */
void DOFSynchronizer::onNodesAdded(const Array<UInt> & /*nodes_list*/) {
auto dof_ids = dof_manager.getDOFIDs();
for (auto sr : iterate_send_recv) {
for (auto && data : communications.iterateSchemes(sr)) {
auto & scheme = data.second;
scheme.resize(0);
}
}
- for(auto & dof_id : dof_ids) {
+ for (auto & dof_id : dof_ids) {
registerDOFs(dof_id);
}
- // const auto & node_synchronizer = dof_manager.getMesh().getNodeSynchronizer();
- // const auto & node_communications = node_synchronizer.getCommunications();
+ // const auto & node_synchronizer =
+ // dof_manager.getMesh().getNodeSynchronizer(); const auto &
+ // node_communications = node_synchronizer.getCommunications();
// std::map<UInt, std::vector<UInt>> nodes_per_proc[2];
// for (auto sr : iterate_send_recv) {
// for (auto && data : node_communications.iterateSchemes(sr)) {
// auto proc = data.first;
// const auto & scheme = data.second;
// for (auto node : scheme) {
// nodes_per_proc[sr][proc].push_back(node);
// }
// }
// }
// std::map<UInt, std::vector<UInt>> dofs_per_proc[2];
// for (auto & dof_id : dof_ids) {
- // const auto & associated_nodes = dof_manager.getDOFsAssociatedNodes(dof_id);
- // const auto & local_equation_numbers =
+ // const auto & associated_nodes =
+ // dof_manager.getDOFsAssociatedNodes(dof_id); const auto &
+ // local_equation_numbers =
// dof_manager.getEquationsNumbers(dof_id);
// for (auto tuple : zip(associated_nodes, local_equation_numbers)) {
// UInt assoc_node;
// UInt local_eq_num;
// std::tie(assoc_node, local_eq_num) = tuple;
// for (auto sr_it = send_recv_t::begin(); sr_it != send_recv_t::end();
// ++sr_it) {
// for (auto & pair : nodes_per_proc[*sr_it]) {
// if (std::find(pair.second.end(), pair.second.end(), assoc_node) !=
// pair.second.end()) {
// dofs_per_proc[*sr_it][pair.first].push_back(local_eq_num);
// }
// }
// }
// }
// }
// for (auto sr_it = send_recv_t::begin(); sr_it != send_recv_t::end();
// ++sr_it) {
// for (auto & pair : dofs_per_proc[*sr_it]) {
// std::sort(pair.second.begin(), pair.second.end(),
// [this](UInt la, UInt lb) -> bool {
// UInt ga = dof_manager.localToGlobalEquationNumber(la);
// UInt gb = dof_manager.localToGlobalEquationNumber(lb);
// return ga < gb;
// });
// auto & scheme = communications.getScheme(pair.first, *sr_it);
// scheme.resize(0);
// for (auto leq : pair.second) {
// scheme.push_back(leq);
// }
// }
// }
dof_changed = true;
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/synchronizer/dof_synchronizer.hh b/src/synchronizer/dof_synchronizer.hh
index c7226fce9..3bcb5ad9b 100644
--- a/src/synchronizer/dof_synchronizer.hh
+++ b/src/synchronizer/dof_synchronizer.hh
@@ -1,112 +1,112 @@
/**
* @file dof_synchronizer.hh
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 17 2011
* @date last modification: Tue Feb 20 2018
*
* @brief Synchronize Array of DOFs
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "aka_common.hh"
#include "synchronizer_impl.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
class Mesh;
class DOFManagerDefault;
-}
+} // namespace akantu
#ifndef __AKANTU_DOF_SYNCHRONIZER_HH__
#define __AKANTU_DOF_SYNCHRONIZER_HH__
namespace akantu {
class DOFSynchronizer : public SynchronizerImpl<UInt> {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
DOFSynchronizer(DOFManagerDefault & dof_manager,
const ID & id = "dof_synchronizer", MemoryID memory_id = 0);
~DOFSynchronizer() override;
virtual void registerDOFs(const ID & dof_id);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
template <typename T>
/// Gather the DOF value on the root proccessor
void gather(const Array<T> & to_gather, Array<T> & gathered);
/// Gather the DOF value on the root proccessor
template <typename T> void gather(const Array<T> & to_gather);
/// Scatter a DOF Array form root to all processors
template <typename T>
void scatter(Array<T> & scattered, const Array<T> & to_scatter);
/// Scatter a DOF Array form root to all processors
template <typename T> void scatter(Array<T> & scattered);
/// Uses the synchronizer to perform a reduction on the vector
template <template <class> class Op, typename T>
void reduceSynchronize(Array<T> & array) const;
template <typename T> void synchronize(Array<T> & vector) const;
void onNodesAdded(const Array<UInt> & nodes);
protected:
/// check if dof changed set on at least one processor
bool hasChanged();
/// init the scheme for scatter and gather operation, need extra memory
void initScatterGatherCommunicationScheme();
Int getRank(const UInt & /*node*/) const final { AKANTU_TO_IMPLEMENT(); }
private:
/// Root processor for scatter/gather operations
Int root;
/// information on the dofs
DOFManagerDefault & dof_manager;
/// dofs from root
Array<UInt> root_dofs;
/// Dofs received from slaves proc (only on master)
std::map<UInt, Array<UInt>> master_receive_dofs;
bool dof_changed;
};
-} // akantu
+} // namespace akantu
#include "dof_synchronizer_inline_impl.cc"
#endif /* __AKANTU_DOF_SYNCHRONIZER_HH__ */
diff --git a/src/synchronizer/dof_synchronizer_inline_impl.cc b/src/synchronizer/dof_synchronizer_inline_impl.cc
index a472ea192..f37d5f6b7 100644
--- a/src/synchronizer/dof_synchronizer_inline_impl.cc
+++ b/src/synchronizer/dof_synchronizer_inline_impl.cc
@@ -1,289 +1,290 @@
/**
* @file dof_synchronizer_inline_impl.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 17 2011
* @date last modification: Wed Nov 08 2017
*
* @brief DOFSynchronizer inline implementation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communication_buffer.hh"
#include "data_accessor.hh"
#include "dof_manager_default.hh"
#include "dof_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_DOF_SYNCHRONIZER_INLINE_IMPL_CC__
#define __AKANTU_DOF_SYNCHRONIZER_INLINE_IMPL_CC__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T>
void DOFSynchronizer::gather(const Array<T> & to_gather, Array<T> & gathered) {
if (this->hasChanged())
initScatterGatherCommunicationScheme();
AKANTU_DEBUG_ASSERT(this->rank == UInt(this->root),
"This function cannot be called on a slave processor");
AKANTU_DEBUG_ASSERT(to_gather.size() ==
this->dof_manager.getLocalSystemSize(),
"The array to gather does not have the correct size");
AKANTU_DEBUG_ASSERT(gathered.size() == this->dof_manager.getSystemSize(),
"The gathered array does not have the correct size");
if (this->nb_proc == 1) {
gathered.copy(to_gather, true);
AKANTU_DEBUG_OUT();
return;
}
std::map<UInt, CommunicationBuffer> buffers;
std::vector<CommunicationRequest> requests;
for (UInt p = 0; p < this->nb_proc; ++p) {
if (p == UInt(this->root))
continue;
auto receive_it = this->master_receive_dofs.find(p);
AKANTU_DEBUG_ASSERT(receive_it != this->master_receive_dofs.end(),
"Could not find the receive list for dofs of proc "
<< p);
const Array<UInt> & receive_dofs = receive_it->second;
if (receive_dofs.size() == 0)
continue;
CommunicationBuffer & buffer = buffers[p];
buffer.resize(receive_dofs.size() * to_gather.getNbComponent() * sizeof(T));
AKANTU_DEBUG_INFO(
"Preparing to receive data for "
<< receive_dofs.size() << " dofs from processor " << p << " "
<< Tag::genTag(p, this->root, Tag::_GATHER, this->hash_id));
requests.push_back(communicator.asyncReceive(
buffer, p, Tag::genTag(p, this->root, Tag::_GATHER, this->hash_id)));
}
auto data_gathered_it = gathered.begin(to_gather.getNbComponent());
{ // copy master data
auto data_to_gather_it = to_gather.begin(to_gather.getNbComponent());
for (auto local_dof : root_dofs) {
UInt global_dof = dof_manager.localToGlobalEquationNumber(local_dof);
Vector<T> dof_data_gathered = data_gathered_it[global_dof];
Vector<T> dof_data_to_gather = data_to_gather_it[local_dof];
dof_data_gathered = dof_data_to_gather;
}
}
auto rr = UInt(-1);
while ((rr = communicator.waitAny(requests)) != UInt(-1)) {
CommunicationRequest & request = requests[rr];
UInt sender = request.getSource();
AKANTU_DEBUG_ASSERT(this->master_receive_dofs.find(sender) !=
this->master_receive_dofs.end() &&
buffers.find(sender) != buffers.end(),
"Missing infos concerning proc " << sender);
const Array<UInt> & receive_dofs =
this->master_receive_dofs.find(sender)->second;
CommunicationBuffer & buffer = buffers[sender];
for (auto global_dof : receive_dofs) {
Vector<T> dof_data = data_gathered_it[global_dof];
buffer >> dof_data;
}
requests.erase(requests.begin() + rr);
}
}
/* -------------------------------------------------------------------------- */
template <typename T> void DOFSynchronizer::gather(const Array<T> & to_gather) {
AKANTU_DEBUG_IN();
if (this->hasChanged())
initScatterGatherCommunicationScheme();
AKANTU_DEBUG_ASSERT(this->rank != UInt(this->root),
"This function cannot be called on the root processor");
AKANTU_DEBUG_ASSERT(to_gather.size() ==
this->dof_manager.getLocalSystemSize(),
"The array to gather does not have the correct size");
if (this->root_dofs.size() == 0) {
AKANTU_DEBUG_OUT();
return;
}
CommunicationBuffer buffer(this->root_dofs.size() *
to_gather.getNbComponent() * sizeof(T));
auto data_it = to_gather.begin(to_gather.getNbComponent());
for (auto dof : this->root_dofs) {
Vector<T> data = data_it[dof];
buffer << data;
}
AKANTU_DEBUG_INFO("Gathering data for "
<< to_gather.size() << " dofs on processor " << this->root
<< " "
<< Tag::genTag(this->rank, 0, Tag::_GATHER, this->hash_id));
communicator.send(buffer, this->root,
Tag::genTag(this->rank, 0, Tag::_GATHER, this->hash_id));
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void DOFSynchronizer::scatter(Array<T> & scattered,
const Array<T> & to_scatter) {
AKANTU_DEBUG_IN();
if (this->hasChanged())
initScatterGatherCommunicationScheme();
AKANTU_DEBUG_ASSERT(this->rank == UInt(this->root),
"This function cannot be called on a slave processor");
AKANTU_DEBUG_ASSERT(scattered.size() ==
this->dof_manager.getLocalSystemSize(),
"The scattered array does not have the correct size");
AKANTU_DEBUG_ASSERT(to_scatter.size() == this->dof_manager.getSystemSize(),
"The array to scatter does not have the correct size");
if (this->nb_proc == 1) {
scattered.copy(to_scatter, true);
AKANTU_DEBUG_OUT();
return;
}
std::map<UInt, CommunicationBuffer> buffers;
std::vector<CommunicationRequest> requests;
for (UInt p = 0; p < nb_proc; ++p) {
auto data_to_scatter_it = to_scatter.begin(to_scatter.getNbComponent());
if (p == this->rank) {
auto data_scattered_it = scattered.begin(to_scatter.getNbComponent());
// copy the data for the local processor
for (auto local_dof : root_dofs) {
auto global_dof = dof_manager.localToGlobalEquationNumber(local_dof);
Vector<T> dof_data_to_scatter = data_to_scatter_it[global_dof];
Vector<T> dof_data_scattered = data_scattered_it[local_dof];
dof_data_scattered = dof_data_to_scatter;
}
continue;
}
const Array<UInt> & receive_dofs =
this->master_receive_dofs.find(p)->second;
// prepare the send buffer
CommunicationBuffer & buffer = buffers[p];
buffer.resize(receive_dofs.size() * scattered.getNbComponent() * sizeof(T));
// pack the data
for (auto global_dof : receive_dofs) {
Vector<T> dof_data_to_scatter = data_to_scatter_it[global_dof];
buffer << dof_data_to_scatter;
}
// send the data
requests.push_back(communicator.asyncSend(
buffer, p, Tag::genTag(p, 0, Tag::_SCATTER, this->hash_id)));
}
// wait a clean communications
communicator.waitAll(requests);
communicator.freeCommunicationRequest(requests);
// synchronize slave and ghost nodes
synchronize(scattered);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T> void DOFSynchronizer::scatter(Array<T> & scattered) {
AKANTU_DEBUG_IN();
if (this->hasChanged())
this->initScatterGatherCommunicationScheme();
AKANTU_DEBUG_ASSERT(this->rank != UInt(this->root),
"This function cannot be called on the root processor");
AKANTU_DEBUG_ASSERT(scattered.size() ==
this->dof_manager.getLocalSystemSize(),
"The scattered array does not have the correct size");
// prepare the data
auto data_scattered_it = scattered.begin(scattered.getNbComponent());
CommunicationBuffer buffer(this->root_dofs.size() *
scattered.getNbComponent() * sizeof(T));
// receive the data
communicator.receive(
buffer, this->root,
Tag::genTag(this->rank, 0, Tag::_SCATTER, this->hash_id));
// unpack the data
for (auto local_dof : root_dofs) {
Vector<T> dof_data_scattered = data_scattered_it[local_dof];
buffer >> dof_data_scattered;
}
// synchronize the ghosts
synchronize(scattered);
AKANTU_DEBUG_OUT();
}
-
/* -------------------------------------------------------------------------- */
template <template <class> class Op, typename T>
void DOFSynchronizer::reduceSynchronize(Array<T> & array) const {
- ReduceDataAccessor<UInt, Op, T> data_accessor(array, SynchronizationTag::_whatever);
+ ReduceDataAccessor<UInt, Op, T> data_accessor(array,
+ SynchronizationTag::_whatever);
this->slaveReductionOnceImpl(data_accessor, SynchronizationTag::_whatever);
this->synchronize(array);
}
/* -------------------------------------------------------------------------- */
-template <typename T> void DOFSynchronizer::synchronize(Array<T> & array) const {
+template <typename T>
+void DOFSynchronizer::synchronize(Array<T> & array) const {
SimpleUIntDataAccessor<T> data_accessor(array, SynchronizationTag::_whatever);
this->synchronizeOnce(data_accessor, SynchronizationTag::_whatever);
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_DOF_SYNCHRONIZER_INLINE_IMPL_CC__ */
diff --git a/src/synchronizer/element_info_per_processor.cc b/src/synchronizer/element_info_per_processor.cc
index a2716090b..dc30efdd1 100644
--- a/src/synchronizer/element_info_per_processor.cc
+++ b/src/synchronizer/element_info_per_processor.cc
@@ -1,125 +1,124 @@
/**
* @file element_info_per_processor.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Mar 16 2016
* @date last modification: Tue Nov 07 2017
*
* @brief Helper class to distribute a mesh
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_info_per_processor.hh"
#include "communicator.hh"
#include "element_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <iostream>
#include <map>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
ElementInfoPerProc::ElementInfoPerProc(ElementSynchronizer & synchronizer,
UInt message_cnt, UInt root,
ElementType type)
: MeshAccessor(synchronizer.getMesh()), synchronizer(synchronizer),
rank(synchronizer.getCommunicator().whoAmI()),
nb_proc(synchronizer.getCommunicator().getNbProc()), root(root),
type(type), message_count(message_cnt), mesh(synchronizer.getMesh()),
- comm(synchronizer.getCommunicator()) {
-}
+ comm(synchronizer.getCommunicator()) {}
/* -------------------------------------------------------------------------- */
bool ElementInfoPerProc::synchronize() {
auto need_synchronize = needSynchronize();
if (need_synchronize) {
synchronizeConnectivities();
synchronizePartitions();
synchronizeTags();
synchronizeGroups();
}
return need_synchronize;
}
/* -------------------------------------------------------------------------- */
void ElementInfoPerProc::fillCommunicationScheme(
const Array<UInt> & partition) {
AKANTU_DEBUG_IN();
Element element;
element.type = this->type;
auto & communications = this->synchronizer.getCommunications();
auto part = partition.begin();
std::map<UInt, Array<Element>> send_array_per_proc;
for (UInt lel = 0; lel < nb_local_element; ++lel) {
UInt nb_send = *part;
++part;
element.element = lel;
element.ghost_type = _not_ghost;
for (UInt p = 0; p < nb_send; ++p, ++part) {
UInt proc = *part;
AKANTU_DEBUG(dblAccessory,
"Must send : " << element << " to proc " << proc);
send_array_per_proc[proc].push_back(element);
}
}
for (auto & send_schemes : send_array_per_proc) {
if (send_schemes.second.size() == 0)
continue;
auto & scheme = communications.createSendScheme(send_schemes.first);
scheme.append(send_schemes.second);
}
std::map<UInt, Array<Element>> recv_array_per_proc;
for (UInt gel = 0; gel < nb_ghost_element; ++gel, ++part) {
UInt proc = *part;
element.element = gel;
element.ghost_type = _ghost;
AKANTU_DEBUG(dblAccessory,
"Must recv : " << element << " from proc " << proc);
recv_array_per_proc[proc].push_back(element);
}
for (auto & recv_schemes : recv_array_per_proc) {
if (recv_schemes.second.size() == 0)
continue;
auto & scheme = communications.createRecvScheme(recv_schemes.first);
scheme.append(recv_schemes.second);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/synchronizer/element_info_per_processor.hh b/src/synchronizer/element_info_per_processor.hh
index 12599ef61..d68a0a91f 100644
--- a/src/synchronizer/element_info_per_processor.hh
+++ b/src/synchronizer/element_info_per_processor.hh
@@ -1,149 +1,151 @@
/**
* @file element_info_per_processor.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Mar 16 2016
* @date last modification: Tue Nov 07 2017
*
* @brief Helper classes to create the distributed synchronizer and distribute
* a mesh
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "communication_buffer.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_INFO_PER_PROCESSOR_HH__
#define __AKANTU_ELEMENT_INFO_PER_PROCESSOR_HH__
namespace akantu {
class ElementSynchronizer;
class Communicator;
class MeshPartition;
-}
+} // namespace akantu
/* -------------------------------------------------------------------------- */
namespace akantu {
class ElementInfoPerProc : protected MeshAccessor {
public:
ElementInfoPerProc(ElementSynchronizer & synchronizer, UInt message_cnt,
UInt root, ElementType type);
bool synchronize();
protected:
virtual void synchronizeConnectivities() = 0;
virtual void synchronizePartitions() = 0;
virtual void synchronizeTags() = 0;
virtual void synchronizeGroups() = 0;
virtual bool needSynchronize() = 0;
protected:
void fillCommunicationScheme(const Array<UInt> & partition);
template <class CommunicationBuffer>
void fillElementGroupsFromBuffer(CommunicationBuffer & buffer);
template <typename T, typename BufferType>
void fillMeshDataTemplated(BufferType & buffer, const std::string & tag_name,
UInt nb_component);
template <typename BufferType>
void fillMeshData(BufferType & buffer, const std::string & tag_name,
const MeshDataTypeCode & type_code, UInt nb_component);
protected:
ElementSynchronizer & synchronizer;
UInt rank{0};
UInt nb_proc{1};
UInt root{0};
ElementType type{_not_defined};
UInt nb_tags{0};
UInt nb_nodes_per_element{0};
UInt nb_element{0};
UInt nb_local_element{0};
UInt nb_ghost_element{0};
UInt message_count{0};
Mesh & mesh;
const Communicator & comm;
};
/* -------------------------------------------------------------------------- */
class MasterElementInfoPerProc : public ElementInfoPerProc {
public:
MasterElementInfoPerProc(ElementSynchronizer & synchronizer, UInt message_cnt,
UInt root, ElementType type,
const MeshPartition & partition);
+
protected:
void synchronizeConnectivities() override;
void synchronizePartitions() override;
void synchronizeTags() override;
void synchronizeGroups() override;
bool needSynchronize() override { return type != _not_defined; }
+
protected:
template <typename T>
void fillTagBufferTemplated(std::vector<DynamicCommunicationBuffer> & buffers,
const std::string & tag_name);
void fillTagBuffer(std::vector<DynamicCommunicationBuffer> & buffers,
const std::string & tag_name);
private:
const MeshPartition & partition;
Vector<UInt> all_nb_local_element;
Vector<UInt> all_nb_ghost_element;
Vector<UInt> all_nb_element_to_send;
};
/* -------------------------------------------------------------------------- */
class SlaveElementInfoPerProc : public ElementInfoPerProc {
public:
SlaveElementInfoPerProc(ElementSynchronizer & synchronizer, UInt message_cnt,
UInt root);
protected:
void synchronizeConnectivities() override;
void synchronizePartitions() override;
void synchronizeTags() override;
void synchronizeGroups() override;
bool needSynchronize() override;
private:
UInt nb_element_to_receive{0};
};
-} // akantu
+} // namespace akantu
#include "element_info_per_processor_tmpl.hh"
#endif /* __AKANTU_ELEMENT_INFO_PER_PROCESSOR_HH__ */
diff --git a/src/synchronizer/element_info_per_processor_tmpl.hh b/src/synchronizer/element_info_per_processor_tmpl.hh
index 7b7bd9fae..5ec21a9d5 100644
--- a/src/synchronizer/element_info_per_processor_tmpl.hh
+++ b/src/synchronizer/element_info_per_processor_tmpl.hh
@@ -1,147 +1,147 @@
/**
* @file element_info_per_processor_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Mar 16 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Helper classes to create the distributed synchronizer and distribute
* a mesh
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_group.hh"
#include "element_info_per_processor.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_ELEMENT_INFO_PER_PROCESSOR_TMPL_HH__
#define __AKANTU_ELEMENT_INFO_PER_PROCESSOR_TMPL_HH__
namespace akantu {
/* -------------------------------------------------------------------------- */
template <typename T, typename BufferType>
void ElementInfoPerProc::fillMeshDataTemplated(BufferType & buffer,
const std::string & tag_name,
UInt nb_component) {
AKANTU_DEBUG_ASSERT(this->mesh.getNbElement(this->type) == nb_local_element,
"Did not got enought informations for the tag "
<< tag_name << " and the element type " << this->type
<< ":"
<< "_not_ghost."
<< " Got " << nb_local_element << " values, expected "
<< mesh.getNbElement(this->type));
mesh.getElementalData<T>(tag_name);
Array<T> & data = mesh.getElementalDataArrayAlloc<T>(
tag_name, this->type, _not_ghost, nb_component);
data.resize(nb_local_element);
/// unpacking the data, element by element
for (UInt i(0); i < nb_local_element; ++i) {
for (UInt j(0); j < nb_component; ++j) {
buffer >> data(i, j);
}
}
AKANTU_DEBUG_ASSERT(mesh.getNbElement(this->type, _ghost) == nb_ghost_element,
"Did not got enought informations for the tag "
<< tag_name << " and the element type " << this->type
<< ":"
<< "_ghost."
<< " Got " << nb_ghost_element << " values, expected "
<< mesh.getNbElement(this->type, _ghost));
Array<T> & data_ghost = mesh.getElementalDataArrayAlloc<T>(
tag_name, this->type, _ghost, nb_component);
data_ghost.resize(nb_ghost_element);
/// unpacking the ghost data, element by element
for (UInt j(0); j < nb_ghost_element; ++j) {
for (UInt k(0); k < nb_component; ++k) {
buffer >> data_ghost(j, k);
}
}
}
/* -------------------------------------------------------------------------- */
template <typename BufferType>
void ElementInfoPerProc::fillMeshData(BufferType & buffer,
const std::string & tag_name,
const MeshDataTypeCode & type_code,
UInt nb_component) {
#define AKANTU_DISTRIBUTED_SYNHRONIZER_TAG_DATA(r, extra_param, elem) \
- case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
+ case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
fillMeshDataTemplated<BOOST_PP_TUPLE_ELEM(2, 1, elem)>(buffer, tag_name, \
nb_component); \
break; \
}
switch (type_code) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_DISTRIBUTED_SYNHRONIZER_TAG_DATA, ,
AKANTU_MESH_DATA_TYPES)
default:
AKANTU_ERROR("Could not determine the type of tag" << tag_name << "!");
break;
}
#undef AKANTU_DISTRIBUTED_SYNHRONIZER_TAG_DATA
}
/* -------------------------------------------------------------------------- */
template <class CommunicationBuffer>
void ElementInfoPerProc::fillElementGroupsFromBuffer(
CommunicationBuffer & buffer) {
AKANTU_DEBUG_IN();
Element el;
el.type = type;
for (auto ghost_type : ghost_types) {
UInt nb_element = mesh.getNbElement(type, ghost_type);
el.ghost_type = ghost_type;
for (UInt e = 0; e < nb_element; ++e) {
el.element = e;
std::vector<std::string> element_to_group;
buffer >> element_to_group;
AKANTU_DEBUG_ASSERT(e < mesh.getNbElement(type, ghost_type),
"The mesh does not have the element " << e);
for (auto && element : element_to_group) {
mesh.getElementGroup(element).add(el, false, false);
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_ELEMENT_INFO_PER_PROCESSOR_TMPL_HH__ */
diff --git a/src/synchronizer/element_synchronizer.cc b/src/synchronizer/element_synchronizer.cc
index c8a0c1f5a..736037373 100644
--- a/src/synchronizer/element_synchronizer.cc
+++ b/src/synchronizer/element_synchronizer.cc
@@ -1,276 +1,277 @@
/**
* @file element_synchronizer.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Dana Christen <dana.christen@epfl.ch>
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Sep 01 2010
* @date last modification: Tue Feb 20 2018
*
* @brief implementation of a communicator using a static_communicator for
* real
* send/receive
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_synchronizer.hh"
#include "aka_common.hh"
#include "mesh.hh"
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <iostream>
#include <map>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
ElementSynchronizer::ElementSynchronizer(Mesh & mesh, const ID & id,
MemoryID memory_id,
bool register_to_event_manager,
EventHandlerPriority event_priority)
: SynchronizerImpl<Element>(mesh.getCommunicator(), id, memory_id),
mesh(mesh), element_to_prank("element_to_prank", id, memory_id) {
AKANTU_DEBUG_IN();
if (register_to_event_manager)
this->mesh.registerEventHandler(*this, event_priority);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
ElementSynchronizer::ElementSynchronizer(const ElementSynchronizer & other,
const ID & id,
bool register_to_event_manager,
EventHandlerPriority event_priority)
: SynchronizerImpl<Element>(other, id), mesh(other.mesh),
element_to_prank("element_to_prank", id, other.memory_id) {
AKANTU_DEBUG_IN();
element_to_prank.copy(other.element_to_prank);
if (register_to_event_manager)
this->mesh.registerEventHandler(*this, event_priority);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
ElementSynchronizer::~ElementSynchronizer() = default;
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::substituteElements(
const std::map<Element, Element> & old_to_new_elements) {
auto found_element_end = old_to_new_elements.end();
// substitute old elements with new ones
for (auto && sr : iterate_send_recv) {
for (auto && scheme_pair : communications.iterateSchemes(sr)) {
auto & list = scheme_pair.second;
for (auto & el : list) {
auto found_element_it = old_to_new_elements.find(el);
if (found_element_it != found_element_end)
el = found_element_it->second;
}
}
}
}
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::onElementsChanged(
const Array<Element> & old_elements_list,
const Array<Element> & new_elements_list, const ElementTypeMapArray<UInt> &,
const ChangedElementsEvent &) {
// create a map to link old elements to new ones
std::map<Element, Element> old_to_new_elements;
for (UInt el = 0; el < old_elements_list.size(); ++el) {
AKANTU_DEBUG_ASSERT(old_to_new_elements.find(old_elements_list(el)) ==
old_to_new_elements.end(),
"The same element cannot appear twice in the list");
old_to_new_elements[old_elements_list(el)] = new_elements_list(el);
}
substituteElements(old_to_new_elements);
communications.invalidateSizes();
}
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::onElementsRemoved(
const Array<Element> & element_to_remove,
const ElementTypeMapArray<UInt> & new_numbering,
const RemovedElementsEvent &) {
AKANTU_DEBUG_IN();
this->filterScheme([&](auto && element) {
return std::find(element_to_remove.begin(), element_to_remove.end(),
element) == element_to_remove.end();
});
this->renumberElements(new_numbering);
communications.invalidateSizes();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::buildElementToPrank() {
AKANTU_DEBUG_IN();
UInt spatial_dimension = mesh.getSpatialDimension();
element_to_prank.initialize(mesh, _spatial_dimension = spatial_dimension,
_element_kind = _ek_not_defined,
_with_nb_element = true, _default_value = rank);
/// assign prank to all ghost elements
for (auto && scheme : communications.iterateSchemes(_recv)) {
auto & recv = scheme.second;
auto proc = scheme.first;
for (auto & element : recv) {
element_to_prank(element) = proc;
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
Int ElementSynchronizer::getRank(const Element & element) const {
if (not element_to_prank.exists(element.type, element.ghost_type)) {
// Nicolas: Ok This is nasty I know....
const_cast<ElementSynchronizer *>(this)->buildElementToPrank();
}
return element_to_prank(element);
}
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::renumberElements(
const ElementTypeMapArray<UInt> & new_numbering) {
for (auto && sr : iterate_send_recv) {
for (auto && scheme_pair : communications.iterateSchemes(sr)) {
auto & list = scheme_pair.second;
for (auto && el : list) {
if (new_numbering.exists(el.type, el.ghost_type))
el.element = new_numbering(el);
}
}
}
}
/* -------------------------------------------------------------------------- */
UInt ElementSynchronizer::sanityCheckDataSize(const Array<Element> & elements,
const SynchronizationTag & tag,
bool from_comm_desc) const {
UInt size = SynchronizerImpl<Element>::sanityCheckDataSize(elements, tag,
from_comm_desc);
// global connectivities;
size += mesh.getNbNodesPerElementList(elements) * sizeof(UInt);
// barycenters
size += (elements.size() * mesh.getSpatialDimension() * sizeof(Real));
return size;
}
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::packSanityCheckData(
CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & /*tag*/) const {
for (auto && element : elements) {
Vector<Real> barycenter(mesh.getSpatialDimension());
mesh.getBarycenter(element, barycenter);
buffer << barycenter;
const auto & conns = mesh.getConnectivity(element.type, element.ghost_type);
for (auto n : arange(conns.getNbComponent())) {
buffer << mesh.getNodeGlobalId(conns(element.element, n));
}
}
}
/* -------------------------------------------------------------------------- */
void ElementSynchronizer::unpackSanityCheckData(CommunicationBuffer & buffer,
const Array<Element> & elements,
const SynchronizationTag & tag,
UInt proc, UInt rank) const {
auto spatial_dimension = mesh.getSpatialDimension();
- std::set<SynchronizationTag> skip_conn_tags{SynchronizationTag::_smmc_facets_conn,
- SynchronizationTag::_giu_global_conn};
+ std::set<SynchronizationTag> skip_conn_tags{
+ SynchronizationTag::_smmc_facets_conn,
+ SynchronizationTag::_giu_global_conn};
bool is_skip_tag_conn = skip_conn_tags.find(tag) != skip_conn_tags.end();
for (auto && element : elements) {
Vector<Real> barycenter_loc(spatial_dimension);
mesh.getBarycenter(element, barycenter_loc);
Vector<Real> barycenter(spatial_dimension);
buffer >> barycenter;
auto dist = barycenter_loc.distance(barycenter);
if (not Math::are_float_equal(dist, 0.)) {
AKANTU_EXCEPTION("Unpacking an unknown value for the element "
<< element << "(barycenter " << barycenter_loc
<< " != buffer " << barycenter << ") [" << dist
<< "] - tag: " << tag << " comm from " << proc << " to "
<< rank);
}
const auto & conns = mesh.getConnectivity(element.type, element.ghost_type);
Vector<UInt> global_conn(conns.getNbComponent());
Vector<UInt> local_global_conn(conns.getNbComponent());
auto is_same = true;
for (auto n : arange(global_conn.size())) {
buffer >> global_conn(n);
auto node = conns(element.element, n);
local_global_conn(n) = mesh.getNodeGlobalId(node);
is_same &= is_skip_tag_conn or mesh.isPureGhostNode(node) or
(local_global_conn(n) == global_conn(n));
}
if (not is_same) {
AKANTU_DEBUG_WARNING(
"The connectivity of the element "
<< element << " " << local_global_conn
<< " does not match the connectivity of the equivalent "
"element on proc "
<< proc << " " << global_conn << " in communication with tag "
<< tag);
}
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/synchronizer/grid_synchronizer.cc b/src/synchronizer/grid_synchronizer.cc
index 4f79e613a..09ac6cbf4 100644
--- a/src/synchronizer/grid_synchronizer.cc
+++ b/src/synchronizer/grid_synchronizer.cc
@@ -1,475 +1,475 @@
/**
* @file grid_synchronizer.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Oct 03 2011
* @date last modification: Tue Nov 07 2017
*
* @brief implementation of the grid synchronizer
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "grid_synchronizer.hh"
#include "aka_grid_dynamic.hh"
#include "communicator.hh"
#include "fe_engine.hh"
#include "integration_point.hh"
#include "mesh.hh"
#include "mesh_io.hh"
#include <iostream>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
template <class E>
void GridSynchronizer::createGridSynchronizer(const SpatialGrid<E> & grid) {
AKANTU_DEBUG_IN();
const Communicator & comm = this->mesh.getCommunicator();
UInt nb_proc = comm.getNbProc();
UInt my_rank = comm.whoAmI();
if (nb_proc == 1)
return;
UInt spatial_dimension = this->mesh.getSpatialDimension();
BBox my_bounding_box(spatial_dimension);
const auto & lower = grid.getLowerBounds();
const auto & upper = grid.getUpperBounds();
const auto & spacing = grid.getSpacing();
my_bounding_box.getLowerBounds() = lower - spacing;
my_bounding_box.getUpperBounds() = upper + spacing;
AKANTU_DEBUG_INFO(
"Exchange of bounding box to detect the overlapping regions.");
auto && bboxes = my_bounding_box.allGather(comm);
std::vector<bool> intersects_proc(nb_proc);
std::fill(intersects_proc.begin(), intersects_proc.end(), true);
Matrix<Int> first_cells(spatial_dimension, nb_proc);
Matrix<Int> last_cells(spatial_dimension, nb_proc);
std::map<UInt, ElementTypeMapArray<UInt>> element_per_proc;
// check the overlapping between my box and the one from other processors
for (UInt p = 0; p < nb_proc; ++p) {
if (p == my_rank)
continue;
const auto & proc_bounding_box = bboxes[p];
auto intersection = my_bounding_box.intersection(proc_bounding_box);
Vector<Int> first_cell_p = first_cells(p);
Vector<Int> last_cell_p = last_cells(p);
intersects_proc[p] = intersection;
- if(intersects_proc[p]) {
+ if (intersects_proc[p]) {
for (UInt s = 0; s < spatial_dimension; ++s) {
first_cell_p(s) = grid.getCellID(intersection.getLowerBounds()(s), s);
last_cell_p(s) = grid.getCellID(intersection.getUpperBounds()(s), s);
}
}
// create the list of cells in the overlapping
using CellID = typename SpatialGrid<E>::CellID;
std::vector<CellID> cell_ids;
if (intersects_proc[p]) {
AKANTU_DEBUG_INFO("I intersects with processor " << p);
CellID cell_id(spatial_dimension);
// for (UInt i = 0; i < spatial_dimension; ++i) {
// if(first_cell_p[i] != 0) --first_cell_p[i];
// if(last_cell_p[i] != 0) ++last_cell_p[i];
// }
for (Int fd = first_cell_p(0); fd <= last_cell_p(0); ++fd) {
cell_id.setID(0, fd);
if (spatial_dimension == 1) {
cell_ids.push_back(cell_id);
} else {
for (Int sd = first_cell_p(1); sd <= last_cell_p(1); ++sd) {
cell_id.setID(1, sd);
if (spatial_dimension == 2) {
cell_ids.push_back(cell_id);
} else {
for (Int ld = first_cell_p(2); ld <= last_cell_p(2); ++ld) {
cell_id.setID(2, ld);
cell_ids.push_back(cell_id);
}
}
}
}
}
// get the list of elements in the cells of the overlapping
std::set<Element> to_send;
for (auto & cur_cell_id : cell_ids) {
auto & cell = grid.getCell(cur_cell_id);
for (auto & element : cell) {
to_send.insert(element);
}
}
AKANTU_DEBUG_INFO("I have prepared " << to_send.size()
<< " elements to send to processor "
<< p);
auto & scheme = this->getCommunications().createSendScheme(p);
std::stringstream sstr;
sstr << "element_per_proc_" << p;
element_per_proc.emplace(
std::piecewise_construct, std::forward_as_tuple(p),
std::forward_as_tuple(sstr.str(), id, memory_id));
ElementTypeMapArray<UInt> & elempproc = element_per_proc[p];
for (auto elem : to_send) {
ElementType type = elem.type;
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
// /!\ this part must be slow due to the access in the
// ElementTypeMapArray<UInt>
if (!elempproc.exists(type, _not_ghost))
elempproc.alloc(0, nb_nodes_per_element, type, _not_ghost);
Vector<UInt> global_connect(nb_nodes_per_element);
Vector<UInt> local_connect = mesh.getConnectivity(type).begin(
nb_nodes_per_element)[elem.element];
for (UInt i = 0; i < nb_nodes_per_element; ++i) {
global_connect(i) = mesh.getNodeGlobalId(local_connect(i));
AKANTU_DEBUG_ASSERT(
global_connect(i) < mesh.getNbGlobalNodes(),
"This global node send in the connectivity does not seem correct "
<< global_connect(i) << " corresponding to "
<< local_connect(i) << " from element " << elem.element);
}
elempproc(type).push_back(global_connect);
scheme.push_back(elem);
}
}
}
AKANTU_DEBUG_INFO("I have finished to compute intersection,"
<< " no it's time to communicate with my neighbors");
/**
* Sending loop, sends the connectivity asynchronously to all concerned proc
*/
std::vector<CommunicationRequest> isend_requests;
Tensor3<UInt> space(2, _max_element_type, nb_proc);
for (UInt p = 0; p < nb_proc; ++p) {
if (p == my_rank)
continue;
if (not intersects_proc[p])
continue;
Matrix<UInt> info_proc = space(p);
auto & elempproc = element_per_proc[p];
UInt count = 0;
for (auto type : elempproc.elementTypes(_all_dimensions, _not_ghost)) {
Array<UInt> & conn = elempproc(type, _not_ghost);
Vector<UInt> info = info_proc((UInt)type);
info[0] = (UInt)type;
info[1] = conn.size() * conn.getNbComponent();
AKANTU_DEBUG_INFO(
"I have " << conn.size() << " elements of type " << type
<< " to send to processor " << p << " (communication tag : "
<< Tag::genTag(my_rank, count, DATA_TAG) << ")");
isend_requests.push_back(
comm.asyncSend(info, p, Tag::genTag(my_rank, count, SIZE_TAG)));
if (info[1] != 0)
isend_requests.push_back(comm.asyncSend<UInt>(
conn, p, Tag::genTag(my_rank, count, DATA_TAG)));
++count;
}
Vector<UInt> info = info_proc((UInt)_not_defined);
info[0] = (UInt)_not_defined;
info[1] = 0;
isend_requests.push_back(
comm.asyncSend(info, p, Tag::genTag(my_rank, count, SIZE_TAG)));
}
/**
* Receives the connectivity and store them in the ghosts elements
*/
MeshAccessor mesh_accessor(mesh);
auto & global_nodes_ids = mesh_accessor.getNodesGlobalIds();
auto & nodes_type = mesh_accessor.getNodesFlags();
std::vector<CommunicationRequest> isend_nodes_requests;
Vector<UInt> nb_nodes_to_recv(nb_proc);
UInt nb_total_nodes_to_recv = 0;
UInt nb_current_nodes = global_nodes_ids.size();
NewNodesEvent new_nodes;
NewElementsEvent new_elements;
std::map<UInt, std::vector<UInt>> ask_nodes_per_proc;
for (UInt p = 0; p < nb_proc; ++p) {
nb_nodes_to_recv(p) = 0;
if (p == my_rank)
continue;
if (!intersects_proc[p])
continue;
auto & scheme = this->getCommunications().createRecvScheme(p);
ask_nodes_per_proc.emplace(std::piecewise_construct,
std::forward_as_tuple(p),
std::forward_as_tuple(0));
auto & ask_nodes = ask_nodes_per_proc[p];
UInt count = 0;
ElementType type = _not_defined;
do {
Vector<UInt> info(2);
comm.receive(info, p, Tag::genTag(p, count, SIZE_TAG));
type = (ElementType)info[0];
if (type == _not_defined)
break;
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(type);
UInt nb_element = info[1] / nb_nodes_per_element;
Array<UInt> tmp_conn(nb_element, nb_nodes_per_element);
tmp_conn.clear();
if (info[1] != 0)
comm.receive<UInt>(tmp_conn, p, Tag::genTag(p, count, DATA_TAG));
AKANTU_DEBUG_INFO("I will receive "
<< nb_element << " elements of type "
<< ElementType(info[0]) << " from processor " << p
<< " (communication tag : "
<< Tag::genTag(p, count, DATA_TAG) << ")");
auto & ghost_connectivity = mesh_accessor.getConnectivity(type, _ghost);
auto & ghost_counter = mesh_accessor.getGhostsCounters(type, _ghost);
UInt nb_ghost_element = ghost_connectivity.size();
Element element{type, 0, _ghost};
Vector<UInt> conn(nb_nodes_per_element);
for (UInt el = 0; el < nb_element; ++el) {
UInt nb_node_to_ask_for_elem = 0;
for (UInt n = 0; n < nb_nodes_per_element; ++n) {
UInt gn = tmp_conn(el, n);
UInt ln = global_nodes_ids.find(gn);
AKANTU_DEBUG_ASSERT(gn < mesh.getNbGlobalNodes(),
"This global node seems not correct "
<< gn << " from element " << el << " node "
<< n);
if (ln == UInt(-1)) {
global_nodes_ids.push_back(gn);
nodes_type.push_back(NodeFlag::_pure_ghost); // pure ghost node
ln = nb_current_nodes;
new_nodes.getList().push_back(ln);
++nb_current_nodes;
ask_nodes.push_back(gn);
++nb_node_to_ask_for_elem;
}
conn[n] = ln;
}
// all the nodes are already known locally, the element should
// already exists
auto c = UInt(-1);
if (nb_node_to_ask_for_elem == 0) {
c = ghost_connectivity.find(conn);
element.element = c;
}
if (c == UInt(-1)) {
element.element = nb_ghost_element;
++nb_ghost_element;
ghost_connectivity.push_back(conn);
ghost_counter.push_back(1);
new_elements.getList().push_back(element);
} else {
++ghost_counter(c);
}
scheme.push_back(element);
}
count++;
} while (type != _not_defined);
AKANTU_DEBUG_INFO("I have "
<< ask_nodes.size()
<< " missing nodes for elements coming from processor "
<< p << " (communication tag : "
<< Tag::genTag(my_rank, 0, ASK_NODES_TAG) << ")");
ask_nodes.push_back(UInt(-1));
isend_nodes_requests.push_back(
comm.asyncSend(ask_nodes, p, Tag::genTag(my_rank, 0, ASK_NODES_TAG)));
nb_nodes_to_recv(p) = ask_nodes.size() - 1;
nb_total_nodes_to_recv += nb_nodes_to_recv(p);
}
comm.waitAll(isend_requests);
comm.freeCommunicationRequest(isend_requests);
/**
* Sends requested nodes to proc
*/
auto & nodes = const_cast<Array<Real> &>(mesh.getNodes());
UInt nb_nodes = nodes.size();
std::vector<CommunicationRequest> isend_coordinates_requests;
std::map<UInt, Array<Real>> nodes_to_send_per_proc;
for (UInt p = 0; p < nb_proc; ++p) {
if (p == my_rank || !intersects_proc[p])
continue;
Array<UInt> asked_nodes;
CommunicationStatus status;
AKANTU_DEBUG_INFO("Waiting list of nodes to send to processor "
<< p << "(communication tag : "
<< Tag::genTag(p, 0, ASK_NODES_TAG) << ")");
comm.probe<UInt>(p, Tag::genTag(p, 0, ASK_NODES_TAG), status);
UInt nb_nodes_to_send = status.size();
asked_nodes.resize(nb_nodes_to_send);
AKANTU_DEBUG_INFO("I have " << nb_nodes_to_send - 1
<< " nodes to send to processor " << p
<< " (communication tag : "
<< Tag::genTag(p, 0, ASK_NODES_TAG) << ")");
AKANTU_DEBUG_INFO("Getting list of nodes to send to processor "
<< p << " (communication tag : "
<< Tag::genTag(p, 0, ASK_NODES_TAG) << ")");
comm.receive(asked_nodes, p, Tag::genTag(p, 0, ASK_NODES_TAG));
nb_nodes_to_send--;
asked_nodes.resize(nb_nodes_to_send);
nodes_to_send_per_proc.emplace(std::piecewise_construct,
std::forward_as_tuple(p),
std::forward_as_tuple(0, spatial_dimension));
auto & nodes_to_send = nodes_to_send_per_proc[p];
auto node_it = nodes.begin(spatial_dimension);
for (UInt n = 0; n < nb_nodes_to_send; ++n) {
UInt ln = global_nodes_ids.find(asked_nodes(n));
- AKANTU_DEBUG_ASSERT(ln != UInt(-1),
- "The node [" << asked_nodes(n)
- << "] requested by proc " << p
- << " was not found locally!");
+ AKANTU_DEBUG_ASSERT(ln != UInt(-1), "The node ["
+ << asked_nodes(n)
+ << "] requested by proc " << p
+ << " was not found locally!");
nodes_to_send.push_back(node_it + ln);
}
if (nb_nodes_to_send != 0) {
AKANTU_DEBUG_INFO("Sending the "
<< nb_nodes_to_send << " nodes to processor " << p
<< " (communication tag : "
<< Tag::genTag(p, 0, SEND_NODES_TAG) << ")");
isend_coordinates_requests.push_back(comm.asyncSend(
nodes_to_send, p, Tag::genTag(my_rank, 0, SEND_NODES_TAG)));
}
#if not defined(AKANTU_NDEBUG)
else {
AKANTU_DEBUG_INFO("No nodes to send to processor " << p);
}
#endif
}
comm.waitAll(isend_nodes_requests);
comm.freeCommunicationRequest(isend_nodes_requests);
nodes.resize(nb_total_nodes_to_recv + nb_nodes);
for (UInt p = 0; p < nb_proc; ++p) {
if ((p != my_rank) && (nb_nodes_to_recv(p) > 0)) {
AKANTU_DEBUG_INFO("Receiving the "
<< nb_nodes_to_recv(p) << " nodes from processor " << p
<< " (communication tag : "
<< Tag::genTag(p, 0, SEND_NODES_TAG) << ")");
Vector<Real> nodes_to_recv(nodes.storage() + nb_nodes * spatial_dimension,
nb_nodes_to_recv(p) * spatial_dimension);
comm.receive(nodes_to_recv, p, Tag::genTag(p, 0, SEND_NODES_TAG));
nb_nodes += nb_nodes_to_recv(p);
}
#if not defined(AKANTU_NDEBUG)
else {
if (p != my_rank) {
AKANTU_DEBUG_INFO("No nodes to receive from processor " << p);
}
}
#endif
}
comm.waitAll(isend_coordinates_requests);
comm.freeCommunicationRequest(isend_coordinates_requests);
mesh.sendEvent(new_nodes);
mesh.sendEvent(new_elements);
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template void GridSynchronizer::createGridSynchronizer<IntegrationPoint>(
const SpatialGrid<IntegrationPoint> & grid);
template void GridSynchronizer::createGridSynchronizer<Element>(
const SpatialGrid<Element> & grid);
} // namespace akantu
diff --git a/src/synchronizer/master_element_info_per_processor.cc b/src/synchronizer/master_element_info_per_processor.cc
index e260e1a30..35b6f2095 100644
--- a/src/synchronizer/master_element_info_per_processor.cc
+++ b/src/synchronizer/master_element_info_per_processor.cc
@@ -1,451 +1,451 @@
/**
* @file master_element_info_per_processor.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Mar 16 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Helper class to distribute a mesh
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_iterators.hh"
#include "communicator.hh"
#include "element_group.hh"
#include "element_info_per_processor.hh"
#include "element_synchronizer.hh"
#include "mesh_iterators.hh"
#include "mesh_utils.hh"
/* -------------------------------------------------------------------------- */
#include <algorithm>
#include <iostream>
#include <map>
#include <tuple>
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
MasterElementInfoPerProc::MasterElementInfoPerProc(
ElementSynchronizer & synchronizer, UInt message_cnt, UInt root,
ElementType type, const MeshPartition & partition)
: ElementInfoPerProc(synchronizer, message_cnt, root, type),
partition(partition), all_nb_local_element(nb_proc, 0),
all_nb_ghost_element(nb_proc, 0), all_nb_element_to_send(nb_proc, 0) {
Vector<UInt> size(5);
size(0) = (UInt)type;
if (type != _not_defined) {
nb_nodes_per_element = Mesh::getNbNodesPerElement(type);
nb_element = mesh.getNbElement(type);
const auto & partition_num =
this->partition.getPartition(this->type, _not_ghost);
const auto & ghost_partition =
this->partition.getGhostPartitionCSR()(this->type, _not_ghost);
for (UInt el = 0; el < nb_element; ++el) {
this->all_nb_local_element[partition_num(el)]++;
for (auto part = ghost_partition.begin(el);
part != ghost_partition.end(el); ++part) {
this->all_nb_ghost_element[*part]++;
}
this->all_nb_element_to_send[partition_num(el)] +=
ghost_partition.getNbCols(el) + 1;
}
/// tag info
auto && tag_names = this->mesh.getTagNames(type);
this->nb_tags = tag_names.size();
size(4) = nb_tags;
for (UInt p = 0; p < nb_proc; ++p) {
if (p != root) {
size(1) = this->all_nb_local_element[p];
size(2) = this->all_nb_ghost_element[p];
size(3) = this->all_nb_element_to_send[p];
AKANTU_DEBUG_INFO(
"Sending connectivities informations to proc "
<< p << " TAG("
<< Tag::genTag(this->rank, this->message_count, Tag::_SIZES)
<< ")");
comm.send(size, p,
Tag::genTag(this->rank, this->message_count, Tag::_SIZES));
} else {
this->nb_local_element = this->all_nb_local_element[p];
this->nb_ghost_element = this->all_nb_ghost_element[p];
}
}
} else {
for (UInt p = 0; p < this->nb_proc; ++p) {
if (p != this->root) {
AKANTU_DEBUG_INFO(
"Sending empty connectivities informations to proc "
<< p << " TAG("
<< Tag::genTag(this->rank, this->message_count, Tag::_SIZES)
<< ")");
comm.send(size, p,
Tag::genTag(this->rank, this->message_count, Tag::_SIZES));
}
}
}
}
/* ------------------------------------------------------------------------ */
void MasterElementInfoPerProc::synchronizeConnectivities() {
const auto & partition_num =
this->partition.getPartition(this->type, _not_ghost);
const auto & ghost_partition =
this->partition.getGhostPartitionCSR()(this->type, _not_ghost);
std::vector<Array<UInt>> buffers(this->nb_proc);
const auto & connectivities =
this->mesh.getConnectivity(this->type, _not_ghost);
/// copying the local connectivity
for (auto && part_conn :
zip(partition_num,
make_view(connectivities, this->nb_nodes_per_element))) {
auto && part = std::get<0>(part_conn);
auto && conn = std::get<1>(part_conn);
for (UInt i = 0; i < conn.size(); ++i) {
buffers[part].push_back(conn[i]);
}
}
/// copying the connectivity of ghost element
for (auto && tuple :
enumerate(make_view(connectivities, this->nb_nodes_per_element))) {
auto && el = std::get<0>(tuple);
auto && conn = std::get<1>(tuple);
for (auto part = ghost_partition.begin(el); part != ghost_partition.end(el);
++part) {
UInt proc = *part;
for (UInt i = 0; i < conn.size(); ++i) {
buffers[proc].push_back(conn[i]);
}
}
}
#ifndef AKANTU_NDEBUG
for (auto p : arange(this->nb_proc)) {
UInt size = this->nb_nodes_per_element *
(this->all_nb_local_element[p] + this->all_nb_ghost_element[p]);
AKANTU_DEBUG_ASSERT(
buffers[p].size() == size,
"The connectivity data packed in the buffer are not correct");
}
#endif
/// send all connectivity and ghost information to all processors
std::vector<CommunicationRequest> requests;
for (auto p : arange(this->nb_proc)) {
if (p == this->root)
continue;
auto && tag =
Tag::genTag(this->rank, this->message_count, Tag::_CONNECTIVITY);
AKANTU_DEBUG_INFO("Sending connectivities to proc " << p << " TAG(" << tag
<< ")");
requests.push_back(comm.asyncSend(buffers[p], p, tag));
}
Array<UInt> & old_nodes = this->getNodesGlobalIds();
/// create the renumbered connectivity
AKANTU_DEBUG_INFO("Renumbering local connectivities");
MeshUtils::renumberMeshNodes(mesh, buffers[root], all_nb_local_element[root],
all_nb_ghost_element[root], type, old_nodes);
comm.waitAll(requests);
comm.freeCommunicationRequest(requests);
}
/* ------------------------------------------------------------------------ */
void MasterElementInfoPerProc::synchronizePartitions() {
const auto & partition_num =
this->partition.getPartition(this->type, _not_ghost);
const auto & ghost_partition =
this->partition.getGhostPartitionCSR()(this->type, _not_ghost);
std::vector<Array<UInt>> buffers(this->partition.getNbPartition());
/// splitting the partition information to send them to processors
Vector<UInt> count_by_proc(nb_proc, 0);
for (UInt el = 0; el < nb_element; ++el) {
UInt proc = partition_num(el);
buffers[proc].push_back(ghost_partition.getNbCols(el));
UInt i(0);
for (auto part = ghost_partition.begin(el); part != ghost_partition.end(el);
++part, ++i) {
buffers[proc].push_back(*part);
}
}
for (UInt el = 0; el < nb_element; ++el) {
UInt i(0);
for (auto part = ghost_partition.begin(el); part != ghost_partition.end(el);
++part, ++i) {
buffers[*part].push_back(partition_num(el));
}
}
#ifndef AKANTU_NDEBUG
for (UInt p = 0; p < this->nb_proc; ++p) {
AKANTU_DEBUG_ASSERT(buffers[p].size() == (this->all_nb_ghost_element[p] +
this->all_nb_element_to_send[p]),
"Data stored in the buffer are most probably wrong");
}
#endif
std::vector<CommunicationRequest> requests;
/// last data to compute the communication scheme
for (UInt p = 0; p < this->nb_proc; ++p) {
if (p == this->root)
continue;
auto && tag =
Tag::genTag(this->rank, this->message_count, Tag::_PARTITIONS);
AKANTU_DEBUG_INFO("Sending partition informations to proc " << p << " TAG("
<< tag << ")");
requests.push_back(comm.asyncSend(buffers[p], p, tag));
}
if (Mesh::getSpatialDimension(this->type) ==
this->mesh.getSpatialDimension()) {
AKANTU_DEBUG_INFO("Creating communications scheme");
this->fillCommunicationScheme(buffers[this->rank]);
}
comm.waitAll(requests);
comm.freeCommunicationRequest(requests);
}
/* -------------------------------------------------------------------------- */
void MasterElementInfoPerProc::synchronizeTags() {
AKANTU_DEBUG_IN();
if (this->nb_tags == 0) {
AKANTU_DEBUG_OUT();
return;
}
/// tag info
auto tag_names = mesh.getTagNames(type);
// Make sure the tags are sorted (or at least not in random order),
// because they come from a map !!
std::sort(tag_names.begin(), tag_names.end());
// Sending information about the tags in mesh_data: name, data type and
// number of components of the underlying array associated to the current
// type
DynamicCommunicationBuffer mesh_data_sizes_buffer;
for (auto && tag_name : tag_names) {
mesh_data_sizes_buffer << tag_name;
mesh_data_sizes_buffer << mesh.getTypeCode(tag_name);
mesh_data_sizes_buffer << mesh.getNbComponent(tag_name, type);
}
AKANTU_DEBUG_INFO(
"Broadcasting the size of the information about the mesh data tags: ("
<< mesh_data_sizes_buffer.size() << ").");
AKANTU_DEBUG_INFO(
"Broadcasting the information about the mesh data tags, addr "
<< (void *)mesh_data_sizes_buffer.storage());
comm.broadcast(mesh_data_sizes_buffer, root);
if (mesh_data_sizes_buffer.size() == 0)
return;
// Sending the actual data to each processor
std::vector<DynamicCommunicationBuffer> buffers(nb_proc);
// Loop over each tag for the current type
for (auto && tag_name : tag_names) {
// Type code of the current tag (i.e. the tag named *names_it)
this->fillTagBuffer(buffers, tag_name);
}
std::vector<CommunicationRequest> requests;
for (UInt p = 0; p < nb_proc; ++p) {
if (p == root)
continue;
auto && tag = Tag::genTag(this->rank, this->message_count, Tag::_MESH_DATA);
AKANTU_DEBUG_INFO("Sending " << buffers[p].size()
<< " bytes of mesh data to proc " << p
<< " TAG(" << tag << ")");
requests.push_back(comm.asyncSend(buffers[p], p, tag));
}
// Loop over each tag for the current type
for (auto && tag_name : tag_names) {
// Reinitializing the mesh data on the master
this->fillMeshData(buffers[root], tag_name, mesh.getTypeCode(tag_name),
mesh.getNbComponent(tag_name, type));
}
comm.waitAll(requests);
comm.freeCommunicationRequest(requests);
requests.clear();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
template <typename T>
void MasterElementInfoPerProc::fillTagBufferTemplated(
std::vector<DynamicCommunicationBuffer> & buffers,
const std::string & tag_name) {
const auto & data = mesh.getElementalDataArray<T>(tag_name, type);
const auto & partition_num =
this->partition.getPartition(this->type, _not_ghost);
const auto & ghost_partition =
this->partition.getGhostPartitionCSR()(this->type, _not_ghost);
// Not possible to use the iterator because it potentially triggers the
// creation of complex
// type templates (such as akantu::Vector< std::vector<Element> > which don't
// implement the right interface
// (e.g. operator<< in that case).
// typename Array<T>::template const_iterator< Vector<T> > data_it =
// data.begin(data.getNbComponent());
// typename Array<T>::template const_iterator< Vector<T> > data_end =
// data.end(data.getNbComponent());
const T * data_it = data.storage();
const T * data_end = data.storage() + data.size() * data.getNbComponent();
const UInt * part = partition_num.storage();
/// copying the data, element by element
for (; data_it != data_end; ++part) {
for (UInt j(0); j < data.getNbComponent(); ++j, ++data_it) {
buffers[*part] << *data_it;
}
}
data_it = data.storage();
/// copying the data for the ghost element
for (UInt el(0); data_it != data_end;
data_it += data.getNbComponent(), ++el) {
auto it = ghost_partition.begin(el);
auto end = ghost_partition.end(el);
for (; it != end; ++it) {
UInt proc = *it;
for (UInt j(0); j < data.getNbComponent(); ++j) {
buffers[proc] << data_it[j];
}
}
}
}
/* -------------------------------------------------------------------------- */
void MasterElementInfoPerProc::fillTagBuffer(
std::vector<DynamicCommunicationBuffer> & buffers,
const std::string & tag_name) {
#define AKANTU_DISTRIBUTED_SYNHRONIZER_TAG_DATA(r, extra_param, elem) \
- case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
+ case MeshDataTypeCode::BOOST_PP_TUPLE_ELEM(2, 0, elem): { \
this->fillTagBufferTemplated<BOOST_PP_TUPLE_ELEM(2, 1, elem)>(buffers, \
tag_name); \
break; \
}
MeshDataTypeCode data_type_code = mesh.getTypeCode(tag_name);
switch (data_type_code) {
BOOST_PP_SEQ_FOR_EACH(AKANTU_DISTRIBUTED_SYNHRONIZER_TAG_DATA, ,
AKANTU_MESH_DATA_TYPES)
default:
AKANTU_ERROR("Could not obtain the type of tag" << tag_name << "!");
break;
}
#undef AKANTU_DISTRIBUTED_SYNHRONIZER_TAG_DATA
}
/* -------------------------------------------------------------------------- */
void MasterElementInfoPerProc::synchronizeGroups() {
AKANTU_DEBUG_IN();
std::vector<DynamicCommunicationBuffer> buffers(nb_proc);
using ElementToGroup = std::vector<std::vector<std::string>>;
ElementToGroup element_to_group(nb_element);
for (auto & eg : mesh.iterateElementGroups()) {
const auto & name = eg.getName();
for (const auto & element : eg.getElements(type, _not_ghost)) {
element_to_group[element].push_back(name);
}
auto eit = eg.begin(type, _not_ghost);
if (eit != eg.end(type, _not_ghost))
const_cast<Array<UInt> &>(eg.getElements(type)).empty();
}
const auto & partition_num =
this->partition.getPartition(this->type, _not_ghost);
const auto & ghost_partition =
this->partition.getGhostPartitionCSR()(this->type, _not_ghost);
/// copying the data, element by element
for (auto && pair : zip(partition_num, element_to_group)) {
buffers[std::get<0>(pair)] << std::get<1>(pair);
}
/// copying the data for the ghost element
for (auto && pair : enumerate(element_to_group)) {
auto && el = std::get<0>(pair);
auto it = ghost_partition.begin(el);
auto end = ghost_partition.end(el);
for (; it != end; ++it) {
UInt proc = *it;
buffers[proc] << std::get<1>(pair);
}
}
std::vector<CommunicationRequest> requests;
for (UInt p = 0; p < this->nb_proc; ++p) {
if (p == this->rank)
continue;
auto && tag = Tag::genTag(this->rank, p, Tag::_ELEMENT_GROUP);
AKANTU_DEBUG_INFO("Sending element groups to proc " << p << " TAG(" << tag
<< ")");
requests.push_back(comm.asyncSend(buffers[p], p, tag));
}
this->fillElementGroupsFromBuffer(buffers[this->rank]);
comm.waitAll(requests);
comm.freeCommunicationRequest(requests);
requests.clear();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/synchronizer/node_info_per_processor.hh b/src/synchronizer/node_info_per_processor.hh
index 3583a3018..6eb275be4 100644
--- a/src/synchronizer/node_info_per_processor.hh
+++ b/src/synchronizer/node_info_per_processor.hh
@@ -1,124 +1,127 @@
/**
* @file node_info_per_processor.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Mar 16 2016
* @date last modification: Wed Nov 08 2017
*
* @brief Helper classes to create the distributed synchronizer and distribute
* a mesh
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communication_buffer.hh"
#include "mesh_accessor.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NODE_INFO_PER_PROCESSOR_HH__
#define __AKANTU_NODE_INFO_PER_PROCESSOR_HH__
namespace akantu {
class NodeSynchronizer;
class Communicator;
} // namespace akantu
/* -------------------------------------------------------------------------- */
namespace akantu {
class NodeInfoPerProc : protected MeshAccessor {
public:
NodeInfoPerProc(NodeSynchronizer & synchronizer, UInt message_cnt, UInt root);
void synchronize();
protected:
virtual void synchronizeNodes() = 0;
virtual void synchronizeTypes() = 0;
virtual void synchronizeGroups() = 0;
virtual void synchronizePeriodicity() = 0;
virtual void synchronizeTags() = 0;
+
protected:
template <class CommunicationBuffer>
void fillNodeGroupsFromBuffer(CommunicationBuffer & buffer);
void fillNodesType();
void fillCommunicationScheme(const Array<UInt> &);
void fillNodalData(DynamicCommunicationBuffer & buffer, std::string tag_name);
void fillPeriodicPairs(const Array<UInt> &, std::vector<UInt> &);
void receiveMissingPeriodic(DynamicCommunicationBuffer &);
protected:
NodeSynchronizer & synchronizer;
const Communicator & comm;
UInt rank;
UInt nb_proc;
UInt root;
Mesh & mesh;
UInt spatial_dimension;
UInt message_count;
};
/* -------------------------------------------------------------------------- */
class MasterNodeInfoPerProc : public NodeInfoPerProc {
public:
MasterNodeInfoPerProc(NodeSynchronizer & synchronizer, UInt message_cnt,
UInt root);
void synchronizeNodes() override;
void synchronizeTypes() override;
void synchronizeGroups() override;
void synchronizePeriodicity() override;
void synchronizeTags() override;
+
private:
void fillTagBuffers(std::vector<DynamicCommunicationBuffer> & buffers,
const std::string & tag_name);
/// get the list of nodes to send and send them
std::vector<Array<UInt>> nodes_per_proc;
Array<UInt> nb_nodes_per_proc;
Array<Real> all_nodes;
Array<NodeFlag> all_periodic_flags;
Array<Int> nodes_pranks;
};
/* -------------------------------------------------------------------------- */
class SlaveNodeInfoPerProc : public NodeInfoPerProc {
public:
SlaveNodeInfoPerProc(NodeSynchronizer & synchronizer, UInt message_cnt,
UInt root);
void synchronizeNodes() override;
void synchronizeTypes() override;
void synchronizeGroups() override;
void synchronizePeriodicity() override;
void synchronizeTags() override;
+
private:
};
} // namespace akantu
#endif /* __AKANTU_NODE_INFO_PER_PROCESSOR_HH__ */
diff --git a/src/synchronizer/node_synchronizer.cc b/src/synchronizer/node_synchronizer.cc
index 9a95192a0..77e19ad67 100644
--- a/src/synchronizer/node_synchronizer.cc
+++ b/src/synchronizer/node_synchronizer.cc
@@ -1,226 +1,226 @@
/**
* @file node_synchronizer.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Nov 15 2017
*
* @brief Implementation of the node synchronizer
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "node_synchronizer.hh"
#include "mesh.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
NodeSynchronizer::NodeSynchronizer(Mesh & mesh, const ID & id,
MemoryID memory_id,
const bool register_to_event_manager,
EventHandlerPriority event_priority)
: SynchronizerImpl<UInt>(mesh.getCommunicator(), id, memory_id),
mesh(mesh) {
AKANTU_DEBUG_IN();
if (register_to_event_manager) {
this->mesh.registerEventHandler(*this, event_priority);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
NodeSynchronizer::~NodeSynchronizer() = default;
/* -------------------------------------------------------------------------- */
Int NodeSynchronizer::getRank(const UInt & node) const {
return this->mesh.getNodePrank(node);
}
/* -------------------------------------------------------------------------- */
void NodeSynchronizer::onNodesAdded(const Array<UInt> & /*nodes_list*/,
const NewNodesEvent &) {
std::map<UInt, std::vector<UInt>> nodes_per_proc;
// recreates fully the schemes due to changes of global ids
// \TODO add an event to handle global id changes
for (auto && data : communications.iterateSchemes(_recv)) {
auto & scheme = data.second;
scheme.resize(0);
}
for (auto && local_id : arange(mesh.getNbNodes())) {
if (not mesh.isSlaveNode(local_id))
continue; // local, master or pure ghost
auto global_id = mesh.getNodeGlobalId(local_id);
auto proc = mesh.getNodePrank(local_id);
AKANTU_DEBUG_ASSERT(
proc != -1,
"The node " << local_id << " does not have a valid associated prank");
nodes_per_proc[proc].push_back(global_id);
auto & scheme = communications.createScheme(proc, _recv);
scheme.push_back(local_id);
}
std::vector<CommunicationRequest> send_requests;
for (auto && pair : communications.iterateSchemes(_recv)) {
auto proc = pair.first;
AKANTU_DEBUG_ASSERT(proc != UInt(-1),
"For real I should send something to proc -1");
// if proc not in nodes_per_proc this should insert an empty array to send
send_requests.push_back(communicator.asyncSend(
nodes_per_proc[proc], proc, Tag::genTag(rank, proc, 0xcafe)));
}
for (auto && data : communications.iterateSchemes(_send)) {
auto proc = data.first;
auto & scheme = data.second;
CommunicationStatus status;
auto tag = Tag::genTag(proc, rank, 0xcafe);
communicator.probe<UInt>(proc, tag, status);
scheme.resize(status.size());
communicator.receive(scheme, proc, tag);
std::transform(scheme.begin(), scheme.end(), scheme.begin(),
[&](auto & gnode) { return mesh.getNodeLocalId(gnode); });
}
// communicator.receiveAnyNumber<UInt>(
// send_requests,
// [&](auto && proc, auto && nodes) {
// auto & scheme = communications.createScheme(proc, _send);
// scheme.resize(nodes.size());
// for (auto && data : enumerate(nodes)) {
// auto global_id = std::get<1>(data);
// auto local_id = mesh.getNodeLocalId(global_id);
// AKANTU_DEBUG_ASSERT(local_id != UInt(-1),
// "The global node " << global_id
// << "is not known on rank "
// << rank);
// scheme[std::get<0>(data)] = local_id;
// }
// },
// Tag::genTag(rank, count, 0xcafe));
// ++count;
communicator.waitAll(send_requests);
communicator.freeCommunicationRequest(send_requests);
}
/* -------------------------------------------------------------------------- */
UInt NodeSynchronizer::sanityCheckDataSize(const Array<UInt> & nodes,
const SynchronizationTag & tag,
bool from_comm_desc) const {
UInt size =
SynchronizerImpl<UInt>::sanityCheckDataSize(nodes, tag, from_comm_desc);
// global id
if (tag != SynchronizationTag::_giu_global_conn) {
size += sizeof(UInt) * nodes.size();
}
// flag
size += sizeof(NodeFlag) * nodes.size();
// positions
size += mesh.getSpatialDimension() * sizeof(Real) * nodes.size();
return size;
}
/* -------------------------------------------------------------------------- */
void NodeSynchronizer::packSanityCheckData(
CommunicationBuffer & buffer, const Array<UInt> & nodes,
const SynchronizationTag & tag) const {
auto dim = mesh.getSpatialDimension();
for (auto && node : nodes) {
if (tag != SynchronizationTag::_giu_global_conn) {
buffer << mesh.getNodeGlobalId(node);
}
buffer << mesh.getNodeFlag(node);
buffer << Vector<Real>(mesh.getNodes().begin(dim)[node]);
}
}
/* -------------------------------------------------------------------------- */
void NodeSynchronizer::unpackSanityCheckData(CommunicationBuffer & buffer,
const Array<UInt> & nodes,
const SynchronizationTag & tag,
UInt proc, UInt rank) const {
auto dim = mesh.getSpatialDimension();
- // std::set<SynchronizationTag> skip_conn_tags{SynchronizationTag::_smmc_facets_conn,
+ // std::set<SynchronizationTag>
+ // skip_conn_tags{SynchronizationTag::_smmc_facets_conn,
// SynchronizationTag::_giu_global_conn};
// bool is_skip_tag_conn = skip_conn_tags.find(tag) != skip_conn_tags.end();
auto periodic = [&](auto && flag) { return flag & NodeFlag::_periodic_mask; };
auto distrib = [&](auto && flag) { return flag & NodeFlag::_shared_mask; };
for (auto && node : nodes) {
if (tag != SynchronizationTag::_giu_global_conn) {
UInt global_id;
buffer >> global_id;
AKANTU_DEBUG_ASSERT(global_id == mesh.getNodeGlobalId(node),
"The nodes global ids do not match: "
<< global_id
<< " != " << mesh.getNodeGlobalId(node));
}
NodeFlag flag;
buffer >> flag;
AKANTU_DEBUG_ASSERT(
(periodic(flag) == periodic(mesh.getNodeFlag(node))) and
(((distrib(flag) == NodeFlag::_master) and
(distrib(mesh.getNodeFlag(node)) ==
NodeFlag::_slave)) or // master to slave
((distrib(flag) == NodeFlag::_slave) and
(distrib(mesh.getNodeFlag(node)) ==
NodeFlag::_master)) or // reverse comm slave to master
(distrib(mesh.getNodeFlag(node)) ==
NodeFlag::_pure_ghost or // pure ghost nodes
distrib(flag) == NodeFlag::_pure_ghost)),
- "The node flags: "
- << flag << " and " << mesh.getNodeFlag(node));
+ "The node flags: " << flag << " and " << mesh.getNodeFlag(node));
Vector<Real> pos_remote(dim);
buffer >> pos_remote;
Vector<Real> pos(mesh.getNodes().begin(dim)[node]);
auto dist = pos_remote.distance(pos);
if (not Math::are_float_equal(dist, 0.)) {
AKANTU_EXCEPTION("Unpacking an unknown value for the node "
<< node << "(position " << pos << " != buffer "
<< pos_remote << ") [" << dist << "] - tag: " << tag
<< " comm from " << proc << " to " << rank);
}
}
}
/* -------------------------------------------------------------------------- */
} // namespace akantu
diff --git a/src/synchronizer/node_synchronizer.hh b/src/synchronizer/node_synchronizer.hh
index bc018ec87..9d263f97d 100644
--- a/src/synchronizer/node_synchronizer.hh
+++ b/src/synchronizer/node_synchronizer.hh
@@ -1,127 +1,128 @@
/**
* @file node_synchronizer.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Nov 08 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Synchronizer for nodal information
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_events.hh"
#include "synchronizer_impl.hh"
/* -------------------------------------------------------------------------- */
#include <unordered_map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_NODE_SYNCHRONIZER_HH__
#define __AKANTU_NODE_SYNCHRONIZER_HH__
namespace akantu {
class NodeSynchronizer : public MeshEventHandler,
public SynchronizerImpl<UInt> {
public:
NodeSynchronizer(Mesh & mesh, const ID & id = "element_synchronizer",
MemoryID memory_id = 0,
const bool register_to_event_manager = true,
EventHandlerPriority event_priority = _ehp_synchronizer);
~NodeSynchronizer() override;
/* ------------------------------------------------------------------------ */
/// Uses the synchronizer to perform a reduction on the vector
template <template <class> class Op, typename T>
void reduceSynchronize(Array<T> & array) const;
/* ------------------------------------------------------------------------ */
template <typename T> void synchronizeData(Array<T> & array) const;
friend class NodeInfoPerProc;
UInt sanityCheckDataSize(const Array<UInt> & nodes,
const SynchronizationTag & tag,
bool from_comm_desc) const override;
void packSanityCheckData(CommunicationBuffer & buffer,
const Array<UInt> & nodes,
const SynchronizationTag & /*tag*/) const override;
void unpackSanityCheckData(CommunicationBuffer & buffer,
const Array<UInt> & nodes,
const SynchronizationTag & tag, UInt proc,
UInt rank) const override;
/// function to implement to react on akantu::NewNodesEvent
void onNodesAdded(const Array<UInt> &, const NewNodesEvent &) override;
/// function to implement to react on akantu::RemovedNodesEvent
void onNodesRemoved(const Array<UInt> &, const Array<UInt> &,
const RemovedNodesEvent &) override {}
/// function to implement to react on akantu::NewElementsEvent
void onElementsAdded(const Array<Element> &,
const NewElementsEvent &) override {}
/// function to implement to react on akantu::RemovedElementsEvent
void onElementsRemoved(const Array<Element> &,
const ElementTypeMapArray<UInt> &,
const RemovedElementsEvent &) override {}
/// function to implement to react on akantu::ChangedElementsEvent
void onElementsChanged(const Array<Element> &, const Array<Element> &,
const ElementTypeMapArray<UInt> &,
const ChangedElementsEvent &) override {}
/* ------------------------------------------------------------------------ */
NodeSynchronizer & operator=(const NodeSynchronizer & other) {
copySchemes(other);
return *this;
}
public:
AKANTU_GET_MACRO(Mesh, mesh, Mesh &);
protected:
Int getRank(const UInt & node) const final;
protected:
Mesh & mesh;
// std::unordered_map<UInt, Int> node_to_prank;
};
/* -------------------------------------------------------------------------- */
template <typename T>
void NodeSynchronizer::synchronizeData(Array<T> & array) const {
SimpleUIntDataAccessor<T> data_accessor(array, SynchronizationTag::_whatever);
this->synchronizeOnce(data_accessor, SynchronizationTag::_whatever);
}
/* -------------------------------------------------------------------------- */
template <template <class> class Op, typename T>
void NodeSynchronizer::reduceSynchronize(Array<T> & array) const {
- ReduceDataAccessor<UInt, Op, T> data_accessor(array, SynchronizationTag::_whatever);
+ ReduceDataAccessor<UInt, Op, T> data_accessor(array,
+ SynchronizationTag::_whatever);
this->slaveReductionOnceImpl(data_accessor, SynchronizationTag::_whatever);
this->synchronizeData(array);
}
} // namespace akantu
#endif /* __AKANTU_NODE_SYNCHRONIZER_HH__ */
diff --git a/src/synchronizer/periodic_node_synchronizer.hh b/src/synchronizer/periodic_node_synchronizer.hh
index 3bed7ba54..fd8df8494 100644
--- a/src/synchronizer/periodic_node_synchronizer.hh
+++ b/src/synchronizer/periodic_node_synchronizer.hh
@@ -1,92 +1,94 @@
/**
* @file periodic_node_synchronizer.hh
*
* @author Nicolas Richart
*
* @date creation Tue May 29 2018
*
* @brief PeriodicNodeSynchronizer definition
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "node_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PERIODIC_NODE_SYNCHRONIZER_HH__
#define __AKANTU_PERIODIC_NODE_SYNCHRONIZER_HH__
namespace akantu {
class PeriodicNodeSynchronizer : public NodeSynchronizer {
public:
PeriodicNodeSynchronizer(
Mesh & mesh, const ID & id = "periodic_node_synchronizer",
MemoryID memory_id = 0, const bool register_to_event_manager = true,
EventHandlerPriority event_priority = _ehp_synchronizer);
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
void update();
/// Uses the synchronizer to perform a reduction on the vector
template <template <class> class Op, typename T>
void reduceSynchronizeWithPBCSlaves(Array<T> & array) const;
/// synchronize ghosts without state
void synchronizeOnceImpl(DataAccessor<UInt> & data_accessor,
const SynchronizationTag & tag) const override;
// /// asynchronous synchronization of ghosts
// void asynchronousSynchronizeImpl(const DataAccessor<UInt> & data_accessor,
// const SynchronizationTag & tag) override;
/// wait end of asynchronous synchronization of ghosts
void waitEndSynchronizeImpl(DataAccessor<UInt> & data_accessor,
const SynchronizationTag & tag) override;
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
// NodeSynchronizer master_to_slaves_synchronizer;
Array<UInt> masters_list;
Array<UInt> slaves_list;
};
/* -------------------------------------------------------------------------- */
template <template <class> class Op, typename T>
void PeriodicNodeSynchronizer::reduceSynchronizeWithPBCSlaves(
Array<T> & array) const {
- ReduceDataAccessor<UInt, Op, T> data_accessor(array, SynchronizationTag::_whatever);
- auto size = data_accessor.getNbData(slaves_list, SynchronizationTag::_whatever);
+ ReduceDataAccessor<UInt, Op, T> data_accessor(array,
+ SynchronizationTag::_whatever);
+ auto size =
+ data_accessor.getNbData(slaves_list, SynchronizationTag::_whatever);
CommunicationBuffer buffer(size);
data_accessor.packData(buffer, slaves_list, SynchronizationTag::_whatever);
data_accessor.unpackData(buffer, masters_list, SynchronizationTag::_whatever);
this->reduceSynchronize<Op>(array);
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_PERIODIC_NODE_SYNCHRONIZER_HH__ */
diff --git a/src/synchronizer/synchronizer_registry.cc b/src/synchronizer/synchronizer_registry.cc
index f99fac614..f1e94eb9e 100644
--- a/src/synchronizer/synchronizer_registry.cc
+++ b/src/synchronizer/synchronizer_registry.cc
@@ -1,120 +1,120 @@
/**
* @file synchronizer_registry.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Jun 16 2011
* @date last modification: Wed Nov 15 2017
*
* @brief Registry of synchronizers
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "synchronizer_registry.hh"
#include "synchronizer.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
/* -------------------------------------------------------------------------- */
SynchronizerRegistry::SynchronizerRegistry() {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
SynchronizerRegistry::~SynchronizerRegistry() {
AKANTU_DEBUG_IN();
synchronizers.clear();
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SynchronizerRegistry::registerDataAccessor(
DataAccessorBase & data_accessor) {
this->data_accessor = &data_accessor;
}
/* -------------------------------------------------------------------------- */
void SynchronizerRegistry::synchronize(SynchronizationTag tag) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(data_accessor != nullptr, "No data accessor set.");
std::pair<Tag2Sync::iterator, Tag2Sync::iterator> range =
synchronizers.equal_range(tag);
for (auto it = range.first; it != range.second; ++it) {
it->second->synchronize(*data_accessor, tag);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SynchronizerRegistry::asynchronousSynchronize(SynchronizationTag tag) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(data_accessor != nullptr, "No data accessor set.");
std::pair<Tag2Sync::iterator, Tag2Sync::iterator> range =
synchronizers.equal_range(tag);
for (auto it = range.first; it != range.second; ++it) {
(*it).second->asynchronousSynchronize(*data_accessor, tag);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SynchronizerRegistry::waitEndSynchronize(SynchronizationTag tag) {
AKANTU_DEBUG_IN();
AKANTU_DEBUG_ASSERT(data_accessor != nullptr, "No data accessor set.");
std::pair<Tag2Sync::iterator, Tag2Sync::iterator> range =
synchronizers.equal_range(tag);
for (auto it = range.first; it != range.second; ++it) {
(*it).second->waitEndSynchronize(*data_accessor, tag);
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
void SynchronizerRegistry::registerSynchronizer(Synchronizer & synchronizer,
SynchronizationTag tag) {
AKANTU_DEBUG_IN();
synchronizers.insert(
std::pair<SynchronizationTag, Synchronizer *>(tag, &synchronizer));
AKANTU_DEBUG_OUT();
}
-} // akantu
+} // namespace akantu
diff --git a/src/synchronizer/synchronizer_registry.hh b/src/synchronizer/synchronizer_registry.hh
index 54c2026ee..1789f7796 100644
--- a/src/synchronizer/synchronizer_registry.hh
+++ b/src/synchronizer/synchronizer_registry.hh
@@ -1,90 +1,90 @@
/**
* @file synchronizer_registry.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Sun Dec 03 2017
*
* @brief Registry of synchronizers
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
/* -------------------------------------------------------------------------- */
#include <map>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SYNCHRONIZER_REGISTRY_HH__
#define __AKANTU_SYNCHRONIZER_REGISTRY_HH__
namespace akantu {
class DataAccessorBase;
class Synchronizer;
-}
+} // namespace akantu
namespace akantu {
class SynchronizerRegistry {
/* ------------------------------------------------------------------------ */
/* Constructors/Destructors */
/* ------------------------------------------------------------------------ */
public:
SynchronizerRegistry();
virtual ~SynchronizerRegistry();
/* ------------------------------------------------------------------------ */
/* Methods */
/* ------------------------------------------------------------------------ */
public:
/// synchronize operation
void synchronize(SynchronizationTag tag);
/// asynchronous synchronization
void asynchronousSynchronize(SynchronizationTag tag);
/// wait end of asynchronous synchronization
void waitEndSynchronize(SynchronizationTag tag);
/// register a new synchronization
void registerSynchronizer(Synchronizer & synchronizer,
SynchronizationTag tag);
/// Register a different data accessor.
void registerDataAccessor(DataAccessorBase & data_accessor);
/* ------------------------------------------------------------------------ */
/* Class Members */
/* ------------------------------------------------------------------------ */
private:
using Tag2Sync = std::multimap<SynchronizationTag, Synchronizer *>;
/// list of registered synchronization
Tag2Sync synchronizers;
/// data accessor that will permit to do the pack/unpack things
DataAccessorBase * data_accessor{nullptr};
};
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SYNCHRONIZER_REGISTRY_HH__ */
diff --git a/src/synchronizer/synchronizer_tmpl.hh b/src/synchronizer/synchronizer_tmpl.hh
index 9fae003aa..11ce4e72c 100644
--- a/src/synchronizer/synchronizer_tmpl.hh
+++ b/src/synchronizer/synchronizer_tmpl.hh
@@ -1,137 +1,137 @@
/**
* @file synchronizer_tmpl.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 07 2016
* @date last modification: Thu May 11 2017
*
* @brief Implementation of the helper classes for the synchronizer
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
#include "data_accessor.hh"
#include "synchronizer.hh"
#include "synchronizer_impl.hh"
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_SYNCHRONIZER_TMPL_HH__
#define __AKANTU_SYNCHRONIZER_TMPL_HH__
namespace akantu {
template <class DataAccessorT>
void Synchronizer::slaveReductionOnce(DataAccessorT & data_accessor,
const SynchronizationTag & tag) const {
if (const auto * synch_el =
dynamic_cast<const SynchronizerImpl<Element> *>(this)) {
synch_el->slaveReductionOnceImpl(
dynamic_cast<DataAccessor<Element> &>(data_accessor), tag);
} else if (const auto * synch_dof =
dynamic_cast<const SynchronizerImpl<UInt> *>(this)) {
synch_dof->slaveReductionOnceImpl(
dynamic_cast<DataAccessor<UInt> &>(data_accessor), tag);
} else {
AKANTU_EXCEPTION("You synchronizer is not of a known type");
}
}
template <class DataAccessorT>
void Synchronizer::synchronizeOnce(DataAccessorT & data_accessor,
const SynchronizationTag & tag) const {
if (const auto * synch_el =
dynamic_cast<const SynchronizerImpl<Element> *>(this)) {
synch_el->synchronizeOnceImpl(
dynamic_cast<DataAccessor<Element> &>(data_accessor), tag);
} else if (const auto * synch_dof =
dynamic_cast<const SynchronizerImpl<UInt> *>(this)) {
synch_dof->synchronizeOnceImpl(
dynamic_cast<DataAccessor<UInt> &>(data_accessor), tag);
} else {
AKANTU_EXCEPTION("You synchronizer is not of a known type");
}
}
/// synchronize ghosts
template <class DataAccessorT>
void Synchronizer::synchronize(DataAccessorT & data_accessor,
const SynchronizationTag & tag) {
if (auto * synch_el = dynamic_cast<SynchronizerImpl<Element> *>(this)) {
synch_el->synchronizeImpl(
dynamic_cast<DataAccessor<Element> &>(data_accessor), tag);
} else if (auto * synch_dof = dynamic_cast<SynchronizerImpl<UInt> *>(this)) {
synch_dof->synchronizeImpl(
dynamic_cast<DataAccessor<UInt> &>(data_accessor), tag);
} else {
AKANTU_EXCEPTION("You synchronizer is not of a known type");
}
}
/* -------------------------------------------------------------------------- */
template <class DataAccessorT>
void Synchronizer::asynchronousSynchronize(const DataAccessorT & data_accessor,
const SynchronizationTag & tag) {
if (auto * synch_el = dynamic_cast<SynchronizerImpl<Element> *>(this)) {
synch_el->asynchronousSynchronizeImpl(
dynamic_cast<const DataAccessor<Element> &>(data_accessor), tag);
} else if (auto * synch_dof = dynamic_cast<SynchronizerImpl<UInt> *>(this)) {
synch_dof->asynchronousSynchronizeImpl(
dynamic_cast<const DataAccessor<UInt> &>(data_accessor), tag);
} else {
AKANTU_EXCEPTION("You synchronizer is not of a known type");
}
}
/* -------------------------------------------------------------------------- */
template <class DataAccessorT>
void Synchronizer::waitEndSynchronize(DataAccessorT & data_accessor,
const SynchronizationTag & tag) {
if (auto * synch_el = dynamic_cast<SynchronizerImpl<Element> *>(this)) {
synch_el->waitEndSynchronizeImpl(
dynamic_cast<DataAccessor<Element> &>(data_accessor), tag);
} else if (auto * synch_dof = dynamic_cast<SynchronizerImpl<UInt> *>(this)) {
synch_dof->waitEndSynchronizeImpl(
dynamic_cast<DataAccessor<UInt> &>(data_accessor), tag);
} else {
AKANTU_EXCEPTION("You synchronizer is not of a known type");
}
}
/// compute buffer size for a given tag and data accessor
template <class DataAccessorT>
void Synchronizer::computeBufferSize(const DataAccessorT & data_accessor,
const SynchronizationTag & tag) {
if (auto * synch_el = dynamic_cast<SynchronizerImpl<Element> *>(this)) {
synch_el->computeBufferSizeImpl(
dynamic_cast<const DataAccessor<Element> &>(data_accessor), tag);
} else if (auto * synch_dof = dynamic_cast<SynchronizerImpl<UInt> *>(this)) {
synch_dof->computeBufferSizeImpl(
dynamic_cast<const DataAccessor<UInt> &>(data_accessor), tag);
} else {
AKANTU_EXCEPTION("You synchronizer is not of a known type");
}
}
-} // akantu
+} // namespace akantu
#endif /* __AKANTU_SYNCHRONIZER_TMPL_HH__ */
diff --git a/test/ci/Dockerfile b/test/ci/Dockerfile
index 55c6d9438..5cb74a1b5 100644
--- a/test/ci/Dockerfile
+++ b/test/ci/Dockerfile
@@ -1,21 +1,22 @@
FROM debian:testing
MAINTAINER Nicolas Richart <nicolas.richart@epfl.ch>
# Make sure the package repository is up to date.
RUN apt-get -qq update && apt-get -qq -y install \
g++ gfortran cmake \
libmumps-seq-dev libscotch-dev \
libboost-dev libopenblas-dev \
python3 python3-dev \
python3-numpy python3-scipy python3-mpi4py\
python3-phabricator python3-click python3-yaml \
+ python3-pytest \
swig3.0 gmsh curl flake8 \
git clang-format xsltproc jq \
php-cli php-curl php-xml \
&& rm -rf /var/lib/apt/lists/*
# apt-get on one line due to https://docs.docker.com/develop/develop-images/dockerfile_best-practices/#run
RUN git clone https://github.com/phacility/libphutil.git /libphutil
RUN git clone https://github.com/phacility/arcanist.git /arcanist
ENV PATH="$PATH:/arcanist/bin/"
\ No newline at end of file
diff --git a/test/ci/scripts/.arcconfig b/test/ci/scripts/.arcconfig
new file mode 100644
index 000000000..e2bfc0aeb
--- /dev/null
+++ b/test/ci/scripts/.arcconfig
@@ -0,0 +1,5 @@
+{
+ "repository.callsign" : "HBMJCI",
+ "phabricator.uri" : "https://c4science.ch/",
+ "projects": ["akantu", "tamaas"]
+}
diff --git a/test/ci/scripts/.arclint b/test/ci/scripts/.arclint
new file mode 100644
index 000000000..26e512f18
--- /dev/null
+++ b/test/ci/scripts/.arclint
@@ -0,0 +1,18 @@
+{
+ "linters": {
+ "python": {
+ "type": "flake8",
+ "include": [ "(\\.py$)", "(^hbm$)" ],
+ "exclude": "(^third-party/)",
+ "severity.rules": {
+ "(^E)": "error",
+ "(^W)": "warning",
+ "(^F)": "advice"
+ }
+ },
+
+ "merges": {
+ "type": "merge-conflict"
+ }
+ }
+}
diff --git a/test/ci/scripts/COPYING b/test/ci/scripts/COPYING
new file mode 100644
index 000000000..94a9ed024
--- /dev/null
+++ b/test/ci/scripts/COPYING
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ <program> Copyright (C) <year> <name of author>
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+<http://www.gnu.org/licenses/>.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+<http://www.gnu.org/philosophy/why-not-lgpl.html>.
diff --git a/test/ci/scripts/COPYING.lesser b/test/ci/scripts/COPYING.lesser
new file mode 100644
index 000000000..65c5ca88a
--- /dev/null
+++ b/test/ci/scripts/COPYING.lesser
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/test/ci/scripts/CTestResults.xml b/test/ci/scripts/CTestResults.xml
deleted file mode 100644
index f913ff9a5..000000000
--- a/test/ci/scripts/CTestResults.xml
+++ /dev/null
@@ -1,5337 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<Site BuildName="Linux-c++"
- BuildStamp="20190110-1339-Experimental"
- Name="5f330afc00f6"
- Generator="ctest-3.13.2"
- CompilerName="/usr/bin/c++"
- CompilerVersion="8.2.0"
- OSName="Linux"
- Hostname="5b4962022198"
- OSRelease="3.10.0-693.17.1.el7.x86_64"
- OSVersion="#1 SMP Thu Jan 25 20:13:58 UTC 2018"
- OSPlatform="x86_64"
- Is64Bits="1"
- VendorString="GenuineIntel"
- VendorID="Intel Corporation"
- FamilyID="6"
- ModelID="58"
- ProcessorCacheSize="4096"
- NumberOfLogicalCPU="4"
- NumberOfPhysicalCPU="4"
- TotalVirtualMemory="1023"
- TotalPhysicalMemory="7983"
- LogicalProcessorsPerPhysical="1"
- ProcessorClockFrequency="2593.75"
- >
- <Testing>
- <StartDateTime>Jan 10 14:51 UTC</StartDateTime>
- <StartTestTime>1547131883</StartTestTime>
- <TestList>
- <Test>./test/test_common/test_grid</Test>
- <Test>./test/test_common/test_common_gtest</Test>
- <Test>./test/test_static_memory/test_static_memory</Test>
- <Test>./test/test_fe_engine/test_mesh_data_string</Test>
- <Test>./test/test_fe_engine/test_mesh_data_UInt</Test>
- <Test>./test/test_fe_engine/test_mesh_boundary</Test>
- <Test>./test/test_fe_engine/test_facet_element_mapping</Test>
- <Test>./test/test_fe_engine/test_fe_engine_gtest</Test>
- <Test>./test/test_mesh_utils/test_purify_mesh</Test>
- <Test>./test/test_mesh_utils/test_mesh_iterators</Test>
- <Test>./test/test_mesh_utils/test_mesh_io/test_mesh_io_msh</Test>
- <Test>./test/test_mesh_utils/test_mesh_io/test_mesh_io_msh_physical_names</Test>
- <Test>./test/test_mesh_utils/test_pbc_tweak/test_pbc_tweak</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_3</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_6</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_4</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_8</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_linear</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_quadratic</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_tetrahedron_10</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_8</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_20</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_6</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_15</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_linear</Test>
- <Test>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_quadratic</Test>
- <Test>./test/test_mesh_utils/test_mesh_partitionate/test_mesh_partitionate_scotch</Test>
- <Test>./test/test_mesh_utils/test_mesh_partitionate/test_mesh_partitionate_mesh_data</Test>
- <Test>./test/test_model/patch_tests/patch_test_linear_gtest</Test>
- <Test>./test/test_model/patch_tests/test_linear_elastic_explicit_python</Test>
- <Test>./test/test_model/patch_tests/test_linear_elastic_static_python</Test>
- <Test>./test/test_model/test_model_solver/test_dof_manager_default</Test>
- <Test>./test/test_model/test_model_solver/test_model_solver</Test>
- <Test>./test/test_model/test_model_solver/test_model_solver_dynamic_explicit</Test>
- <Test>./test/test_model/test_model_solver/test_model_solver_dynamic_implicit</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_reassign_material_4</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_reassign_material_2</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_reassign_material_1</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_material_eigenstrain</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_material_selector</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_gtest_4</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_gtest_2</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_gtest_1</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_local_material</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_interpolate_stress</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_orthotropic</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_mazars</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_multi_material_elastic</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_gtest</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation_tension</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_standard_linear_isotropic_hardening</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell/test_material_viscoelasti_maxwell_relaxation</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_cohesive/test_solid_mechanics_model_cohesive_gtest_1</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_cohesive/test_solid_mechanics_model_cohesive_gtest_2</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_gtest</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_buildfragments/test_cohesive_buildfragments</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion/test_cohesive_insertion_along_physical_surfaces</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_energies_gtest_1</Test>
- <Test>./test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_energies_gtest_2</Test>
- <Test>./test/test_solver/test_sparse_matrix_profile</Test>
- <Test>./test/test_solver/test_sparse_matrix_assemble</Test>
- <Test>./test/test_solver/test_sparse_matrix_product</Test>
- <Test>./test/test_solver/test_sparse_solver_mumps_4</Test>
- <Test>./test/test_solver/test_sparse_solver_mumps_2</Test>
- <Test>./test/test_solver/test_sparse_solver_mumps_1</Test>
- <Test>./test/test_io/test_parser/test_parser</Test>
- <Test>./test/test_io/test_dumper/test_dumper</Test>
- <Test>./test/test_synchronizer/test_dof_synchronizer_4</Test>
- <Test>./test/test_synchronizer/test_dof_synchronizer_2</Test>
- <Test>./test/test_synchronizer/test_dof_synchronizer_1</Test>
- <Test>./test/test_synchronizer/test_synchronizers_gtest_4</Test>
- <Test>./test/test_synchronizer/test_synchronizers_gtest_2</Test>
- <Test>./test/test_synchronizer/test_synchronizers_gtest_1</Test>
- <Test>./test/test_python_interface/test_multiple_init</Test>
- <Test>./test/test_python_interface/test_mesh_interface</Test>
- <Test>./test/test_python_interface/test_boundary_condition_functors</Test>
- </TestList>
- <Test Status="passed">
- <Name>test_grid</Name>
- <Path>./test/test_common</Path>
- <FullName>./test/test_common/test_grid</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_grid" "-e" "./test_grid" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_common"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.811359</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_grid" "-e" "./test_grid" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_common"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_common
-Executing the test test_grid
-Run ./test_grid
-SpatialGrid&lt;akantu::Element&gt; [
- + dimension : 2
- + lower bounds : {-1, -1}
- + upper bounds : {1, 1}
- + spacing : {0.2, 0.2}
- + center : {0, 0}
- + nb_cells : 88/100
-]
-
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_common_gtest</Name>
- <Path>./test/test_common</Path>
- <FullName>./test/test_common/test_common_gtest</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_common_gtest" "-e" "./test_common_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_common" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_common_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.930595</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_common_gtest" "-e" "./test_common_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_common" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_common_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_common
-Executing the test test_common_gtest
-Run ./test_common_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_common_gtest.xml
-[==========] Running 109 tests from 12 test cases.
-[----------] Global test environment set-up.
-[----------] 3 tests from TestCsrFixture
-[ RUN ] TestCsrFixture.CheckInsertion
-[ OK ] TestCsrFixture.CheckInsertion (20 ms)
-[ RUN ] TestCsrFixture.Iteration
-[ OK ] TestCsrFixture.Iteration (57 ms)
-[ RUN ] TestCsrFixture.ReverseIteration
-[ OK ] TestCsrFixture.ReverseIteration (59 ms)
-[----------] 3 tests from TestCsrFixture (136 ms total)
-
-[----------] 4 tests from TestZipFixutre
-[ RUN ] TestZipFixutre.SimpleTest
-[ OK ] TestZipFixutre.SimpleTest (0 ms)
-[ RUN ] TestZipFixutre.ConstTest
-[ OK ] TestZipFixutre.ConstTest (0 ms)
-[ RUN ] TestZipFixutre.MixteTest
-[ OK ] TestZipFixutre.MixteTest (0 ...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_static_memory</Name>
- <Path>./test/test_static_memory</Path>
- <FullName>./test/test_static_memory/test_static_memory</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_static_memory" "-e" "./test_static_memory" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_static_memory"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.783542</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_static_memory" "-e" "./test_static_memory" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_static_memory"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_static_memory
-Executing the test test_static_memory
-Run ./test_static_memory
-StaticMemory [
- + nb memories : 1
- Memory [
- + memory id : 0
- + nb vectors : 1
- Array&lt;int&gt; [
- + id : test_int
- + size : 2000
- + nb_component : 3
- + allocated size : 3000
- + memory size : 140.62KiByte
- + address : 0x561339005cb0
- ]
- + total size : 35.16KiByte
- ]
- + total size : 35.16KiByte
-]
-
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_data_string</Name>
- <Path>./test/test_fe_engine</Path>
- <FullName>./test/test_fe_engine/test_mesh_data_string</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_data_string" "-e" "./test_mesh_data_string" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.0308513</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_data_string" "-e" "./test_mesh_data_string" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine
-Executing the test test_mesh_data_string
-Run ./test_mesh_data_string
-Testing with type string and values "5","10"...
-Array&lt;std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, std::allocator&lt;char&gt; &gt;&gt; [
- + id : :mesh_data:string_data:_triangle_6
- + size : 2
- + nb_component : 1
- + allocated size : 2
- + memory size : 2.00KiByte
- + address : 0x557b52e98de0
-]
-
-4
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_data_UInt</Name>
- <Path>./test/test_fe_engine</Path>
- <FullName>./test/test_fe_engine/test_mesh_data_UInt</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_data_UInt" "-e" "./test_mesh_data_UInt" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.0295062</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_data_UInt" "-e" "./test_mesh_data_UInt" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine
-Executing the test test_mesh_data_UInt
-Run ./test_mesh_data_UInt
-Testing with type UInt and values 5,10...
-Array&lt;unsigned int&gt; [
- + id : :mesh_data:UInt_data:_triangle_6
- + size : 2
- + nb_component : 1
- + allocated size : 2000
- + memory size : 31.25KiByte
- + address : 0x55d00fbbbda0
-]
-
-1
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_boundary</Name>
- <Path>./test/test_fe_engine</Path>
- <FullName>./test/test_fe_engine/test_mesh_boundary</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_boundary" "-e" "./test_mesh_boundary" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.79937</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_boundary" "-e" "./test_mesh_boundary" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine
-Executing the test test_mesh_boundary
-Run ./test_mesh_boundary
-Loading the mesh.
-Examining mesh:
-Mesh [
- + id : mesh_names
- + spatial dimension : 3
- + nodes [
- Array&lt;double&gt; [
- + id : mesh_names:coordinates
- + size : 125
- + nb_component : 3
- + allocated size : 2000
- + memory size : 375.00KiByte
- + address : 0x56398f784460
- ]
- + connectivities [
- ElementTypeMapArray&lt;unsigned int&gt; [
- (not_ghost:_quadrangle_4) [
- Array&lt;unsigned int&gt; [
- + id : mesh_names:connectivities:_quadrangle_4
- + size : 96
- + nb_component : 4
- + allocated size : 2000
- + memory size : 125.00KiByte
- + address : 0x56398f790d30
- ]
- ]
- (not_ghost:_hexahedron_8) [
- Array&lt;unsigned int&gt; [
- + id : mesh_names:connectivities:_hexahedron_8
- + size : 64
- + nb_component : 8...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_facet_element_mapping</Name>
- <Path>./test/test_fe_engine</Path>
- <FullName>./test/test_fe_engine/test_facet_element_mapping</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_facet_element_mapping" "-e" "./test_facet_element_mapping" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.797762</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_facet_element_mapping" "-e" "./test_facet_element_mapping" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine
-Executing the test test_facet_element_mapping
-Run ./test_facet_element_mapping
-ELEMENT-SUBELEMENT MAPPING:
- Ghost type: not_ghost
- Element type: _hexahedron_8
- subelement_to_element:
- Array&lt;akantu::Element&gt; [
- + id : my_mesh:mesh_data:subelement_to_element:_hexahedron_8
- + size : 64
- + nb_component : 6
- + allocated size : 64
- + memory size : 54.00KiByte
- + address : 0x55c7edbeba80
- ]
- Element [_quadrangle_4, 0, not_ghost], Element [_quadrangle_4, 35, not_ghost], Element [_quadrangle_4, 51, not_ghost], ElementNull, ElementNull, ElementNull, for element 0
- Element [_quadrangle_4, 34, not_ghost], Element [_quadrangle_4, 55, not_ghost], ElementNull, ElementNull, ElementNull, ElementNull, for element 1
- Element [_quadrangle_4, 33, not_ghost], Element [_quadrangle_4, 59, not_ghost], ElementNull, ...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_fe_engine_gtest</Name>
- <Path>./test/test_fe_engine</Path>
- <FullName>./test/test_fe_engine/test_fe_engine_gtest</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_fe_engine_gtest" "-e" "./test_fe_engine_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_fe_engine_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>3.12487</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_fe_engine_gtest" "-e" "./test_fe_engine_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_fe_engine_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_fe_engine
-Executing the test test_fe_engine_gtest
-Run ./test_fe_engine_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_fe_engine_gtest.xml
-[==========] Running 120 tests from 84 test cases.
-[----------] Global test environment set-up.
-[----------] 1 test from Split1/TestGaussIntegrationFixture/0, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;, std::integral_constant&lt;unsigned long, 0ul&gt; &gt;
-[ RUN ] Split1/TestGaussIntegrationFixture/0.ArbitraryOrder
-[ OK ] Split1/TestGaussIntegrationFixture/0.ArbitraryOrder (5 ms)
-[----------] 1 test from Split1/TestGaussIntegrationFixture/0 (5 ms total)
-
-[----------] 1 test from Split1/TestGaussIntegrationFixture/1, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;, std::integral_constant&lt;unsigned long, 1ul&gt; &gt;
-[ RUN ] Split1/TestG...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_purify_mesh</Name>
- <Path>./test/test_mesh_utils</Path>
- <FullName>./test/test_mesh_utils/test_purify_mesh</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_purify_mesh" "-e" "./test_purify_mesh" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.788076</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_purify_mesh" "-e" "./test_purify_mesh" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils
-Executing the test test_purify_mesh
-Run ./test_purify_mesh
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_iterators</Name>
- <Path>./test/test_mesh_utils</Path>
- <FullName>./test/test_mesh_utils/test_mesh_iterators</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_iterators" "-e" "./test_mesh_iterators" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.796961</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_iterators" "-e" "./test_mesh_iterators" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils
-Executing the test test_mesh_iterators
-Run ./test_mesh_iterators
-extruded_surfaces
-initial_surfaces
-lines
-points
-v1
-v2
-extruded_surfaces_nodes
-initial_surfaces_nodes
-lines_nodes
-points_nodes
-v1_nodes
-v2_nodes
-0 extruded_surfaces
-1 initial_surfaces
-2 lines
-3 points
-4 v1
-5 v2
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_io_msh</Name>
- <Path>./test/test_mesh_utils/test_mesh_io</Path>
- <FullName>./test/test_mesh_utils/test_mesh_io/test_mesh_io_msh</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_io_msh" "-e" "./test_mesh_io_msh" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_io"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1.24573</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_io_msh" "-e" "./test_mesh_io_msh" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_io"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_io
-Executing the test test_mesh_io_msh
-Run ./test_mesh_io_msh
-Mesh [
- + id : mesh
- + spatial dimension : 3
- + nodes [
- Array&lt;double&gt; [
- + id : mesh:coordinates
- + size : 1114
- + nb_component : 3
- + allocated size : 2000
- + memory size : 375.00KiByte
- + address : 0x55c1af41d210
- ]
- + connectivities [
- ElementTypeMapArray&lt;unsigned int&gt; [
- (not_ghost:_point_1) [
- Array&lt;unsigned int&gt; [
- + id : mesh:connectivities:_point_1
- + size : 8
- + nb_component : 1
- + allocated size : 2000
- + memory size : 31.25KiByte
- + address : 0x55c1af429b50
- ]
- ]
- (not_ghost:_segment_2) [
- Array&lt;unsigned int&gt; [
- + id : mesh:connectivities:_segment_2
- + size : 120
- + nb_component : 2
- + allocated size : 2000
- + memory size : 62.50KiB...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_io_msh_physical_names</Name>
- <Path>./test/test_mesh_utils/test_mesh_io</Path>
- <FullName>./test/test_mesh_utils/test_mesh_io/test_mesh_io_msh_physical_names</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_io_msh_physical_names" "-e" "./test_mesh_io_msh_physical_names" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_io" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_mesh_io/test_mesh_io_msh_physical_names.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.796444</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_io_msh_physical_names" "-e" "./test_mesh_io_msh_physical_names" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_io" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_mesh_io/test_mesh_io_msh_physical_names.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_io
-Executing the test test_mesh_io_msh_physical_names
-Run ./test_mesh_io_msh_physical_names
-Element 0 (of type _quadrangle_4) has physical name Sides.
-Element 1 (of type _quadrangle_4) has physical name Sides.
-Element 2 (of type _quadrangle_4) has physical name Sides.
-Element 3 (of type _quadrangle_4) has physical name Sides.
-Element 4 (of type _quadrangle_4) has physical name Top.
-Element 5 (of type _quadrangle_4) has physical name Top.
-Element 6 (of type _quadrangle_4) has physical name Top.
-Element 7 (of type _quadrangle_4) has physical name Top.
-Element 8 (of type _quadrangle_4) has physical name Sides.
-Element 9 (of type _quadrangle_4) has physical name Sides.
-Element 10 (of type _quadrangle_4) has physical name Sides.
-Element 11 (of type _quadrangle_4) has physical name Sides.
-Element 12 (of type _quadrangle_4) has physical name Bottom.
-Element 13 (of type _quadrangle_4) has physical name Bottom.
-...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_pbc_tweak</Name>
- <Path>./test/test_mesh_utils/test_pbc_tweak</Path>
- <FullName>./test/test_mesh_utils/test_pbc_tweak/test_pbc_tweak</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_pbc_tweak" "-e" "./test_pbc_tweak" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_pbc_tweak"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.910628</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_pbc_tweak" "-e" "./test_pbc_tweak" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_pbc_tweak"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_pbc_tweak
-Executing the test test_pbc_tweak
-Run ./test_pbc_tweak
-&lt;1234&gt;[R0|S1] {1547131895556212} --- The connectivity vector for the type _hexahedron_8 created (getConnectivityPointer(): /home/jenkins/workspace/akantu-private-master-5327/src/mesh/mesh_inline_impl.cc:185)
-&lt;1234&gt;[R0|S1] {1547131895573213} --- There are not facets, add them in the mesh file or call the buildFacet method. (fillElementToSubElementsData(): /home/jenkins/workspace/akantu-private-master-5327/src/mesh_utils/mesh_utils.cc:1514)
-&lt;1234&gt;[R0|S1] {1547131895627216} --- Creating FEEngine boundary SolidMechanicsFEEngine (getFEEngineClassBoundary(): /home/jenkins/workspace/akantu-private-master-5327/src/model/model_inline_impl.cc:53)
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_triangle_3</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_3</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_triangle_3" "-e" "./test_buildfacets_triangle_3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_3.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.781012</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_triangle_3" "-e" "./test_buildfacets_triangle_3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_3.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_triangle_3
-Run ./test_buildfacets_triangle_3
-ElementToSubelement2
-_segment_2 0 connected to _triangle_3 0, _not_defined 4294967295,
-_segment_2 1 connected to _triangle_3 0, _triangle_3 1,
-_segment_2 2 connected to _triangle_3 0, _not_defined 4294967295,
-_segment_2 3 connected to _triangle_3 1, _triangle_3 4,
-_segment_2 4 connected to _triangle_3 1, _triangle_3 2,
-_segment_2 5 connected to _triangle_3 2, _triangle_3 3,
-_segment_2 6 connected to _triangle_3 2, _not_defined 4294967295,
-_segment_2 7 connected to _triangle_3 3, _triangle_3 6,
-_segment_2 8 connected to _triangle_3 3, _not_defined 4294967295,
-_segment_2 9 connected to _triangle_3 4, _not_defined 4294967295,
-_segment_2 10 connected to _triangle_3 4, _triangle_3 5,
-_segment_2 11 connected to _triangle_3 5, _not_defined 4294967295,
-_segment_2 12 connected to _triangle_3 5, _triang...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_triangle_6</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_6</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_triangle_6" "-e" "./test_buildfacets_triangle_6" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_6.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.773091</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_triangle_6" "-e" "./test_buildfacets_triangle_6" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_triangle_6.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_triangle_6
-Run ./test_buildfacets_triangle_6
-ElementToSubelement2
-_segment_3 0 connected to _triangle_6 0, _not_defined 4294967295,
-_segment_3 1 connected to _triangle_6 0, _triangle_6 1,
-_segment_3 2 connected to _triangle_6 0, _not_defined 4294967295,
-_segment_3 3 connected to _triangle_6 1, _triangle_6 4,
-_segment_3 4 connected to _triangle_6 1, _triangle_6 2,
-_segment_3 5 connected to _triangle_6 2, _triangle_6 3,
-_segment_3 6 connected to _triangle_6 2, _not_defined 4294967295,
-_segment_3 7 connected to _triangle_6 3, _triangle_6 6,
-_segment_3 8 connected to _triangle_6 3, _not_defined 4294967295,
-_segment_3 9 connected to _triangle_6 4, _not_defined 4294967295,
-_segment_3 10 connected to _triangle_6 4, _triangle_6 5,
-_segment_3 11 connected to _triangle_6 5, _not_defined 4294967295,
-_segment_3 12 connected to _triangle_6 5, _triang...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_quadrangle_4</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_4</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_quadrangle_4" "-e" "./test_buildfacets_quadrangle_4" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_4.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.779211</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_quadrangle_4" "-e" "./test_buildfacets_quadrangle_4" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_4.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_quadrangle_4
-Run ./test_buildfacets_quadrangle_4
-ElementToSubelement2
-_segment_2 0 connected to _quadrangle_4 0, _not_defined 4294967295,
-_segment_2 1 connected to _quadrangle_4 0, _quadrangle_4 2,
-_segment_2 2 connected to _quadrangle_4 0, _quadrangle_4 1,
-_segment_2 3 connected to _quadrangle_4 0, _not_defined 4294967295,
-_segment_2 4 connected to _quadrangle_4 1, _quadrangle_4 3,
-_segment_2 5 connected to _quadrangle_4 1, _not_defined 4294967295,
-_segment_2 6 connected to _quadrangle_4 1, _not_defined 4294967295,
-_segment_2 7 connected to _quadrangle_4 2, _not_defined 4294967295,
-_segment_2 8 connected to _quadrangle_4 2, _not_defined 4294967295,
-_segment_2 9 connected to _quadrangle_4 2, _quadrangle_4 3,
-_segment_2 10 connected to _quadrangle_4 3, _not_defined 4294967295,
-_segment_2 11 connected to _quadrangle_4 3, _not_defined 4294967...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_quadrangle_8</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_8</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_quadrangle_8" "-e" "./test_buildfacets_quadrangle_8" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_8.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.791376</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_quadrangle_8" "-e" "./test_buildfacets_quadrangle_8" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_quadrangle_8.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_quadrangle_8
-Run ./test_buildfacets_quadrangle_8
-ElementToSubelement2
-_segment_3 0 connected to _quadrangle_8 0, _not_defined 4294967295,
-_segment_3 1 connected to _quadrangle_8 0, _quadrangle_8 2,
-_segment_3 2 connected to _quadrangle_8 0, _quadrangle_8 1,
-_segment_3 3 connected to _quadrangle_8 0, _not_defined 4294967295,
-_segment_3 4 connected to _quadrangle_8 1, _quadrangle_8 3,
-_segment_3 5 connected to _quadrangle_8 1, _not_defined 4294967295,
-_segment_3 6 connected to _quadrangle_8 1, _not_defined 4294967295,
-_segment_3 7 connected to _quadrangle_8 2, _not_defined 4294967295,
-_segment_3 8 connected to _quadrangle_8 2, _not_defined 4294967295,
-_segment_3 9 connected to _quadrangle_8 2, _quadrangle_8 3,
-_segment_3 10 connected to _quadrangle_8 3, _not_defined 4294967295,
-_segment_3 11 connected to _quadrangle_8 3, _not_defined 4294967...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_mixed2d_linear</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_linear</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed2d_linear" "-e" "./test_buildfacets_mixed2d_linear" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_linear.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.777441</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed2d_linear" "-e" "./test_buildfacets_mixed2d_linear" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_linear.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_mixed2d_linear
-Run ./test_buildfacets_mixed2d_linear
-ElementToSubelement2
-_segment_2 0 connected to _triangle_3 0, _quadrangle_4 0,
-_segment_2 1 connected to _triangle_3 0, _triangle_3 2,
-_segment_2 2 connected to _triangle_3 0, _not_defined 4294967295,
-_segment_2 3 connected to _triangle_3 1, _quadrangle_4 1,
-_segment_2 4 connected to _triangle_3 1, _triangle_3 3,
-_segment_2 5 connected to _triangle_3 1, _triangle_3 2,
-_segment_2 6 connected to _triangle_3 2, _not_defined 4294967295,
-_segment_2 7 connected to _triangle_3 3, _not_defined 4294967295,
-_segment_2 8 connected to _triangle_3 3, _not_defined 4294967295,
-_segment_2 9 connected to _quadrangle_4 0, _not_defined 4294967295,
-_segment_2 10 connected to _quadrangle_4 0, _quadrangle_4 1,
-_segment_2 11 connected to _quadrangle_4 0, _not_defined 4294967295,
-_segment_2 12 connected to _q...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_mixed2d_quadratic</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_quadratic</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed2d_quadratic" "-e" "./test_buildfacets_mixed2d_quadratic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_quadratic.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.77115</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed2d_quadratic" "-e" "./test_buildfacets_mixed2d_quadratic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed2d_quadratic.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_mixed2d_quadratic
-Run ./test_buildfacets_mixed2d_quadratic
-ElementToSubelement2
-_segment_3 0 connected to _triangle_6 0, _quadrangle_8 0,
-_segment_3 1 connected to _triangle_6 0, _triangle_6 2,
-_segment_3 2 connected to _triangle_6 0, _not_defined 4294967295,
-_segment_3 3 connected to _triangle_6 1, _quadrangle_8 1,
-_segment_3 4 connected to _triangle_6 1, _triangle_6 3,
-_segment_3 5 connected to _triangle_6 1, _triangle_6 2,
-_segment_3 6 connected to _triangle_6 2, _not_defined 4294967295,
-_segment_3 7 connected to _triangle_6 3, _not_defined 4294967295,
-_segment_3 8 connected to _triangle_6 3, _not_defined 4294967295,
-_segment_3 9 connected to _quadrangle_8 0, _not_defined 4294967295,
-_segment_3 10 connected to _quadrangle_8 0, _quadrangle_8 1,
-_segment_3 11 connected to _quadrangle_8 0, _not_defined 4294967295,
-_segment_3 12 connected...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_tetrahedron_10</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_tetrahedron_10</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_tetrahedron_10" "-e" "./test_buildfacets_tetrahedron_10" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_tetrahedron_10.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.802719</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_tetrahedron_10" "-e" "./test_buildfacets_tetrahedron_10" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_tetrahedron_10.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_tetrahedron_10
-Run ./test_buildfacets_tetrahedron_10
-ElementToSubelement3
-_triangle_6 0 connected to _tetrahedron_10 0, _tetrahedron_10 11,
-_triangle_6 1 connected to _tetrahedron_10 0, _tetrahedron_10 12,
-_triangle_6 2 connected to _tetrahedron_10 0, _tetrahedron_10 6,
-_triangle_6 3 connected to _tetrahedron_10 0, _not_defined 4294967295,
-_triangle_6 4 connected to _tetrahedron_10 1, _tetrahedron_10 11,
-_triangle_6 5 connected to _tetrahedron_10 1, _tetrahedron_10 15,
-_triangle_6 6 connected to _tetrahedron_10 1, _not_defined 4294967295,
-_triangle_6 7 connected to _tetrahedron_10 1, _tetrahedron_10 13,
-_triangle_6 8 connected to _tetrahedron_10 2, _not_defined 4294967295,
-_triangle_6 9 connected to _tetrahedron_10 2, _tetrahedron_10 12,
-_triangle_6 10 connected to _tetrahedron_10 2, _not_defined 4294967295,
-_triangle_6 11 connected to _te...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_hexahedron_8</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_8</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_hexahedron_8" "-e" "./test_buildfacets_hexahedron_8" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_8.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.782066</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_hexahedron_8" "-e" "./test_buildfacets_hexahedron_8" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_8.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_hexahedron_8
-Run ./test_buildfacets_hexahedron_8
-ElementToSubelement3
-_quadrangle_4 0 connected to _hexahedron_8 0, _not_defined 4294967295,
-_quadrangle_4 1 connected to _hexahedron_8 0, _hexahedron_8 3,
-_quadrangle_4 2 connected to _hexahedron_8 0, _hexahedron_8 1,
-_quadrangle_4 3 connected to _hexahedron_8 0, _not_defined 4294967295,
-_quadrangle_4 4 connected to _hexahedron_8 0, _not_defined 4294967295,
-_quadrangle_4 5 connected to _hexahedron_8 0, _not_defined 4294967295,
-_quadrangle_4 6 connected to _hexahedron_8 1, _not_defined 4294967295,
-_quadrangle_4 7 connected to _hexahedron_8 1, _hexahedron_8 2,
-_quadrangle_4 8 connected to _hexahedron_8 1, _not_defined 4294967295,
-_quadrangle_4 9 connected to _hexahedron_8 1, _not_defined 4294967295,
-_quadrangle_4 10 connected to _hexahedron_8 1, _not_defined 4294967295,
-_quadrangle_4 11 connec...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_hexahedron_20</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_20</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_hexahedron_20" "-e" "./test_buildfacets_hexahedron_20" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_20.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.778573</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_hexahedron_20" "-e" "./test_buildfacets_hexahedron_20" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_hexahedron_20.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_hexahedron_20
-Run ./test_buildfacets_hexahedron_20
-ElementToSubelement3
-_quadrangle_8 0 connected to _hexahedron_20 0, _hexahedron_20 3,
-_quadrangle_8 1 connected to _hexahedron_20 0, _hexahedron_20 1,
-_quadrangle_8 2 connected to _hexahedron_20 0, _not_defined 4294967295,
-_quadrangle_8 3 connected to _hexahedron_20 0, _not_defined 4294967295,
-_quadrangle_8 4 connected to _hexahedron_20 0, _not_defined 4294967295,
-_quadrangle_8 5 connected to _hexahedron_20 0, _not_defined 4294967295,
-_quadrangle_8 6 connected to _hexahedron_20 1, _not_defined 4294967295,
-_quadrangle_8 7 connected to _hexahedron_20 1, _hexahedron_20 2,
-_quadrangle_8 8 connected to _hexahedron_20 1, _not_defined 4294967295,
-_quadrangle_8 9 connected to _hexahedron_20 1, _not_defined 4294967295,
-_quadrangle_8 10 connected to _hexahedron_20 1, _not_defined 4294967295,
-_quadra...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_pentahedron_6</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_6</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_pentahedron_6" "-e" "./test_buildfacets_pentahedron_6" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_6.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.784735</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_pentahedron_6" "-e" "./test_buildfacets_pentahedron_6" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_6.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_pentahedron_6
-Run ./test_buildfacets_pentahedron_6
-ElementToSubelement3
-_triangle_3 0 connected to _pentahedron_6 0, _not_defined 4294967295,
-_triangle_3 1 connected to _pentahedron_6 0, _pentahedron_6 2,
-_triangle_3 2 connected to _pentahedron_6 1, _not_defined 4294967295,
-_triangle_3 3 connected to _pentahedron_6 1, _pentahedron_6 3,
-_triangle_3 4 connected to _pentahedron_6 2, _not_defined 4294967295,
-_triangle_3 5 connected to _pentahedron_6 3, _not_defined 4294967295,
-ElementToSubelement3
-_quadrangle_4 0 connected to _pentahedron_6 0, _pentahedron_6 1,
-_quadrangle_4 1 connected to _pentahedron_6 0, _not_defined 4294967295,
-_quadrangle_4 2 connected to _pentahedron_6 0, _not_defined 4294967295,
-_quadrangle_4 3 connected to _pentahedron_6 1, _not_defined 4294967295,
-_quadrangle_4 4 connected to _pentahedron_6 1, _not_defined 4294967295, ...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_pentahedron_15</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_15</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_pentahedron_15" "-e" "./test_buildfacets_pentahedron_15" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_15.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.797393</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_pentahedron_15" "-e" "./test_buildfacets_pentahedron_15" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_pentahedron_15.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_pentahedron_15
-Run ./test_buildfacets_pentahedron_15
-ElementToSubelement3
-_triangle_6 0 connected to _pentahedron_15 0, _not_defined 4294967295,
-_triangle_6 1 connected to _pentahedron_15 0, _pentahedron_15 2,
-_triangle_6 2 connected to _pentahedron_15 1, _not_defined 4294967295,
-_triangle_6 3 connected to _pentahedron_15 1, _pentahedron_15 3,
-_triangle_6 4 connected to _pentahedron_15 2, _not_defined 4294967295,
-_triangle_6 5 connected to _pentahedron_15 3, _not_defined 4294967295,
-ElementToSubelement3
-_quadrangle_8 0 connected to _pentahedron_15 0, _pentahedron_15 1,
-_quadrangle_8 1 connected to _pentahedron_15 0, _not_defined 4294967295,
-_quadrangle_8 2 connected to _pentahedron_15 0, _not_defined 4294967295,
-_quadrangle_8 3 connected to _pentahedron_15 1, _not_defined 4294967295,
-_quadrangle_8 4 connected to _pentahedron_15 1, _not_defin...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_mixed3d_linear</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_linear</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed3d_linear" "-e" "./test_buildfacets_mixed3d_linear" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_linear.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.788664</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed3d_linear" "-e" "./test_buildfacets_mixed3d_linear" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_linear.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_mixed3d_linear
-Run ./test_buildfacets_mixed3d_linear
-ElementToSubelement3
-_quadrangle_4 0 connected to _pentahedron_6 0, _pentahedron_6 2,
-_quadrangle_4 1 connected to _pentahedron_6 0, _not_defined 4294967295,
-_quadrangle_4 2 connected to _pentahedron_6 0, _hexahedron_8 0,
-_quadrangle_4 3 connected to _pentahedron_6 1, _pentahedron_6 3,
-_quadrangle_4 4 connected to _pentahedron_6 1, _pentahedron_6 2,
-_quadrangle_4 5 connected to _pentahedron_6 1, _hexahedron_8 1,
-_quadrangle_4 6 connected to _pentahedron_6 2, _not_defined 4294967295,
-_quadrangle_4 7 connected to _pentahedron_6 3, _not_defined 4294967295,
-_quadrangle_4 8 connected to _pentahedron_6 3, _not_defined 4294967295,
-_quadrangle_4 9 connected to _hexahedron_8 0, _not_defined 4294967295,
-_quadrangle_4 10 connected to _hexahedron_8 0, _not_defined 4294967295,
-_quadrangle_4 11 connec...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_buildfacets_mixed3d_quadratic</Name>
- <Path>./test/test_mesh_utils/test_buildfacets</Path>
- <FullName>./test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_quadratic</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed3d_quadratic" "-e" "./test_buildfacets_mixed3d_quadratic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_quadratic.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.800241</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_buildfacets_mixed3d_quadratic" "-e" "./test_buildfacets_mixed3d_quadratic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_mesh_utils/test_buildfacets/test_buildfacets_mixed3d_quadratic.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_buildfacets
-Executing the test test_buildfacets_mixed3d_quadratic
-Run ./test_buildfacets_mixed3d_quadratic
-ElementToSubelement3
-_quadrangle_8 0 connected to _pentahedron_15 0, _pentahedron_15 2,
-_quadrangle_8 1 connected to _pentahedron_15 0, _not_defined 4294967295,
-_quadrangle_8 2 connected to _pentahedron_15 0, _hexahedron_20 0,
-_quadrangle_8 3 connected to _pentahedron_15 1, _pentahedron_15 3,
-_quadrangle_8 4 connected to _pentahedron_15 1, _pentahedron_15 2,
-_quadrangle_8 5 connected to _pentahedron_15 1, _hexahedron_20 1,
-_quadrangle_8 6 connected to _pentahedron_15 2, _not_defined 4294967295,
-_quadrangle_8 7 connected to _pentahedron_15 3, _not_defined 4294967295,
-_quadrangle_8 8 connected to _pentahedron_15 3, _not_defined 4294967295,
-_quadrangle_8 9 connected to _hexahedron_20 0, _not_defined 4294967295,
-_quadrangle_8 10 connected to _hexahedron_20 0, _hexahedron_20 1,
-_quadran...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_partitionate_scotch</Name>
- <Path>./test/test_mesh_utils/test_mesh_partitionate</Path>
- <FullName>./test/test_mesh_utils/test_mesh_partitionate/test_mesh_partitionate_scotch</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_partitionate_scotch" "-e" "./test_mesh_partitionate_scotch" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_partitionate"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.810945</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_partitionate_scotch" "-e" "./test_mesh_partitionate_scotch" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_partitionate"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_partitionate
-Executing the test test_mesh_partitionate_scotch
-Run ./test_mesh_partitionate_scotch
-&lt;1479&gt;[R0|S1] {1547131906660809} ==&gt; getStaticCommunicator() (getStaticCommunicator(): /home/jenkins/workspace/akantu-private-master-5327/src/synchronizer/communicator.cc:79)
-&lt;1479&gt;[R0|S1] {1547131906660809} &lt;== getStaticCommunicator() (getStaticCommunicator(): /home/jenkins/workspace/akantu-private-master-5327/src/synchronizer/communicator.cc:88)
-&lt;1479&gt;[R0|S1] {1547131906660809} &lt;== GroupManager() (GroupManager(): /home/jenkins/workspace/akantu-private-master-5327/src/mesh/group_manager.cc:62)
-&lt;1479&gt;[R0|S1] {1547131906660809} ==&gt; Mesh() (Mesh(): /home/jenkins/workspace/akantu-private-master-5327/src/mesh/mesh.cc:74)
-&lt;1479&gt;[R0|S1] {1547131906660809} &lt;== Mesh() (Mesh(): /home/jenkins/workspace/akantu-private-master-5327/src/mesh/mesh.cc:76)
-&lt;1479&gt;[R0|S1] {1547131906660809} ==&gt; Mesh() (Mesh(): /home/jenkins/w...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_partitionate_mesh_data</Name>
- <Path>./test/test_mesh_utils/test_mesh_partitionate</Path>
- <FullName>./test/test_mesh_utils/test_mesh_partitionate/test_mesh_partitionate_mesh_data</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_partitionate_mesh_data" "-e" "./test_mesh_partitionate_mesh_data" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_partitionate"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.799429</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_partitionate_mesh_data" "-e" "./test_mesh_partitionate_mesh_data" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_partitionate"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_mesh_utils/test_mesh_partitionate
-Executing the test test_mesh_partitionate_mesh_data
-Run ./test_mesh_partitionate_mesh_data
-*Assigned proc 0 to elem 0 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 1 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 2 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 3 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 4 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 5 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 6 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 7 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 8 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to elem 9 (type _quadrangle_4, barycenter x-coordinate 0.025)
-*Assigned proc 0 to el...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>patch_test_linear_gtest</Name>
- <Path>./test/test_model/patch_tests</Path>
- <FullName>./test/test_model/patch_tests/patch_test_linear_gtest</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "patch_test_linear_gtest" "-e" "./patch_test_linear_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/patch_test_linear_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>3.09331</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "patch_test_linear_gtest" "-e" "./patch_test_linear_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/patch_test_linear_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests
-Executing the test patch_test_linear_gtest
-Run ./patch_test_linear_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/patch_test_linear_gtest.xml
-[==========] Running 44 tests from 28 test cases.
-[----------] Global test environment set-up.
-[----------] 2 tests from TestPatchTestSMMLinear/0, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;, std::integral_constant&lt;bool, true&gt; &gt;
-[ RUN ] TestPatchTestSMMLinear/0.Explicit
-[ OK ] TestPatchTestSMMLinear/0.Explicit (72 ms)
-[ RUN ] TestPatchTestSMMLinear/0.Implicit
-[ OK ] TestPatchTestSMMLinear/0.Implicit (13 ms)
-[----------] 2 tests from TestPatchTestSMMLinear/0 (85 ms total)
-
-[----------] 2 tests from TestPatchTestSMMLinear/1, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)10&gt;, std::integral_constant&lt;boo...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_linear_elastic_explicit_python</Name>
- <Path>./test/test_model/patch_tests</Path>
- <FullName>./test/test_model/patch_tests/test_linear_elastic_explicit_python</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_linear_elastic_explicit_python" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests" "patch_test_linear_elastic_explicit.py"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>2.22681</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_linear_elastic_explicit_python" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests" "patch_test_linear_elastic_explicit.py"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests
-Executing the test test_linear_elastic_explicit_python
-Run /usr/bin/python3 patch_test_linear_elastic_explicit.py
-............
-----------------------------------------------------------------------
-Ran 12 tests in 1.212s
-
-OK
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_linear_elastic_static_python</Name>
- <Path>./test/test_model/patch_tests</Path>
- <FullName>./test/test_model/patch_tests/test_linear_elastic_static_python</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_linear_elastic_static_python" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests" "patch_test_linear_elastic_static.py"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1.52176</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_linear_elastic_static_python" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests" "patch_test_linear_elastic_static.py"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/patch_tests
-Executing the test test_linear_elastic_static_python
-Run /usr/bin/python3 patch_test_linear_elastic_static.py
-............
-----------------------------------------------------------------------
-Ran 12 tests in 0.517s
-
-OK
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_dof_manager_default</Name>
- <Path>./test/test_model/test_model_solver</Path>
- <FullName>./test/test_model/test_model_solver/test_dof_manager_default</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_manager_default" "-e" "./test_dof_manager_default" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_dof_manager_default.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.794174</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_manager_default" "-e" "./test_dof_manager_default" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_dof_manager_default.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver
-Executing the test test_dof_manager_default
-Run ./test_dof_manager_default
- disp force blocked
- 0 0 true
- 1 0 false
- 2 0 false
- 3 0 false
- 4 0 false
- 5 0 false
- 6 0 false
- 7 0 false
- 8 0 false
- 9 0 false
- 10 10 false
-Comparing last generated output to the reference file
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_model_solver</Name>
- <Path>./test/test_model/test_model_solver</Path>
- <FullName>./test/test_model/test_model_solver/test_model_solver</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_model_solver" "-e" "./test_model_solver" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_model_solver.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.791413</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_model_solver" "-e" "./test_model_solver" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_model_solver.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver
-Executing the test test_model_solver
-Run ./test_model_solver
-node, disp, force, blocked
-0, 0, 0, 1
-1, -0.1010101, 0, 0
-2, -0.2020202, 0, 0
-3, -0.3030303, 0, 0
-4, -0.4040404, 0, 0
-5, -0.5050505, 0, 0
-6, -0.6060606, 0, 0
-7, -0.7070707, 0, 0
-8, -0.8080808, 0, 0
-9, -0.9090909, 0, 0
-10, -1.010101, 0, 0
-11, -1.111111, 0, 0
-12, -1.212121, 0, 0
-13, -1.313131, 0, 0
-14, -1.414141, 0, 0
-15, -1.515152, 0, 0
-16, -1.616162, 0, 0
-17, -1.717172, 0, 0
-18, -1.818182, 0, 0
-19, -1.919192, 0, 0
-20, -2.020202, 0, 0
-21, -2.121212, 0, 0
-22, -2.222222, 0, 0
-23, -2.323232, 0, 0
-24,...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_model_solver_dynamic_explicit</Name>
- <Path>./test/test_model/test_model_solver</Path>
- <FullName>./test/test_model/test_model_solver/test_model_solver_dynamic_explicit</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_model_solver_dynamic_explicit" "-e" "./test_model_solver_dynamic_explicit" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_model_solver_dynamic_explicit.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Failed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1.74932</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_model_solver_dynamic_explicit" "-e" "./test_model_solver_dynamic_explicit" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_model_solver_dynamic_explicit.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver
-Executing the test test_model_solver_dynamic_explicit
-Run ./test_model_solver_dynamic_explicit
- time, wext, epot, ekin, total, max_disp, min_disp
- 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 1.000000e-02, -1.000000e-02
- 1.000000e-03, 0.000000e+00, 2.464762e-02, 2.465579e-02, 4.930341e-02, 1.000000e-02, -1.000000e-02
- 2.000000e-03, 0.000000e+00, 2.467180e-02, 2.463164e-02, 4.930344e-02, 9.994082e-03, -9.990151e-03
- 3.000000e-03, 0.000000e+00, 2.469535e-02, 2.460813e-02, 4.930348e-02, 9.995108e-03, -9.994951e-03
- 4.000000e-03, 0.000000e+00, 2.471764e-02, 2.458588e-02, 4.930352e-02, 1.001558e-02, -1.001466e-02
- 5.000000e-03, 0.000000e+00, 2.473805e-02, 2.456551e-02, 4.930355e-02, 1.002761e-02, -1.002451e-02
- 6.000000e-03, 0.000000e+00, 2.475604e-02, 2.454754e-02, 4.930358e-02, 1.003241e-02, -1.002448e-02
- 7.000000e-03, 0.000000e+00, 2.477124e-02, 2.453236e-02, 4.930360e-02, 1.003156e-02, -1.001458e-02
- 8.000000e-03, 0.000000e+00, 2.478334e-02, 2.452027e-02, 4.930361e-02, 1.002688e-02, -1.001808e-02
- 9.000000e-03, 0.000000e+00, 2.479207e-02, 2.451156e-02, 4.930363e-02, 1.004157e-02, -1.003757e-02
- 1.000000e-02, 0.000000e+00, 2.479710e-02, 2.450656e-02, 4.930366e-02, 1.005530e-02, -1.004718e-02
- 1.100000e-02, 0.000000e+00, 2.479802e-02, 2.450566e-02, 4.930368e-02, 1.006202e-02, -1.004689e-02
- 1.200000e-02, 0.000000e+00, 2.479443e-02, 2.450927e-02, 4.930371e-02, 1.006296e-02, -1.003670e-02
- 1.300000e-02, 0.000000e+00, 2.478598e-02, 2.451775e-02, 4.930372e-02, 1.005956e-02, -1.003757e-02
- 1.400000e-02, 0.000000e+00, 2.477239e-02, 2.453134e-02, 4.930373e-02, 1.006400e-02, -1.005664e-02
- 1.500000e-02, 0.000000e+00, 2.475352e-02, 2.455021e-02, 4.930374e-02, 1.007863e-02, -1.006580e-02
- 1.600000e-02, 0.000000e+00, 2.472930e-02, 2.457444e-02, 4.930374e-02, 1.008633e-02, -1.006504e-02
- 1.700000e-02, 0.000000e+00, 2.469966e-02, 2.460408e-02, 4.930374e-02, 1.008815e-02, -1.005437e-02
- 1.800000e-02, 0.000000e+00, 2.466454e-02, 2.463921e-02, 4.930375e-02, 1.008534e-02, -1.005151e-02
- 1.900000e-02, 0.000000e+00, 2.462384e-02, 2.467992e-02, 4.930375e-02, 1.008067e-02, -1.006999e-02
- 2.000000e-02, 0.000000e+00, 2.457750e-02, 2.472626e-02, 4.930376e-02, 1.009574e-02, -1.007854e-02
- 2.100000e-02, 0.000000e+00, 2.452550e-02, 2.477825e-02, 4.930375e-02, 1.010392e-02, -1.007717e-02
- 2.200000e-02, 0.000000e+00, 2.446795e-02, 2.483579e-02, 4.930374e-02, 1.010616e-02, -1.006587e-02
- 2.300000e-02, 0.000000e+00, 2.440504e-02, 2.489868e-02, 4.930372e-02, 1.010356e-02, -1.005853e-02
- 2.400000e-02, 0.000000e+00, 2.433702e-02, 2.496669e-02, 4.930370e-02, 1.009736e-02, -1.007631e-02
- 2.500000e-02, 0.000000e+00, 2.426417e-02, 2.503952e-02, 4.930369e-02, 1.010545e-02, -1.008416e-02
- 2.600000e-02, 0.000000e+00, 2.418676e-02, 2.511691e-02, 4.930367e-02, 1.011382e-02, -1.008208e-02
- 2.700000e-02, 0.000000e+00, 2.410506e-02, 2.519859e-02, 4.930365e-02, 1.011621e-02, -1.007008e-02
- 2.800000e-02, 0.000000e+00, 2.401936e-02, 2.528427e-02, 4.930363e-02, 1.011362e-02, -1.005792e-02
- 2.900000e-02, 0.000000e+00, 2.393001e-02, 2.537359e-02, 4.930360e-02, 1.011017e-02, -1.007498e-02
- 3.000000e-02, 0.000000e+00, 2.383747e-02, 2.546610e-02, 4.930357e-02, 1.011337e-02, -1.008211e-02
- 3.100000e-02, 0.000000e+00, 2.374226e-02, 2.556128e-02, 4.930353e-02, 1.011567e-02, -1.007931e-02
- 3.200000e-02, 0.000000e+00, 2.364493e-02, 2.565857e-02, 4.930350e-02, 1.011807e-02, -1.006659e-02
- 3.300000e-02, 0.000000e+00, 2.354607e-02, 2.575740e-02, 4.930346e-02, 1.011540e-02, -1.004974e-02
- 3.400000e-02, 0.000000e+00, 2.344621e-02, 2.585722e-02, 4.930343e-02, 1.011477e-02, -1.006612e-02
- 3.500000e-02, 0.000000e+00, 2.334591e-02, 2.595749e-02, 4.930340e-02, 1.012163e-02, -1.007258e-02
- 3.600000e-02, 0.000000e+00, 2.324571e-02, 2.605764e-02, 4.930336e-02, 1.012698e-02, -1.006913e-02
- 3.700000e-02, 0.000000e+00, 2.314623e-02, 2.615708e-02, 4.930332e-02, 1.013019e-02, -1.005575e-02
- 3.800000e-02, 0.000000e+00, 2.304813e-02, 2.625514e-02, 4.930327e-02, 1.013119e-02, -1.003478e-02
- 3.900000e-02, 0.000000e+00, 2.295211e-02, 2.635112e-02, 4.930323e-02, 1.013020e-02, -1.005060e-02
- 4.000000e-02, 0.000000e+00, 2.285890e-02, 2.644429e-02, 4.930318e-02, 1.012776e-02, -1.005652e-02
- 4.100000e-02, 0.000000e+00, 2.276918e-02, 2.653396e-02, 4.930314e-02, 1.012593e-02, -1.005255e-02
- 4.200000e-02, 0.000000e+00, 2.268362e-02, 2.661948e-02, 4.930310e-02, 1.013238e-02, -1.003867e-02
- 4.300000e-02, 0.000000e+00, 2.260283e-02, 2.670023e-02, 4.930307e-02, 1.013796e-02, -1.001493e-02
- 4.400000e-02, 0.000000e+00, 2.252744e-02, 2.677559e-02, 4.930303e-02, 1.014203e-02, -1.003064e-02
- 4.500000e-02, 0.000000e+00, 2.245807e-02, 2.684492e-02, 4.930298e-02, 1.014420e-02, -1.003660e-02
- 4.600000e-02, 0.000000e+00, 2.239538e-02, 2.690756e-02, 4.930294e-02, 1.014433e-02, -1.003288e-02
- 4.700000e-02, 0.000000e+00, 2.234005e-02, 2.696285e-02, 4.930290e-02, 1.014263e-02, -1.001956e-02
- 4.800000e-02, 0.000000e+00, 2.229271e-02, 2.701016e-02, 4.930287e-02, 1.013954e-02, -1.001137e-02
- 4.900000e-02, 0.000000e+00, 2.225394e-02, 2.704889e-02, 4.930283e-02, 1.013569e-02, -1.003457e-02
- 5.000000e-02, 0.000000e+00, 2.222426e-02, 2.707854e-02, 4.930281e-02, 1.013996e-02, -1.005043e-02
- 5.100000e-02, 0.000000e+00, 2.220412e-02, 2.709866e-02, 4.930278e-02, 1.014354e-02, -1.042293e-02
- 5.200000e-02, 0.000000e+00, 2.219395e-02, 2.710880e-02, 4.930275e-02, 1.014550e-02, -1.104464e-02
- 5.300000e-02, 0.000000e+00, 2.219417e-02, 2.710855e-02, 4.930273e-02, 1.014558e-02, -1.166358e-02
- 5.400000e-02, 0.000000e+00, 2.220519e-02, 2.709751e-02, 4.930270e-02, 1.014381e-02, -1.228907e-02
- 5.500000e-02, 0.000000e+00, 2.222739e-02, 2.707529e-02, 4.930268e-02, 1.014047e-02, -1.291439e-02
- 5.600000e-02, 0.000000e+00, 2.226109e-02, 2.704158e-02, 4.930267e-02, 1.013605e-02, -1.353784e-02
- 5.700000e-02, 0.000000e+00, 2.230652e-02, 2.699614e-02, 4.930266e-02, 1.013627e-02, -1.415821e-02
- 5.800000e-02, 0.000000e+00, 2.236383e-02, 2.693882e-02, 4.930265e-02, 1.013940e-02, -1.477420e-02
- 5.900000e-02, 0.000000e+00, 2.243311e-02, 2.686954e-02, 4.930265e-02, 1.014150e-02, -1.538461e-02
- 6.000000e-02, 0.000000e+00, 2.251437e-02, 2.678828e-02, 4.930265e-02, 1.014211e-02, -1.598837e-02
- 6.100000e-02, 0.000000e+00, 2.260762e-02, 2.669503e-02, 4.930265e-02, 1.014098e-02, -1.658462e-02
- 6.200000e-02, 0.000000e+00, 2.271284e-02, 2.658982e-02, 4.930266e-02, 1.013812e-02, -1.717280e-02
- 6.300000e-02, 0.000000e+00, 2.282993e-02, 2.647274e-02, 4.930267e-02, 1.013378e-02, -1.775258e-02
- 6.400000e-02, 0.000000e+00, 2.295875e-02, 2.634393e-02, 4.930268e-02, 1.012845e-02, -1.832385e-02
- 6.500000e-02, 0.000000e+00, 2.309904e-02, 2.620367e-02, 4.930271e-02, 1.012546e-02, -1.888664e-02
- 6.600000e-02, 0.000000e+00, 2.325045e-02, 2.605229e-02, 4.930273e-02, 1.012695e-02, -1.944102e-02
- 6.700000e-02, 0.000000e+00, 2.341256e-02, 2.589020e-02, 4.930276e-02, 1.012729e-02, -1.998699e-02
- 6.800000e-02, 0.000000e+00, 2.358492e-02, 2.571788e-02, 4.930279e-02, 1.012611e-02, -2.052443e-02
- 6.900000e-02, 0.000000e+00, 2.376702e-02, 2.553581e-02, 4.930283e-02, 1.012326e-02, -2.105299e-02
- 7.000000e-02, 0.000000e+00, 2.395833e-02, 2.534453e-02, 4.930286e-02, 1.011884e-02, -2.157209e-02
- 7.100000e-02, 0.000000e+00, 2.415828e-02, 2.514462e-02, 4.930290e-02, 1.011319e-02, -2.208094e-02
- 7.200000e-02, 0.000000e+00, 2.436621e-02, 2.493673e-02, 4.930295e-02, 1.010680e-02, -2.257856e-02
- 7.300000e-02, 0.000000e+00, 2.458138e-02, 2.472162e-02, 4.930300e-02, 1.010756e-02, -2.306390e-02
- 7.400000e-02, 0.000000e+00, 2.480297e-02, 2.450009e-02, 4.930306e-02, 1.010774e-02, -2.353590e-02
- 7.500000e-02, 0.000000e+00, 2.503010e-02, 2.427301e-02, 4.930311e-02, 1.010683e-02, -2.399358e-02
- 7.600000e-02, 0.000000e+00, 2.526187e-02, 2.404129e-02, 4.930317e-02, 1.010449e-02, -2.443616e-02
- 7.700000e-02, 0.000000e+00, 2.549739e-02, 2.380584e-02, 4.930323e-02, 1.010059e-02, -2.486306e-02
- 7.800000e-02, 0.000000e+00, 2.573571e-02, 2.356758e-02, 4.930329e-02, 1.009523e-02, -2.527397e-02
- 7.900000e-02, 0.000000e+00, 2.597587e-02, 2.332748e-02, 4.930335e-02, 1.008874e-02, -2.566879e-02
- 8.000000e-02, 0.000000e+00, 2.621687e-02, 2.308655e-02, 4.930342e-02, 1.008159e-02, -2.604760e-02
- 8.100000e-02, 0.000000e+00, 2.645763e-02, 2.284586e-02, 4.930349e-02, 1.007993e-02, -2.641058e-02
- 8.200000e-02, 0.000000e+00, 2.669704e-02, 2.260652e-02, 4.930356e-02, 1.007886e-02, -2.675792e-02
- 8.300000e-02, 0.000000e+00, 2.693397e-02, 2.236966e-02, 4.930363e-02, 1.007664e-02, -2.708973e-02
- 8.400000e-02, 0.000000e+00, 2.716730e-02, 2.213639e-02, 4.930370e-02, 1.007301e-02, -2.740597e-02
- 8.500000e-02, 0.000000e+00, 2.739594e-02, 2.190782e-02, 4.930376e-02, 1.006793e-02, -2.770640e-02
- 8.600000e-02, 0.000000e+00, 2.761880e-02, 2.168503e-02, 4.930383e-02, 1.006157e-02, -2.799061e-02
- 8.700000e-02, 0.000000e+00, 2.783480e-02, 2.146910e-02, 4.930390e-02, 1.005428e-02, -2.825797e-02
- 8.800000e-02, 0.000000e+00, 2.804284e-02, 2.126113e-02, 4.930397e-02, 1.004873e-02, -2.850776e-02
- 8.900000e-02, 0.000000e+00, 2.824181e-02, 2.106223e-02, 4.930404e-02, 1.004748e-02, -2.873920e-02
- 9.000000e-02, 0.000000e+00, 2.843061e-02, 2.087349e-02, 4.930411e-02, 1.004555e-02, -2.895154e-02
- 9.100000e-02, 0.000000e+00, 2.860816e-02, 2.069601e-02, 4.930417e-02, 1.004254e-02, -2.914417e-02
- 9.200000e-02, 0.000000e+00, 2.877342e-02, 2.053081e-02, 4.930423e-02, 1.004419e-02, -2.931667e-02
- 9.300000e-02, 0.000000e+00, 2.892545e-02, 2.037883e-02, 4.930429e-02, 1.004952e-02, -2.946883e-02
- 9.400000e-02, 0.000000e+00, 2.906333e-02, 2.024101e-02, 4.930434e-02, 1.005001e-02, -2.960067e-02
- 9.500000e-02, 0.000000e+00, 2.918619e-02, 2.011820e-02, 4.930439e-02, 1.004641e-02, -2.971240e-02
- 9.600000e-02, 0.000000e+00, 2.929319e-02, 2.001125e-02, 4.930444e-02, 1.005770e-02, -2.980439e-02
- 9.700000e-02, 0.000000e+00, 2.938351e-02, 1.992099e-02, 4.930449e-02, 1.006924e-02, -2.987706e-02
- 9.800000e-02, 0.000000e+00, 2.945638e-02, 1.984816e-02, 4.930454e-02, 1.007523e-02, -2.993081e-02
- 9.900000e-02, 0.000000e+00, 2.951111e-02, 1.979347e-02, 4.930457e-02, 1.007634e-02, -2.996594e-02
- 1.000000e-01, 0.000000e+00, 2.954709e-02, 1.975751e-02, 4.930461e-02, 1.007327e-02, -2.998263e-02
- 1.010000e-01, 0.000000e+00, 2.956383e-02, 1.974080e-02, 4.930463e-02, 1.008468e-02, -2.998084e-02
- 1.020000e-01, 0.000000e+00, 2.956090e-02, 1.974375e-02, 4.930465e-02, 1.009669e-02, -2.996038e-02
- 1.030000e-01, 0.000000e+00, 2.953796e-02, 1.976671e-02, 4.930467e-02, 1.010311e-02, -2.992090e-02
- 1.040000e-01, 0.000000e+00, 2.949470e-02, 1.980999e-02, 4.930469e-02, 1.010459e-02, -2.986197e-02
- 1.050000e-01, 0.000000e+00, 2.943089e-02, 1.987381e-02, 4.930470e-02, 1.010181e-02, -2.978317e-02
- 1.060000e-01, 0.000000e+00, 2.934637e-02, 1.995832e-02, 4.930470e-02, 1.011194e-02, -2.968413e-02
- 1.070000e-01, 0.000000e+00, 2.924111e-02, 2.006359e-02, 4.930470e-02, 1.012418e-02, -2.956463e-02
- 1.080000e-01, 0.000000e+00, 2.911515e-02, 2.018953e-02, 4.930468e-02, 1.013078e-02, -2.942464e-02
- 1.090000e-01, 0.000000e+00, 2.896868e-02, 2.033599e-02, 4.930467e-02, 1.013238e-02, -2.926433e-02
- 1.100000e-01, 0.000000e+00, 2.880196e-02, 2.050268e-02, 4.930465e-02, 1.012965e-02, -2.908411e-02
- 1.110000e-01, 0.000000e+00, 2.861536e-02, 2.068926e-02, 4.930462e-02, 1.013712e-02, -2.888451e-02
- 1.120000e-01, 0.000000e+00, 2.840928e-02, 2.089531e-02, 4.930459e-02, 1.014933e-02, -2.866620e-02
- 1.130000e-01, 0.000000e+00, 2.818423e-02, 2.112032e-02, 4.930455e-02, 1.015587e-02, -2.842986e-02
- 1.140000e-01, 0.000000e+00, 2.794078e-02, 2.136373e-02, 4.930451e-02, 1.015736e-02, -2.817612e-02
- 1.150000e-01, 0.000000e+00, 2.767962e-02, 2.162484e-02, 4.930446e-02, 1.015446e-02, -2.790553e-02
- 1.160000e-01, 0.000000e+00, 2.740154e-02, 2.190286e-02, 4.930440e-02, 1.015800e-02, -2.761845e-02
- 1.170000e-01, 0.000000e+00, 2.710745e-02, 2.219689e-02, 4.930434e-02, 1.016999e-02, -2.731508e-02
- 1.180000e-01, 0.000000e+00, 2.679834e-02, 2.250593e-02, 4.930428e-02, 1.017627e-02, -2.699546e-02
- 1.190000e-01, 0.000000e+00, 2.647526e-02, 2.282894e-02, 4.930421e-02, 1.017745e-02, -2.665954e-02
- 1.200000e-01, 0.000000e+00, 2.613932e-02, 2.316482e-02, 4.930413e-02, 1.017418e-02, -2.630719e-02
- 1.210000e-01, 0.000000e+00, 2.579166e-02, 2.351240e-02, 4.930406e-02, 1.017283e-02, -2.593831e-02
- 1.220000e-01, 0.000000e+00, 2.543353e-02, 2.387044e-02, 4.930397e-02, 1.018444e-02, -2.555289e-02
- 1.230000e-01, 0.000000e+00, 2.506624e-02, 2.423765e-02, 4.930389e-02, 1.019031e-02, -2.515107e-02
- 1.240000e-01, 0.000000e+00, 2.469118e-02, 2.461261e-02, 4.930380e-02, 1.019103e-02, -2.473318e-02
- 1.250000e-01, 0.000000e+00, 2.430983e-02, 2.499387e-02, 4.930370e-02, 1.018727e-02, -2.429974e-02
- 1.260000e-01, 0.000000e+00, 2.392369e-02, 2.537991e-02, 4.930360e-02, 1.018041e-02, -2.385145e-02
- 1.270000e-01, 0.000000e+00, 2.353430e-02, 2.576920e-02, 4.930351e-02, 1.019155e-02, -2.338915e-02
- 1.280000e-01, 0.000000e+00, 2.314322e-02, 2.616019e-02, 4.930341e-02, 1.019693e-02, -2.291374e-02
- 1.290000e-01, 0.000000e+00, 2.275201e-02, 2.655130e-02, 4.930331e-02, 1.019713e-02, -2.242610e-02
- 1.300000e-01, 0.000000e+00, 2.236227e-02, 2.694094e-02, 4.930321e-02, 1.019280e-02, -2.192705e-02
- 1.310000e-01, 0.000000e+00, 2.197563e-02, 2.732747e-02, 4.930310e-02, 1.018463e-02, -2.141730e-02
- 1.320000e-01, 0.000000e+00, 2.159377e-02, 2.770923e-02, 4.930300e-02, 1.019092e-02, -2.089736e-02
- 1.330000e-01, 0.000000e+00, 2.121837e-02, 2.808453e-02, 4.930289e-02, 1.019580e-02, -2.036762e-02
- 1.340000e-01, 0.000000e+00, 2.085110e-02, 2.845169e-02, 4.930279e-02, 1.019549e-02, -1.982829e-02
- 1.350000e-01, 0.000000e+00, 2.049361e-02, 2.880909e-02, 4.930269e-02, 1.019061e-02, -1.927952e-02
- 1.360000e-01, 0.000000e+00, 2.014749e-02, 2.915510e-02, 4.930259e-02, 1.018184e-02, -1.872142e-02
- 1.370000e-01, 0.000000e+00, 1.981433e-02, 2.948817e-02, 4.930250e-02, 1.018290e-02, -1.815413e-02
- 1.380000e-01, 0.000000e+00, 1.949566e-02, 2.980674e-02, 4.930240e-02, 1.018735e-02, -1.757790e-02
- 1.390000e-01, 0.000000e+00, 1.919302e-02, 3.010929e-02, 4.930231e-02, 1.018659e-02, -1.699315e-02
- 1.400000e-01, 0.000000e+00, 1.890789e-02, 3.039432e-02, 4.930222e-02, 1.018125e-02, -1.640045e-02
- 1.410000e-01, 0.000000e+00, 1.864175e-02, 3.066038e-02, 4.930213e-02, 1.017199e-02, -1.580055e-02
- 1.420000e-01, 0.000000e+00, 1.839597e-02, 3.090608e-02, 4.930205e-02, 1.016854e-02, -1.519436e-02
- 1.430000e-01, 0.000000e+00, 1.817185e-02, 3.113013e-02, 4.930197e-02, 1.017270e-02, -1.458287e-02
- 1.440000e-01, 0.000000e+00, 1.797059e-02, 3.133131e-02, 4.930190e-02, 1.017164e-02, -1.396709e-02
- 1.450000e-01, 0.000000e+00, 1.779333e-02, 3.150851e-02, 4.930184e-02, 1.016599e-02, -1.334802e-02
- 1.460000e-01, 0.000000e+00, 1.764109e-02, 3.166069e-02, 4.930178e-02, 1.015639e-02, -1.272653e-02
- 1.470000e-01, 0.000000e+00, 1.751486e-02, 3.178686e-02, 4.930172e-02, 1.014953e-02, -1.210336e-02
- 1.480000e-01, 0.000000e+00, 1.741553e-02, 3.188614e-02, 4.930167e-02, 1.015358e-02, -1.147909e-02
- 1.490000e-01, 0.000000e+00, 1.734391e-02, 3.195772e-02, 4.930163e-02, 1.015243e-02, -1.085415e-02
- 1.500000e-01, 0.000000e+00, 1.730067e-02, 3.200093e-02, 4.930159e-02, 1.014942e-02, -1.022881e-02
- 1.510000e-01, 0.000000e+00, 1.728636e-02, 3.201520e-02, 4.930157e-02, 1.015210e-02, -1.037297e-02
- 1.520000e-01, 0.000000e+00, 1.730142e-02, 3.200013e-02, 4.930155e-02, 1.015311e-02, -1.100150e-02
- 1.530000e-01, 0.000000e+00, 1.734613e-02, 3.195541e-02, 4.930154e-02, 1.015241e-02, -1.162750e-02
- 1.540000e-01, 0.000000e+00, 1.742069e-02, 3.188084e-02, 4.930153e-02, 1.015012e-02, -1.225044e-02
- 1.550000e-01, 0.000000e+00, 1.752520e-02, 3.177633e-02, 4.930153e-02, 1.014645e-02, -1.286995e-02
- 1.560000e-01, 0.000000e+00, 1.765964e-02, 3.164190e-02, 4.930154e-02, 1.014826e-02, -1.348575e-02
- 1.570000e-01, 0.000000e+00, 1.782387e-02, 3.147769e-02, 4.930156e-02, 1.014949e-02, -1.409767e-02
- 1.580000e-01, 0.000000e+00, 1.801762e-02, 3.128397e-02, 4.930158e-02, 1.014904e-02, -1.470554e-02
- 1.590000e-01, 0.000000e+00, 1.824045e-02, 3.106117e-02, 4.930162e-02, 1.014691e-02, -1.530922e-02
- 1.600000e-01, 0.000000e+00, 1.849180e-02, 3.080986e-02, 4.930166e-02, 1.014325e-02, -1.590851e-02
- 1.610000e-01, 0.000000e+00, 1.877098e-02, 3.053073e-02, 4.930171e-02, 1.013835e-02, -1.650312e-02
- 1.620000e-01, 0.000000e+00, 1.907720e-02, 3.022457e-02, 4.930177e-02, 1.013791e-02, -1.709265e-02
- 1.630000e-01, 0.000000e+00, 1.940953e-02, 2.989230e-02, 4.930183e-02, 1.013774e-02, -1.767657e-02
- 1.640000e-01, 0.000000e+00, 1.976699e-02, 2.953491e-02, 4.930190e-02, 1.013589e-02, -1.825422e-02
- 1.650000e-01, 0.000000e+00, 2.014845e-02, 2.915353e-02, 4.930198e-02, 1.013442e-02, -1.882479e-02
- 1.660000e-01, 0.000000e+00, 2.055265e-02, 2.874942e-02, 4.930207e-02, 1.013297e-02, -1.938741e-02
- 1.670000e-01, 0.000000e+00, 2.097820e-02, 2.832396e-02, 4.930216e-02, 1.013007e-02, -1.994111e-02
- 1.680000e-01, 0.000000e+00, 2.142360e-02, 2.787866e-02, 4.930226e-02, 1.012584e-02, -2.048492e-02
- 1.690000e-01, 0.000000e+00, 2.188726e-02, 2.741510e-02, 4.930237e-02, 1.012356e-02, -2.101789e-02
- 1.700000e-01, 0.000000e+00, 2.236751e-02, 2.693496e-02, 4.930247e-02, 1.012374e-02, -2.153912e-02
- 1.710000e-01, 0.000000e+00, 2.286260e-02, 2.643999e-02, 4.930259e-02, 1.012266e-02, -2.204783e-02
- 1.720000e-01, 0.000000e+00, 2.337072e-02, 2.593198e-02, 4.930271e-02, 1.012016e-02, -2.254339e-02
- 1.730000e-01, 0.000000e+00, 2.388999e-02, 2.541284e-02, 4.930283e-02, 1.011625e-02, -2.302529e-02
- 1.740000e-01, 0.000000e+00, 2.441841e-02, 2.488455e-02, 4.930296e-02, 1.011105e-02, -2.349319e-02
- 1.750000e-01, 0.000000e+00, 2.495393e-02, 2.434916e-02, 4.930309e-02, 1.010578e-02, -2.394688e-02
- 1.760000e-01, 0.000000e+00, 2.549444e-02, 2.380879e-02, 4.930322e-02, 1.010506e-02, -2.438626e-02
- 1.770000e-01, 0.000000e+00, 2.603777e-02, 2.326559e-02, 4.930336e-02, 1.010305e-02, -2.481131e-02
- 1.780000e-01, 0.000000e+00, 2.658177e-02, 2.272173e-02, 4.930350e-02, 1.009965e-02, -2.522201e-02
- 1.790000e-01, 0.000000e+00, 2.712424e-02, 2.217940e-02, 4.930363e-02, 1.009486e-02, -2.561835e-02
- 1.800000e-01, 0.000000e+00, 2.766299e-02, 2.164078e-02, 4.930377e-02, 1.008886e-02, -2.600023e-02
- 1.810000e-01, 0.000000e+00, 2.819582e-02, 2.110810e-02, 4.930391e-02, 1.008192e-02, -2.636748e-02
- 1.820000e-01, 0.000000e+00, 2.872049e-02, 2.058356e-02, 4.930405e-02, 1.008049e-02, -2.671980e-02
- 1.830000e-01, 0.000000e+00, 2.923477e-02, 2.006942e-02, 4.930419e-02, 1.007777e-02, -2.705679e-02
- 1.840000e-01, 0.000000e+00, 2.973645e-02, 1.956788e-02, 4.930433e-02, 1.007939e-02, -2.737789e-02
- 1.850000e-01, 0.000000e+00, 3.022333e-02, 1.908113e-02, 4.930446e-02, 1.007823e-02, -2.768250e-02
- 1.860000e-01, 0.000000e+00, 3.069328e-02, 1.861131e-02, 4.930459e-02, 1.007296e-02, -2.796995e-02
- 1.870000e-01, 0.000000e+00, 3.114424e-02, 1.816047e-02, 4.930471e-02, 1.008037e-02, -2.823954e-02
- 1.880000e-01, 0.000000e+00, 3.157422e-02, 1.773062e-02, 4.930484e-02, 1.009006e-02, -2.849063e-02
- 1.890000e-01, 0.000000e+00, 3.198124e-02, 1.732371e-02, 4.930495e-02, 1.009446e-02, -2.872265e-02
- 1.900000e-01, 0.000000e+00, 3.236343e-02, 1.694164e-02, 4.930507e-02, 1.009414e-02, -2.893517e-02
- 1.910000e-01, 0.000000e+00, 3.271894e-02, 1.658623e-02, 4.930518e-02, 1.008967e-02, -2.912787e-02
- 1.920000e-01, 0.000000e+00, 3.304605e-02, 1.625923e-02, 4.930528e-02, 1.009993e-02, -2.930059e-02
- 1.930000e-01, 0.000000e+00, 3.334311e-02, 1.596227e-02, 4.930537e-02, 1.011037e-02, -2.945335e-02
- 1.940000e-01, 0.000000e+00, 3.360862e-02, 1.569684e-02, 4.930546e-02, 1.011551e-02, -2.958627e-02
- 1.950000e-01, 0.000000e+00, 3.384120e-02, 1.546434e-02, 4.930554e-02, 1.011587e-02, -2.969957e-02
- 1.960000e-01, 0.000000e+00, 3.403960e-02, 1.526601e-02, 4.930561e-02, 1.011204e-02, -2.979353e-02
- 1.970000e-01, 0.000000e+00, 3.420267e-02, 1.510300e-02, 4.930567e-02, 1.012409e-02, -2.986842e-02
- 1.980000e-01, 0.000000e+00, 3.432939e-02, 1.497634e-02, 4.930573e-02, 1.013509e-02, -2.992448e-02
- 1.990000e-01, 0.000000e+00, 3.441885e-02, 1.488693e-02, 4.930578e-02, 1.014075e-02, -2.996190e-02
- 2.000000e-01, 0.000000e+00, 3.447029e-02, 1.483552e-02, 4.930582e-02, 1.014159e-02, -2.998072e-02
- 2.010000e-01, 0.000000e+00, 3.448312e-02, 1.482272e-02, 4.930584e-02, 1.013819e-02, -2.998091e-02
- 2.020000e-01, 0.000000e+00, 3.445691e-02, 1.484895e-02, 4.930586e-02, 1.015072e-02, -2.996230e-02
- 2.030000e-01, 0.000000e+00, 3.439139e-02, 1.491447e-02, 4.930587e-02, 1.016205e-02, -2.992464e-02
- 2.040000e-01, 0.000000e+00, 3.428647e-02, 1.501939e-02, 4.930586e-02, 1.016800e-02, -2.986763e-02
- 2.050000e-01, 0.000000e+00, 3.414218e-02, 1.516367e-02, 4.930585e-02, 1.016909e-02, -2.979095e-02
- 2.060000e-01, 0.000000e+00, 3.395871e-02, 1.534712e-02, 4.930583e-02, 1.016588e-02, -2.969431e-02
- 2.070000e-01, 0.000000e+00, 3.373638e-02, 1.556942e-02, 4.930580e-02, 1.017746e-02, -2.957751e-02
- 2.080000e-01, 0.000000e+00, 3.347570e-02, 1.583005e-02, 4.930576e-02, 1.018887e-02, -2.944044e-02
- 2.090000e-01, 0.000000e+00, 3.317735e-02, 1.612836e-02, 4.930570e-02, 1.019486e-02, -2.928316e-02
- 2.100000e-01, 0.000000e+00, 3.284217e-02, 1.646347e-02, 4.930564e-02, 1.019595e-02, -2.910585e-02
- 2.110000e-01, 0.000000e+00, 3.247119e-02, 1.683438e-02, 4.930557e-02, 1.019269e-02, -2.890887e-02
- 2.120000e-01, 0.000000e+00, 3.206557e-02, 1.723992e-02, 4.930549e-02, 1.020191e-02, -2.869266e-02
- 2.130000e-01, 0.000000e+00, 3.162662e-02, 1.767877e-02, 4.930540e-02, 1.021318e-02, -2.845779e-02
- 2.140000e-01, 0.000000e+00, 3.115578e-02, 1.814951e-02, 4.930530e-02, 1.021898e-02, -2.820485e-02
- 2.150000e-01, 0.000000e+00, 3.065462e-02, 1.865057e-02, 4.930519e-02, 1.021985e-02, -2.793444e-02
- 2.160000e-01, 0.000000e+00, 3.012486e-02, 1.918021e-02, 4.930507e-02, 1.021632e-02, -2.764710e-02
- 2.170000e-01, 0.000000e+00, 2.956835e-02, 1.973659e-02, 4.930495e-02, 1.022193e-02, -2.734330e-02
- 2.180000e-01, 0.000000e+00, 2.898711e-02, 2.031770e-02, 4.930481e-02, 1.023285e-02, -2.702342e-02
- 2.190000e-01, 0.000000e+00, 2.838327e-02, 2.092140e-02, 4.930468e-02, 1.023828e-02, -2.668770e-02
- 2.200000e-01, 0.000000e+00, 2.775906e-02, 2.154547e-02, 4.930453e-02, 1.023873e-02, -2.633629e-02
- 2.210000e-01, 0.000000e+00, 2.711681e-02, 2.218757e-02, 4.930438e-02, 1.023475e-02, -2.596925e-02
- 2.220000e-01, 0.000000e+00, 2.645890e-02, 2.284532e-02, 4.930423e-02, 1.023578e-02, -2.558661e-02
- 2.230000e-01, 0.000000e+00, 2.578783e-02, 2.351624e-02, 4.930407e-02, 1.024621e-02, -2.518838e-02
- 2.240000e-01, 0.000000e+00, 2.510615e-02, 2.419775e-02, 4.930390e-02, 1.025112e-02, -2.477464e-02
- 2.250000e-01, 0.000000e+00, 2.441651e-02, 2.488722e-02, 4.930373e-02, 1.025103e-02, -2.434553e-02
- 2.260000e-01, 0.000000e+00, 2.372163e-02, 2.558192e-02, 4.930356e-02, 1.024647e-02, -2.390133e-02
- 2.270000e-01, 0.000000e+00, 2.302428e-02, 2.627910e-02, 4.930338e-02, 1.024233e-02, -2.344244e-02
- 2.280000e-01, 0.000000e+00, 2.232724e-02, 2.697597e-02, 4.930321e-02, 1.025219e-02, -2.296942e-02
- 2.290000e-01, 0.000000e+00, 2.163331e-02, 2.766972e-02, 4.930303e-02, 1.025652e-02, -2.248294e-02
- 2.300000e-01, 0.000000e+00, 2.094528e-02, 2.835758e-02, 4.930286e-02, 1.025582e-02, -2.198377e-02
- 2.310000e-01, 0.000000e+00, 2.026595e-02, 2.903673e-02, 4.930268e-02, 1.025063e-02, -2.147275e-02
- 2.320000e-01, 0.000000e+00, 1.959810e-02, 2.970441e-02, 4.930251e-02, 1.024152e-02, -2.095073e-02
- 2.330000e-01, 0.000000e+00, 1.894453e-02, 3.035781e-02, 4.930234e-02, 1.025046e-02, -2.041851e-02
- 2.340000e-01, 0.000000e+00, 1.830799e-02, 3.099418e-02, 4.930217e-02, 1.025420e-02, -1.987684e-02
- 2.350000e-01, 0.000000e+00, 1.769121e-02, 3.161080e-02, 4.930200e-02, 1.025291e-02, -1.932637e-02
- 2.360000e-01, 0.000000e+00, 1.709683e-02, 3.220501e-02, 4.930184e-02, 1.024712e-02, -1.876761e-02
- 2.370000e-01, 0.000000e+00, 1.652743e-02, 3.277425e-02, 4.930169e-02, 1.023737e-02, -1.820097e-02
- 2.380000e-01, 0.000000e+00, 1.598548e-02, 3.331606e-02, 4.930154e-02, 1.024142e-02, -1.762679e-02
- 2.390000e-01, 0.000000e+00, 1.547336e-02, 3.382803e-02, 4.930139e-02, 1.024466e-02, -1.704530e-02
- 2.400000e-01, 0.000000e+00, 1.499337e-02, 3.430788e-02, 4.930126e-02, 1.024287e-02, -1.645675e-02
- 2.410000e-01, 0.000000e+00, 1.454772e-02, 3.475341e-02, 4.930112e-02, 1.023656e-02, -1.586138e-02
- 2.420000e-01, 0.000000e+00, 1.413849e-02, 3.516251e-02, 4.930100e-02, 1.022628e-02, -1.525953e-02
- 2.430000e-01, 0.000000e+00, 1.376765e-02, 3.553324e-02, 4.930089e-02, 1.022619e-02, -1.465161e-02
- 2.440000e-01, 0.000000e+00, 1.343700e-02, 3.586378e-02, 4.930079e-02, 1.022908e-02, -1.403817e-02
- 2.450000e-01, 0.000000e+00, 1.314820e-02, 3.615250e-02, 4.930069e-02, 1.022693e-02, -1.341988e-02
- 2.460000e-01, 0.000000e+00, 1.290271e-02, 3.639790e-02, 4.930061e-02, 1.022027e-02, -1.279753e-02
- 2.470000e-01, 0.000000e+00, 1.270186e-02, 3.659868e-02, 4.930054e-02, 1.020963e-02, -1.217201e-02
- 2.480000e-01, 0.000000e+00, 1.254682e-02, 3.675366e-02, 4.930048e-02, 1.020651e-02, -1.154426e-02
- 2.490000e-01, 0.000000e+00, 1.243858e-02, 3.686184e-02, 4.930042e-02, 1.020924e-02, -1.091522e-02
- 2.500000e-01, 0.000000e+00, 1.237799e-02, 3.692239e-02, 4.930038e-02, 1.020694e-02, -1.029430e-02
- 2.510000e-01, 0.000000e+00, 1.236568e-02, 3.693468e-02, 4.930036e-02, 1.020012e-02, -1.030956e-02
- 2.520000e-01, 0.000000e+00, 1.240209e-02, 3.689825e-02, 4.930034e-02, 1.018933e-02, -1.092245e-02
- 2.530000e-01, 0.000000e+00, 1.248745e-02, 3.681289e-02, 4.930034e-02, 1.018452e-02, -1.154741e-02
- 2.540000e-01, 0.000000e+00, 1.262179e-02, 3.667856e-02, 4.930035e-02, 1.018733e-02, -1.217124e-02
- 2.550000e-01, 0.000000e+00, 1.280493e-02, 3.649544e-02, 4.930037e-02, 1.018511e-02, -1.279356e-02
- 2.560000e-01, 0.000000e+00, 1.303655e-02, 3.626386e-02, 4.930041e-02, 1.017837e-02, -1.341388e-02
- 2.570000e-01, 0.000000e+00, 1.331609e-02, 3.598436e-02, 4.930045e-02, 1.016767e-02, -1.403594e-02
- 2.580000e-01, 0.000000e+00, 1.364285e-02, 3.565766e-02, 4.930051e-02, 1.016262e-02, -1.465476e-02
- 2.590000e-01, 0.000000e+00, 1.401589e-02, 3.528469e-02, 4.930058e-02, 1.016573e-02, -1.526837e-02
- 2.600000e-01, 0.000000e+00, 1.443408e-02, 3.486658e-02, 4.930066e-02, 1.016383e-02, -1.587583e-02
- 2.610000e-01, 0.000000e+00, 1.489609e-02, 3.440467e-02, 4.930076e-02, 1.015743e-02, -1.647628e-02
- 2.620000e-01, 0.000000e+00, 1.540038e-02, 3.390049e-02, 4.930087e-02, 1.015050e-02, -1.706896e-02
- 2.630000e-01, 0.000000e+00, 1.594524e-02, 3.335574e-02, 4.930098e-02, 1.014921e-02, -1.765319e-02
- 2.640000e-01, 0.000000e+00, 1.652882e-02, 3.277229e-02, 4.930111e-02, 1.014682e-02, -1.822843e-02
- 2.650000e-01, 0.000000e+00, 1.714909e-02, 3.215215e-02, 4.930124e-02, 1.014546e-02, -1.879423e-02
- 2.660000e-01, 0.000000e+00, 1.780388e-02, 3.149751e-02, 4.930139e-02, 1.013960e-02, -1.935024e-02
- 2.670000e-01, 0.000000e+00, 1.849083e-02, 3.081072e-02, 4.930155e-02, 1.013940e-02, -1.989620e-02
- 2.680000e-01, 0.000000e+00, 1.920744e-02, 3.009427e-02, 4.930171e-02, 1.013806e-02, -2.043189e-02
- 2.690000e-01, 0.000000e+00, 1.995106e-02, 2.935083e-02, 4.930189e-02, 1.013512e-02, -2.095718e-02
- 2.700000e-01, 0.000000e+00, 2.071888e-02, 2.858319e-02, 4.930207e-02, 1.013205e-02, -2.147394e-02
- 2.710000e-01, 0.000000e+00, 2.150802e-02, 2.779423e-02, 4.930226e-02, 1.012692e-02, -2.198178e-02
- 2.720000e-01, 0.000000e+00, 2.231549e-02, 2.698695e-02, 4.930245e-02, 1.012172e-02, -2.247855e-02
- 2.730000e-01, 0.000000e+00, 2.313822e-02, 2.616442e-02, 4.930265e-02, 1.012047e-02, -2.296372e-02
- 2.740000e-01, 0.000000e+00, 2.397305e-02, 2.532980e-02, 4.930285e-02, 1.012494e-02, -2.343664e-02
- 2.750000e-01, 0.000000e+00, 2.481674e-02, 2.448631e-02, 4.930305e-02, 1.012517e-02, -2.389661e-02
- 2.760000e-01, 0.000000e+00, 2.566599e-02, 2.363727e-02, 4.930327e-02, 1.012088e-02, -2.434287e-02
- 2.770000e-01, 0.000000e+00, 2.651742e-02, 2.278605e-02, 4.930348e-02, 1.011260e-02, -2.477469e-02
- 2.780000e-01, 0.000000e+00, 2.736764e-02, 2.193605e-02, 4.930369e-02, 1.011842e-02, -2.519140e-02
- 2.790000e-01, 0.000000e+00, 2.821323e-02, 2.109068e-02, 4.930390e-02, 1.012459e-02, -2.559242e-02
- 2.800000e-01, 0.000000e+00, 2.905079e-02, 2.025333e-02, 4.930411e-02, 1.012574e-02, -2.597731e-02
- 2.810000e-01, 0.000000e+00, 2.987694e-02, 1.942739e-02, 4.930433e-02, 1.012235e-02, -2.634730e-02
- 2.820000e-01, 0.000000e+00, 3.068832e-02, 1.861621e-02, 4.930453e-02, 1.011496e-02, -2.670466e-02
- 2.830000e-01, 0.000000e+00, 3.148160e-02, 1.782314e-02, 4.930474e-02, 1.012482e-02, -2.704476e-02
- 2.840000e-01, 0.000000e+00, 3.225346e-02, 1.705148e-02, 4.930494e-02, 1.013191e-02, -2.736703e-02
- 2.850000e-01, 0.000000e+00, 3.300066e-02, 1.630448e-02, 4.930514e-02, 1.013396e-02, -2.767102e-02
- 2.860000e-01, 0.000000e+00, 3.372002e-02, 1.558531e-02, 4.930533e-02, 1.013146e-02, -2.795635e-02
- 2.870000e-01, 0.000000e+00, 3.440848e-02, 1.489704e-02, 4.930552e-02, 1.012504e-02, -2.822282e-02
- 2.880000e-01, 0.000000e+00, 3.506309e-02, 1.424261e-02, 4.930570e-02, 1.013849e-02, -2.847029e-02
- 2.890000e-01, 0.000000e+00, 3.568101e-02, 1.362486e-02, 4.930586e-02, 1.014642e-02, -2.869875e-02
- 2.900000e-01, 0.000000e+00, 3.625954e-02, 1.304649e-02, 4.930603e-02, 1.014928e-02, -2.890827e-02
- 2.910000e-01, 0.000000e+00, 3.679611e-02, 1.251007e-02, 4.930618e-02, 1.014756e-02, -2.910078e-02
- 2.920000e-01, 0.000000e+00, 3.728826e-02, 1.201806e-02, 4.930632e-02, 1.014415e-02, -2.927844e-02
- 2.930000e-01, 0.000000e+00, 3.773373e-02, 1.157273e-02, 4.930645e-02, 1.015831e-02, -2.943669e-02
- 2.940000e-01, 0.000000e+00, 3.813038e-02, 1.117619e-02, 4.930657e-02, 1.016693e-02, -2.957518e-02
- 2.950000e-01, 0.000000e+00, 3.847631e-02, 1.083037e-02, 4.930668e-02, 1.017045e-02, -2.969366e-02
- 2.960000e-01, 0.000000e+00, 3.876980e-02, 1.053697e-02, 4.930677e-02, 1.016936e-02, -2.979200e-02
- 2.970000e-01, 0.000000e+00, 3.900936e-02, 1.029750e-02, 4.930686e-02, 1.016788e-02, -2.987023e-02
- 2.980000e-01, 0.000000e+00, 3.919367e-02, 1.011326e-02, 4.930692e-02, 1.018257e-02, -2.992847e-02
- 2.990000e-01, 0.000000e+00, 3.932162e-02, 9.985363e-03, 4.930698e-02, 1.019167e-02, -2.996696e-02
- 3.000000e-01, 0.000000e+00, 3.939231e-02, 9.914714e-03, 4.930702e-02, 1.019565e-02, -2.998593e-02
- 3.010000e-01, 0.000000e+00, 3.940506e-02, 9.901996e-03, 4.930705e-02, 1.019497e-02, -2.998880e-02
- 3.020000e-01, 0.000000e+00, 3.935941e-02, 9.947657e-03, 4.930707e-02, 1.019413e-02, -2.997366e-02
- 3.030000e-01, 0.000000e+00, 3.925516e-02, 1.005190e-02, 4.930706e-02, 1.020910e-02, -2.993849e-02
- 3.040000e-01, 0.000000e+00, 3.909236e-02, 1.021469e-02, 4.930704e-02, 1.021846e-02, -2.988304e-02
- 3.050000e-01, 0.000000e+00, 3.887128e-02, 1.043573e-02, 4.930701e-02, 1.022266e-02, -2.980712e-02
- 3.060000e-01, 0.000000e+00, 3.859244e-02, 1.071453e-02, 4.930697e-02, 1.022216e-02, -2.971066e-02
- 3.070000e-01, 0.000000e+00, 3.825655e-02, 1.105036e-02, 4.930691e-02, 1.022051e-02, -2.959369e-02
- 3.080000e-01, 0.000000e+00, 3.786457e-02, 1.144227e-02, 4.930684e-02, 1.023553e-02, -2.945636e-02
- 3.090000e-01, 0.000000e+00, 3.741767e-02, 1.188907e-02, 4.930675e-02, 1.024490e-02, -2.929896e-02
- 3.100000e-01, 0.000000e+00, 3.691728e-02, 1.238937e-02, 4.930664e-02, 1.024907e-02, -2.912184e-02
- 3.110000e-01, 0.000000e+00, 3.636503e-02, 1.294150e-02, 4.930653e-02, 1.024851e-02, -2.892829e-02
- 3.120000e-01, 0.000000e+00, 3.576281e-02, 1.354358e-02, 4.930639e-02, 1.024464e-02, -2.871565e-02
- 3.130000e-01, 0.000000e+00, 3.511272e-02, 1.419353e-02, 4.930625e-02, 1.025948e-02, -2.848405e-02
- 3.140000e-01, 0.000000e+00, 3.441704e-02, 1.488905e-02, 4.930610e-02, 1.026864e-02, -2.823395e-02
- 3.150000e-01, 0.000000e+00, 3.367825e-02, 1.562768e-02, 4.930593e-02, 1.027256e-02, -2.796587e-02
- 3.160000e-01, 0.000000e+00, 3.289900e-02, 1.640676e-02, 4.930575e-02, 1.027171e-02, -2.768034e-02
- 3.170000e-01, 0.000000e+00, 3.208210e-02, 1.722346e-02, 4.930557e-02, 1.026658e-02, -2.737789e-02
- 3.180000e-01, 0.000000e+00, 3.123058e-02, 1.807479e-02, 4.930537e-02, 1.027882e-02, -2.705896e-02
- 3.190000e-01, 0.000000e+00, 3.034761e-02, 1.895755e-02, 4.930516e-02, 1.028757e-02, -2.672392e-02
- 3.200000e-01, 0.000000e+00, 2.943652e-02, 1.986842e-02, 4.930494e-02, 1.029106e-02, -2.637301e-02
- 3.210000e-01, 0.000000e+00, 2.850079e-02, 2.080393e-02, 4.930472e-02, 1.028975e-02, -2.600660e-02
- 3.220000e-01, 0.000000e+00, 2.754398e-02, 2.176051e-02, 4.930449e-02, 1.028412e-02, -2.562589e-02
- 3.230000e-01, 0.000000e+00, 2.656976e-02, 2.273450e-02, 4.930426e-02, 1.029188e-02, -2.522953e-02
- 3.240000e-01, 0.000000e+00, 2.558189e-02, 2.372213e-02, 4.930402e-02, 1.030008e-02, -2.481764e-02
- 3.250000e-01, 0.000000e+00, 2.458419e-02, 2.471958e-02, 4.930377e-02, 1.030300e-02, -2.439036e-02
- 3.260000e-01, 0.000000e+00, 2.358058e-02, 2.572295e-02, 4.930352e-02, 1.030109e-02, -2.394798e-02
- 3.270000e-01, 0.000000e+00, 2.257501e-02, 2.672826e-02, 4.930327e-02, 1.029485e-02, -2.349086e-02
- 3.280000e-01, 0.000000e+00, 2.157150e-02, 2.773152e-02, 4.930302e-02, 1.029757e-02, -2.301949e-02
- 3.290000e-01, 0.000000e+00, 2.057407e-02, 2.872870e-02, 4.930277e-02, 1.030516e-02, -2.253446e-02
- 3.300000e-01, 0.000000e+00, 1.958673e-02, 2.971580e-02, 4.930252e-02, 1.030745e-02, -2.203647e-02
- 3.310000e-01, 0.000000e+00, 1.861344e-02, 3.068883e-02, 4.930228e-02, 1.030490e-02, -2.152628e-02
- 3.320000e-01, 0.000000e+00, 1.765816e-02, 3.164387e-02, 4.930203e-02, 1.029799e-02, -2.100470e-02
- 3.330000e-01, 0.000000e+00, 1.672478e-02, 3.257701e-02, 4.930179e-02, 1.029556e-02, -2.047342e-02
- 3.340000e-01, 0.000000e+00, 1.581713e-02, 3.348442e-02, 4.930156e-02, 1.030254e-02, -1.993361e-02
- 3.350000e-01, 0.000000e+00, 1.493901e-02, 3.436231e-02, 4.930133e-02, 1.030421e-02, -1.938467e-02
- 3.360000e-01, 0.000000e+00, 1.409410e-02, 3.520701e-02, 4.930110e-02, 1.030104e-02, -1.882703e-02
- 3.370000e-01, 0.000000e+00, 1.328596e-02, 3.601493e-02, 4.930089e-02, 1.029349e-02, -1.826104e-02
- 3.380000e-01, 0.000000e+00, 1.251804e-02, 3.678265e-02, 4.930068e-02, 1.028625e-02, -1.768700e-02
- 3.390000e-01, 0.000000e+00, 1.179360e-02, 3.750688e-02, 4.930049e-02, 1.029269e-02, -1.710521e-02
- 3.400000e-01, 0.000000e+00, 1.111578e-02, 3.818452e-02, 4.930030e-02, 1.029384e-02, -1.651600e-02
- 3.410000e-01, 0.000000e+00, 1.048753e-02, 3.881260e-02, 4.930013e-02, 1.029013e-02, -1.591976e-02
- 3.420000e-01, 0.000000e+00, 9.911642e-03, 3.938832e-02, 4.929997e-02, 1.028205e-02, -1.531699e-02
- 3.430000e-01, 0.000000e+00, 9.390729e-03, 3.990909e-02, 4.929981e-02, 1.027074e-02, -1.471063e-02
- 3.440000e-01, 0.000000e+00, 8.927204e-03, 4.037247e-02, 4.929968e-02, 1.027680e-02, -1.409984e-02
- 3.450000e-01, 0.000000e+00, 8.523254e-03, 4.077630e-02, 4.929956e-02, 1.027757e-02, -1.348420e-02
- 3.460000e-01, 0.000000e+00, 8.180827e-03, 4.111862e-02, 4.929945e-02, 1.027349e-02, -1.286421e-02
- 3.470000e-01, 0.000000e+00, 7.901627e-03, 4.139773e-02, 4.929936e-02, 1.026503e-02, -1.224048e-02
- 3.480000e-01, 0.000000e+00, 7.687112e-03, 4.161217e-02, 4.929928e-02, 1.025271e-02, -1.161372e-02
- 3.490000e-01, 0.000000e+00, 7.538500e-03, 4.176072e-02, 4.929922e-02, 1.025664e-02, -1.098475e-02
- 3.500000e-01, 0.000000e+00, 7.456766e-03, 4.184241e-02, 4.929918e-02, 1.025723e-02, -1.035653e-02
- 3.510000e-01, 0.000000e+00, 7.442635e-03, 4.185651e-02, 4.929915e-02, 1.025298e-02, -1.026813e-02
- 3.520000e-01, 0.000000e+00, 7.496568e-03, 4.180257e-02, 4.929914e-02, 1.024437e-02, -1.087872e-02
- 3.530000e-01, 0.000000e+00, 7.618746e-03, 4.168040e-02, 4.929914e-02, 1.023189e-02, -1.149013e-02
- 3.540000e-01, 0.000000e+00, 7.809064e-03, 4.149010e-02, 4.929917e-02, 1.023439e-02, -1.211210e-02
- 3.550000e-01, 0.000000e+00, 8.067137e-03, 4.123207e-02, 4.929921e-02, 1.023504e-02, -1.273728e-02
- 3.560000e-01, 0.000000e+00, 8.392306e-03, 4.090696e-02, 4.929926e-02, 1.023086e-02, -1.335969e-02
- 3.570000e-01, 0.000000e+00, 8.783652e-03, 4.051569e-02, 4.929934e-02, 1.022232e-02, -1.397845e-02
- 3.580000e-01, 0.000000e+00, 9.240000e-03, 4.005943e-02, 4.929943e-02, 1.020992e-02, -1.459275e-02
- 3.590000e-01, 0.000000e+00, 9.759919e-03, 3.953961e-02, 4.929953e-02, 1.021244e-02, -1.520184e-02
- 3.600000e-01, 0.000000e+00, 1.034171e-02, 3.895794e-02, 4.929966e-02, 1.021339e-02, -1.580508e-02
- 3.610000e-01, 0.000000e+00, 1.098342e-02, 3.831637e-02, 4.929980e-02, 1.020952e-02, -1.640195e-02
- 3.620000e-01, 0.000000e+00, 1.168282e-02, 3.761713e-02, 4.929995e-02, 1.020130e-02, -1.699203e-02
- 3.630000e-01, 0.000000e+00, 1.243744e-02, 3.686268e-02, 4.930012e-02, 1.018922e-02, -1.757496e-02
- 3.640000e-01, 0.000000e+00, 1.324456e-02, 3.605574e-02, 4.930030e-02, 1.019316e-02, -1.815180e-02
- 3.650000e-01, 0.000000e+00, 1.410126e-02, 3.519923e-02, 4.930050e-02, 1.019463e-02, -1.872745e-02
- 3.660000e-01, 0.000000e+00, 1.500444e-02, 3.429626e-02, 4.930070e-02, 1.019129e-02, -1.929394e-02
- 3.670000e-01, 0.000000e+00, 1.595077e-02, 3.335016e-02, 4.930092e-02, 1.018360e-02, -1.985042e-02
- 3.680000e-01, 0.000000e+00, 1.693674e-02, 3.236442e-02, 4.930115e-02, 1.017206e-02, -2.039609e-02
- 3.690000e-01, 0.000000e+00, 1.795866e-02, 3.134274e-02, 4.930140e-02, 1.017864e-02, -2.093023e-02
- 3.700000e-01, 0.000000e+00, 1.901265e-02, 3.028900e-02, 4.930165e-02, 1.018082e-02, -2.145219e-02
- 3.710000e-01, 0.000000e+00, 2.009468e-02, 2.920723e-02, 4.930191e-02, 1.017819e-02, -2.196142e-02
- 3.720000e-01, 0.000000e+00, 2.120059e-02, 2.810158e-02, 4.930218e-02, 1.017121e-02, -2.245747e-02
- 3.730000e-01, 0.000000e+00, 2.232613e-02, 2.697632e-02, 4.930245e-02, 1.016227e-02, -2.293997e-02
- 3.740000e-01, 0.000000e+00, 2.346694e-02, 2.583579e-02, 4.930272e-02, 1.017052e-02, -2.340863e-02
- 3.750000e-01, 0.000000e+00, 2.461858e-02, 2.468443e-02, 4.930301e-02, 1.017353e-02, -2.386325e-02
- 3.760000e-01, 0.000000e+00, 2.577656e-02, 2.352673e-02, 4.930329e-02, 1.017173e-02, -2.430367e-02
- 3.770000e-01, 0.000000e+00, 2.693631e-02, 2.236727e-02, 4.930358e-02, 1.016559e-02, -2.473282e-02
- 3.780000e-01, 0.000000e+00, 2.809323e-02, 2.121064e-02, 4.930387e-02, 1.016063e-02, -2.514853e-02
- 3.790000e-01, 0.000000e+00, 2.924267e-02, 2.006148e-02, 4.930416e-02, 1.016979e-02, -2.554902e-02
- 3.800000e-01, 0.000000e+00, 3.038005e-02, 1.892440e-02, 4.930444e-02, 1.017370e-02, -2.593414e-02
- 3.810000e-01, 0.000000e+00, 3.150077e-02, 1.780396e-02, 4.930473e-02, 1.017279e-02, -2.630379e-02
- 3.820000e-01, 0.000000e+00, 3.260031e-02, 1.670470e-02, 4.930500e-02, 1.016752e-02, -2.665781e-02
- 3.830000e-01, 0.000000e+00, 3.367421e-02, 1.563107e-02, 4.930528e-02, 1.016668e-02, -2.699601e-02
- 3.840000e-01, 0.000000e+00, 3.471809e-02, 1.458746e-02, 4.930555e-02, 1.017673e-02, -2.731813e-02
- 3.850000e-01, 0.000000e+00, 3.572764e-02, 1.357817e-02, 4.930581e-02, 1.018152e-02, -2.762381e-02
- 3.860000e-01, 0.000000e+00, 3.669867e-02, 1.260740e-02, 4.930607e-02, 1.018148e-02, -2.791261e-02
- 3.870000e-01, 0.000000e+00, 3.762709e-02, 1.167922e-02, 4.930631e-02, 1.017706e-02, -2.818404e-02
- 3.880000e-01, 0.000000e+00, 3.850899e-02, 1.079755e-02, 4.930654e-02, 1.018001e-02, -2.843759e-02
- 3.890000e-01, 0.000000e+00, 3.934064e-02, 9.966122e-03, 4.930676e-02, 1.019088e-02, -2.867274e-02
- 3.900000e-01, 0.000000e+00, 4.011850e-02, 9.188474e-03, 4.930697e-02, 1.019647e-02, -2.888904e-02
- 3.910000e-01, 0.000000e+00, 4.083921e-02, 8.467959e-03, 4.930717e-02, 1.019720e-02, -2.908911e-02
- 3.920000e-01, 0.000000e+00, 4.149963e-02, 7.807722e-03, 4.930735e-02, 1.019352e-02, -2.927077e-02
- 3.930000e-01, 0.000000e+00, 4.209682e-02, 7.210699e-03, 4.930752e-02, 1.019951e-02, -2.943258e-02
- 3.940000e-01, 0.000000e+00, 4.262808e-02, 6.679596e-03, 4.930768e-02, 1.021105e-02, -2.957420e-02
- 3.950000e-01, 0.000000e+00, 4.309094e-02, 6.216873e-03, 4.930781e-02, 1.021728e-02, -2.969537e-02
- 3.960000e-01, 0.000000e+00, 4.348322e-02, 5.824718e-03, 4.930793e-02, 1.021863e-02, -2.979594e-02
- 3.970000e-01, 0.000000e+00, 4.380300e-02, 5.505038e-03, 4.930804e-02, 1.021553e-02, -2.987585e-02
- 3.980000e-01, 0.000000e+00, 4.404867e-02, 5.259452e-03, 4.930812e-02, 1.022347e-02, -2.993515e-02
- 3.990000e-01, 0.000000e+00, 4.421889e-02, 5.089296e-03, 4.930818e-02, 1.023548e-02, -2.997398e-02
- 4.000000e-01, 0.000000e+00, 4.431261e-02, 4.995618e-03, 4.930823e-02, 1.024215e-02, -2.999255e-02
-Comparing last generated output to the reference file
-1,402c1,202
-&lt; time, wext, epot, ekin, total, max_disp, min_disp
-&lt; 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 1.000000e-02, -1.000000e-02
-&lt; 1.000000e-03, 0.000000e+00, 2.464762e-02, 2.465579e-02, 4.930341e-02, 1.000000e-02, -1.000000e-02
-&lt; 2.000000e-03, 0.000000e+00, 2.467180e-02, 2.463164e-02, 4.930344e-02, 9.994082e-03, -9.990151e-03
-&lt; 3.000000e-03, 0.000000e+00, 2.469535e-02, 2.460813e-02, 4.930348e-02, 9.995108e-03, -9.994951e-03
-&lt; 4.000000e-03, 0.000000e+00, 2.471764e-02, 2.458588e-02, 4.930352e-02, 1.001558e-02, -1.001466e-02
-&lt; 5.000000e-03, 0.000000e+00, 2.473805e-02, 2.456551e-02, 4.930355e-02, 1.002761e-02, -1.002451e-02
-&lt; 6.000000e-03, 0.000000e+00, 2.475604e-02, 2.454754e-02, 4.930358e-02, 1.003241e-02, -1.002448e-02
-&lt; 7.000000e-03, 0.000000e+00, 2.477124e-02, 2.453236e-02, 4.930360e-02, 1.003156e-02, -1.001458e-02
-&lt; 8.000000e-03, 0.000000e+00, 2.478334e-02, 2.452027e-02, 4.930361e-02, 1.002688e-02, -1.001808e-02
-&lt; 9.000000e-03, 0.000000e+00, 2.479207e-02, 2.451156e-02, 4.930363e-02, 1.004157e-02, -1.003757e-02
-&lt; 1.000000e-02, 0.000000e+00, 2.479710e-02, 2.450656e-02, 4.930366e-02, 1.005530e-02, -1.004718e-02
-&lt; 1.100000e-02, 0.000000e+00, 2.479802e-02, 2.450566e-02, 4.930368e-02, 1.006202e-02, -1.004689e-02
-&lt; 1.200000e-02, 0.000000e+00, 2.479443e-02, 2.450927e-02, 4.930371e-02, 1.006296e-02, -1.003670e-02
-&lt; 1.300000e-02, 0.000000e+00, 2.478598e-02, 2.451775e-02, 4.930372e-02, 1.005956e-02, -1.003757e-02
-&lt; 1.400000e-02, 0.000000e+00, 2.477239e-02, 2.453134e-02, 4.930373e-02, 1.006400e-02, -1.005664e-02
-&lt; 1.500000e-02, 0.000000e+00, 2.475352e-02, 2.455021e-02, 4.930374e-02, 1.007863e-02, -1.006580e-02
-&lt; 1.600000e-02, 0.000000e+00, 2.472930e-02, 2.457444e-02, 4.930374e-02, 1.008633e-02, -1.006504e-02
-&lt; 1.700000e-02, 0.000000e+00, 2.469966e-02, 2.460408e-02, 4.930374e-02, 1.008815e-02, -1.005437e-02
-&lt; 1.800000e-02, 0.000000e+00, 2.466454e-02, 2.463921e-02, 4.930375e-02, 1.008534e-02, -1.005151e-02
-&lt; 1.900000e-02, 0.000000e+00, 2.462384e-02, 2.467992e-02, 4.930375e-02, 1.008067e-02, -1.006999e-02
-&lt; 2.000000e-02, 0.000000e+00, 2.457750e-02, 2.472626e-02, 4.930376e-02, 1.009574e-02, -1.007854e-02
-&lt; 2.100000e-02, 0.000000e+00, 2.452550e-02, 2.477825e-02, 4.930375e-02, 1.010392e-02, -1.007717e-02
-&lt; 2.200000e-02, 0.000000e+00, 2.446795e-02, 2.483579e-02, 4.930374e-02, 1.010616e-02, -1.006587e-02
-&lt; 2.300000e-02, 0.000000e+00, 2.440504e-02, 2.489868e-02, 4.930372e-02, 1.010356e-02, -1.005853e-02
-&lt; 2.400000e-02, 0.000000e+00, 2.433702e-02, 2.496669e-02, 4.930370e-02, 1.009736e-02, -1.007631e-02
-&lt; 2.500000e-02, 0.000000e+00, 2.426417e-02, 2.503952e-02, 4.930369e-02, 1.010545e-02, -1.008416e-02
-&lt; 2.600000e-02, 0.000000e+00, 2.418676e-02, 2.511691e-02, 4.930367e-02, 1.011382e-02, -1.008208e-02
-&lt; 2.700000e-02, 0.000000e+00, 2.410506e-02, 2.519859e-02, 4.930365e-02, 1.011621e-02, -1.007008e-02
-&lt; 2.800000e-02, 0.000000e+00, 2.401936e-02, 2.528427e-02, 4.930363e-02, 1.011362e-02, -1.005792e-02
-&lt; 2.900000e-02, 0.000000e+00, 2.393001e-02, 2.537359e-02, 4.930360e-02, 1.011017e-02, -1.007498e-02
-&lt; 3.000000e-02, 0.000000e+00, 2.383747e-02, 2.546610e-02, 4.930357e-02, 1.011337e-02, -1.008211e-02
-&lt; 3.100000e-02, 0.000000e+00, 2.374226e-02, 2.556128e-02, 4.930353e-02, 1.011567e-02, -1.007931e-02
-&lt; 3.200000e-02, 0.000000e+00, 2.364493e-02, 2.565857e-02, 4.930350e-02, 1.011807e-02, -1.006659e-02
-&lt; 3.300000e-02, 0.000000e+00, 2.354607e-02, 2.575740e-02, 4.930346e-02, 1.011540e-02, -1.004974e-02
-&lt; 3.400000e-02, 0.000000e+00, 2.344621e-02, 2.585722e-02, 4.930343e-02, 1.011477e-02, -1.006612e-02
-&lt; 3.500000e-02, 0.000000e+00, 2.334591e-02, 2.595749e-02, 4.930340e-02, 1.012163e-02, -1.007258e-02
-&lt; 3.600000e-02, 0.000000e+00, 2.324571e-02, 2.605764e-02, 4.930336e-02, 1.012698e-02, -1.006913e-02
-&lt; 3.700000e-02, 0.000000e+00, 2.314623e-02, 2.615708e-02, 4.930332e-02, 1.013019e-02, -1.005575e-02
-&lt; 3.800000e-02, 0.000000e+00, 2.304813e-02, 2.625514e-02, 4.930327e-02, 1.013119e-02, -1.003478e-02
-&lt; 3.900000e-02, 0.000000e+00, 2.295211e-02, 2.635112e-02, 4.930323e-02, 1.013020e-02, -1.005060e-02
-&lt; 4.000000e-02, 0.000000e+00, 2.285890e-02, 2.644429e-02, 4.930318e-02, 1.012776e-02, -1.005652e-02
-&lt; 4.100000e-02, 0.000000e+00, 2.276918e-02, 2.653396e-02, 4.930314e-02, 1.012593e-02, -1.005255e-02
-&lt; 4.200000e-02, 0.000000e+00, 2.268362e-02, 2.661948e-02, 4.930310e-02, 1.013238e-02, -1.003867e-02
-&lt; 4.300000e-02, 0.000000e+00, 2.260283e-02, 2.670023e-02, 4.930307e-02, 1.013796e-02, -1.001493e-02
-&lt; 4.400000e-02, 0.000000e+00, 2.252744e-02, 2.677559e-02, 4.930303e-02, 1.014203e-02, -1.003064e-02
-&lt; 4.500000e-02, 0.000000e+00, 2.245807e-02, 2.684492e-02, 4.930298e-02, 1.014420e-02, -1.003660e-02
-&lt; 4.600000e-02, 0.000000e+00, 2.239538e-02, 2.690756e-02, 4.930294e-02, 1.014433e-02, -1.003288e-02
-&lt; 4.700000e-02, 0.000000e+00, 2.234005e-02, 2.696285e-02, 4.930290e-02, 1.014263e-02, -1.001956e-02
-&lt; 4.800000e-02, 0.000000e+00, 2.229271e-02, 2.701016e-02, 4.930287e-02, 1.013954e-02, -1.001137e-02
-&lt; 4.900000e-02, 0.000000e+00, 2.225394e-02, 2.704889e-02, 4.930283e-02, 1.013569e-02, -1.003457e-02
-&lt; 5.000000e-02, 0.000000e+00, 2.222426e-02, 2.707854e-02, 4.930281e-02, 1.013996e-02, -1.005043e-02
-&lt; 5.100000e-02, 0.000000e+00, 2.220412e-02, 2.709866e-02, 4.930278e-02, 1.014354e-02, -1.042293e-02
-&lt; 5.200000e-02, 0.000000e+00, 2.219395e-02, 2.710880e-02, 4.930275e-02, 1.014550e-02, -1.104464e-02
-&lt; 5.300000e-02, 0.000000e+00, 2.219417e-02, 2.710855e-02, 4.930273e-02, 1.014558e-02, -1.166358e-02
-&lt; 5.400000e-02, 0.000000e+00, 2.220519e-02, 2.709751e-02, 4.930270e-02, 1.014381e-02, -1.228907e-02
-&lt; 5.500000e-02, 0.000000e+00, 2.222739e-02, 2.707529e-02, 4.930268e-02, 1.014047e-02, -1.291439e-02
-&lt; 5.600000e-02, 0.000000e+00, 2.226109e-02, 2.704158e-02, 4.930267e-02, 1.013605e-02, -1.353784e-02
-&lt; 5.700000e-02, 0.000000e+00, 2.230652e-02, 2.699614e-02, 4.930266e-02, 1.013627e-02, -1.415821e-02
-&lt; 5.800000e-02, 0.000000e+00, 2.236383e-02, 2.693882e-02, 4.930265e-02, 1.013940e-02, -1.477420e-02
-&lt; 5.900000e-02, 0.000000e+00, 2.243311e-02, 2.686954e-02, 4.930265e-02, 1.014150e-02, -1.538461e-02
-&lt; 6.000000e-02, 0.000000e+00, 2.251437e-02, 2.678828e-02, 4.930265e-02, 1.014211e-02, -1.598837e-02
-&lt; 6.100000e-02, 0.000000e+00, 2.260762e-02, 2.669503e-02, 4.930265e-02, 1.014098e-02, -1.658462e-02
-&lt; 6.200000e-02, 0.000000e+00, 2.271284e-02, 2.658982e-02, 4.930266e-02, 1.013812e-02, -1.717280e-02
-&lt; 6.300000e-02, 0.000000e+00, 2.282993e-02, 2.647274e-02, 4.930267e-02, 1.013378e-02, -1.775258e-02
-&lt; 6.400000e-02, 0.000000e+00, 2.295875e-02, 2.634393e-02, 4.930268e-02, 1.012845e-02, -1.832385e-02
-&lt; 6.500000e-02, 0.000000e+00, 2.309904e-02, 2.620367e-02, 4.930271e-02, 1.012546e-02, -1.888664e-02
-&lt; 6.600000e-02, 0.000000e+00, 2.325045e-02, 2.605229e-02, 4.930273e-02, 1.012695e-02, -1.944102e-02
-&lt; 6.700000e-02, 0.000000e+00, 2.341256e-02, 2.589020e-02, 4.930276e-02, 1.012729e-02, -1.998699e-02
-&lt; 6.800000e-02, 0.000000e+00, 2.358492e-02, 2.571788e-02, 4.930279e-02, 1.012611e-02, -2.052443e-02
-&lt; 6.900000e-02, 0.000000e+00, 2.376702e-02, 2.553581e-02, 4.930283e-02, 1.012326e-02, -2.105299e-02
-&lt; 7.000000e-02, 0.000000e+00, 2.395833e-02, 2.534453e-02, 4.930286e-02, 1.011884e-02, -2.157209e-02
-&lt; 7.100000e-02, 0.000000e+00, 2.415828e-02, 2.514462e-02, 4.930290e-02, 1.011319e-02, -2.208094e-02
-&lt; 7.200000e-02, 0.000000e+00, 2.436621e-02, 2.493673e-02, 4.930295e-02, 1.010680e-02, -2.257856e-02
-&lt; 7.300000e-02, 0.000000e+00, 2.458138e-02, 2.472162e-02, 4.930300e-02, 1.010756e-02, -2.306390e-02
-&lt; 7.400000e-02, 0.000000e+00, 2.480297e-02, 2.450009e-02, 4.930306e-02, 1.010774e-02, -2.353590e-02
-&lt; 7.500000e-02, 0.000000e+00, 2.503010e-02, 2.427301e-02, 4.930311e-02, 1.010683e-02, -2.399358e-02
-&lt; 7.600000e-02, 0.000000e+00, 2.526187e-02, 2.404129e-02, 4.930317e-02, 1.010449e-02, -2.443616e-02
-&lt; 7.700000e-02, 0.000000e+00, 2.549739e-02, 2.380584e-02, 4.930323e-02, 1.010059e-02, -2.486306e-02
-&lt; 7.800000e-02, 0.000000e+00, 2.573571e-02, 2.356758e-02, 4.930329e-02, 1.009523e-02, -2.527397e-02
-&lt; 7.900000e-02, 0.000000e+00, 2.597587e-02, 2.332748e-02, 4.930335e-02, 1.008874e-02, -2.566879e-02
-&lt; 8.000000e-02, 0.000000e+00, 2.621687e-02, 2.308655e-02, 4.930342e-02, 1.008159e-02, -2.604760e-02
-&lt; 8.100000e-02, 0.000000e+00, 2.645763e-02, 2.284586e-02, 4.930349e-02, 1.007993e-02, -2.641058e-02
-&lt; 8.200000e-02, 0.000000e+00, 2.669704e-02, 2.260652e-02, 4.930356e-02, 1.007886e-02, -2.675792e-02
-&lt; 8.300000e-02, 0.000000e+00, 2.693397e-02, 2.236966e-02, 4.930363e-02, 1.007664e-02, -2.708973e-02
-&lt; 8.400000e-02, 0.000000e+00, 2.716730e-02, 2.213639e-02, 4.930370e-02, 1.007301e-02, -2.740597e-02
-&lt; 8.500000e-02, 0.000000e+00, 2.739594e-02, 2.190782e-02, 4.930376e-02, 1.006793e-02, -2.770640e-02
-&lt; 8.600000e-02, 0.000000e+00, 2.761880e-02, 2.168503e-02, 4.930383e-02, 1.006157e-02, -2.799061e-02
-&lt; 8.700000e-02, 0.000000e+00, 2.783480e-02, 2.146910e-02, 4.930390e-02, 1.005428e-02, -2.825797e-02
-&lt; 8.800000e-02, 0.000000e+00, 2.804284e-02, 2.126113e-02, 4.930397e-02, 1.004873e-02, -2.850776e-02
-&lt; 8.900000e-02, 0.000000e+00, 2.824181e-02, 2.106223e-02, 4.930404e-02, 1.004748e-02, -2.873920e-02
-&lt; 9.000000e-02, 0.000000e+00, 2.843061e-02, 2.087349e-02, 4.930411e-02, 1.004555e-02, -2.895154e-02
-&lt; 9.100000e-02, 0.000000e+00, 2.860816e-02, 2.069601e-02, 4.930417e-02, 1.004254e-02, -2.914417e-02
-&lt; 9.200000e-02, 0.000000e+00, 2.877342e-02, 2.053081e-02, 4.930423e-02, 1.004419e-02, -2.931667e-02
-&lt; 9.300000e-02, 0.000000e+00, 2.892545e-02, 2.037883e-02, 4.930429e-02, 1.004952e-02, -2.946883e-02
-&lt; 9.400000e-02, 0.000000e+00, 2.906333e-02, 2.024101e-02, 4.930434e-02, 1.005001e-02, -2.960067e-02
-&lt; 9.500000e-02, 0.000000e+00, 2.918619e-02, 2.011820e-02, 4.930439e-02, 1.004641e-02, -2.971240e-02
-&lt; 9.600000e-02, 0.000000e+00, 2.929319e-02, 2.001125e-02, 4.930444e-02, 1.005770e-02, -2.980439e-02
-&lt; 9.700000e-02, 0.000000e+00, 2.938351e-02, 1.992099e-02, 4.930449e-02, 1.006924e-02, -2.987706e-02
-&lt; 9.800000e-02, 0.000000e+00, 2.945638e-02, 1.984816e-02, 4.930454e-02, 1.007523e-02, -2.993081e-02
-&lt; 9.900000e-02, 0.000000e+00, 2.951111e-02, 1.979347e-02, 4.930457e-02, 1.007634e-02, -2.996594e-02
-&lt; 1.000000e-01, 0.000000e+00, 2.954709e-02, 1.975751e-02, 4.930461e-02, 1.007327e-02, -2.998263e-02
-&lt; 1.010000e-01, 0.000000e+00, 2.956383e-02, 1.974080e-02, 4.930463e-02, 1.008468e-02, -2.998084e-02
-&lt; 1.020000e-01, 0.000000e+00, 2.956090e-02, 1.974375e-02, 4.930465e-02, 1.009669e-02, -2.996038e-02
-&lt; 1.030000e-01, 0.000000e+00, 2.953796e-02, 1.976671e-02, 4.930467e-02, 1.010311e-02, -2.992090e-02
-&lt; 1.040000e-01, 0.000000e+00, 2.949470e-02, 1.980999e-02, 4.930469e-02, 1.010459e-02, -2.986197e-02
-&lt; 1.050000e-01, 0.000000e+00, 2.943089e-02, 1.987381e-02, 4.930470e-02, 1.010181e-02, -2.978317e-02
-&lt; 1.060000e-01, 0.000000e+00, 2.934637e-02, 1.995832e-02, 4.930470e-02, 1.011194e-02, -2.968413e-02
-&lt; 1.070000e-01, 0.000000e+00, 2.924111e-02, 2.006359e-02, 4.930470e-02, 1.012418e-02, -2.956463e-02
-&lt; 1.080000e-01, 0.000000e+00, 2.911515e-02, 2.018953e-02, 4.930468e-02, 1.013078e-02, -2.942464e-02
-&lt; 1.090000e-01, 0.000000e+00, 2.896868e-02, 2.033599e-02, 4.930467e-02, 1.013238e-02, -2.926433e-02
-&lt; 1.100000e-01, 0.000000e+00, 2.880196e-02, 2.050268e-02, 4.930465e-02, 1.012965e-02, -2.908411e-02
-&lt; 1.110000e-01, 0.000000e+00, 2.861536e-02, 2.068926e-02, 4.930462e-02, 1.013712e-02, -2.888451e-02
-&lt; 1.120000e-01, 0.000000e+00, 2.840928e-02, 2.089531e-02, 4.930459e-02, 1.014933e-02, -2.866620e-02
-&lt; 1.130000e-01, 0.000000e+00, 2.818423e-02, 2.112032e-02, 4.930455e-02, 1.015587e-02, -2.842986e-02
-&lt; 1.140000e-01, 0.000000e+00, 2.794078e-02, 2.136373e-02, 4.930451e-02, 1.015736e-02, -2.817612e-02
-&lt; 1.150000e-01, 0.000000e+00, 2.767962e-02, 2.162484e-02, 4.930446e-02, 1.015446e-02, -2.790553e-02
-&lt; 1.160000e-01, 0.000000e+00, 2.740154e-02, 2.190286e-02, 4.930440e-02, 1.015800e-02, -2.761845e-02
-&lt; 1.170000e-01, 0.000000e+00, 2.710745e-02, 2.219689e-02, 4.930434e-02, 1.016999e-02, -2.731508e-02
-&lt; 1.180000e-01, 0.000000e+00, 2.679834e-02, 2.250593e-02, 4.930428e-02, 1.017627e-02, -2.699546e-02
-&lt; 1.190000e-01, 0.000000e+00, 2.647526e-02, 2.282894e-02, 4.930421e-02, 1.017745e-02, -2.665954e-02
-&lt; 1.200000e-01, 0.000000e+00, 2.613932e-02, 2.316482e-02, 4.930413e-02, 1.017418e-02, -2.630719e-02
-&lt; 1.210000e-01, 0.000000e+00, 2.579166e-02, 2.351240e-02, 4.930406e-02, 1.017283e-02, -2.593831e-02
-&lt; 1.220000e-01, 0.000000e+00, 2.543353e-02, 2.387044e-02, 4.930397e-02, 1.018444e-02, -2.555289e-02
-&lt; 1.230000e-01, 0.000000e+00, 2.506624e-02, 2.423765e-02, 4.930389e-02, 1.019031e-02, -2.515107e-02
-&lt; 1.240000e-01, 0.000000e+00, 2.469118e-02, 2.461261e-02, 4.930380e-02, 1.019103e-02, -2.473318e-02
-&lt; 1.250000e-01, 0.000000e+00, 2.430983e-02, 2.499387e-02, 4.930370e-02, 1.018727e-02, -2.429974e-02
-&lt; 1.260000e-01, 0.000000e+00, 2.392369e-02, 2.537991e-02, 4.930360e-02, 1.018041e-02, -2.385145e-02
-&lt; 1.270000e-01, 0.000000e+00, 2.353430e-02, 2.576920e-02, 4.930351e-02, 1.019155e-02, -2.338915e-02
-&lt; 1.280000e-01, 0.000000e+00, 2.314322e-02, 2.616019e-02, 4.930341e-02, 1.019693e-02, -2.291374e-02
-&lt; 1.290000e-01, 0.000000e+00, 2.275201e-02, 2.655130e-02, 4.930331e-02, 1.019713e-02, -2.242610e-02
-&lt; 1.300000e-01, 0.000000e+00, 2.236227e-02, 2.694094e-02, 4.930321e-02, 1.019280e-02, -2.192705e-02
-&lt; 1.310000e-01, 0.000000e+00, 2.197563e-02, 2.732747e-02, 4.930310e-02, 1.018463e-02, -2.141730e-02
-&lt; 1.320000e-01, 0.000000e+00, 2.159377e-02, 2.770923e-02, 4.930300e-02, 1.019092e-02, -2.089736e-02
-&lt; 1.330000e-01, 0.000000e+00, 2.121837e-02, 2.808453e-02, 4.930289e-02, 1.019580e-02, -2.036762e-02
-&lt; 1.340000e-01, 0.000000e+00, 2.085110e-02, 2.845169e-02, 4.930279e-02, 1.019549e-02, -1.982829e-02
-&lt; 1.350000e-01, 0.000000e+00, 2.049361e-02, 2.880909e-02, 4.930269e-02, 1.019061e-02, -1.927952e-02
-&lt; 1.360000e-01, 0.000000e+00, 2.014749e-02, 2.915510e-02, 4.930259e-02, 1.018184e-02, -1.872142e-02
-&lt; 1.370000e-01, 0.000000e+00, 1.981433e-02, 2.948817e-02, 4.930250e-02, 1.018290e-02, -1.815413e-02
-&lt; 1.380000e-01, 0.000000e+00, 1.949566e-02, 2.980674e-02, 4.930240e-02, 1.018735e-02, -1.757790e-02
-&lt; 1.390000e-01, 0.000000e+00, 1.919302e-02, 3.010929e-02, 4.930231e-02, 1.018659e-02, -1.699315e-02
-&lt; 1.400000e-01, 0.000000e+00, 1.890789e-02, 3.039432e-02, 4.930222e-02, 1.018125e-02, -1.640045e-02
-&lt; 1.410000e-01, 0.000000e+00, 1.864175e-02, 3.066038e-02, 4.930213e-02, 1.017199e-02, -1.580055e-02
-&lt; 1.420000e-01, 0.000000e+00, 1.839597e-02, 3.090608e-02, 4.930205e-02, 1.016854e-02, -1.519436e-02
-&lt; 1.430000e-01, 0.000000e+00, 1.817185e-02, 3.113013e-02, 4.930197e-02, 1.017270e-02, -1.458287e-02
-&lt; 1.440000e-01, 0.000000e+00, 1.797059e-02, 3.133131e-02, 4.930190e-02, 1.017164e-02, -1.396709e-02
-&lt; 1.450000e-01, 0.000000e+00, 1.779333e-02, 3.150851e-02, 4.930184e-02, 1.016599e-02, -1.334802e-02
-&lt; 1.460000e-01, 0.000000e+00, 1.764109e-02, 3.166069e-02, 4.930178e-02, 1.015639e-02, -1.272653e-02
-&lt; 1.470000e-01, 0.000000e+00, 1.751486e-02, 3.178686e-02, 4.930172e-02, 1.014953e-02, -1.210336e-02
-&lt; 1.480000e-01, 0.000000e+00, 1.741553e-02, 3.188614e-02, 4.930167e-02, 1.015358e-02, -1.147909e-02
-&lt; 1.490000e-01, 0.000000e+00, 1.734391e-02, 3.195772e-02, 4.930163e-02, 1.015243e-02, -1.085415e-02
-&lt; 1.500000e-01, 0.000000e+00, 1.730067e-02, 3.200093e-02, 4.930159e-02, 1.014942e-02, -1.022881e-02
-&lt; 1.510000e-01, 0.000000e+00, 1.728636e-02, 3.201520e-02, 4.930157e-02, 1.015210e-02, -1.037297e-02
-&lt; 1.520000e-01, 0.000000e+00, 1.730142e-02, 3.200013e-02, 4.930155e-02, 1.015311e-02, -1.100150e-02
-&lt; 1.530000e-01, 0.000000e+00, 1.734613e-02, 3.195541e-02, 4.930154e-02, 1.015241e-02, -1.162750e-02
-&lt; 1.540000e-01, 0.000000e+00, 1.742069e-02, 3.188084e-02, 4.930153e-02, 1.015012e-02, -1.225044e-02
-&lt; 1.550000e-01, 0.000000e+00, 1.752520e-02, 3.177633e-02, 4.930153e-02, 1.014645e-02, -1.286995e-02
-&lt; 1.560000e-01, 0.000000e+00, 1.765964e-02, 3.164190e-02, 4.930154e-02, 1.014826e-02, -1.348575e-02
-&lt; 1.570000e-01, 0.000000e+00, 1.782387e-02, 3.147769e-02, 4.930156e-02, 1.014949e-02, -1.409767e-02
-&lt; 1.580000e-01, 0.000000e+00, 1.801762e-02, 3.128397e-02, 4.930158e-02, 1.014904e-02, -1.470554e-02
-&lt; 1.590000e-01, 0.000000e+00, 1.824045e-02, 3.106117e-02, 4.930162e-02, 1.014691e-02, -1.530922e-02
-&lt; 1.600000e-01, 0.000000e+00, 1.849180e-02, 3.080986e-02, 4.930166e-02, 1.014325e-02, -1.590851e-02
-&lt; 1.610000e-01, 0.000000e+00, 1.877098e-02, 3.053073e-02, 4.930171e-02, 1.013835e-02, -1.650312e-02
-&lt; 1.620000e-01, 0.000000e+00, 1.907720e-02, 3.022457e-02, 4.930177e-02, 1.013791e-02, -1.709265e-02
-&lt; 1.630000e-01, 0.000000e+00, 1.940953e-02, 2.989230e-02, 4.930183e-02, 1.013774e-02, -1.767657e-02
-&lt; 1.640000e-01, 0.000000e+00, 1.976699e-02, 2.953491e-02, 4.930190e-02, 1.013589e-02, -1.825422e-02
-&lt; 1.650000e-01, 0.000000e+00, 2.014845e-02, 2.915353e-02, 4.930198e-02, 1.013442e-02, -1.882479e-02
-&lt; 1.660000e-01, 0.000000e+00, 2.055265e-02, 2.874942e-02, 4.930207e-02, 1.013297e-02, -1.938741e-02
-&lt; 1.670000e-01, 0.000000e+00, 2.097820e-02, 2.832396e-02, 4.930216e-02, 1.013007e-02, -1.994111e-02
-&lt; 1.680000e-01, 0.000000e+00, 2.142360e-02, 2.787866e-02, 4.930226e-02, 1.012584e-02, -2.048492e-02
-&lt; 1.690000e-01, 0.000000e+00, 2.188726e-02, 2.741510e-02, 4.930237e-02, 1.012356e-02, -2.101789e-02
-&lt; 1.700000e-01, 0.000000e+00, 2.236751e-02, 2.693496e-02, 4.930247e-02, 1.012374e-02, -2.153912e-02
-&lt; 1.710000e-01, 0.000000e+00, 2.286260e-02, 2.643999e-02, 4.930259e-02, 1.012266e-02, -2.204783e-02
-&lt; 1.720000e-01, 0.000000e+00, 2.337072e-02, 2.593198e-02, 4.930271e-02, 1.012016e-02, -2.254339e-02
-&lt; 1.730000e-01, 0.000000e+00, 2.388999e-02, 2.541284e-02, 4.930283e-02, 1.011625e-02, -2.302529e-02
-&lt; 1.740000e-01, 0.000000e+00, 2.441841e-02, 2.488455e-02, 4.930296e-02, 1.011105e-02, -2.349319e-02
-&lt; 1.750000e-01, 0.000000e+00, 2.495393e-02, 2.434916e-02, 4.930309e-02, 1.010578e-02, -2.394688e-02
-&lt; 1.760000e-01, 0.000000e+00, 2.549444e-02, 2.380879e-02, 4.930322e-02, 1.010506e-02, -2.438626e-02
-&lt; 1.770000e-01, 0.000000e+00, 2.603777e-02, 2.326559e-02, 4.930336e-02, 1.010305e-02, -2.481131e-02
-&lt; 1.780000e-01, 0.000000e+00, 2.658177e-02, 2.272173e-02, 4.930350e-02, 1.009965e-02, -2.522201e-02
-&lt; 1.790000e-01, 0.000000e+00, 2.712424e-02, 2.217940e-02, 4.930363e-02, 1.009486e-02, -2.561835e-02
-&lt; 1.800000e-01, 0.000000e+00, 2.766299e-02, 2.164078e-02, 4.930377e-02, 1.008886e-02, -2.600023e-02
-&lt; 1.810000e-01, 0.000000e+00, 2.819582e-02, 2.110810e-02, 4.930391e-02, 1.008192e-02, -2.636748e-02
-&lt; 1.820000e-01, 0.000000e+00, 2.872049e-02, 2.058356e-02, 4.930405e-02, 1.008049e-02, -2.671980e-02
-&lt; 1.830000e-01, 0.000000e+00, 2.923477e-02, 2.006942e-02, 4.930419e-02, 1.007777e-02, -2.705679e-02
-&lt; 1.840000e-01, 0.000000e+00, 2.973645e-02, 1.956788e-02, 4.930433e-02, 1.007939e-02, -2.737789e-02
-&lt; 1.850000e-01, 0.000000e+00, 3.022333e-02, 1.908113e-02, 4.930446e-02, 1.007823e-02, -2.768250e-02
-&lt; 1.860000e-01, 0.000000e+00, 3.069328e-02, 1.861131e-02, 4.930459e-02, 1.007296e-02, -2.796995e-02
-&lt; 1.870000e-01, 0.000000e+00, 3.114424e-02, 1.816047e-02, 4.930471e-02, 1.008037e-02, -2.823954e-02
-&lt; 1.880000e-01, 0.000000e+00, 3.157422e-02, 1.773062e-02, 4.930484e-02, 1.009006e-02, -2.849063e-02
-&lt; 1.890000e-01, 0.000000e+00, 3.198124e-02, 1.732371e-02, 4.930495e-02, 1.009446e-02, -2.872265e-02
-&lt; 1.900000e-01, 0.000000e+00, 3.236343e-02, 1.694164e-02, 4.930507e-02, 1.009414e-02, -2.893517e-02
-&lt; 1.910000e-01, 0.000000e+00, 3.271894e-02, 1.658623e-02, 4.930518e-02, 1.008967e-02, -2.912787e-02
-&lt; 1.920000e-01, 0.000000e+00, 3.304605e-02, 1.625923e-02, 4.930528e-02, 1.009993e-02, -2.930059e-02
-&lt; 1.930000e-01, 0.000000e+00, 3.334311e-02, 1.596227e-02, 4.930537e-02, 1.011037e-02, -2.945335e-02
-&lt; 1.940000e-01, 0.000000e+00, 3.360862e-02, 1.569684e-02, 4.930546e-02, 1.011551e-02, -2.958627e-02
-&lt; 1.950000e-01, 0.000000e+00, 3.384120e-02, 1.546434e-02, 4.930554e-02, 1.011587e-02, -2.969957e-02
-&lt; 1.960000e-01, 0.000000e+00, 3.403960e-02, 1.526601e-02, 4.930561e-02, 1.011204e-02, -2.979353e-02
-&lt; 1.970000e-01, 0.000000e+00, 3.420267e-02, 1.510300e-02, 4.930567e-02, 1.012409e-02, -2.986842e-02
-&lt; 1.980000e-01, 0.000000e+00, 3.432939e-02, 1.497634e-02, 4.930573e-02, 1.013509e-02, -2.992448e-02
-&lt; 1.990000e-01, 0.000000e+00, 3.441885e-02, 1.488693e-02, 4.930578e-02, 1.014075e-02, -2.996190e-02
-&lt; 2.000000e-01, 0.000000e+00, 3.447029e-02, 1.483552e-02, 4.930582e-02, 1.014159e-02, -2.998072e-02
-&lt; 2.010000e-01, 0.000000e+00, 3.448312e-02, 1.482272e-02, 4.930584e-02, 1.013819e-02, -2.998091e-02
-&lt; 2.020000e-01, 0.000000e+00, 3.445691e-02, 1.484895e-02, 4.930586e-02, 1.015072e-02, -2.996230e-02
-&lt; 2.030000e-01, 0.000000e+00, 3.439139e-02, 1.491447e-02, 4.930587e-02, 1.016205e-02, -2.992464e-02
-&lt; 2.040000e-01, 0.000000e+00, 3.428647e-02, 1.501939e-02, 4.930586e-02, 1.016800e-02, -2.986763e-02
-&lt; 2.050000e-01, 0.000000e+00, 3.414218e-02, 1.516367e-02, 4.930585e-02, 1.016909e-02, -2.979095e-02
-&lt; 2.060000e-01, 0.000000e+00, 3.395871e-02, 1.534712e-02, 4.930583e-02, 1.016588e-02, -2.969431e-02
-&lt; 2.070000e-01, 0.000000e+00, 3.373638e-02, 1.556942e-02, 4.930580e-02, 1.017746e-02, -2.957751e-02
-&lt; 2.080000e-01, 0.000000e+00, 3.347570e-02, 1.583005e-02, 4.930576e-02, 1.018887e-02, -2.944044e-02
-&lt; 2.090000e-01, 0.000000e+00, 3.317735e-02, 1.612836e-02, 4.930570e-02, 1.019486e-02, -2.928316e-02
-&lt; 2.100000e-01, 0.000000e+00, 3.284217e-02, 1.646347e-02, 4.930564e-02, 1.019595e-02, -2.910585e-02
-&lt; 2.110000e-01, 0.000000e+00, 3.247119e-02, 1.683438e-02, 4.930557e-02, 1.019269e-02, -2.890887e-02
-&lt; 2.120000e-01, 0.000000e+00, 3.206557e-02, 1.723992e-02, 4.930549e-02, 1.020191e-02, -2.869266e-02
-&lt; 2.130000e-01, 0.000000e+00, 3.162662e-02, 1.767877e-02, 4.930540e-02, 1.021318e-02, -2.845779e-02
-&lt; 2.140000e-01, 0.000000e+00, 3.115578e-02, 1.814951e-02, 4.930530e-02, 1.021898e-02, -2.820485e-02
-&lt; 2.150000e-01, 0.000000e+00, 3.065462e-02, 1.865057e-02, 4.930519e-02, 1.021985e-02, -2.793444e-02
-&lt; 2.160000e-01, 0.000000e+00, 3.012486e-02, 1.918021e-02, 4.930507e-02, 1.021632e-02, -2.764710e-02
-&lt; 2.170000e-01, 0.000000e+00, 2.956835e-02, 1.973659e-02, 4.930495e-02, 1.022193e-02, -2.734330e-02
-&lt; 2.180000e-01, 0.000000e+00, 2.898711e-02, 2.031770e-02, 4.930481e-02, 1.023285e-02, -2.702342e-02
-&lt; 2.190000e-01, 0.000000e+00, 2.838327e-02, 2.092140e-02, 4.930468e-02, 1.023828e-02, -2.668770e-02
-&lt; 2.200000e-01, 0.000000e+00, 2.775906e-02, 2.154547e-02, 4.930453e-02, 1.023873e-02, -2.633629e-02
-&lt; 2.210000e-01, 0.000000e+00, 2.711681e-02, 2.218757e-02, 4.930438e-02, 1.023475e-02, -2.596925e-02
-&lt; 2.220000e-01, 0.000000e+00, 2.645890e-02, 2.284532e-02, 4.930423e-02, 1.023578e-02, -2.558661e-02
-&lt; 2.230000e-01, 0.000000e+00, 2.578783e-02, 2.351624e-02, 4.930407e-02, 1.024621e-02, -2.518838e-02
-&lt; 2.240000e-01, 0.000000e+00, 2.510615e-02, 2.419775e-02, 4.930390e-02, 1.025112e-02, -2.477464e-02
-&lt; 2.250000e-01, 0.000000e+00, 2.441651e-02, 2.488722e-02, 4.930373e-02, 1.025103e-02, -2.434553e-02
-&lt; 2.260000e-01, 0.000000e+00, 2.372163e-02, 2.558192e-02, 4.930356e-02, 1.024647e-02, -2.390133e-02
-&lt; 2.270000e-01, 0.000000e+00, 2.302428e-02, 2.627910e-02, 4.930338e-02, 1.024233e-02, -2.344244e-02
-&lt; 2.280000e-01, 0.000000e+00, 2.232724e-02, 2.697597e-02, 4.930321e-02, 1.025219e-02, -2.296942e-02
-&lt; 2.290000e-01, 0.000000e+00, 2.163331e-02, 2.766972e-02, 4.930303e-02, 1.025652e-02, -2.248294e-02
-&lt; 2.300000e-01, 0.000000e+00, 2.094528e-02, 2.835758e-02, 4.930286e-02, 1.025582e-02, -2.198377e-02
-&lt; 2.310000e-01, 0.000000e+00, 2.026595e-02, 2.903673e-02, 4.930268e-02, 1.025063e-02, -2.147275e-02
-&lt; 2.320000e-01, 0.000000e+00, 1.959810e-02, 2.970441e-02, 4.930251e-02, 1.024152e-02, -2.095073e-02
-&lt; 2.330000e-01, 0.000000e+00, 1.894453e-02, 3.035781e-02, 4.930234e-02, 1.025046e-02, -2.041851e-02
-&lt; 2.340000e-01, 0.000000e+00, 1.830799e-02, 3.099418e-02, 4.930217e-02, 1.025420e-02, -1.987684e-02
-&lt; 2.350000e-01, 0.000000e+00, 1.769121e-02, 3.161080e-02, 4.930200e-02, 1.025291e-02, -1.932637e-02
-&lt; 2.360000e-01, 0.000000e+00, 1.709683e-02, 3.220501e-02, 4.930184e-02, 1.024712e-02, -1.876761e-02
-&lt; 2.370000e-01, 0.000000e+00, 1.652743e-02, 3.277425e-02, 4.930169e-02, 1.023737e-02, -1.820097e-02
-&lt; 2.380000e-01, 0.000000e+00, 1.598548e-02, 3.331606e-02, 4.930154e-02, 1.024142e-02, -1.762679e-02
-&lt; 2.390000e-01, 0.000000e+00, 1.547336e-02, 3.382803e-02, 4.930139e-02, 1.024466e-02, -1.704530e-02
-&lt; 2.400000e-01, 0.000000e+00, 1.499337e-02, 3.430788e-02, 4.930126e-02, 1.024287e-02, -1.645675e-02
-&lt; 2.410000e-01, 0.000000e+00, 1.454772e-02, 3.475341e-02, 4.930112e-02, 1.023656e-02, -1.586138e-02
-&lt; 2.420000e-01, 0.000000e+00, 1.413849e-02, 3.516251e-02, 4.930100e-02, 1.022628e-02, -1.525953e-02
-&lt; 2.430000e-01, 0.000000e+00, 1.376765e-02, 3.553324e-02, 4.930089e-02, 1.022619e-02, -1.465161e-02
-&lt; 2.440000e-01, 0.000000e+00, 1.343700e-02, 3.586378e-02, 4.930079e-02, 1.022908e-02, -1.403817e-02
-&lt; 2.450000e-01, 0.000000e+00, 1.314820e-02, 3.615250e-02, 4.930069e-02, 1.022693e-02, -1.341988e-02
-&lt; 2.460000e-01, 0.000000e+00, 1.290271e-02, 3.639790e-02, 4.930061e-02, 1.022027e-02, -1.279753e-02
-&lt; 2.470000e-01, 0.000000e+00, 1.270186e-02, 3.659868e-02, 4.930054e-02, 1.020963e-02, -1.217201e-02
-&lt; 2.480000e-01, 0.000000e+00, 1.254682e-02, 3.675366e-02, 4.930048e-02, 1.020651e-02, -1.154426e-02
-&lt; 2.490000e-01, 0.000000e+00, 1.243858e-02, 3.686184e-02, 4.930042e-02, 1.020924e-02, -1.091522e-02
-&lt; 2.500000e-01, 0.000000e+00, 1.237799e-02, 3.692239e-02, 4.930038e-02, 1.020694e-02, -1.029430e-02
-&lt; 2.510000e-01, 0.000000e+00, 1.236568e-02, 3.693468e-02, 4.930036e-02, 1.020012e-02, -1.030956e-02
-&lt; 2.520000e-01, 0.000000e+00, 1.240209e-02, 3.689825e-02, 4.930034e-02, 1.018933e-02, -1.092245e-02
-&lt; 2.530000e-01, 0.000000e+00, 1.248745e-02, 3.681289e-02, 4.930034e-02, 1.018452e-02, -1.154741e-02
-&lt; 2.540000e-01, 0.000000e+00, 1.262179e-02, 3.667856e-02, 4.930035e-02, 1.018733e-02, -1.217124e-02
-&lt; 2.550000e-01, 0.000000e+00, 1.280493e-02, 3.649544e-02, 4.930037e-02, 1.018511e-02, -1.279356e-02
-&lt; 2.560000e-01, 0.000000e+00, 1.303655e-02, 3.626386e-02, 4.930041e-02, 1.017837e-02, -1.341388e-02
-&lt; 2.570000e-01, 0.000000e+00, 1.331609e-02, 3.598436e-02, 4.930045e-02, 1.016767e-02, -1.403594e-02
-&lt; 2.580000e-01, 0.000000e+00, 1.364285e-02, 3.565766e-02, 4.930051e-02, 1.016262e-02, -1.465476e-02
-&lt; 2.590000e-01, 0.000000e+00, 1.401589e-02, 3.528469e-02, 4.930058e-02, 1.016573e-02, -1.526837e-02
-&lt; 2.600000e-01, 0.000000e+00, 1.443408e-02, 3.486658e-02, 4.930066e-02, 1.016383e-02, -1.587583e-02
-&lt; 2.610000e-01, 0.000000e+00, 1.489609e-02, 3.440467e-02, 4.930076e-02, 1.015743e-02, -1.647628e-02
-&lt; 2.620000e-01, 0.000000e+00, 1.540038e-02, 3.390049e-02, 4.930087e-02, 1.015050e-02, -1.706896e-02
-&lt; 2.630000e-01, 0.000000e+00, 1.594524e-02, 3.335574e-02, 4.930098e-02, 1.014921e-02, -1.765319e-02
-&lt; 2.640000e-01, 0.000000e+00, 1.652882e-02, 3.277229e-02, 4.930111e-02, 1.014682e-02, -1.822843e-02
-&lt; 2.650000e-01, 0.000000e+00, 1.714909e-02, 3.215215e-02, 4.930124e-02, 1.014546e-02, -1.879423e-02
-&lt; 2.660000e-01, 0.000000e+00, 1.780388e-02, 3.149751e-02, 4.930139e-02, 1.013960e-02, -1.935024e-02
-&lt; 2.670000e-01, 0.000000e+00, 1.849083e-02, 3.081072e-02, 4.930155e-02, 1.013940e-02, -1.989620e-02
-&lt; 2.680000e-01, 0.000000e+00, 1.920744e-02, 3.009427e-02, 4.930171e-02, 1.013806e-02, -2.043189e-02
-&lt; 2.690000e-01, 0.000000e+00, 1.995106e-02, 2.935083e-02, 4.930189e-02, 1.013512e-02, -2.095718e-02
-&lt; 2.700000e-01, 0.000000e+00, 2.071888e-02, 2.858319e-02, 4.930207e-02, 1.013205e-02, -2.147394e-02
-&lt; 2.710000e-01, 0.000000e+00, 2.150802e-02, 2.779423e-02, 4.930226e-02, 1.012692e-02, -2.198178e-02
-&lt; 2.720000e-01, 0.000000e+00, 2.231549e-02, 2.698695e-02, 4.930245e-02, 1.012172e-02, -2.247855e-02
-&lt; 2.730000e-01, 0.000000e+00, 2.313822e-02, 2.616442e-02, 4.930265e-02, 1.012047e-02, -2.296372e-02
-&lt; 2.740000e-01, 0.000000e+00, 2.397305e-02, 2.532980e-02, 4.930285e-02, 1.012494e-02, -2.343664e-02
-&lt; 2.750000e-01, 0.000000e+00, 2.481674e-02, 2.448631e-02, 4.930305e-02, 1.012517e-02, -2.389661e-02
-&lt; 2.760000e-01, 0.000000e+00, 2.566599e-02, 2.363727e-02, 4.930327e-02, 1.012088e-02, -2.434287e-02
-&lt; 2.770000e-01, 0.000000e+00, 2.651742e-02, 2.278605e-02, 4.930348e-02, 1.011260e-02, -2.477469e-02
-&lt; 2.780000e-01, 0.000000e+00, 2.736764e-02, 2.193605e-02, 4.930369e-02, 1.011842e-02, -2.519140e-02
-&lt; 2.790000e-01, 0.000000e+00, 2.821323e-02, 2.109068e-02, 4.930390e-02, 1.012459e-02, -2.559242e-02
-&lt; 2.800000e-01, 0.000000e+00, 2.905079e-02, 2.025333e-02, 4.930411e-02, 1.012574e-02, -2.597731e-02
-&lt; 2.810000e-01, 0.000000e+00, 2.987694e-02, 1.942739e-02, 4.930433e-02, 1.012235e-02, -2.634730e-02
-&lt; 2.820000e-01, 0.000000e+00, 3.068832e-02, 1.861621e-02, 4.930453e-02, 1.011496e-02, -2.670466e-02
-&lt; 2.830000e-01, 0.000000e+00, 3.148160e-02, 1.782314e-02, 4.930474e-02, 1.012482e-02, -2.704476e-02
-&lt; 2.840000e-01, 0.000000e+00, 3.225346e-02, 1.705148e-02, 4.930494e-02, 1.013191e-02, -2.736703e-02
-&lt; 2.850000e-01, 0.000000e+00, 3.300066e-02, 1.630448e-02, 4.930514e-02, 1.013396e-02, -2.767102e-02
-&lt; 2.860000e-01, 0.000000e+00, 3.372002e-02, 1.558531e-02, 4.930533e-02, 1.013146e-02, -2.795635e-02
-&lt; 2.870000e-01, 0.000000e+00, 3.440848e-02, 1.489704e-02, 4.930552e-02, 1.012504e-02, -2.822282e-02
-&lt; 2.880000e-01, 0.000000e+00, 3.506309e-02, 1.424261e-02, 4.930570e-02, 1.013849e-02, -2.847029e-02
-&lt; 2.890000e-01, 0.000000e+00, 3.568101e-02, 1.362486e-02, 4.930586e-02, 1.014642e-02, -2.869875e-02
-&lt; 2.900000e-01, 0.000000e+00, 3.625954e-02, 1.304649e-02, 4.930603e-02, 1.014928e-02, -2.890827e-02
-&lt; 2.910000e-01, 0.000000e+00, 3.679611e-02, 1.251007e-02, 4.930618e-02, 1.014756e-02, -2.910078e-02
-&lt; 2.920000e-01, 0.000000e+00, 3.728826e-02, 1.201806e-02, 4.930632e-02, 1.014415e-02, -2.927844e-02
-&lt; 2.930000e-01, 0.000000e+00, 3.773373e-02, 1.157273e-02, 4.930645e-02, 1.015831e-02, -2.943669e-02
-&lt; 2.940000e-01, 0.000000e+00, 3.813038e-02, 1.117619e-02, 4.930657e-02, 1.016693e-02, -2.957518e-02
-&lt; 2.950000e-01, 0.000000e+00, 3.847631e-02, 1.083037e-02, 4.930668e-02, 1.017045e-02, -2.969366e-02
-&lt; 2.960000e-01, 0.000000e+00, 3.876980e-02, 1.053697e-02, 4.930677e-02, 1.016936e-02, -2.979200e-02
-&lt; 2.970000e-01, 0.000000e+00, 3.900936e-02, 1.029750e-02, 4.930686e-02, 1.016788e-02, -2.987023e-02
-&lt; 2.980000e-01, 0.000000e+00, 3.919367e-02, 1.011326e-02, 4.930692e-02, 1.018257e-02, -2.992847e-02
-&lt; 2.990000e-01, 0.000000e+00, 3.932162e-02, 9.985363e-03, 4.930698e-02, 1.019167e-02, -2.996696e-02
-&lt; 3.000000e-01, 0.000000e+00, 3.939231e-02, 9.914714e-03, 4.930702e-02, 1.019565e-02, -2.998593e-02
-&lt; 3.010000e-01, 0.000000e+00, 3.940506e-02, 9.901996e-03, 4.930705e-02, 1.019497e-02, -2.998880e-02
-&lt; 3.020000e-01, 0.000000e+00, 3.935941e-02, 9.947657e-03, 4.930707e-02, 1.019413e-02, -2.997366e-02
-&lt; 3.030000e-01, 0.000000e+00, 3.925516e-02, 1.005190e-02, 4.930706e-02, 1.020910e-02, -2.993849e-02
-&lt; 3.040000e-01, 0.000000e+00, 3.909236e-02, 1.021469e-02, 4.930704e-02, 1.021846e-02, -2.988304e-02
-&lt; 3.050000e-01, 0.000000e+00, 3.887128e-02, 1.043573e-02, 4.930701e-02, 1.022266e-02, -2.980712e-02
-&lt; 3.060000e-01, 0.000000e+00, 3.859244e-02, 1.071453e-02, 4.930697e-02, 1.022216e-02, -2.971066e-02
-&lt; 3.070000e-01, 0.000000e+00, 3.825655e-02, 1.105036e-02, 4.930691e-02, 1.022051e-02, -2.959369e-02
-&lt; 3.080000e-01, 0.000000e+00, 3.786457e-02, 1.144227e-02, 4.930684e-02, 1.023553e-02, -2.945636e-02
-&lt; 3.090000e-01, 0.000000e+00, 3.741767e-02, 1.188907e-02, 4.930675e-02, 1.024490e-02, -2.929896e-02
-&lt; 3.100000e-01, 0.000000e+00, 3.691728e-02, 1.238937e-02, 4.930664e-02, 1.024907e-02, -2.912184e-02
-&lt; 3.110000e-01, 0.000000e+00, 3.636503e-02, 1.294150e-02, 4.930653e-02, 1.024851e-02, -2.892829e-02
-&lt; 3.120000e-01, 0.000000e+00, 3.576281e-02, 1.354358e-02, 4.930639e-02, 1.024464e-02, -2.871565e-02
-&lt; 3.130000e-01, 0.000000e+00, 3.511272e-02, 1.419353e-02, 4.930625e-02, 1.025948e-02, -2.848405e-02
-&lt; 3.140000e-01, 0.000000e+00, 3.441704e-02, 1.488905e-02, 4.930610e-02, 1.026864e-02, -2.823395e-02
-&lt; 3.150000e-01, 0.000000e+00, 3.367825e-02, 1.562768e-02, 4.930593e-02, 1.027256e-02, -2.796587e-02
-&lt; 3.160000e-01, 0.000000e+00, 3.289900e-02, 1.640676e-02, 4.930575e-02, 1.027171e-02, -2.768034e-02
-&lt; 3.170000e-01, 0.000000e+00, 3.208210e-02, 1.722346e-02, 4.930557e-02, 1.026658e-02, -2.737789e-02
-&lt; 3.180000e-01, 0.000000e+00, 3.123058e-02, 1.807479e-02, 4.930537e-02, 1.027882e-02, -2.705896e-02
-&lt; 3.190000e-01, 0.000000e+00, 3.034761e-02, 1.895755e-02, 4.930516e-02, 1.028757e-02, -2.672392e-02
-&lt; 3.200000e-01, 0.000000e+00, 2.943652e-02, 1.986842e-02, 4.930494e-02, 1.029106e-02, -2.637301e-02
-&lt; 3.210000e-01, 0.000000e+00, 2.850079e-02, 2.080393e-02, 4.930472e-02, 1.028975e-02, -2.600660e-02
-&lt; 3.220000e-01, 0.000000e+00, 2.754398e-02, 2.176051e-02, 4.930449e-02, 1.028412e-02, -2.562589e-02
-&lt; 3.230000e-01, 0.000000e+00, 2.656976e-02, 2.273450e-02, 4.930426e-02, 1.029188e-02, -2.522953e-02
-&lt; 3.240000e-01, 0.000000e+00, 2.558189e-02, 2.372213e-02, 4.930402e-02, 1.030008e-02, -2.481764e-02
-&lt; 3.250000e-01, 0.000000e+00, 2.458419e-02, 2.471958e-02, 4.930377e-02, 1.030300e-02, -2.439036e-02
-&lt; 3.260000e-01, 0.000000e+00, 2.358058e-02, 2.572295e-02, 4.930352e-02, 1.030109e-02, -2.394798e-02
-&lt; 3.270000e-01, 0.000000e+00, 2.257501e-02, 2.672826e-02, 4.930327e-02, 1.029485e-02, -2.349086e-02
-&lt; 3.280000e-01, 0.000000e+00, 2.157150e-02, 2.773152e-02, 4.930302e-02, 1.029757e-02, -2.301949e-02
-&lt; 3.290000e-01, 0.000000e+00, 2.057407e-02, 2.872870e-02, 4.930277e-02, 1.030516e-02, -2.253446e-02
-&lt; 3.300000e-01, 0.000000e+00, 1.958673e-02, 2.971580e-02, 4.930252e-02, 1.030745e-02, -2.203647e-02
-&lt; 3.310000e-01, 0.000000e+00, 1.861344e-02, 3.068883e-02, 4.930228e-02, 1.030490e-02, -2.152628e-02
-&lt; 3.320000e-01, 0.000000e+00, 1.765816e-02, 3.164387e-02, 4.930203e-02, 1.029799e-02, -2.100470e-02
-&lt; 3.330000e-01, 0.000000e+00, 1.672478e-02, 3.257701e-02, 4.930179e-02, 1.029556e-02, -2.047342e-02
-&lt; 3.340000e-01, 0.000000e+00, 1.581713e-02, 3.348442e-02, 4.930156e-02, 1.030254e-02, -1.993361e-02
-&lt; 3.350000e-01, 0.000000e+00, 1.493901e-02, 3.436231e-02, 4.930133e-02, 1.030421e-02, -1.938467e-02
-&lt; 3.360000e-01, 0.000000e+00, 1.409410e-02, 3.520701e-02, 4.930110e-02, 1.030104e-02, -1.882703e-02
-&lt; 3.370000e-01, 0.000000e+00, 1.328596e-02, 3.601493e-02, 4.930089e-02, 1.029349e-02, -1.826104e-02
-&lt; 3.380000e-01, 0.000000e+00, 1.251804e-02, 3.678265e-02, 4.930068e-02, 1.028625e-02, -1.768700e-02
-&lt; 3.390000e-01, 0.000000e+00, 1.179360e-02, 3.750688e-02, 4.930049e-02, 1.029269e-02, -1.710521e-02
-&lt; 3.400000e-01, 0.000000e+00, 1.111578e-02, 3.818452e-02, 4.930030e-02, 1.029384e-02, -1.651600e-02
-&lt; 3.410000e-01, 0.000000e+00, 1.048753e-02, 3.881260e-02, 4.930013e-02, 1.029013e-02, -1.591976e-02
-&lt; 3.420000e-01, 0.000000e+00, 9.911642e-03, 3.938832e-02, 4.929997e-02, 1.028205e-02, -1.531699e-02
-&lt; 3.430000e-01, 0.000000e+00, 9.390729e-03, 3.990909e-02, 4.929981e-02, 1.027074e-02, -1.471063e-02
-&lt; 3.440000e-01, 0.000000e+00, 8.927204e-03, 4.037247e-02, 4.929968e-02, 1.027680e-02, -1.409984e-02
-&lt; 3.450000e-01, 0.000000e+00, 8.523254e-03, 4.077630e-02, 4.929956e-02, 1.027757e-02, -1.348420e-02
-&lt; 3.460000e-01, 0.000000e+00, 8.180827e-03, 4.111862e-02, 4.929945e-02, 1.027349e-02, -1.286421e-02
-&lt; 3.470000e-01, 0.000000e+00, 7.901627e-03, 4.139773e-02, 4.929936e-02, 1.026503e-02, -1.224048e-02
-&lt; 3.480000e-01, 0.000000e+00, 7.687112e-03, 4.161217e-02, 4.929928e-02, 1.025271e-02, -1.161372e-02
-&lt; 3.490000e-01, 0.000000e+00, 7.538500e-03, 4.176072e-02, 4.929922e-02, 1.025664e-02, -1.098475e-02
-&lt; 3.500000e-01, 0.000000e+00, 7.456766e-03, 4.184241e-02, 4.929918e-02, 1.025723e-02, -1.035653e-02
-&lt; 3.510000e-01, 0.000000e+00, 7.442635e-03, 4.185651e-02, 4.929915e-02, 1.025298e-02, -1.026813e-02
-&lt; 3.520000e-01, 0.000000e+00, 7.496568e-03, 4.180257e-02, 4.929914e-02, 1.024437e-02, -1.087872e-02
-&lt; 3.530000e-01, 0.000000e+00, 7.618746e-03, 4.168040e-02, 4.929914e-02, 1.023189e-02, -1.149013e-02
-&lt; 3.540000e-01, 0.000000e+00, 7.809064e-03, 4.149010e-02, 4.929917e-02, 1.023439e-02, -1.211210e-02
-&lt; 3.550000e-01, 0.000000e+00, 8.067137e-03, 4.123207e-02, 4.929921e-02, 1.023504e-02, -1.273728e-02
-&lt; 3.560000e-01, 0.000000e+00, 8.392306e-03, 4.090696e-02, 4.929926e-02, 1.023086e-02, -1.335969e-02
-&lt; 3.570000e-01, 0.000000e+00, 8.783652e-03, 4.051569e-02, 4.929934e-02, 1.022232e-02, -1.397845e-02
-&lt; 3.580000e-01, 0.000000e+00, 9.240000e-03, 4.005943e-02, 4.929943e-02, 1.020992e-02, -1.459275e-02
-&lt; 3.590000e-01, 0.000000e+00, 9.759919e-03, 3.953961e-02, 4.929953e-02, 1.021244e-02, -1.520184e-02
-&lt; 3.600000e-01, 0.000000e+00, 1.034171e-02, 3.895794e-02, 4.929966e-02, 1.021339e-02, -1.580508e-02
-&lt; 3.610000e-01, 0.000000e+00, 1.098342e-02, 3.831637e-02, 4.929980e-02, 1.020952e-02, -1.640195e-02
-&lt; 3.620000e-01, 0.000000e+00, 1.168282e-02, 3.761713e-02, 4.929995e-02, 1.020130e-02, -1.699203e-02
-&lt; 3.630000e-01, 0.000000e+00, 1.243744e-02, 3.686268e-02, 4.930012e-02, 1.018922e-02, -1.757496e-02
-&lt; 3.640000e-01, 0.000000e+00, 1.324456e-02, 3.605574e-02, 4.930030e-02, 1.019316e-02, -1.815180e-02
-&lt; 3.650000e-01, 0.000000e+00, 1.410126e-02, 3.519923e-02, 4.930050e-02, 1.019463e-02, -1.872745e-02
-&lt; 3.660000e-01, 0.000000e+00, 1.500444e-02, 3.429626e-02, 4.930070e-02, 1.019129e-02, -1.929394e-02
-&lt; 3.670000e-01, 0.000000e+00, 1.595077e-02, 3.335016e-02, 4.930092e-02, 1.018360e-02, -1.985042e-02
-&lt; 3.680000e-01, 0.000000e+00, 1.693674e-02, 3.236442e-02, 4.930115e-02, 1.017206e-02, -2.039609e-02
-&lt; 3.690000e-01, 0.000000e+00, 1.795866e-02, 3.134274e-02, 4.930140e-02, 1.017864e-02, -2.093023e-02
-&lt; 3.700000e-01, 0.000000e+00, 1.901265e-02, 3.028900e-02, 4.930165e-02, 1.018082e-02, -2.145219e-02
-&lt; 3.710000e-01, 0.000000e+00, 2.009468e-02, 2.920723e-02, 4.930191e-02, 1.017819e-02, -2.196142e-02
-&lt; 3.720000e-01, 0.000000e+00, 2.120059e-02, 2.810158e-02, 4.930218e-02, 1.017121e-02, -2.245747e-02
-&lt; 3.730000e-01, 0.000000e+00, 2.232613e-02, 2.697632e-02, 4.930245e-02, 1.016227e-02, -2.293997e-02
-&lt; 3.740000e-01, 0.000000e+00, 2.346694e-02, 2.583579e-02, 4.930272e-02, 1.017052e-02, -2.340863e-02
-&lt; 3.750000e-01, 0.000000e+00, 2.461858e-02, 2.468443e-02, 4.930301e-02, 1.017353e-02, -2.386325e-02
-&lt; 3.760000e-01, 0.000000e+00, 2.577656e-02, 2.352673e-02, 4.930329e-02, 1.017173e-02, -2.430367e-02
-&lt; 3.770000e-01, 0.000000e+00, 2.693631e-02, 2.236727e-02, 4.930358e-02, 1.016559e-02, -2.473282e-02
-&lt; 3.780000e-01, 0.000000e+00, 2.809323e-02, 2.121064e-02, 4.930387e-02, 1.016063e-02, -2.514853e-02
-&lt; 3.790000e-01, 0.000000e+00, 2.924267e-02, 2.006148e-02, 4.930416e-02, 1.016979e-02, -2.554902e-02
-&lt; 3.800000e-01, 0.000000e+00, 3.038005e-02, 1.892440e-02, 4.930444e-02, 1.017370e-02, -2.593414e-02
-&lt; 3.810000e-01, 0.000000e+00, 3.150077e-02, 1.780396e-02, 4.930473e-02, 1.017279e-02, -2.630379e-02
-&lt; 3.820000e-01, 0.000000e+00, 3.260031e-02, 1.670470e-02, 4.930500e-02, 1.016752e-02, -2.665781e-02
-&lt; 3.830000e-01, 0.000000e+00, 3.367421e-02, 1.563107e-02, 4.930528e-02, 1.016668e-02, -2.699601e-02
-&lt; 3.840000e-01, 0.000000e+00, 3.471809e-02, 1.458746e-02, 4.930555e-02, 1.017673e-02, -2.731813e-02
-&lt; 3.850000e-01, 0.000000e+00, 3.572764e-02, 1.357817e-02, 4.930581e-02, 1.018152e-02, -2.762381e-02
-&lt; 3.860000e-01, 0.000000e+00, 3.669867e-02, 1.260740e-02, 4.930607e-02, 1.018148e-02, -2.791261e-02
-&lt; 3.870000e-01, 0.000000e+00, 3.762709e-02, 1.167922e-02, 4.930631e-02, 1.017706e-02, -2.818404e-02
-&lt; 3.880000e-01, 0.000000e+00, 3.850899e-02, 1.079755e-02, 4.930654e-02, 1.018001e-02, -2.843759e-02
-&lt; 3.890000e-01, 0.000000e+00, 3.934064e-02, 9.966122e-03, 4.930676e-02, 1.019088e-02, -2.867274e-02
-&lt; 3.900000e-01, 0.000000e+00, 4.011850e-02, 9.188474e-03, 4.930697e-02, 1.019647e-02, -2.888904e-02
-&lt; 3.910000e-01, 0.000000e+00, 4.083921e-02, 8.467959e-03, 4.930717e-02, 1.019720e-02, -2.908911e-02
-&lt; 3.920000e-01, 0.000000e+00, 4.149963e-02, 7.807722e-03, 4.930735e-02, 1.019352e-02, -2.927077e-02
-&lt; 3.930000e-01, 0.000000e+00, 4.209682e-02, 7.210699e-03, 4.930752e-02, 1.019951e-02, -2.943258e-02
-&lt; 3.940000e-01, 0.000000e+00, 4.262808e-02, 6.679596e-03, 4.930768e-02, 1.021105e-02, -2.957420e-02
-&lt; 3.950000e-01, 0.000000e+00, 4.309094e-02, 6.216873e-03, 4.930781e-02, 1.021728e-02, -2.969537e-02
-&lt; 3.960000e-01, 0.000000e+00, 4.348322e-02, 5.824718e-03, 4.930793e-02, 1.021863e-02, -2.979594e-02
-&lt; 3.970000e-01, 0.000000e+00, 4.380300e-02, 5.505038e-03, 4.930804e-02, 1.021553e-02, -2.987585e-02
-&lt; 3.980000e-01, 0.000000e+00, 4.404867e-02, 5.259452e-03, 4.930812e-02, 1.022347e-02, -2.993515e-02
-&lt; 3.990000e-01, 0.000000e+00, 4.421889e-02, 5.089296e-03, 4.930818e-02, 1.023548e-02, -2.997398e-02
-&lt; 4.000000e-01, 0.000000e+00, 4.431261e-02, 4.995618e-03, 4.930823e-02, 1.024215e-02, -2.999255e-02
----
-&gt; time, wext, epot, ekin, total
-&gt; 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00
-&gt; 1.000000e-03, 1.924722e-02, 0.000000e+00, 4.811805e-03, -1.443541e-02
-&gt; 2.000000e-03, 7.544910e-02, 1.539778e-03, 4.104277e-02, -3.286655e-02
-&gt; 3.000000e-03, 1.641711e-01, 1.277399e-02, 1.026039e-01, -4.879315e-02
-&gt; 4.000000e-03, 2.786135e-01, 4.522315e-02, 1.726814e-01, -6.070893e-02
-&gt; 5.000000e-03, 4.104158e-01, 1.067830e-01, 2.359790e-01, -6.765376e-02
-&gt; 6.000000e-03, 5.506284e-01, 1.962976e-01, 2.848677e-01, -6.946319e-02
-&gt; 7.000000e-03, 6.907258e-01, 3.026027e-01, 3.213269e-01, -6.679618e-02
-&gt; 8.000000e-03, 8.235280e-01, 4.085476e-01, 3.540512e-01, -6.092923e-02
-&gt; 9.000000e-03, 9.439160e-01, 4.978886e-01, 3.926220e-01, -5.340544e-02
-&gt; 1.000000e-02, 1.049253e+00, 5.615394e-01, 4.420333e-01, -4.568068e-02
-&gt; 1.100000e-02, 1.139471e+00, 6.001689e-01, 5.004111e-01, -3.889055e-02
-&gt; 1.200000e-02, 1.216814e+00, 6.222053e-01, 5.608233e-01, -3.378522e-02
-&gt; 1.300000e-02, 1.285307e+00, 6.387420e-01, 6.157750e-01, -3.079051e-02
-&gt; 1.400000e-02, 1.350014e+00, 6.582947e-01, 6.616184e-01, -3.010097e-02
-&gt; 1.500000e-02, 1.416205e+00, 6.841084e-01, 7.003760e-01, -3.172026e-02
-&gt; 1.600000e-02, 1.488556e+00, 7.150033e-01, 7.381286e-01, -3.542428e-02
-&gt; 1.700000e-02, 1.570488e+00, 7.486463e-01, 7.811484e-01, -4.069348e-02
-&gt; 1.800000e-02, 1.663725e+00, 7.848509e-01, 8.321767e-01, -4.669719e-02
-&gt; 1.900000e-02, 1.768133e+00, 8.267258e-01, 8.890138e-01, -5.239372e-02
-&gt; 2.000000e-02, 1.881847e+00, 8.789917e-01, 9.461098e-01, -5.674575e-02
-&gt; 2.100000e-02, 2.001645e+00, 9.446119e-01, 9.980522e-01, -5.898042e-02
-&gt; 2.200000e-02, 2.123510e+00, 1.021932e+00, 1.042789e+00, -5.878926e-02
-&gt; 2.300000e-02, 2.243293e+00, 1.104220e+00, 1.082689e+00, -5.638445e-02
-&gt; 2.400000e-02, 2.357353e+00, 1.182038e+00, 1.122921e+00, -5.239410e-02
-&gt; 2.500000e-02, 2.463100e+00, 1.247222e+00, 1.168226e+00, -4.765154e-02
-&gt; 2.600000e-02, 2.559355e+00, 1.296283e+00, 1.220098e+00, -4.297453e-02
-&gt; 2.700000e-02, 2.646474e+00, 1.331444e+00, 1.276012e+00, -3.901774e-02
-&gt; 2.800000e-02, 2.726234e+00, 1.358899e+00, 1.331106e+00, -3.622904e-02
-&gt; 2.900000e-02, 2.801504e+00, 1.385433e+00, 1.381192e+00, -3.487894e-02
-&gt; 3.000000e-02, 2.875759e+00, 1.415405e+00, 1.425254e+00, -3.510011e-02
-&gt; 3.100000e-02, 2.952514e+00, 1.449677e+00, 1.465951e+00, -3.688626e-02
-&gt; 3.200000e-02, 3.034778e+00, 1.486848e+00, 1.507885e+00, -4.004507e-02
-&gt; 3.300000e-02, 3.124593e+00, 1.525682e+00, 1.554763e+00, -4.414798e-02
-&gt; 3.400000e-02, 3.222752e+00, 1.567030e+00, 1.607185e+00, -4.853750e-02
-&gt; 3.500000e-02, 3.328707e+00, 1.613902e+00, 1.662376e+00, -5.242873e-02
-&gt; 3.600000e-02, 3.440696e+00, 1.669638e+00, 1.715968e+00, -5.508969e-02
-&gt; 3.700000e-02, 3.556055e+00, 1.735334e+00, 1.764686e+00, -5.603565e-02
-&gt; 3.800000e-02, 3.671663e+00, 1.808207e+00, 1.808298e+00, -5.515709e-02
-&gt; 3.900000e-02, 3.784439e+00, 1.882035e+00, 1.849676e+00, -5.272824e-02
-&gt; 4.000000e-02, 3.891833e+00, 1.949566e+00, 1.892969e+00, -4.929854e-02
-&gt; 4.100000e-02, 3.992209e+00, 2.005627e+00, 1.941059e+00, -4.552221e-02
-&gt; 4.200000e-02, 4.085079e+00, 2.049233e+00, 1.993845e+00, -4.200110e-02
-&gt; 4.300000e-02, 4.171155e+00, 2.083581e+00, 2.048378e+00, -3.919586e-02
-&gt; 4.400000e-02, 4.252207e+00, 2.114075e+00, 2.100718e+00, -3.741365e-02
-&gt; 4.500000e-02, 4.330757e+00, 2.145571e+00, 2.148349e+00, -3.683681e-02
-&gt; 4.600000e-02, 4.409668e+00, 2.180453e+00, 2.191673e+00, -3.754236e-02
-&gt; 4.700000e-02, 4.491683e+00, 2.218500e+00, 2.233700e+00, -3.948263e-02
-&gt; 4.800000e-02, 4.578993e+00, 2.258392e+00, 2.278162e+00, -4.243784e-02
-&gt; 4.900000e-02, 4.672905e+00, 2.299687e+00, 2.327234e+00, -4.598492e-02
-&gt; 5.000000e-02, 4.773656e+00, 2.343889e+00, 2.380238e+00, -4.952919e-02
-&gt; 5.100000e-02, 4.880391e+00, 2.393852e+00, 2.434123e+00, -5.241609e-02
-&gt; 5.200000e-02, 4.991327e+00, 2.451873e+00, 2.485361e+00, -5.409363e-02
-&gt; 5.300000e-02, 5.104048e+00, 2.517682e+00, 2.532103e+00, -5.426309e-02
-&gt; 5.400000e-02, 5.215902e+00, 2.587675e+00, 2.575273e+00, -5.295449e-02
-&gt; 5.500000e-02, 5.324424e+00, 2.655976e+00, 2.617951e+00, -5.049671e-02
-&gt; 5.600000e-02, 5.427722e+00, 2.716861e+00, 2.663460e+00, -4.740164e-02
-&gt; 5.700000e-02, 5.524767e+00, 2.767211e+00, 2.713338e+00, -4.421819e-02
-&gt; 5.800000e-02, 5.615540e+00, 2.807687e+00, 2.766435e+00, -4.141752e-02
-&gt; 5.900000e-02, 5.701017e+00, 2.842012e+00, 2.819662e+00, -3.934282e-02
-&gt; 6.000000e-02, 5.782997e+00, 2.874878e+00, 2.869903e+00, -3.821586e-02
-&gt; 6.100000e-02, 5.863804e+00, 2.909729e+00, 2.915913e+00, -3.816187e-02
-&gt; 6.200000e-02, 5.945910e+00, 2.947649e+00, 2.959048e+00, -3.921337e-02
-&gt; 6.300000e-02, 6.031541e+00, 2.987868e+00, 3.002393e+00, -4.127997e-02
-&gt; 6.400000e-02, 6.122326e+00, 3.029366e+00, 3.048854e+00, -4.410625e-02
-&gt; 6.500000e-02, 6.219053e+00, 3.072399e+00, 3.099393e+00, -4.726090e-02
-&gt; 6.600000e-02, 6.321551e+00, 3.118890e+00, 3.152471e+00, -5.019079e-02
-&gt; 6.700000e-02, 6.428739e+00, 3.171376e+00, 3.205023e+00, -5.234038e-02
-&gt; 6.800000e-02, 6.538804e+00, 3.231154e+00, 3.254352e+00, -5.329761e-02
-&gt; 6.900000e-02, 6.649505e+00, 3.296829e+00, 3.299768e+00, -5.290698e-02
-&gt; 7.000000e-02, 6.758531e+00, 3.364253e+00, 3.342976e+00, -5.130238e-02
-&gt; 7.100000e-02, 6.863874e+00, 3.428021e+00, 3.387004e+00, -4.884867e-02
-&gt; 7.200000e-02, 6.964135e+00, 3.483775e+00, 3.434336e+00, -4.602356e-02
-&gt; 7.300000e-02, 7.058744e+00, 3.530045e+00, 3.485406e+00, -4.329419e-02
-&gt; 7.400000e-02, 7.148039e+00, 3.568642e+00, 3.538360e+00, -4.103614e-02
-&gt; 7.500000e-02, 7.233194e+00, 3.603462e+00, 3.590222e+00, -3.951078e-02
-&gt; 7.600000e-02, 7.316028e+00, 3.638427e+00, 3.638719e+00, -3.888137e-02
-&gt; 7.700000e-02, 7.398704e+00, 3.675808e+00, 3.683666e+00, -3.923058e-02
-&gt; 7.800000e-02, 7.483383e+00, 3.715787e+00, 3.727044e+00, -4.055097e-02
-&gt; 7.900000e-02, 7.571876e+00, 3.757398e+00, 3.771769e+00, -4.270937e-02
-&gt; 8.000000e-02, 7.665370e+00, 3.800060e+00, 3.819894e+00, -4.541484e-02
-&gt; 8.100000e-02, 7.764237e+00, 3.844634e+00, 3.871374e+00, -4.822880e-02
-&gt; 8.200000e-02, 7.867993e+00, 3.893242e+00, 3.924112e+00, -5.063825e-02
-&gt; 8.300000e-02, 7.975381e+00, 3.947930e+00, 3.975273e+00, -5.217807e-02
-&gt; 8.400000e-02, 8.084582e+00, 4.009009e+00, 4.023016e+00, -5.255764e-02
-&gt; 8.500000e-02, 8.193512e+00, 4.074162e+00, 4.067611e+00, -5.173878e-02
-&gt; 8.600000e-02, 8.300152e+00, 4.138970e+00, 4.111248e+00, -4.993296e-02
-&gt; 8.700000e-02, 8.402872e+00, 4.198673e+00, 4.156676e+00, -4.752308e-02
-&gt; 8.800000e-02, 8.500685e+00, 4.250219e+00, 4.205518e+00, -4.494907e-02
-&gt; 8.900000e-02, 8.593396e+00, 4.293497e+00, 4.257291e+00, -4.260745e-02
-&gt; 9.000000e-02, 8.681624e+00, 4.331094e+00, 4.309731e+00, -4.079866e-02
-&gt; 9.100000e-02, 8.766692e+00, 4.366781e+00, 4.360188e+00, -3.972347e-02
-&gt; 9.200000e-02, 8.850415e+00, 4.403659e+00, 4.407254e+00, -3.950187e-02
-&gt; 9.300000e-02, 8.934799e+00, 4.443008e+00, 4.451610e+00, -4.018076e-02
-&gt; 9.400000e-02, 9.021726e+00, 4.484427e+00, 4.495585e+00, -4.171383e-02
-&gt; 9.500000e-02, 9.112650e+00, 4.527010e+00, 4.541714e+00, -4.392571e-02
-&gt; 9.600000e-02, 9.208375e+00, 4.570691e+00, 4.591191e+00, -4.649370e-02
-&gt; 9.700000e-02, 9.308934e+00, 4.616805e+00, 4.643150e+00, -4.897872e-02
-&gt; 9.800000e-02, 9.413588e+00, 4.667457e+00, 4.695217e+00, -5.091327e-02
-&gt; 9.900000e-02, 9.520953e+00, 4.724055e+00, 4.744977e+00, -5.192103e-02
-&gt; 1.000000e-01, 9.629231e+00, 4.785960e+00, 4.791450e+00, -5.182094e-02
-&gt; 1.010000e-01, 9.736493e+00, 4.850148e+00, 4.835673e+00, -5.067197e-02
-&gt; 1.020000e-01, 9.840994e+00, 4.912200e+00, 4.880052e+00, -4.874114e-02
-&gt; 1.030000e-01, 9.941443e+00, 4.968158e+00, 4.926871e+00, -4.641354e-02
-&gt; 1.040000e-01, 1.003721e+01, 5.016221e+00, 4.976901e+00, -4.408719e-02
-&gt; 1.050000e-01, 1.012841e+01, 5.057374e+00, 5.028941e+00, -4.209564e-02
-&gt; 1.060000e-01, 1.021589e+01, 5.094642e+00, 5.080574e+00, -4.067867e-02
-&gt; 1.070000e-01, 1.030109e+01, 5.131446e+00, 5.129654e+00, -3.999074e-02
-&gt; 1.080000e-01, 1.038578e+01, 5.170044e+00, 5.175617e+00, -4.011736e-02
-&gt; 1.090000e-01, 1.047180e+01, 5.210922e+00, 5.219809e+00, -4.107221e-02
-&gt; 1.100000e-01, 1.056078e+01, 5.253361e+00, 5.264649e+00, -4.276975e-02
-&gt; 1.110000e-01, 1.065384e+01, 5.296709e+00, 5.312135e+00, -4.499416e-02
-&gt; 1.120000e-01, 1.075145e+01, 5.341421e+00, 5.362631e+00, -4.739742e-02
-&gt; 1.130000e-01, 1.085335e+01, 5.389147e+00, 5.414654e+00, -4.954964e-02
-&gt; 1.140000e-01, 1.095860e+01, 5.441765e+00, 5.465802e+00, -5.103651e-02
-&gt; 1.150000e-01, 1.106574e+01, 5.499941e+00, 5.514230e+00, -5.157042e-02
-&gt; 1.160000e-01, 1.117301e+01, 5.562169e+00, 5.559771e+00, -5.106959e-02
-&gt; 1.170000e-01, 1.127865e+01, 5.624950e+00, 5.604027e+00, -4.967191e-02
-&gt; 1.180000e-01, 1.138118e+01, 5.684123e+00, 5.649372e+00, -4.768056e-02
-&gt; 1.190000e-01, 1.147961e+01, 5.736648e+00, 5.697494e+00, -4.546955e-02
-&gt; 1.200000e-01, 1.157364e+01, 5.781883e+00, 5.748366e+00, -4.339216e-02
-&gt; 1.210000e-01, 1.166365e+01, 5.821646e+00, 5.800281e+00, -4.172580e-02
-&gt; 1.220000e-01, 1.175067e+01, 5.859105e+00, 5.850906e+00, -4.066105e-02
-&gt; 1.230000e-01, 1.183619e+01, 5.897159e+00, 5.898718e+00, -4.031593e-02
-&gt; 1.240000e-01, 1.192194e+01, 5.937262e+00, 5.943927e+00, -4.074610e-02
-&gt; 1.250000e-01, 1.200957e+01, 5.979304e+00, 5.988335e+00, -4.193206e-02
-&gt; 1.260000e-01, 1.210045e+01, 6.022488e+00, 6.034218e+00, -4.374866e-02
-&gt; 1.270000e-01, 1.219542e+01, 6.066540e+00, 6.082933e+00, -4.594296e-02
-&gt; 1.280000e-01, 1.229462e+01, 6.112381e+00, 6.134091e+00, -4.815033e-02
-&gt; 1.290000e-01, 1.239757e+01, 6.161797e+00, 6.185814e+00, -4.996112e-02
-&gt; 1.300000e-01, 1.250316e+01, 6.216250e+00, 6.235890e+00, -5.102196e-02
-&gt; 1.310000e-01, 1.260988e+01, 6.275615e+00, 6.283133e+00, -5.113320e-02
-&gt; 1.320000e-01, 1.271605e+01, 6.337648e+00, 6.328101e+00, -5.030151e-02
-&gt; 1.330000e-01, 1.282009e+01, 6.398625e+00, 6.372739e+00, -4.872635e-02
-&gt; 1.340000e-01, 1.292077e+01, 6.454861e+00, 6.419180e+00, -4.672983e-02
-&gt; 1.350000e-01, 1.301741e+01, 6.504308e+00, 6.468437e+00, -4.466441e-02
-&gt; 1.360000e-01, 1.310997e+01, 6.547342e+00, 6.519792e+00, -4.283774e-02
-&gt; 1.370000e-01, 1.319907e+01, 6.586347e+00, 6.571248e+00, -4.147793e-02
-&gt; 1.380000e-01, 1.328588e+01, 6.624381e+00, 6.620760e+00, -4.073562e-02
-&gt; 1.390000e-01, 1.337190e+01, 6.663715e+00, 6.667490e+00, -4.069893e-02
-&gt; 1.400000e-01, 1.345879e+01, 6.705086e+00, 6.712307e+00, -4.139541e-02
-&gt; 1.410000e-01, 1.354801e+01, 6.747997e+00, 6.757246e+00, -4.277127e-02
-&gt; 1.420000e-01, 1.364068e+01, 6.791770e+00, 6.804253e+00, -4.466204e-02
-&gt; 1.430000e-01, 1.373734e+01, 6.836567e+00, 6.853993e+00, -4.678304e-02
-&gt; 1.440000e-01, 1.383789e+01, 6.883676e+00, 6.905454e+00, -4.876336e-02
-&gt; 1.450000e-01, 1.394162e+01, 6.934820e+00, 6.956577e+00, -5.022499e-02
-&gt; 1.460000e-01, 1.404731e+01, 6.990905e+00, 7.005525e+00, -5.088203e-02
-&gt; 1.470000e-01, 1.415344e+01, 7.051017e+00, 7.051804e+00, -5.062015e-02
-&gt; 1.480000e-01, 1.425843e+01, 7.112348e+00, 7.096558e+00, -4.952254e-02
-&gt; 1.490000e-01, 1.436089e+01, 7.171194e+00, 7.141859e+00, -4.783344e-02
-&gt; 1.500000e-01, 1.445984e+01, 7.224534e+00, 7.189427e+00, -4.587902e-02
-&gt; 1.510000e-01, 1.455488e+01, 7.271311e+00, 7.239584e+00, -4.398256e-02
-&gt; 1.520000e-01, 1.464622e+01, 7.312746e+00, 7.291064e+00, -4.240718e-02
-&gt; 1.530000e-01, 1.473466e+01, 7.351526e+00, 7.341800e+00, -4.133848e-02
-&gt; 1.540000e-01, 1.482148e+01, 7.390392e+00, 7.390193e+00, -4.089453e-02
-&gt; 1.550000e-01, 1.490818e+01, 7.430951e+00, 7.436090e+00, -4.113741e-02
-&gt; 1.560000e-01, 1.499628e+01, 7.473347e+00, 7.480867e+00, -4.206627e-02
-&gt; 1.570000e-01, 1.508708e+01, 7.516906e+00, 7.526578e+00, -4.359163e-02
-&gt; 1.580000e-01, 1.518141e+01, 7.561212e+00, 7.574691e+00, -4.551149e-02
-&gt; 1.590000e-01, 1.527958e+01, 7.606867e+00, 7.625194e+00, -4.751673e-02
-&gt; 1.600000e-01, 1.538123e+01, 7.655381e+00, 7.676611e+00, -4.924161e-02
-&gt; 1.610000e-01, 1.548550e+01, 7.708229e+00, 7.726916e+00, -5.035053e-02
-&gt; 1.620000e-01, 1.559107e+01, 7.765661e+00, 7.774776e+00, -5.062954e-02
-&gt; 1.630000e-01, 1.569645e+01, 7.826041e+00, 7.820364e+00, -5.004463e-02
-&gt; 1.640000e-01, 1.580019e+01, 7.886200e+00, 7.865245e+00, -4.874245e-02
-&gt; 1.650000e-01, 1.590109e+01, 7.942690e+00, 7.911405e+00, -4.699614e-02
-&gt; 1.660000e-01, 1.599843e+01, 7.993275e+00, 7.960036e+00, -4.512352e-02
-&gt; 1.670000e-01, 1.609206e+01, 8.037839e+00, 8.010809e+00, -4.341392e-02
-&gt; 1.680000e-01, 1.618241e+01, 8.078239e+00, 8.062085e+00, -4.208869e-02
-&gt; 1.690000e-01, 1.627044e+01, 8.117221e+00, 8.111926e+00, -4.129744e-02
-&gt; 1.700000e-01, 1.635748e+01, 8.157064e+00, 8.159285e+00, -4.113111e-02
-&gt; 1.710000e-01, 1.644499e+01, 8.198724e+00, 8.204642e+00, -4.162733e-02
-&gt; 1.720000e-01, 1.653437e+01, 8.241918e+00, 8.249700e+00, -4.275539e-02
-&gt; 1.730000e-01, 1.662670e+01, 8.285980e+00, 8.296335e+00, -4.438932e-02
-&gt; 1.740000e-01, 1.672259e+01, 8.330851e+00, 8.345448e+00, -4.629310e-02
-&gt; 1.750000e-01, 1.682207e+01, 8.377515e+00, 8.396413e+00, -4.814226e-02
-&gt; 1.760000e-01, 1.692460e+01, 8.427537e+00, 8.447477e+00, -4.958815e-02
-&gt; 1.770000e-01, 1.702917e+01, 8.481986e+00, 8.496833e+00, -5.034693e-02
-&gt; 1.780000e-01, 1.713442e+01, 8.540409e+00, 8.543733e+00, -5.027843e-02
-&gt; 1.790000e-01, 1.723892e+01, 8.600565e+00, 8.588937e+00, -4.942161e-02
-&gt; 1.800000e-01, 1.734136e+01, 8.659147e+00, 8.634240e+00, -4.797275e-02
-&gt; 1.810000e-01, 1.744075e+01, 8.713165e+00, 8.681366e+00, -4.621929e-02
-&gt; 1.820000e-01, 1.753661e+01, 8.761236e+00, 8.730913e+00, -4.446102e-02
-&gt; 1.830000e-01, 1.762902e+01, 8.804074e+00, 8.781992e+00, -4.295118e-02
-&gt; 1.840000e-01, 1.771860e+01, 8.843949e+00, 8.832780e+00, -4.187331e-02
-&gt; 1.850000e-01, 1.780644e+01, 8.883452e+00, 8.881643e+00, -4.134683e-02
-&gt; 1.860000e-01, 1.789389e+01, 8.924312e+00, 8.928135e+00, -4.143908e-02
-&gt; 1.870000e-01, 1.798234e+01, 8.966911e+00, 8.973265e+00, -4.216308e-02
-&gt; 1.880000e-01, 1.807304e+01, 9.010711e+00, 9.018871e+00, -4.345642e-02
-&gt; 1.890000e-01, 1.816686e+01, 9.055209e+00, 9.066490e+00, -4.515690e-02
-&gt; 1.900000e-01, 1.826416e+01, 9.100743e+00, 9.116418e+00, -4.700003e-02
-&gt; 1.910000e-01, 1.836476e+01, 9.148575e+00, 9.167532e+00, -4.865647e-02
-&gt; 1.920000e-01, 1.846795e+01, 9.200154e+00, 9.217992e+00, -4.980621e-02
-&gt; 1.930000e-01, 1.857260e+01, 9.256012e+00, 9.266364e+00, -5.022446e-02
-&gt; 1.940000e-01, 1.867736e+01, 9.315012e+00, 9.312505e+00, -4.984383e-02
-&gt; 1.950000e-01, 1.878087e+01, 9.374466e+00, 9.357637e+00, -4.876681e-02
-&gt; 1.960000e-01, 1.888197e+01, 9.431154e+00, 9.403596e+00, -4.722524e-02
-&gt; 1.970000e-01, 1.897991e+01, 9.482701e+00, 9.451700e+00, -4.550804e-02
-&gt; 1.980000e-01, 1.907442e+01, 9.528582e+00, 9.501948e+00, -4.389005e-02
-&gt; 1.990000e-01, 1.916580e+01, 9.570188e+00, 9.553022e+00, -4.258852e-02
-&gt; 2.000000e-01, 1.925484e+01, 9.609975e+00, 9.603108e+00, -4.175376e-02
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_model_solver_dynamic_implicit</Name>
- <Path>./test/test_model/test_model_solver</Path>
- <FullName>./test/test_model/test_model_solver/test_model_solver_dynamic_implicit</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_model_solver_dynamic_implicit" "-e" "./test_model_solver_dynamic_implicit" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_model_solver_dynamic_implicit.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Failed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>3.17552</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_model_solver_dynamic_implicit" "-e" "./test_model_solver_dynamic_implicit" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_model_solver/test_model_solver_dynamic_implicit.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_model_solver
-Executing the test test_model_solver_dynamic_implicit
-Run ./test_model_solver_dynamic_implicit
- time, wext, epot, ekin, total, max_disp, min_disp
- 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 1.000000e-02, -1.000000e-02
- 1.000000e-03, 0.000000e+00, 2.463541e-02, 2.455458e-02, 4.918998e-02, 9.999143e-03, -9.997528e-03
- 2.000000e-03, 0.000000e+00, 2.465923e-02, 2.453076e-02, 4.918998e-02, 9.996985e-03, -9.987643e-03
- 3.000000e-03, 0.000000e+00, 2.468202e-02, 2.450796e-02, 4.918998e-02, 9.995896e-03, -9.992367e-03
- 4.000000e-03, 0.000000e+00, 2.470323e-02, 2.448676e-02, 4.918998e-02, 1.001196e-02, -1.001196e-02
- 5.000000e-03, 0.000000e+00, 2.472244e-02, 2.446755e-02, 4.918998e-02, 1.002165e-02, -1.002165e-02
- 6.000000e-03, 0.000000e+00, 2.473928e-02, 2.445070e-02, 4.918998e-02, 1.002143e-02, -1.002143e-02
- 7.000000e-03, 0.000000e+00, 2.475332e-02, 2.443667e-02, 4.918998e-02, 1.002450e-02, -1.001130e-02
- 8.000000e-03, 0.000000e+00, 2.476406e-02, 2.442593e-02, 4.918998e-02, 1.003228e-02, -1.001456e-02
- 9.000000e-03, 0.000000e+00, 2.477109e-02, 2.441890e-02, 4.918998e-02, 1.003704e-02, -1.003376e-02
- 1.000000e-02, 0.000000e+00, 2.477411e-02, 2.441588e-02, 4.918998e-02, 1.004302e-02, -1.004302e-02
- 1.100000e-02, 0.000000e+00, 2.477282e-02, 2.441716e-02, 4.918998e-02, 1.004236e-02, -1.004236e-02
- 1.200000e-02, 0.000000e+00, 2.476690e-02, 2.442308e-02, 4.918998e-02, 1.004789e-02, -1.003177e-02
- 1.300000e-02, 0.000000e+00, 2.475602e-02, 2.443397e-02, 4.918998e-02, 1.005379e-02, -1.003231e-02
- 1.400000e-02, 0.000000e+00, 2.473994e-02, 2.445004e-02, 4.918998e-02, 1.005707e-02, -1.005091e-02
- 1.500000e-02, 0.000000e+00, 2.471854e-02, 2.447144e-02, 4.918998e-02, 1.005956e-02, -1.005956e-02
- 1.600000e-02, 0.000000e+00, 2.469168e-02, 2.449831e-02, 4.918998e-02, 1.006363e-02, -1.005827e-02
- 1.700000e-02, 0.000000e+00, 2.465919e-02, 2.453079e-02, 4.918998e-02, 1.007036e-02, -1.004704e-02
- 1.800000e-02, 0.000000e+00, 2.462098e-02, 2.456900e-02, 4.918998e-02, 1.007511e-02, -1.004388e-02
- 1.900000e-02, 0.000000e+00, 2.457705e-02, 2.461294e-02, 4.918998e-02, 1.007770e-02, -1.006174e-02
- 2.000000e-02, 0.000000e+00, 2.452745e-02, 2.466253e-02, 4.918998e-02, 1.007882e-02, -1.006964e-02
- 2.100000e-02, 0.000000e+00, 2.447226e-02, 2.471773e-02, 4.918998e-02, 1.008327e-02, -1.006760e-02
- 2.200000e-02, 0.000000e+00, 2.441153e-02, 2.477846e-02, 4.918998e-02, 1.008864e-02, -1.005559e-02
- 2.300000e-02, 0.000000e+00, 2.434540e-02, 2.484458e-02, 4.918998e-02, 1.009204e-02, -1.004814e-02
- 2.400000e-02, 0.000000e+00, 2.427412e-02, 2.491587e-02, 4.918998e-02, 1.009362e-02, -1.006519e-02
- 2.500000e-02, 0.000000e+00, 2.419795e-02, 2.499203e-02, 4.918998e-02, 1.009653e-02, -1.007228e-02
- 2.600000e-02, 0.000000e+00, 2.411717e-02, 2.507281e-02, 4.918998e-02, 1.010222e-02, -1.006942e-02
- 2.700000e-02, 0.000000e+00, 2.403208e-02, 2.515790e-02, 4.918998e-02, 1.010652e-02, -1.005659e-02
- 2.800000e-02, 0.000000e+00, 2.394304e-02, 2.524694e-02, 4.918998e-02, 1.010899e-02, -1.004470e-02
- 2.900000e-02, 0.000000e+00, 2.385051e-02, 2.533948e-02, 4.918998e-02, 1.010992e-02, -1.006095e-02
- 3.000000e-02, 0.000000e+00, 2.375495e-02, 2.543503e-02, 4.918998e-02, 1.011087e-02, -1.006726e-02
- 3.100000e-02, 0.000000e+00, 2.365683e-02, 2.553315e-02, 4.918998e-02, 1.011540e-02, -1.006362e-02
- 3.200000e-02, 0.000000e+00, 2.355663e-02, 2.563335e-02, 4.918998e-02, 1.011840e-02, -1.005000e-02
- 3.300000e-02, 0.000000e+00, 2.345493e-02, 2.573506e-02, 4.918998e-02, 1.011970e-02, -1.003389e-02
- 3.400000e-02, 0.000000e+00, 2.335233e-02, 2.583766e-02, 4.918998e-02, 1.012040e-02, -1.004939e-02
- 3.500000e-02, 0.000000e+00, 2.324944e-02, 2.594054e-02, 4.918998e-02, 1.012478e-02, -1.005495e-02
- 3.600000e-02, 0.000000e+00, 2.314686e-02, 2.604313e-02, 4.918998e-02, 1.012824e-02, -1.005094e-02
- 3.700000e-02, 0.000000e+00, 2.304521e-02, 2.614477e-02, 4.918998e-02, 1.013016e-02, -1.003714e-02
- 3.800000e-02, 0.000000e+00, 2.294518e-02, 2.624480e-02, 4.918998e-02, 1.013053e-02, -1.001679e-02
- 3.900000e-02, 0.000000e+00, 2.284747e-02, 2.634251e-02, 4.918998e-02, 1.012994e-02, -1.003169e-02
- 4.000000e-02, 0.000000e+00, 2.275275e-02, 2.643724e-02, 4.918998e-02, 1.013171e-02, -1.003668e-02
- 4.100000e-02, 0.000000e+00, 2.266166e-02, 2.652832e-02, 4.918998e-02, 1.013394e-02, -1.003174e-02
- 4.200000e-02, 0.000000e+00, 2.257489e-02, 2.661510e-02, 4.918998e-02, 1.013462e-02, -1.001689e-02
- 4.300000e-02, 0.000000e+00, 2.249314e-02, 2.669684e-02, 4.918998e-02, 1.013395e-02, -1.001502e-02
- 4.400000e-02, 0.000000e+00, 2.241710e-02, 2.677288e-02, 4.918998e-02, 1.013605e-02, -1.002973e-02
- 4.500000e-02, 0.000000e+00, 2.234742e-02, 2.684257e-02, 4.918998e-02, 1.013837e-02, -1.003006e-02
- 4.600000e-02, 0.000000e+00, 2.228470e-02, 2.690529e-02, 4.918998e-02, 1.013946e-02, -1.001567e-02
- 4.700000e-02, 0.000000e+00, 2.222957e-02, 2.696041e-02, 4.918998e-02, 1.013907e-02, -9.993727e-03
- 4.800000e-02, 0.000000e+00, 2.218267e-02, 2.700731e-02, 4.918998e-02, 1.013753e-02, -9.970899e-03
- 4.900000e-02, 0.000000e+00, 2.214457e-02, 2.704541e-02, 4.918998e-02, 1.013616e-02, -9.985244e-03
- 5.000000e-02, 0.000000e+00, 2.211579e-02, 2.707420e-02, 4.918998e-02, 1.013734e-02, -9.989716e-03
- 5.100000e-02, 0.000000e+00, 2.209680e-02, 2.709318e-02, 4.918998e-02, 1.013722e-02, -1.047754e-02
- 5.200000e-02, 0.000000e+00, 2.208809e-02, 2.710189e-02, 4.918998e-02, 1.013572e-02, -1.110650e-02
- 5.300000e-02, 0.000000e+00, 2.209011e-02, 2.709987e-02, 4.918998e-02, 1.013505e-02, -1.173513e-02
- 5.400000e-02, 0.000000e+00, 2.210323e-02, 2.708675e-02, 4.918998e-02, 1.013603e-02, -1.236205e-02
- 5.500000e-02, 0.000000e+00, 2.212775e-02, 2.706223e-02, 4.918998e-02, 1.013613e-02, -1.298586e-02
- 5.600000e-02, 0.000000e+00, 2.216394e-02, 2.702605e-02, 4.918998e-02, 1.013490e-02, -1.360554e-02
- 5.700000e-02, 0.000000e+00, 2.221204e-02, 2.697794e-02, 4.918998e-02, 1.013243e-02, -1.422054e-02
- 5.800000e-02, 0.000000e+00, 2.227224e-02, 2.691774e-02, 4.918998e-02, 1.012925e-02, -1.483080e-02
- 5.900000e-02, 0.000000e+00, 2.234464e-02, 2.684535e-02, 4.918998e-02, 1.012832e-02, -1.543647e-02
- 6.000000e-02, 0.000000e+00, 2.242925e-02, 2.676073e-02, 4.918998e-02, 1.012731e-02, -1.603761e-02
- 6.100000e-02, 0.000000e+00, 2.252608e-02, 2.666391e-02, 4.918998e-02, 1.012500e-02, -1.663392e-02
- 6.200000e-02, 0.000000e+00, 2.263506e-02, 2.655493e-02, 4.918998e-02, 1.012178e-02, -1.722458e-02
- 6.300000e-02, 0.000000e+00, 2.275606e-02, 2.643392e-02, 4.918998e-02, 1.012138e-02, -1.780840e-02
- 6.400000e-02, 0.000000e+00, 2.288887e-02, 2.630111e-02, 4.918998e-02, 1.012043e-02, -1.838408e-02
- 6.500000e-02, 0.000000e+00, 2.303319e-02, 2.615679e-02, 4.918998e-02, 1.011837e-02, -1.895048e-02
- 6.600000e-02, 0.000000e+00, 2.318871e-02, 2.600127e-02, 4.918998e-02, 1.011509e-02, -1.950691e-02
- 6.700000e-02, 0.000000e+00, 2.335505e-02, 2.583494e-02, 4.918998e-02, 1.011090e-02, -2.005316e-02
- 6.800000e-02, 0.000000e+00, 2.353174e-02, 2.565824e-02, 4.918998e-02, 1.010757e-02, -2.058934e-02
- 6.900000e-02, 0.000000e+00, 2.371825e-02, 2.547174e-02, 4.918998e-02, 1.010570e-02, -2.111561e-02
- 7.000000e-02, 0.000000e+00, 2.391397e-02, 2.527601e-02, 4.918998e-02, 1.010268e-02, -2.163189e-02
- 7.100000e-02, 0.000000e+00, 2.411829e-02, 2.507170e-02, 4.918998e-02, 1.009853e-02, -2.213766e-02
- 7.200000e-02, 0.000000e+00, 2.433051e-02, 2.485947e-02, 4.918998e-02, 1.009554e-02, -2.263198e-02
- 7.300000e-02, 0.000000e+00, 2.454988e-02, 2.464010e-02, 4.918998e-02, 1.009360e-02, -2.311369e-02
- 7.400000e-02, 0.000000e+00, 2.477557e-02, 2.441442e-02, 4.918998e-02, 1.009083e-02, -2.358169e-02
- 7.500000e-02, 0.000000e+00, 2.500671e-02, 2.418327e-02, 4.918998e-02, 1.008692e-02, -2.403521e-02
- 7.600000e-02, 0.000000e+00, 2.524242e-02, 2.394756e-02, 4.918998e-02, 1.008201e-02, -2.447394e-02
- 7.700000e-02, 0.000000e+00, 2.548177e-02, 2.370821e-02, 4.918998e-02, 1.007672e-02, -2.489797e-02
- 7.800000e-02, 0.000000e+00, 2.572377e-02, 2.346622e-02, 4.918998e-02, 1.007410e-02, -2.530753e-02
- 7.900000e-02, 0.000000e+00, 2.596736e-02, 2.322263e-02, 4.918998e-02, 1.007055e-02, -2.570277e-02
- 8.000000e-02, 0.000000e+00, 2.621151e-02, 2.297848e-02, 4.918998e-02, 1.006591e-02, -2.608346e-02
- 8.100000e-02, 0.000000e+00, 2.645516e-02, 2.273483e-02, 4.918998e-02, 1.006055e-02, -2.644898e-02
- 8.200000e-02, 0.000000e+00, 2.669722e-02, 2.249277e-02, 4.918998e-02, 1.005778e-02, -2.679840e-02
- 8.300000e-02, 0.000000e+00, 2.693655e-02, 2.225343e-02, 4.918998e-02, 1.005447e-02, -2.713073e-02
- 8.400000e-02, 0.000000e+00, 2.717203e-02, 2.201796e-02, 4.918998e-02, 1.005019e-02, -2.744520e-02
- 8.500000e-02, 0.000000e+00, 2.740252e-02, 2.178746e-02, 4.918998e-02, 1.004490e-02, -2.774146e-02
- 8.600000e-02, 0.000000e+00, 2.762693e-02, 2.156306e-02, 4.918998e-02, 1.003894e-02, -2.801957e-02
- 8.700000e-02, 0.000000e+00, 2.784410e-02, 2.134588e-02, 4.918998e-02, 1.003504e-02, -2.827985e-02
- 8.800000e-02, 0.000000e+00, 2.805292e-02, 2.113706e-02, 4.918998e-02, 1.003121e-02, -2.852264e-02
- 8.900000e-02, 0.000000e+00, 2.825227e-02, 2.093772e-02, 4.918998e-02, 1.002639e-02, -2.874802e-02
- 9.000000e-02, 0.000000e+00, 2.844108e-02, 2.074891e-02, 4.918998e-02, 1.002067e-02, -2.895570e-02
- 9.100000e-02, 0.000000e+00, 2.861831e-02, 2.057168e-02, 4.918998e-02, 1.001579e-02, -2.914504e-02
- 9.200000e-02, 0.000000e+00, 2.878293e-02, 2.040705e-02, 4.918998e-02, 1.001219e-02, -2.931523e-02
- 9.300000e-02, 0.000000e+00, 2.893393e-02, 2.025605e-02, 4.918998e-02, 1.000784e-02, -2.946560e-02
- 9.400000e-02, 0.000000e+00, 2.907038e-02, 2.011961e-02, 4.918998e-02, 1.000254e-02, -2.959577e-02
- 9.500000e-02, 0.000000e+00, 2.919138e-02, 1.999860e-02, 4.918998e-02, 9.998658e-03, -2.970580e-02
- 9.600000e-02, 0.000000e+00, 2.929611e-02, 1.989388e-02, 4.918998e-02, 1.001243e-02, -2.979609e-02
- 9.700000e-02, 0.000000e+00, 2.938375e-02, 1.980624e-02, 4.918998e-02, 1.004316e-02, -2.986714e-02
- 9.800000e-02, 0.000000e+00, 2.945357e-02, 1.973642e-02, 4.918998e-02, 1.007269e-02, -2.991931e-02
- 9.900000e-02, 0.000000e+00, 2.950491e-02, 1.968508e-02, 4.918998e-02, 1.008646e-02, -2.995267e-02
- 1.000000e-01, 0.000000e+00, 2.953720e-02, 1.965278e-02, 4.918998e-02, 1.008319e-02, -2.996688e-02
- 1.010000e-01, 0.000000e+00, 2.954993e-02, 1.964006e-02, 4.918998e-02, 1.006204e-02, -2.996139e-02
- 1.020000e-01, 0.000000e+00, 2.954263e-02, 1.964735e-02, 4.918998e-02, 1.002266e-02, -2.993565e-02
- 1.030000e-01, 0.000000e+00, 2.951494e-02, 1.967504e-02, 4.918998e-02, 1.000190e-02, -2.988934e-02
- 1.040000e-01, 0.000000e+00, 2.946660e-02, 1.972339e-02, 4.918998e-02, 1.001330e-02, -2.982252e-02
- 1.050000e-01, 0.000000e+00, 2.939743e-02, 1.979256e-02, 4.918998e-02, 1.002205e-02, -2.973562e-02
- 1.060000e-01, 0.000000e+00, 2.930733e-02, 1.988265e-02, 4.918998e-02, 1.002090e-02, -2.962929e-02
- 1.070000e-01, 0.000000e+00, 2.919627e-02, 1.999371e-02, 4.918998e-02, 1.002152e-02, -2.950414e-02
- 1.080000e-01, 0.000000e+00, 2.906433e-02, 2.012566e-02, 4.918998e-02, 1.002550e-02, -2.936055e-02
- 1.090000e-01, 0.000000e+00, 2.891170e-02, 2.027828e-02, 4.918998e-02, 1.003506e-02, -2.919853e-02
- 1.100000e-01, 0.000000e+00, 2.873867e-02, 2.045131e-02, 4.918998e-02, 1.004339e-02, -2.901780e-02
- 1.110000e-01, 0.000000e+00, 2.854558e-02, 2.064440e-02, 4.918998e-02, 1.004179e-02, -2.881799e-02
- 1.120000e-01, 0.000000e+00, 2.833288e-02, 2.085711e-02, 4.918998e-02, 1.004548e-02, -2.859884e-02
- 1.130000e-01, 0.000000e+00, 2.810111e-02, 2.108887e-02, 4.918998e-02, 1.004888e-02, -2.836045e-02
- 1.140000e-01, 0.000000e+00, 2.785095e-02, 2.133903e-02, 4.918998e-02, 1.005312e-02, -2.810326e-02
- 1.150000e-01, 0.000000e+00, 2.758313e-02, 2.160685e-02, 4.918998e-02, 1.005987e-02, -2.782801e-02
- 1.160000e-01, 0.000000e+00, 2.729845e-02, 2.189153e-02, 4.918998e-02, 1.006350e-02, -2.753553e-02
- 1.170000e-01, 0.000000e+00, 2.699782e-02, 2.219216e-02, 4.918998e-02, 1.006700e-02, -2.722645e-02
- 1.180000e-01, 0.000000e+00, 2.668223e-02, 2.250775e-02, 4.918998e-02, 1.006980e-02, -2.690111e-02
- 1.190000e-01, 0.000000e+00, 2.635278e-02, 2.283721e-02, 4.918998e-02, 1.007407e-02, -2.655953e-02
- 1.200000e-01, 0.000000e+00, 2.601061e-02, 2.317937e-02, 4.918998e-02, 1.007918e-02, -2.620153e-02
- 1.210000e-01, 0.000000e+00, 2.565693e-02, 2.353305e-02, 4.918998e-02, 1.008343e-02, -2.582696e-02
- 1.220000e-01, 0.000000e+00, 2.529303e-02, 2.389696e-02, 4.918998e-02, 1.008663e-02, -2.543593e-02
- 1.230000e-01, 0.000000e+00, 2.492027e-02, 2.426971e-02, 4.918998e-02, 1.008961e-02, -2.502889e-02
- 1.240000e-01, 0.000000e+00, 2.454009e-02, 2.464989e-02, 4.918998e-02, 1.009453e-02, -2.460663e-02
- 1.250000e-01, 0.000000e+00, 2.415395e-02, 2.503604e-02, 4.918998e-02, 1.009870e-02, -2.417009e-02
- 1.260000e-01, 0.000000e+00, 2.376334e-02, 2.542664e-02, 4.918998e-02, 1.010184e-02, -2.372013e-02
- 1.270000e-01, 0.000000e+00, 2.336983e-02, 2.582015e-02, 4.918998e-02, 1.010401e-02, -2.325739e-02
- 1.280000e-01, 0.000000e+00, 2.297504e-02, 2.621495e-02, 4.918998e-02, 1.010561e-02, -2.278215e-02
- 1.290000e-01, 0.000000e+00, 2.258058e-02, 2.660940e-02, 4.918998e-02, 1.010914e-02, -2.229444e-02
- 1.300000e-01, 0.000000e+00, 2.218810e-02, 2.700188e-02, 4.918998e-02, 1.011209e-02, -2.179424e-02
- 1.310000e-01, 0.000000e+00, 2.179925e-02, 2.739073e-02, 4.918998e-02, 1.011469e-02, -2.128166e-02
- 1.320000e-01, 0.000000e+00, 2.141571e-02, 2.777428e-02, 4.918998e-02, 1.011657e-02, -2.075713e-02
- 1.330000e-01, 0.000000e+00, 2.103916e-02, 2.815083e-02, 4.918998e-02, 1.011933e-02, -2.022144e-02
- 1.340000e-01, 0.000000e+00, 2.067127e-02, 2.851871e-02, 4.918998e-02, 1.012279e-02, -1.967558e-02
- 1.350000e-01, 0.000000e+00, 2.031370e-02, 2.887629e-02, 4.918998e-02, 1.012547e-02, -1.912057e-02
- 1.360000e-01, 0.000000e+00, 1.996805e-02, 2.922193e-02, 4.918998e-02, 1.012714e-02, -1.855727e-02
- 1.370000e-01, 0.000000e+00, 1.963596e-02, 2.955403e-02, 4.918998e-02, 1.012792e-02, -1.798619e-02
- 1.380000e-01, 0.000000e+00, 1.931900e-02, 2.987098e-02, 4.918998e-02, 1.012821e-02, -1.740759e-02
- 1.390000e-01, 0.000000e+00, 1.901871e-02, 3.017127e-02, 4.918998e-02, 1.013035e-02, -1.682153e-02
- 1.400000e-01, 0.000000e+00, 1.873656e-02, 3.045343e-02, 4.918998e-02, 1.013173e-02, -1.622816e-02
- 1.410000e-01, 0.000000e+00, 1.847395e-02, 3.071603e-02, 4.918998e-02, 1.013283e-02, -1.562786e-02
- 1.420000e-01, 0.000000e+00, 1.823228e-02, 3.095771e-02, 4.918998e-02, 1.013314e-02, -1.502134e-02
- 1.430000e-01, 0.000000e+00, 1.801283e-02, 3.117715e-02, 4.918998e-02, 1.013526e-02, -1.440959e-02
- 1.440000e-01, 0.000000e+00, 1.781683e-02, 3.137315e-02, 4.918998e-02, 1.013707e-02, -1.379371e-02
- 1.450000e-01, 0.000000e+00, 1.764538e-02, 3.154460e-02, 4.918998e-02, 1.013805e-02, -1.317468e-02
- 1.460000e-01, 0.000000e+00, 1.749954e-02, 3.169044e-02, 4.918998e-02, 1.013805e-02, -1.255323e-02
- 1.470000e-01, 0.000000e+00, 1.738028e-02, 3.180970e-02, 4.918998e-02, 1.013725e-02, -1.192976e-02
- 1.480000e-01, 0.000000e+00, 1.728845e-02, 3.190153e-02, 4.918998e-02, 1.013619e-02, -1.130448e-02
- 1.490000e-01, 0.000000e+00, 1.722478e-02, 3.196520e-02, 4.918998e-02, 1.013684e-02, -1.067751e-02
- 1.500000e-01, 0.000000e+00, 1.718991e-02, 3.200007e-02, 4.918998e-02, 1.013658e-02, -1.004918e-02
- 1.510000e-01, 0.000000e+00, 1.718437e-02, 3.200561e-02, 4.918998e-02, 1.013608e-02, -1.053831e-02
- 1.520000e-01, 0.000000e+00, 1.720859e-02, 3.198140e-02, 4.918998e-02, 1.013539e-02, -1.116732e-02
- 1.530000e-01, 0.000000e+00, 1.726285e-02, 3.192713e-02, 4.918998e-02, 1.013597e-02, -1.179529e-02
- 1.540000e-01, 0.000000e+00, 1.734731e-02, 3.184267e-02, 4.918998e-02, 1.013604e-02, -1.242110e-02
- 1.550000e-01, 0.000000e+00, 1.746202e-02, 3.172797e-02, 4.918998e-02, 1.013524e-02, -1.304378e-02
- 1.560000e-01, 0.000000e+00, 1.760690e-02, 3.158309e-02, 4.918998e-02, 1.013351e-02, -1.366266e-02
- 1.570000e-01, 0.000000e+00, 1.778175e-02, 3.140823e-02, 4.918998e-02, 1.013112e-02, -1.427739e-02
- 1.580000e-01, 0.000000e+00, 1.798624e-02, 3.120374e-02, 4.918998e-02, 1.012915e-02, -1.488781e-02
- 1.590000e-01, 0.000000e+00, 1.821989e-02, 3.097010e-02, 4.918998e-02, 1.012807e-02, -1.549379e-02
- 1.600000e-01, 0.000000e+00, 1.848210e-02, 3.070788e-02, 4.918998e-02, 1.012632e-02, -1.609505e-02
- 1.610000e-01, 0.000000e+00, 1.877218e-02, 3.041781e-02, 4.918998e-02, 1.012409e-02, -1.669100e-02
- 1.620000e-01, 0.000000e+00, 1.908929e-02, 3.010070e-02, 4.918998e-02, 1.012243e-02, -1.728075e-02
- 1.630000e-01, 0.000000e+00, 1.943245e-02, 2.975754e-02, 4.918998e-02, 1.012141e-02, -1.786326e-02
- 1.640000e-01, 0.000000e+00, 1.980057e-02, 2.938942e-02, 4.918998e-02, 1.011978e-02, -1.843751e-02
- 1.650000e-01, 0.000000e+00, 2.019245e-02, 2.899754e-02, 4.918998e-02, 1.011728e-02, -1.900266e-02
- 1.660000e-01, 0.000000e+00, 2.060680e-02, 2.858319e-02, 4.918998e-02, 1.011395e-02, -1.955819e-02
- 1.670000e-01, 0.000000e+00, 2.104219e-02, 2.814780e-02, 4.918998e-02, 1.011011e-02, -2.010389e-02
- 1.680000e-01, 0.000000e+00, 2.149708e-02, 2.769291e-02, 4.918998e-02, 1.010755e-02, -2.063967e-02
- 1.690000e-01, 0.000000e+00, 2.196983e-02, 2.722015e-02, 4.918998e-02, 1.010487e-02, -2.116544e-02
- 1.700000e-01, 0.000000e+00, 2.245875e-02, 2.673123e-02, 4.918998e-02, 1.010175e-02, -2.168089e-02
- 1.710000e-01, 0.000000e+00, 2.296205e-02, 2.622794e-02, 4.918998e-02, 1.009798e-02, -2.218540e-02
- 1.720000e-01, 0.000000e+00, 2.347781e-02, 2.571217e-02, 4.918998e-02, 1.009546e-02, -2.267814e-02
- 1.730000e-01, 0.000000e+00, 2.400409e-02, 2.518590e-02, 4.918998e-02, 1.009300e-02, -2.315814e-02
- 1.740000e-01, 0.000000e+00, 2.453884e-02, 2.465114e-02, 4.918998e-02, 1.008987e-02, -2.362454e-02
- 1.750000e-01, 0.000000e+00, 2.508001e-02, 2.410997e-02, 4.918998e-02, 1.008590e-02, -2.407672e-02
- 1.760000e-01, 0.000000e+00, 2.562547e-02, 2.356452e-02, 4.918998e-02, 1.008124e-02, -2.451438e-02
- 1.770000e-01, 0.000000e+00, 2.617303e-02, 2.301696e-02, 4.918998e-02, 1.007671e-02, -2.493746e-02
- 1.780000e-01, 0.000000e+00, 2.672048e-02, 2.246951e-02, 4.918998e-02, 1.007349e-02, -2.534601e-02
- 1.790000e-01, 0.000000e+00, 2.726559e-02, 2.192440e-02, 4.918998e-02, 1.006952e-02, -2.573998e-02
- 1.800000e-01, 0.000000e+00, 2.780613e-02, 2.138385e-02, 4.918998e-02, 1.006527e-02, -2.611907e-02
- 1.810000e-01, 0.000000e+00, 2.833986e-02, 2.085013e-02, 4.918998e-02, 1.006031e-02, -2.648272e-02
- 1.820000e-01, 0.000000e+00, 2.886451e-02, 2.032547e-02, 4.918998e-02, 1.005712e-02, -2.683018e-02
- 1.830000e-01, 0.000000e+00, 2.937784e-02, 1.981214e-02, 4.918998e-02, 1.005352e-02, -2.716064e-02
- 1.840000e-01, 0.000000e+00, 2.987766e-02, 1.931232e-02, 4.918998e-02, 1.004922e-02, -2.747347e-02
- 1.850000e-01, 0.000000e+00, 3.036180e-02, 1.882819e-02, 4.918998e-02, 1.004416e-02, -2.776832e-02
- 1.860000e-01, 0.000000e+00, 3.082811e-02, 1.836188e-02, 4.918998e-02, 1.003859e-02, -2.804514e-02
- 1.870000e-01, 0.000000e+00, 3.127450e-02, 1.791549e-02, 4.918998e-02, 1.003449e-02, -2.830407e-02
- 1.880000e-01, 0.000000e+00, 3.169893e-02, 1.749105e-02, 4.918998e-02, 1.003029e-02, -2.854528e-02
- 1.890000e-01, 0.000000e+00, 3.209947e-02, 1.709051e-02, 4.918998e-02, 1.002558e-02, -2.876879e-02
- 1.900000e-01, 0.000000e+00, 3.247424e-02, 1.671574e-02, 4.918998e-02, 1.002042e-02, -2.897437e-02
- 1.910000e-01, 0.000000e+00, 3.282145e-02, 1.636854e-02, 4.918998e-02, 1.001506e-02, -2.916153e-02
- 1.920000e-01, 0.000000e+00, 3.313937e-02, 1.605061e-02, 4.918998e-02, 1.001119e-02, -2.932967e-02
- 1.930000e-01, 0.000000e+00, 3.342643e-02, 1.576355e-02, 4.918998e-02, 1.000684e-02, -2.947822e-02
- 1.940000e-01, 0.000000e+00, 3.368115e-02, 1.550883e-02, 4.918998e-02, 1.003367e-02, -2.960682e-02
- 1.950000e-01, 0.000000e+00, 3.390217e-02, 1.528782e-02, 4.918998e-02, 1.006048e-02, -2.971541e-02
- 1.960000e-01, 0.000000e+00, 3.408823e-02, 1.510176e-02, 4.918998e-02, 1.007733e-02, -2.980420e-02
- 1.970000e-01, 0.000000e+00, 3.423821e-02, 1.495178e-02, 4.918998e-02, 1.010808e-02, -2.987354e-02
- 1.980000e-01, 0.000000e+00, 3.435115e-02, 1.483884e-02, 4.918998e-02, 1.012904e-02, -2.992372e-02
- 1.990000e-01, 0.000000e+00, 3.442622e-02, 1.476376e-02, 4.918998e-02, 1.013369e-02, -2.995485e-02
- 2.000000e-01, 0.000000e+00, 3.446275e-02, 1.472723e-02, 4.918998e-02, 1.012203e-02, -2.996678e-02
- 2.010000e-01, 0.000000e+00, 3.446018e-02, 1.472980e-02, 4.918998e-02, 1.009410e-02, -2.995914e-02
- 2.020000e-01, 0.000000e+00, 3.441813e-02, 1.477185e-02, 4.918998e-02, 1.004987e-02, -2.993151e-02
- 2.030000e-01, 0.000000e+00, 3.433639e-02, 1.485359e-02, 4.918998e-02, 1.000333e-02, -2.988359e-02
- 2.040000e-01, 0.000000e+00, 3.421491e-02, 1.497507e-02, 4.918998e-02, 1.001455e-02, -2.981534e-02
- 2.050000e-01, 0.000000e+00, 3.405379e-02, 1.513620e-02, 4.918998e-02, 1.002237e-02, -2.972700e-02
- 2.060000e-01, 0.000000e+00, 3.385326e-02, 1.533672e-02, 4.918998e-02, 1.002028e-02, -2.961903e-02
- 2.070000e-01, 0.000000e+00, 3.361378e-02, 1.557621e-02, 4.918998e-02, 1.002347e-02, -2.949194e-02
- 2.080000e-01, 0.000000e+00, 3.333592e-02, 1.585406e-02, 4.918998e-02, 1.002744e-02, -2.934617e-02
- 2.090000e-01, 0.000000e+00, 3.302047e-02, 1.616951e-02, 4.918998e-02, 1.003627e-02, -2.918187e-02
- 2.100000e-01, 0.000000e+00, 3.266832e-02, 1.652166e-02, 4.918998e-02, 1.004366e-02, -2.899899e-02
- 2.110000e-01, 0.000000e+00, 3.228053e-02, 1.690945e-02, 4.918998e-02, 1.004160e-02, -2.879732e-02
- 2.120000e-01, 0.000000e+00, 3.185834e-02, 1.733164e-02, 4.918998e-02, 1.004564e-02, -2.857666e-02
- 2.130000e-01, 0.000000e+00, 3.140314e-02, 1.778684e-02, 4.918998e-02, 1.004976e-02, -2.833699e-02
- 2.140000e-01, 0.000000e+00, 3.091647e-02, 1.827352e-02, 4.918998e-02, 1.005506e-02, -2.807858e-02
- 2.150000e-01, 0.000000e+00, 3.039996e-02, 1.879002e-02, 4.918998e-02, 1.006008e-02, -2.780195e-02
- 2.160000e-01, 0.000000e+00, 2.985544e-02, 1.933454e-02, 4.918998e-02, 1.006421e-02, -2.750778e-02
- 2.170000e-01, 0.000000e+00, 2.928485e-02, 1.990514e-02, 4.918998e-02, 1.006779e-02, -2.719672e-02
- 2.180000e-01, 0.000000e+00, 2.869025e-02, 2.049974e-02, 4.918998e-02, 1.007096e-02, -2.686926e-02
- 2.190000e-01, 0.000000e+00, 2.807383e-02, 2.111616e-02, 4.918998e-02, 1.007485e-02, -2.652566e-02
- 2.200000e-01, 0.000000e+00, 2.743785e-02, 2.175213e-02, 4.918998e-02, 1.007911e-02, -2.616593e-02
- 2.210000e-01, 0.000000e+00, 2.678471e-02, 2.240527e-02, 4.918998e-02, 1.008268e-02, -2.579003e-02
- 2.220000e-01, 0.000000e+00, 2.611689e-02, 2.307309e-02, 4.918998e-02, 1.008702e-02, -2.539799e-02
- 2.230000e-01, 0.000000e+00, 2.543697e-02, 2.375301e-02, 4.918998e-02, 1.009049e-02, -2.499009e-02
- 2.240000e-01, 0.000000e+00, 2.474756e-02, 2.444242e-02, 4.918998e-02, 1.009459e-02, -2.456685e-02
- 2.250000e-01, 0.000000e+00, 2.405136e-02, 2.513863e-02, 4.918998e-02, 1.009820e-02, -2.412905e-02
- 2.260000e-01, 0.000000e+00, 2.335110e-02, 2.583889e-02, 4.918998e-02, 1.010110e-02, -2.367750e-02
- 2.270000e-01, 0.000000e+00, 2.264958e-02, 2.654040e-02, 4.918998e-02, 1.010344e-02, -2.321296e-02
- 2.280000e-01, 0.000000e+00, 2.194964e-02, 2.724034e-02, 4.918998e-02, 1.010633e-02, -2.273594e-02
- 2.290000e-01, 0.000000e+00, 2.125408e-02, 2.793590e-02, 4.918998e-02, 1.010870e-02, -2.224672e-02
- 2.300000e-01, 0.000000e+00, 2.056575e-02, 2.862423e-02, 4.918998e-02, 1.011213e-02, -2.174544e-02
- 2.310000e-01, 0.000000e+00, 1.988748e-02, 2.930251e-02, 4.918998e-02, 1.011572e-02, -2.123219e-02
- 2.320000e-01, 0.000000e+00, 1.922210e-02, 2.996788e-02, 4.918998e-02, 1.011859e-02, -2.070724e-02
- 2.330000e-01, 0.000000e+00, 1.857241e-02, 3.061758e-02, 4.918998e-02, 1.012061e-02, -2.017110e-02
- 2.340000e-01, 0.000000e+00, 1.794113e-02, 3.124885e-02, 4.918998e-02, 1.012275e-02, -1.962454e-02
- 2.350000e-01, 0.000000e+00, 1.733097e-02, 3.185901e-02, 4.918998e-02, 1.012473e-02, -1.906849e-02
- 2.360000e-01, 0.000000e+00, 1.674458e-02, 3.244541e-02, 4.918998e-02, 1.012603e-02, -1.850384e-02
- 2.370000e-01, 0.000000e+00, 1.618452e-02, 3.300547e-02, 4.918998e-02, 1.012698e-02, -1.793136e-02
- 2.380000e-01, 0.000000e+00, 1.565326e-02, 3.353673e-02, 4.918998e-02, 1.012868e-02, -1.735155e-02
- 2.390000e-01, 0.000000e+00, 1.515317e-02, 3.403682e-02, 4.918998e-02, 1.012980e-02, -1.676471e-02
- 2.400000e-01, 0.000000e+00, 1.468652e-02, 3.450346e-02, 4.918998e-02, 1.013218e-02, -1.617104e-02
- 2.410000e-01, 0.000000e+00, 1.425549e-02, 3.493449e-02, 4.918998e-02, 1.013424e-02, -1.557079e-02
- 2.420000e-01, 0.000000e+00, 1.386211e-02, 3.532787e-02, 4.918998e-02, 1.013560e-02, -1.496441e-02
- 2.430000e-01, 0.000000e+00, 1.350826e-02, 3.568172e-02, 4.918998e-02, 1.013612e-02, -1.435262e-02
- 2.440000e-01, 0.000000e+00, 1.319568e-02, 3.599430e-02, 4.918998e-02, 1.013679e-02, -1.373634e-02
- 2.450000e-01, 0.000000e+00, 1.292597e-02, 3.626401e-02, 4.918998e-02, 1.013695e-02, -1.311656e-02
- 2.460000e-01, 0.000000e+00, 1.270058e-02, 3.648940e-02, 4.918998e-02, 1.013657e-02, -1.249418e-02
- 2.470000e-01, 0.000000e+00, 1.252078e-02, 3.666920e-02, 4.918998e-02, 1.013637e-02, -1.186989e-02
- 2.480000e-01, 0.000000e+00, 1.238764e-02, 3.680234e-02, 4.918998e-02, 1.013649e-02, -1.124416e-02
- 2.490000e-01, 0.000000e+00, 1.230208e-02, 3.688791e-02, 4.918998e-02, 1.013633e-02, -1.061726e-02
- 2.500000e-01, 0.000000e+00, 1.226482e-02, 3.692516e-02, 4.918998e-02, 1.013718e-02, -9.989451e-03
- 2.510000e-01, 0.000000e+00, 1.227642e-02, 3.691356e-02, 4.918998e-02, 1.013763e-02, -1.060057e-02
- 2.520000e-01, 0.000000e+00, 1.233721e-02, 3.685277e-02, 4.918998e-02, 1.013736e-02, -1.122864e-02
- 2.530000e-01, 0.000000e+00, 1.244733e-02, 3.674265e-02, 4.918998e-02, 1.013633e-02, -1.185486e-02
- 2.540000e-01, 0.000000e+00, 1.260673e-02, 3.658325e-02, 4.918998e-02, 1.013533e-02, -1.247942e-02
- 2.550000e-01, 0.000000e+00, 1.281516e-02, 3.637482e-02, 4.918998e-02, 1.013370e-02, -1.310102e-02
- 2.560000e-01, 0.000000e+00, 1.307219e-02, 3.611780e-02, 4.918998e-02, 1.013187e-02, -1.371935e-02
- 2.570000e-01, 0.000000e+00, 1.337714e-02, 3.581284e-02, 4.918998e-02, 1.013052e-02, -1.433413e-02
- 2.580000e-01, 0.000000e+00, 1.372916e-02, 3.546082e-02, 4.918998e-02, 1.012903e-02, -1.494518e-02
- 2.590000e-01, 0.000000e+00, 1.412721e-02, 3.506277e-02, 4.918998e-02, 1.012752e-02, -1.555234e-02
- 2.600000e-01, 0.000000e+00, 1.457006e-02, 3.461993e-02, 4.918998e-02, 1.012680e-02, -1.615410e-02
- 2.610000e-01, 0.000000e+00, 1.505627e-02, 3.413372e-02, 4.918998e-02, 1.012565e-02, -1.674946e-02
- 2.620000e-01, 0.000000e+00, 1.558422e-02, 3.360577e-02, 4.918998e-02, 1.012379e-02, -1.733757e-02
- 2.630000e-01, 0.000000e+00, 1.615209e-02, 3.303789e-02, 4.918998e-02, 1.012130e-02, -1.791791e-02
- 2.640000e-01, 0.000000e+00, 1.675793e-02, 3.243205e-02, 4.918998e-02, 1.011854e-02, -1.849027e-02
- 2.650000e-01, 0.000000e+00, 1.739960e-02, 3.179038e-02, 4.918998e-02, 1.011531e-02, -1.905389e-02
- 2.660000e-01, 0.000000e+00, 1.807480e-02, 3.111519e-02, 4.918998e-02, 1.011273e-02, -1.960855e-02
- 2.670000e-01, 0.000000e+00, 1.878105e-02, 3.040893e-02, 4.918998e-02, 1.011001e-02, -2.015403e-02
- 2.680000e-01, 0.000000e+00, 1.951576e-02, 2.967422e-02, 4.918998e-02, 1.010703e-02, -2.069011e-02
- 2.690000e-01, 0.000000e+00, 2.027620e-02, 2.891378e-02, 4.918998e-02, 1.010418e-02, -2.121629e-02
- 2.700000e-01, 0.000000e+00, 2.105952e-02, 2.813046e-02, 4.918998e-02, 1.010206e-02, -2.173140e-02
- 2.710000e-01, 0.000000e+00, 2.186275e-02, 2.732723e-02, 4.918998e-02, 1.009948e-02, -2.223456e-02
- 2.720000e-01, 0.000000e+00, 2.268280e-02, 2.650719e-02, 4.918998e-02, 1.009621e-02, -2.272502e-02
- 2.730000e-01, 0.000000e+00, 2.351650e-02, 2.567348e-02, 4.918998e-02, 1.009231e-02, -2.320237e-02
- 2.740000e-01, 0.000000e+00, 2.436063e-02, 2.482935e-02, 4.918998e-02, 1.008809e-02, -2.366644e-02
- 2.750000e-01, 0.000000e+00, 2.521189e-02, 2.397810e-02, 4.918998e-02, 1.008410e-02, -2.411684e-02
- 2.760000e-01, 0.000000e+00, 2.606690e-02, 2.312309e-02, 4.918998e-02, 1.008067e-02, -2.455347e-02
- 2.770000e-01, 0.000000e+00, 2.692225e-02, 2.226773e-02, 4.918998e-02, 1.007683e-02, -2.497616e-02
- 2.780000e-01, 0.000000e+00, 2.777454e-02, 2.141545e-02, 4.918998e-02, 1.007262e-02, -2.538456e-02
- 2.790000e-01, 0.000000e+00, 2.862032e-02, 2.056966e-02, 4.918998e-02, 1.006862e-02, -2.577824e-02
- 2.800000e-01, 0.000000e+00, 2.945617e-02, 1.973382e-02, 4.918998e-02, 1.006538e-02, -2.615627e-02
- 2.810000e-01, 0.000000e+00, 3.027865e-02, 1.891133e-02, 4.918998e-02, 1.006167e-02, -2.651792e-02
- 2.820000e-01, 0.000000e+00, 3.108437e-02, 1.810561e-02, 4.918998e-02, 1.005730e-02, -2.686263e-02
- 2.830000e-01, 0.000000e+00, 3.187000e-02, 1.731999e-02, 4.918998e-02, 1.005230e-02, -2.719011e-02
- 2.840000e-01, 0.000000e+00, 3.263224e-02, 1.655774e-02, 4.918998e-02, 1.004698e-02, -2.750031e-02
- 2.850000e-01, 0.000000e+00, 3.336788e-02, 1.582210e-02, 4.918998e-02, 1.004318e-02, -2.779336e-02
- 2.860000e-01, 0.000000e+00, 3.407378e-02, 1.511620e-02, 4.918998e-02, 1.003881e-02, -2.806916e-02
- 2.870000e-01, 0.000000e+00, 3.474690e-02, 1.444308e-02, 4.918998e-02, 1.003421e-02, -2.832761e-02
- 2.880000e-01, 0.000000e+00, 3.538432e-02, 1.380566e-02, 4.918998e-02, 1.002916e-02, -2.856836e-02
- 2.890000e-01, 0.000000e+00, 3.598325e-02, 1.320673e-02, 4.918998e-02, 1.002443e-02, -2.879091e-02
- 2.900000e-01, 0.000000e+00, 3.654103e-02, 1.264896e-02, 4.918998e-02, 1.002037e-02, -2.899476e-02
- 2.910000e-01, 0.000000e+00, 3.705511e-02, 1.213488e-02, 4.918998e-02, 1.001592e-02, -2.917946e-02
- 2.920000e-01, 0.000000e+00, 3.752315e-02, 1.166684e-02, 4.918998e-02, 1.001085e-02, -2.934460e-02
- 2.930000e-01, 0.000000e+00, 3.794296e-02, 1.124702e-02, 4.918998e-02, 1.005402e-02, -2.949011e-02
- 2.940000e-01, 0.000000e+00, 3.831255e-02, 1.087744e-02, 4.918998e-02, 1.009386e-02, -2.961612e-02
- 2.950000e-01, 0.000000e+00, 3.863007e-02, 1.055991e-02, 4.918998e-02, 1.012284e-02, -2.972291e-02
- 2.960000e-01, 0.000000e+00, 3.889390e-02, 1.029608e-02, 4.918998e-02, 1.013993e-02, -2.981085e-02
- 2.970000e-01, 0.000000e+00, 3.910263e-02, 1.008736e-02, 4.918998e-02, 1.015363e-02, -2.987968e-02
- 2.980000e-01, 0.000000e+00, 3.925505e-02, 9.934932e-03, 4.918998e-02, 1.017050e-02, -2.992914e-02
- 2.990000e-01, 0.000000e+00, 3.935018e-02, 9.839800e-03, 4.918998e-02, 1.017214e-02, -2.995885e-02
- 3.000000e-01, 0.000000e+00, 3.938725e-02, 9.802738e-03, 4.918998e-02, 1.015800e-02, -2.996849e-02
- 3.010000e-01, 0.000000e+00, 3.936570e-02, 9.824283e-03, 4.918998e-02, 1.012737e-02, -2.995815e-02
- 3.020000e-01, 0.000000e+00, 3.928525e-02, 9.904730e-03, 4.918998e-02, 1.007954e-02, -2.992750e-02
- 3.030000e-01, 0.000000e+00, 3.914584e-02, 1.004414e-02, 4.918998e-02, 1.001388e-02, -2.987670e-02
- 3.040000e-01, 0.000000e+00, 3.894763e-02, 1.024235e-02, 4.918998e-02, 1.001571e-02, -2.980613e-02
- 3.050000e-01, 0.000000e+00, 3.869101e-02, 1.049897e-02, 4.918998e-02, 1.002259e-02, -2.971626e-02
- 3.060000e-01, 0.000000e+00, 3.837663e-02, 1.081335e-02, 4.918998e-02, 1.001957e-02, -2.960770e-02
- 3.070000e-01, 0.000000e+00, 3.800538e-02, 1.118461e-02, 4.918998e-02, 1.002385e-02, -2.948014e-02
- 3.080000e-01, 0.000000e+00, 3.757837e-02, 1.161162e-02, 4.918998e-02, 1.002865e-02, -2.933342e-02
- 3.090000e-01, 0.000000e+00, 3.709694e-02, 1.209305e-02, 4.918998e-02, 1.003739e-02, -2.916735e-02
- 3.100000e-01, 0.000000e+00, 3.656265e-02, 1.262733e-02, 4.918998e-02, 1.004385e-02, -2.898197e-02
- 3.110000e-01, 0.000000e+00, 3.597731e-02, 1.321268e-02, 4.918998e-02, 1.004150e-02, -2.877762e-02
- 3.120000e-01, 0.000000e+00, 3.534293e-02, 1.384706e-02, 4.918998e-02, 1.004628e-02, -2.855414e-02
- 3.130000e-01, 0.000000e+00, 3.466173e-02, 1.452825e-02, 4.918998e-02, 1.005062e-02, -2.831197e-02
- 3.140000e-01, 0.000000e+00, 3.393614e-02, 1.525385e-02, 4.918998e-02, 1.005449e-02, -2.805168e-02
- 3.150000e-01, 0.000000e+00, 3.316875e-02, 1.602123e-02, 4.918998e-02, 1.006019e-02, -2.777407e-02
- 3.160000e-01, 0.000000e+00, 3.236238e-02, 1.682760e-02, 4.918998e-02, 1.006416e-02, -2.747964e-02
- 3.170000e-01, 0.000000e+00, 3.152002e-02, 1.766996e-02, 4.918998e-02, 1.006861e-02, -2.716815e-02
- 3.180000e-01, 0.000000e+00, 3.064480e-02, 1.854518e-02, 4.918998e-02, 1.007246e-02, -2.683960e-02
- 3.190000e-01, 0.000000e+00, 2.973999e-02, 1.944999e-02, 4.918998e-02, 1.007579e-02, -2.649401e-02
- 3.200000e-01, 0.000000e+00, 2.880904e-02, 2.038095e-02, 4.918998e-02, 1.007888e-02, -2.613194e-02
- 3.210000e-01, 0.000000e+00, 2.785549e-02, 2.133449e-02, 4.918998e-02, 1.008291e-02, -2.575361e-02
- 3.220000e-01, 0.000000e+00, 2.688303e-02, 2.230695e-02, 4.918998e-02, 1.008663e-02, -2.535920e-02
- 3.230000e-01, 0.000000e+00, 2.589543e-02, 2.329456e-02, 4.918998e-02, 1.008991e-02, -2.494935e-02
- 3.240000e-01, 0.000000e+00, 2.489651e-02, 2.429348e-02, 4.918998e-02, 1.009362e-02, -2.452482e-02
- 3.250000e-01, 0.000000e+00, 2.389020e-02, 2.529978e-02, 4.918998e-02, 1.009772e-02, -2.408679e-02
- 3.260000e-01, 0.000000e+00, 2.288049e-02, 2.630949e-02, 4.918998e-02, 1.010146e-02, -2.363533e-02
- 3.270000e-01, 0.000000e+00, 2.187140e-02, 2.731859e-02, 4.918998e-02, 1.010460e-02, -2.317043e-02
- 3.280000e-01, 0.000000e+00, 2.086694e-02, 2.832304e-02, 4.918998e-02, 1.010714e-02, -2.269224e-02
- 3.290000e-01, 0.000000e+00, 1.987115e-02, 2.931883e-02, 4.918998e-02, 1.011010e-02, -2.220103e-02
- 3.300000e-01, 0.000000e+00, 1.888807e-02, 3.030191e-02, 4.918998e-02, 1.011241e-02, -2.169790e-02
- 3.310000e-01, 0.000000e+00, 1.792171e-02, 3.126827e-02, 4.918998e-02, 1.011420e-02, -2.118268e-02
- 3.320000e-01, 0.000000e+00, 1.697603e-02, 3.221395e-02, 4.918998e-02, 1.011652e-02, -2.065598e-02
- 3.330000e-01, 0.000000e+00, 1.605492e-02, 3.313507e-02, 4.918998e-02, 1.011892e-02, -2.011861e-02
- 3.340000e-01, 0.000000e+00, 1.516219e-02, 3.402779e-02, 4.918998e-02, 1.012187e-02, -1.957154e-02
- 3.350000e-01, 0.000000e+00, 1.430160e-02, 3.488838e-02, 4.918998e-02, 1.012458e-02, -1.901603e-02
- 3.360000e-01, 0.000000e+00, 1.347679e-02, 3.571320e-02, 4.918998e-02, 1.012676e-02, -1.845177e-02
- 3.370000e-01, 0.000000e+00, 1.269124e-02, 3.649875e-02, 4.918998e-02, 1.012829e-02, -1.787902e-02
- 3.380000e-01, 0.000000e+00, 1.194832e-02, 3.724166e-02, 4.918998e-02, 1.013031e-02, -1.729808e-02
- 3.390000e-01, 0.000000e+00, 1.125125e-02, 3.793873e-02, 4.918998e-02, 1.013186e-02, -1.670970e-02
- 3.400000e-01, 0.000000e+00, 1.060310e-02, 3.858689e-02, 4.918998e-02, 1.013268e-02, -1.611469e-02
- 3.410000e-01, 0.000000e+00, 1.000674e-02, 3.918325e-02, 4.918998e-02, 1.013298e-02, -1.551310e-02
- 3.420000e-01, 0.000000e+00, 9.464844e-03, 3.972514e-02, 4.918998e-02, 1.013320e-02, -1.490573e-02
- 3.430000e-01, 0.000000e+00, 8.979894e-03, 4.021009e-02, 4.918998e-02, 1.013469e-02, -1.429347e-02
- 3.440000e-01, 0.000000e+00, 8.554159e-03, 4.063582e-02, 4.918998e-02, 1.013614e-02, -1.367776e-02
- 3.450000e-01, 0.000000e+00, 8.189695e-03, 4.100029e-02, 4.918998e-02, 1.013717e-02, -1.305905e-02
- 3.460000e-01, 0.000000e+00, 7.888311e-03, 4.130167e-02, 4.918998e-02, 1.013758e-02, -1.243730e-02
- 3.470000e-01, 0.000000e+00, 7.651565e-03, 4.153842e-02, 4.918998e-02, 1.013751e-02, -1.181284e-02
- 3.480000e-01, 0.000000e+00, 7.480770e-03, 4.170921e-02, 4.918998e-02, 1.013821e-02, -1.118611e-02
- 3.490000e-01, 0.000000e+00, 7.376997e-03, 4.181299e-02, 4.918998e-02, 1.013821e-02, -1.055843e-02
- 3.500000e-01, 0.000000e+00, 7.341051e-03, 4.184893e-02, 4.918998e-02, 1.013750e-02, -1.003107e-02
- 3.510000e-01, 0.000000e+00, 7.373458e-03, 4.181653e-02, 4.918998e-02, 1.013627e-02, -1.065862e-02
- 3.520000e-01, 0.000000e+00, 7.474469e-03, 4.171552e-02, 4.918998e-02, 1.013518e-02, -1.128578e-02
- 3.530000e-01, 0.000000e+00, 7.644073e-03, 4.154591e-02, 4.918998e-02, 1.013523e-02, -1.191296e-02
- 3.540000e-01, 0.000000e+00, 7.881997e-03, 4.130799e-02, 4.918998e-02, 1.013502e-02, -1.253811e-02
- 3.550000e-01, 0.000000e+00, 8.187683e-03, 4.100230e-02, 4.918998e-02, 1.013426e-02, -1.316034e-02
- 3.560000e-01, 0.000000e+00, 8.560282e-03, 4.062970e-02, 4.918998e-02, 1.013288e-02, -1.377895e-02
- 3.570000e-01, 0.000000e+00, 8.998670e-03, 4.019131e-02, 4.918998e-02, 1.013148e-02, -1.439394e-02
- 3.580000e-01, 0.000000e+00, 9.501471e-03, 3.968851e-02, 4.918998e-02, 1.013060e-02, -1.500524e-02
- 3.590000e-01, 0.000000e+00, 1.006705e-02, 3.912293e-02, 4.918998e-02, 1.012906e-02, -1.561105e-02
- 3.600000e-01, 0.000000e+00, 1.069353e-02, 3.849646e-02, 4.918998e-02, 1.012682e-02, -1.621076e-02
- 3.610000e-01, 0.000000e+00, 1.137872e-02, 3.781126e-02, 4.918998e-02, 1.012410e-02, -1.680396e-02
- 3.620000e-01, 0.000000e+00, 1.212023e-02, 3.706975e-02, 4.918998e-02, 1.012194e-02, -1.739111e-02
- 3.630000e-01, 0.000000e+00, 1.291539e-02, 3.627459e-02, 4.918998e-02, 1.012048e-02, -1.797178e-02
- 3.640000e-01, 0.000000e+00, 1.376132e-02, 3.542866e-02, 4.918998e-02, 1.011861e-02, -1.854427e-02
- 3.650000e-01, 0.000000e+00, 1.465493e-02, 3.453505e-02, 4.918998e-02, 1.011615e-02, -1.910784e-02
- 3.660000e-01, 0.000000e+00, 1.559293e-02, 3.359705e-02, 4.918998e-02, 1.011311e-02, -1.966195e-02
- 3.670000e-01, 0.000000e+00, 1.657185e-02, 3.261814e-02, 4.918998e-02, 1.011062e-02, -2.020716e-02
- 3.680000e-01, 0.000000e+00, 1.758803e-02, 3.160196e-02, 4.918998e-02, 1.010831e-02, -2.074257e-02
- 3.690000e-01, 0.000000e+00, 1.863760e-02, 3.055239e-02, 4.918998e-02, 1.010535e-02, -2.126682e-02
- 3.700000e-01, 0.000000e+00, 1.971650e-02, 2.947348e-02, 4.918998e-02, 1.010176e-02, -2.177939e-02
- 3.710000e-01, 0.000000e+00, 2.082056e-02, 2.836943e-02, 4.918998e-02, 1.009772e-02, -2.227998e-02
- 3.720000e-01, 0.000000e+00, 2.194552e-02, 2.724447e-02, 4.918998e-02, 1.009472e-02, -2.276955e-02
- 3.730000e-01, 0.000000e+00, 2.308708e-02, 2.610291e-02, 4.918998e-02, 1.009187e-02, -2.324675e-02
- 3.740000e-01, 0.000000e+00, 2.424085e-02, 2.494913e-02, 4.918998e-02, 1.008852e-02, -2.371044e-02
- 3.750000e-01, 0.000000e+00, 2.540231e-02, 2.378768e-02, 4.918998e-02, 1.008460e-02, -2.416009e-02
- 3.760000e-01, 0.000000e+00, 2.656678e-02, 2.262320e-02, 4.918998e-02, 1.008022e-02, -2.459537e-02
- 3.770000e-01, 0.000000e+00, 2.772956e-02, 2.146042e-02, 4.918998e-02, 1.007700e-02, -2.501745e-02
- 3.780000e-01, 0.000000e+00, 2.888595e-02, 2.030403e-02, 4.918998e-02, 1.007352e-02, -2.542449e-02
- 3.790000e-01, 0.000000e+00, 3.003135e-02, 1.915864e-02, 4.918998e-02, 1.006943e-02, -2.581575e-02
- 3.800000e-01, 0.000000e+00, 3.116124e-02, 1.802875e-02, 4.918998e-02, 1.006475e-02, -2.619086e-02
- 3.810000e-01, 0.000000e+00, 3.227114e-02, 1.691885e-02, 4.918998e-02, 1.005979e-02, -2.654973e-02
- 3.820000e-01, 0.000000e+00, 3.335654e-02, 1.583345e-02, 4.918998e-02, 1.005617e-02, -2.689365e-02
- 3.830000e-01, 0.000000e+00, 3.441290e-02, 1.477709e-02, 4.918998e-02, 1.005220e-02, -2.722056e-02
- 3.840000e-01, 0.000000e+00, 3.543571e-02, 1.375428e-02, 4.918998e-02, 1.004771e-02, -2.752998e-02
- 3.850000e-01, 0.000000e+00, 3.642064e-02, 1.276934e-02, 4.918998e-02, 1.004273e-02, -2.782162e-02
- 3.860000e-01, 0.000000e+00, 3.736362e-02, 1.182636e-02, 4.918998e-02, 1.003778e-02, -2.809572e-02
- 3.870000e-01, 0.000000e+00, 3.826080e-02, 1.092918e-02, 4.918998e-02, 1.003391e-02, -2.835304e-02
- 3.880000e-01, 0.000000e+00, 3.910848e-02, 1.008151e-02, 4.918998e-02, 1.002963e-02, -2.859183e-02
- 3.890000e-01, 0.000000e+00, 3.990303e-02, 9.286950e-03, 4.918998e-02, 1.002479e-02, -2.881171e-02
- 3.900000e-01, 0.000000e+00, 4.064097e-02, 8.549018e-03, 4.918998e-02, 1.001943e-02, -2.901251e-02
- 3.910000e-01, 0.000000e+00, 4.131896e-02, 7.871019e-03, 4.918998e-02, 1.001437e-02, -2.919482e-02
- 3.920000e-01, 0.000000e+00, 4.193398e-02, 7.256004e-03, 4.918998e-02, 1.006177e-02, -2.935893e-02
- 3.930000e-01, 0.000000e+00, 4.248323e-02, 6.706755e-03, 4.918998e-02, 1.011199e-02, -2.950349e-02
- 3.940000e-01, 0.000000e+00, 4.296419e-02, 6.225797e-03, 4.918998e-02, 1.015046e-02, -2.962829e-02
- 3.950000e-01, 0.000000e+00, 4.337460e-02, 5.815386e-03, 4.918998e-02, 1.017663e-02, -2.973334e-02
- 3.960000e-01, 0.000000e+00, 4.371250e-02, 5.477480e-03, 4.918998e-02, 1.019017e-02, -2.981959e-02
- 3.970000e-01, 0.000000e+00, 4.397626e-02, 5.213723e-03, 4.918998e-02, 1.019834e-02, -2.988681e-02
- 3.980000e-01, 0.000000e+00, 4.416451e-02, 5.025474e-03, 4.918998e-02, 1.021258e-02, -2.993397e-02
- 3.990000e-01, 0.000000e+00, 4.427614e-02, 4.913846e-03, 4.918998e-02, 1.021041e-02, -2.996088e-02
- 4.000000e-01, 0.000000e+00, 4.431026e-02, 4.879723e-03, 4.918998e-02, 1.019127e-02, -2.996761e-02
-Comparing last generated output to the reference file
-1,402c1,202
-&lt; time, wext, epot, ekin, total, max_disp, min_disp
-&lt; 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 1.000000e-02, -1.000000e-02
-&lt; 1.000000e-03, 0.000000e+00, 2.463541e-02, 2.455458e-02, 4.918998e-02, 9.999143e-03, -9.997528e-03
-&lt; 2.000000e-03, 0.000000e+00, 2.465923e-02, 2.453076e-02, 4.918998e-02, 9.996985e-03, -9.987643e-03
-&lt; 3.000000e-03, 0.000000e+00, 2.468202e-02, 2.450796e-02, 4.918998e-02, 9.995896e-03, -9.992367e-03
-&lt; 4.000000e-03, 0.000000e+00, 2.470323e-02, 2.448676e-02, 4.918998e-02, 1.001196e-02, -1.001196e-02
-&lt; 5.000000e-03, 0.000000e+00, 2.472244e-02, 2.446755e-02, 4.918998e-02, 1.002165e-02, -1.002165e-02
-&lt; 6.000000e-03, 0.000000e+00, 2.473928e-02, 2.445070e-02, 4.918998e-02, 1.002143e-02, -1.002143e-02
-&lt; 7.000000e-03, 0.000000e+00, 2.475332e-02, 2.443667e-02, 4.918998e-02, 1.002450e-02, -1.001130e-02
-&lt; 8.000000e-03, 0.000000e+00, 2.476406e-02, 2.442593e-02, 4.918998e-02, 1.003228e-02, -1.001456e-02
-&lt; 9.000000e-03, 0.000000e+00, 2.477109e-02, 2.441890e-02, 4.918998e-02, 1.003704e-02, -1.003376e-02
-&lt; 1.000000e-02, 0.000000e+00, 2.477411e-02, 2.441588e-02, 4.918998e-02, 1.004302e-02, -1.004302e-02
-&lt; 1.100000e-02, 0.000000e+00, 2.477282e-02, 2.441716e-02, 4.918998e-02, 1.004236e-02, -1.004236e-02
-&lt; 1.200000e-02, 0.000000e+00, 2.476690e-02, 2.442308e-02, 4.918998e-02, 1.004789e-02, -1.003177e-02
-&lt; 1.300000e-02, 0.000000e+00, 2.475602e-02, 2.443397e-02, 4.918998e-02, 1.005379e-02, -1.003231e-02
-&lt; 1.400000e-02, 0.000000e+00, 2.473994e-02, 2.445004e-02, 4.918998e-02, 1.005707e-02, -1.005091e-02
-&lt; 1.500000e-02, 0.000000e+00, 2.471854e-02, 2.447144e-02, 4.918998e-02, 1.005956e-02, -1.005956e-02
-&lt; 1.600000e-02, 0.000000e+00, 2.469168e-02, 2.449831e-02, 4.918998e-02, 1.006363e-02, -1.005827e-02
-&lt; 1.700000e-02, 0.000000e+00, 2.465919e-02, 2.453079e-02, 4.918998e-02, 1.007036e-02, -1.004704e-02
-&lt; 1.800000e-02, 0.000000e+00, 2.462098e-02, 2.456900e-02, 4.918998e-02, 1.007511e-02, -1.004388e-02
-&lt; 1.900000e-02, 0.000000e+00, 2.457705e-02, 2.461294e-02, 4.918998e-02, 1.007770e-02, -1.006174e-02
-&lt; 2.000000e-02, 0.000000e+00, 2.452745e-02, 2.466253e-02, 4.918998e-02, 1.007882e-02, -1.006964e-02
-&lt; 2.100000e-02, 0.000000e+00, 2.447226e-02, 2.471773e-02, 4.918998e-02, 1.008327e-02, -1.006760e-02
-&lt; 2.200000e-02, 0.000000e+00, 2.441153e-02, 2.477846e-02, 4.918998e-02, 1.008864e-02, -1.005559e-02
-&lt; 2.300000e-02, 0.000000e+00, 2.434540e-02, 2.484458e-02, 4.918998e-02, 1.009204e-02, -1.004814e-02
-&lt; 2.400000e-02, 0.000000e+00, 2.427412e-02, 2.491587e-02, 4.918998e-02, 1.009362e-02, -1.006519e-02
-&lt; 2.500000e-02, 0.000000e+00, 2.419795e-02, 2.499203e-02, 4.918998e-02, 1.009653e-02, -1.007228e-02
-&lt; 2.600000e-02, 0.000000e+00, 2.411717e-02, 2.507281e-02, 4.918998e-02, 1.010222e-02, -1.006942e-02
-&lt; 2.700000e-02, 0.000000e+00, 2.403208e-02, 2.515790e-02, 4.918998e-02, 1.010652e-02, -1.005659e-02
-&lt; 2.800000e-02, 0.000000e+00, 2.394304e-02, 2.524694e-02, 4.918998e-02, 1.010899e-02, -1.004470e-02
-&lt; 2.900000e-02, 0.000000e+00, 2.385051e-02, 2.533948e-02, 4.918998e-02, 1.010992e-02, -1.006095e-02
-&lt; 3.000000e-02, 0.000000e+00, 2.375495e-02, 2.543503e-02, 4.918998e-02, 1.011087e-02, -1.006726e-02
-&lt; 3.100000e-02, 0.000000e+00, 2.365683e-02, 2.553315e-02, 4.918998e-02, 1.011540e-02, -1.006362e-02
-&lt; 3.200000e-02, 0.000000e+00, 2.355663e-02, 2.563335e-02, 4.918998e-02, 1.011840e-02, -1.005000e-02
-&lt; 3.300000e-02, 0.000000e+00, 2.345493e-02, 2.573506e-02, 4.918998e-02, 1.011970e-02, -1.003389e-02
-&lt; 3.400000e-02, 0.000000e+00, 2.335233e-02, 2.583766e-02, 4.918998e-02, 1.012040e-02, -1.004939e-02
-&lt; 3.500000e-02, 0.000000e+00, 2.324944e-02, 2.594054e-02, 4.918998e-02, 1.012478e-02, -1.005495e-02
-&lt; 3.600000e-02, 0.000000e+00, 2.314686e-02, 2.604313e-02, 4.918998e-02, 1.012824e-02, -1.005094e-02
-&lt; 3.700000e-02, 0.000000e+00, 2.304521e-02, 2.614477e-02, 4.918998e-02, 1.013016e-02, -1.003714e-02
-&lt; 3.800000e-02, 0.000000e+00, 2.294518e-02, 2.624480e-02, 4.918998e-02, 1.013053e-02, -1.001679e-02
-&lt; 3.900000e-02, 0.000000e+00, 2.284747e-02, 2.634251e-02, 4.918998e-02, 1.012994e-02, -1.003169e-02
-&lt; 4.000000e-02, 0.000000e+00, 2.275275e-02, 2.643724e-02, 4.918998e-02, 1.013171e-02, -1.003668e-02
-&lt; 4.100000e-02, 0.000000e+00, 2.266166e-02, 2.652832e-02, 4.918998e-02, 1.013394e-02, -1.003174e-02
-&lt; 4.200000e-02, 0.000000e+00, 2.257489e-02, 2.661510e-02, 4.918998e-02, 1.013462e-02, -1.001689e-02
-&lt; 4.300000e-02, 0.000000e+00, 2.249314e-02, 2.669684e-02, 4.918998e-02, 1.013395e-02, -1.001502e-02
-&lt; 4.400000e-02, 0.000000e+00, 2.241710e-02, 2.677288e-02, 4.918998e-02, 1.013605e-02, -1.002973e-02
-&lt; 4.500000e-02, 0.000000e+00, 2.234742e-02, 2.684257e-02, 4.918998e-02, 1.013837e-02, -1.003006e-02
-&lt; 4.600000e-02, 0.000000e+00, 2.228470e-02, 2.690529e-02, 4.918998e-02, 1.013946e-02, -1.001567e-02
-&lt; 4.700000e-02, 0.000000e+00, 2.222957e-02, 2.696041e-02, 4.918998e-02, 1.013907e-02, -9.993727e-03
-&lt; 4.800000e-02, 0.000000e+00, 2.218267e-02, 2.700731e-02, 4.918998e-02, 1.013753e-02, -9.970899e-03
-&lt; 4.900000e-02, 0.000000e+00, 2.214457e-02, 2.704541e-02, 4.918998e-02, 1.013616e-02, -9.985244e-03
-&lt; 5.000000e-02, 0.000000e+00, 2.211579e-02, 2.707420e-02, 4.918998e-02, 1.013734e-02, -9.989716e-03
-&lt; 5.100000e-02, 0.000000e+00, 2.209680e-02, 2.709318e-02, 4.918998e-02, 1.013722e-02, -1.047754e-02
-&lt; 5.200000e-02, 0.000000e+00, 2.208809e-02, 2.710189e-02, 4.918998e-02, 1.013572e-02, -1.110650e-02
-&lt; 5.300000e-02, 0.000000e+00, 2.209011e-02, 2.709987e-02, 4.918998e-02, 1.013505e-02, -1.173513e-02
-&lt; 5.400000e-02, 0.000000e+00, 2.210323e-02, 2.708675e-02, 4.918998e-02, 1.013603e-02, -1.236205e-02
-&lt; 5.500000e-02, 0.000000e+00, 2.212775e-02, 2.706223e-02, 4.918998e-02, 1.013613e-02, -1.298586e-02
-&lt; 5.600000e-02, 0.000000e+00, 2.216394e-02, 2.702605e-02, 4.918998e-02, 1.013490e-02, -1.360554e-02
-&lt; 5.700000e-02, 0.000000e+00, 2.221204e-02, 2.697794e-02, 4.918998e-02, 1.013243e-02, -1.422054e-02
-&lt; 5.800000e-02, 0.000000e+00, 2.227224e-02, 2.691774e-02, 4.918998e-02, 1.012925e-02, -1.483080e-02
-&lt; 5.900000e-02, 0.000000e+00, 2.234464e-02, 2.684535e-02, 4.918998e-02, 1.012832e-02, -1.543647e-02
-&lt; 6.000000e-02, 0.000000e+00, 2.242925e-02, 2.676073e-02, 4.918998e-02, 1.012731e-02, -1.603761e-02
-&lt; 6.100000e-02, 0.000000e+00, 2.252608e-02, 2.666391e-02, 4.918998e-02, 1.012500e-02, -1.663392e-02
-&lt; 6.200000e-02, 0.000000e+00, 2.263506e-02, 2.655493e-02, 4.918998e-02, 1.012178e-02, -1.722458e-02
-&lt; 6.300000e-02, 0.000000e+00, 2.275606e-02, 2.643392e-02, 4.918998e-02, 1.012138e-02, -1.780840e-02
-&lt; 6.400000e-02, 0.000000e+00, 2.288887e-02, 2.630111e-02, 4.918998e-02, 1.012043e-02, -1.838408e-02
-&lt; 6.500000e-02, 0.000000e+00, 2.303319e-02, 2.615679e-02, 4.918998e-02, 1.011837e-02, -1.895048e-02
-&lt; 6.600000e-02, 0.000000e+00, 2.318871e-02, 2.600127e-02, 4.918998e-02, 1.011509e-02, -1.950691e-02
-&lt; 6.700000e-02, 0.000000e+00, 2.335505e-02, 2.583494e-02, 4.918998e-02, 1.011090e-02, -2.005316e-02
-&lt; 6.800000e-02, 0.000000e+00, 2.353174e-02, 2.565824e-02, 4.918998e-02, 1.010757e-02, -2.058934e-02
-&lt; 6.900000e-02, 0.000000e+00, 2.371825e-02, 2.547174e-02, 4.918998e-02, 1.010570e-02, -2.111561e-02
-&lt; 7.000000e-02, 0.000000e+00, 2.391397e-02, 2.527601e-02, 4.918998e-02, 1.010268e-02, -2.163189e-02
-&lt; 7.100000e-02, 0.000000e+00, 2.411829e-02, 2.507170e-02, 4.918998e-02, 1.009853e-02, -2.213766e-02
-&lt; 7.200000e-02, 0.000000e+00, 2.433051e-02, 2.485947e-02, 4.918998e-02, 1.009554e-02, -2.263198e-02
-&lt; 7.300000e-02, 0.000000e+00, 2.454988e-02, 2.464010e-02, 4.918998e-02, 1.009360e-02, -2.311369e-02
-&lt; 7.400000e-02, 0.000000e+00, 2.477557e-02, 2.441442e-02, 4.918998e-02, 1.009083e-02, -2.358169e-02
-&lt; 7.500000e-02, 0.000000e+00, 2.500671e-02, 2.418327e-02, 4.918998e-02, 1.008692e-02, -2.403521e-02
-&lt; 7.600000e-02, 0.000000e+00, 2.524242e-02, 2.394756e-02, 4.918998e-02, 1.008201e-02, -2.447394e-02
-&lt; 7.700000e-02, 0.000000e+00, 2.548177e-02, 2.370821e-02, 4.918998e-02, 1.007672e-02, -2.489797e-02
-&lt; 7.800000e-02, 0.000000e+00, 2.572377e-02, 2.346622e-02, 4.918998e-02, 1.007410e-02, -2.530753e-02
-&lt; 7.900000e-02, 0.000000e+00, 2.596736e-02, 2.322263e-02, 4.918998e-02, 1.007055e-02, -2.570277e-02
-&lt; 8.000000e-02, 0.000000e+00, 2.621151e-02, 2.297848e-02, 4.918998e-02, 1.006591e-02, -2.608346e-02
-&lt; 8.100000e-02, 0.000000e+00, 2.645516e-02, 2.273483e-02, 4.918998e-02, 1.006055e-02, -2.644898e-02
-&lt; 8.200000e-02, 0.000000e+00, 2.669722e-02, 2.249277e-02, 4.918998e-02, 1.005778e-02, -2.679840e-02
-&lt; 8.300000e-02, 0.000000e+00, 2.693655e-02, 2.225343e-02, 4.918998e-02, 1.005447e-02, -2.713073e-02
-&lt; 8.400000e-02, 0.000000e+00, 2.717203e-02, 2.201796e-02, 4.918998e-02, 1.005019e-02, -2.744520e-02
-&lt; 8.500000e-02, 0.000000e+00, 2.740252e-02, 2.178746e-02, 4.918998e-02, 1.004490e-02, -2.774146e-02
-&lt; 8.600000e-02, 0.000000e+00, 2.762693e-02, 2.156306e-02, 4.918998e-02, 1.003894e-02, -2.801957e-02
-&lt; 8.700000e-02, 0.000000e+00, 2.784410e-02, 2.134588e-02, 4.918998e-02, 1.003504e-02, -2.827985e-02
-&lt; 8.800000e-02, 0.000000e+00, 2.805292e-02, 2.113706e-02, 4.918998e-02, 1.003121e-02, -2.852264e-02
-&lt; 8.900000e-02, 0.000000e+00, 2.825227e-02, 2.093772e-02, 4.918998e-02, 1.002639e-02, -2.874802e-02
-&lt; 9.000000e-02, 0.000000e+00, 2.844108e-02, 2.074891e-02, 4.918998e-02, 1.002067e-02, -2.895570e-02
-&lt; 9.100000e-02, 0.000000e+00, 2.861831e-02, 2.057168e-02, 4.918998e-02, 1.001579e-02, -2.914504e-02
-&lt; 9.200000e-02, 0.000000e+00, 2.878293e-02, 2.040705e-02, 4.918998e-02, 1.001219e-02, -2.931523e-02
-&lt; 9.300000e-02, 0.000000e+00, 2.893393e-02, 2.025605e-02, 4.918998e-02, 1.000784e-02, -2.946560e-02
-&lt; 9.400000e-02, 0.000000e+00, 2.907038e-02, 2.011961e-02, 4.918998e-02, 1.000254e-02, -2.959577e-02
-&lt; 9.500000e-02, 0.000000e+00, 2.919138e-02, 1.999860e-02, 4.918998e-02, 9.998658e-03, -2.970580e-02
-&lt; 9.600000e-02, 0.000000e+00, 2.929611e-02, 1.989388e-02, 4.918998e-02, 1.001243e-02, -2.979609e-02
-&lt; 9.700000e-02, 0.000000e+00, 2.938375e-02, 1.980624e-02, 4.918998e-02, 1.004316e-02, -2.986714e-02
-&lt; 9.800000e-02, 0.000000e+00, 2.945357e-02, 1.973642e-02, 4.918998e-02, 1.007269e-02, -2.991931e-02
-&lt; 9.900000e-02, 0.000000e+00, 2.950491e-02, 1.968508e-02, 4.918998e-02, 1.008646e-02, -2.995267e-02
-&lt; 1.000000e-01, 0.000000e+00, 2.953720e-02, 1.965278e-02, 4.918998e-02, 1.008319e-02, -2.996688e-02
-&lt; 1.010000e-01, 0.000000e+00, 2.954993e-02, 1.964006e-02, 4.918998e-02, 1.006204e-02, -2.996139e-02
-&lt; 1.020000e-01, 0.000000e+00, 2.954263e-02, 1.964735e-02, 4.918998e-02, 1.002266e-02, -2.993565e-02
-&lt; 1.030000e-01, 0.000000e+00, 2.951494e-02, 1.967504e-02, 4.918998e-02, 1.000190e-02, -2.988934e-02
-&lt; 1.040000e-01, 0.000000e+00, 2.946660e-02, 1.972339e-02, 4.918998e-02, 1.001330e-02, -2.982252e-02
-&lt; 1.050000e-01, 0.000000e+00, 2.939743e-02, 1.979256e-02, 4.918998e-02, 1.002205e-02, -2.973562e-02
-&lt; 1.060000e-01, 0.000000e+00, 2.930733e-02, 1.988265e-02, 4.918998e-02, 1.002090e-02, -2.962929e-02
-&lt; 1.070000e-01, 0.000000e+00, 2.919627e-02, 1.999371e-02, 4.918998e-02, 1.002152e-02, -2.950414e-02
-&lt; 1.080000e-01, 0.000000e+00, 2.906433e-02, 2.012566e-02, 4.918998e-02, 1.002550e-02, -2.936055e-02
-&lt; 1.090000e-01, 0.000000e+00, 2.891170e-02, 2.027828e-02, 4.918998e-02, 1.003506e-02, -2.919853e-02
-&lt; 1.100000e-01, 0.000000e+00, 2.873867e-02, 2.045131e-02, 4.918998e-02, 1.004339e-02, -2.901780e-02
-&lt; 1.110000e-01, 0.000000e+00, 2.854558e-02, 2.064440e-02, 4.918998e-02, 1.004179e-02, -2.881799e-02
-&lt; 1.120000e-01, 0.000000e+00, 2.833288e-02, 2.085711e-02, 4.918998e-02, 1.004548e-02, -2.859884e-02
-&lt; 1.130000e-01, 0.000000e+00, 2.810111e-02, 2.108887e-02, 4.918998e-02, 1.004888e-02, -2.836045e-02
-&lt; 1.140000e-01, 0.000000e+00, 2.785095e-02, 2.133903e-02, 4.918998e-02, 1.005312e-02, -2.810326e-02
-&lt; 1.150000e-01, 0.000000e+00, 2.758313e-02, 2.160685e-02, 4.918998e-02, 1.005987e-02, -2.782801e-02
-&lt; 1.160000e-01, 0.000000e+00, 2.729845e-02, 2.189153e-02, 4.918998e-02, 1.006350e-02, -2.753553e-02
-&lt; 1.170000e-01, 0.000000e+00, 2.699782e-02, 2.219216e-02, 4.918998e-02, 1.006700e-02, -2.722645e-02
-&lt; 1.180000e-01, 0.000000e+00, 2.668223e-02, 2.250775e-02, 4.918998e-02, 1.006980e-02, -2.690111e-02
-&lt; 1.190000e-01, 0.000000e+00, 2.635278e-02, 2.283721e-02, 4.918998e-02, 1.007407e-02, -2.655953e-02
-&lt; 1.200000e-01, 0.000000e+00, 2.601061e-02, 2.317937e-02, 4.918998e-02, 1.007918e-02, -2.620153e-02
-&lt; 1.210000e-01, 0.000000e+00, 2.565693e-02, 2.353305e-02, 4.918998e-02, 1.008343e-02, -2.582696e-02
-&lt; 1.220000e-01, 0.000000e+00, 2.529303e-02, 2.389696e-02, 4.918998e-02, 1.008663e-02, -2.543593e-02
-&lt; 1.230000e-01, 0.000000e+00, 2.492027e-02, 2.426971e-02, 4.918998e-02, 1.008961e-02, -2.502889e-02
-&lt; 1.240000e-01, 0.000000e+00, 2.454009e-02, 2.464989e-02, 4.918998e-02, 1.009453e-02, -2.460663e-02
-&lt; 1.250000e-01, 0.000000e+00, 2.415395e-02, 2.503604e-02, 4.918998e-02, 1.009870e-02, -2.417009e-02
-&lt; 1.260000e-01, 0.000000e+00, 2.376334e-02, 2.542664e-02, 4.918998e-02, 1.010184e-02, -2.372013e-02
-&lt; 1.270000e-01, 0.000000e+00, 2.336983e-02, 2.582015e-02, 4.918998e-02, 1.010401e-02, -2.325739e-02
-&lt; 1.280000e-01, 0.000000e+00, 2.297504e-02, 2.621495e-02, 4.918998e-02, 1.010561e-02, -2.278215e-02
-&lt; 1.290000e-01, 0.000000e+00, 2.258058e-02, 2.660940e-02, 4.918998e-02, 1.010914e-02, -2.229444e-02
-&lt; 1.300000e-01, 0.000000e+00, 2.218810e-02, 2.700188e-02, 4.918998e-02, 1.011209e-02, -2.179424e-02
-&lt; 1.310000e-01, 0.000000e+00, 2.179925e-02, 2.739073e-02, 4.918998e-02, 1.011469e-02, -2.128166e-02
-&lt; 1.320000e-01, 0.000000e+00, 2.141571e-02, 2.777428e-02, 4.918998e-02, 1.011657e-02, -2.075713e-02
-&lt; 1.330000e-01, 0.000000e+00, 2.103916e-02, 2.815083e-02, 4.918998e-02, 1.011933e-02, -2.022144e-02
-&lt; 1.340000e-01, 0.000000e+00, 2.067127e-02, 2.851871e-02, 4.918998e-02, 1.012279e-02, -1.967558e-02
-&lt; 1.350000e-01, 0.000000e+00, 2.031370e-02, 2.887629e-02, 4.918998e-02, 1.012547e-02, -1.912057e-02
-&lt; 1.360000e-01, 0.000000e+00, 1.996805e-02, 2.922193e-02, 4.918998e-02, 1.012714e-02, -1.855727e-02
-&lt; 1.370000e-01, 0.000000e+00, 1.963596e-02, 2.955403e-02, 4.918998e-02, 1.012792e-02, -1.798619e-02
-&lt; 1.380000e-01, 0.000000e+00, 1.931900e-02, 2.987098e-02, 4.918998e-02, 1.012821e-02, -1.740759e-02
-&lt; 1.390000e-01, 0.000000e+00, 1.901871e-02, 3.017127e-02, 4.918998e-02, 1.013035e-02, -1.682153e-02
-&lt; 1.400000e-01, 0.000000e+00, 1.873656e-02, 3.045343e-02, 4.918998e-02, 1.013173e-02, -1.622816e-02
-&lt; 1.410000e-01, 0.000000e+00, 1.847395e-02, 3.071603e-02, 4.918998e-02, 1.013283e-02, -1.562786e-02
-&lt; 1.420000e-01, 0.000000e+00, 1.823228e-02, 3.095771e-02, 4.918998e-02, 1.013314e-02, -1.502134e-02
-&lt; 1.430000e-01, 0.000000e+00, 1.801283e-02, 3.117715e-02, 4.918998e-02, 1.013526e-02, -1.440959e-02
-&lt; 1.440000e-01, 0.000000e+00, 1.781683e-02, 3.137315e-02, 4.918998e-02, 1.013707e-02, -1.379371e-02
-&lt; 1.450000e-01, 0.000000e+00, 1.764538e-02, 3.154460e-02, 4.918998e-02, 1.013805e-02, -1.317468e-02
-&lt; 1.460000e-01, 0.000000e+00, 1.749954e-02, 3.169044e-02, 4.918998e-02, 1.013805e-02, -1.255323e-02
-&lt; 1.470000e-01, 0.000000e+00, 1.738028e-02, 3.180970e-02, 4.918998e-02, 1.013725e-02, -1.192976e-02
-&lt; 1.480000e-01, 0.000000e+00, 1.728845e-02, 3.190153e-02, 4.918998e-02, 1.013619e-02, -1.130448e-02
-&lt; 1.490000e-01, 0.000000e+00, 1.722478e-02, 3.196520e-02, 4.918998e-02, 1.013684e-02, -1.067751e-02
-&lt; 1.500000e-01, 0.000000e+00, 1.718991e-02, 3.200007e-02, 4.918998e-02, 1.013658e-02, -1.004918e-02
-&lt; 1.510000e-01, 0.000000e+00, 1.718437e-02, 3.200561e-02, 4.918998e-02, 1.013608e-02, -1.053831e-02
-&lt; 1.520000e-01, 0.000000e+00, 1.720859e-02, 3.198140e-02, 4.918998e-02, 1.013539e-02, -1.116732e-02
-&lt; 1.530000e-01, 0.000000e+00, 1.726285e-02, 3.192713e-02, 4.918998e-02, 1.013597e-02, -1.179529e-02
-&lt; 1.540000e-01, 0.000000e+00, 1.734731e-02, 3.184267e-02, 4.918998e-02, 1.013604e-02, -1.242110e-02
-&lt; 1.550000e-01, 0.000000e+00, 1.746202e-02, 3.172797e-02, 4.918998e-02, 1.013524e-02, -1.304378e-02
-&lt; 1.560000e-01, 0.000000e+00, 1.760690e-02, 3.158309e-02, 4.918998e-02, 1.013351e-02, -1.366266e-02
-&lt; 1.570000e-01, 0.000000e+00, 1.778175e-02, 3.140823e-02, 4.918998e-02, 1.013112e-02, -1.427739e-02
-&lt; 1.580000e-01, 0.000000e+00, 1.798624e-02, 3.120374e-02, 4.918998e-02, 1.012915e-02, -1.488781e-02
-&lt; 1.590000e-01, 0.000000e+00, 1.821989e-02, 3.097010e-02, 4.918998e-02, 1.012807e-02, -1.549379e-02
-&lt; 1.600000e-01, 0.000000e+00, 1.848210e-02, 3.070788e-02, 4.918998e-02, 1.012632e-02, -1.609505e-02
-&lt; 1.610000e-01, 0.000000e+00, 1.877218e-02, 3.041781e-02, 4.918998e-02, 1.012409e-02, -1.669100e-02
-&lt; 1.620000e-01, 0.000000e+00, 1.908929e-02, 3.010070e-02, 4.918998e-02, 1.012243e-02, -1.728075e-02
-&lt; 1.630000e-01, 0.000000e+00, 1.943245e-02, 2.975754e-02, 4.918998e-02, 1.012141e-02, -1.786326e-02
-&lt; 1.640000e-01, 0.000000e+00, 1.980057e-02, 2.938942e-02, 4.918998e-02, 1.011978e-02, -1.843751e-02
-&lt; 1.650000e-01, 0.000000e+00, 2.019245e-02, 2.899754e-02, 4.918998e-02, 1.011728e-02, -1.900266e-02
-&lt; 1.660000e-01, 0.000000e+00, 2.060680e-02, 2.858319e-02, 4.918998e-02, 1.011395e-02, -1.955819e-02
-&lt; 1.670000e-01, 0.000000e+00, 2.104219e-02, 2.814780e-02, 4.918998e-02, 1.011011e-02, -2.010389e-02
-&lt; 1.680000e-01, 0.000000e+00, 2.149708e-02, 2.769291e-02, 4.918998e-02, 1.010755e-02, -2.063967e-02
-&lt; 1.690000e-01, 0.000000e+00, 2.196983e-02, 2.722015e-02, 4.918998e-02, 1.010487e-02, -2.116544e-02
-&lt; 1.700000e-01, 0.000000e+00, 2.245875e-02, 2.673123e-02, 4.918998e-02, 1.010175e-02, -2.168089e-02
-&lt; 1.710000e-01, 0.000000e+00, 2.296205e-02, 2.622794e-02, 4.918998e-02, 1.009798e-02, -2.218540e-02
-&lt; 1.720000e-01, 0.000000e+00, 2.347781e-02, 2.571217e-02, 4.918998e-02, 1.009546e-02, -2.267814e-02
-&lt; 1.730000e-01, 0.000000e+00, 2.400409e-02, 2.518590e-02, 4.918998e-02, 1.009300e-02, -2.315814e-02
-&lt; 1.740000e-01, 0.000000e+00, 2.453884e-02, 2.465114e-02, 4.918998e-02, 1.008987e-02, -2.362454e-02
-&lt; 1.750000e-01, 0.000000e+00, 2.508001e-02, 2.410997e-02, 4.918998e-02, 1.008590e-02, -2.407672e-02
-&lt; 1.760000e-01, 0.000000e+00, 2.562547e-02, 2.356452e-02, 4.918998e-02, 1.008124e-02, -2.451438e-02
-&lt; 1.770000e-01, 0.000000e+00, 2.617303e-02, 2.301696e-02, 4.918998e-02, 1.007671e-02, -2.493746e-02
-&lt; 1.780000e-01, 0.000000e+00, 2.672048e-02, 2.246951e-02, 4.918998e-02, 1.007349e-02, -2.534601e-02
-&lt; 1.790000e-01, 0.000000e+00, 2.726559e-02, 2.192440e-02, 4.918998e-02, 1.006952e-02, -2.573998e-02
-&lt; 1.800000e-01, 0.000000e+00, 2.780613e-02, 2.138385e-02, 4.918998e-02, 1.006527e-02, -2.611907e-02
-&lt; 1.810000e-01, 0.000000e+00, 2.833986e-02, 2.085013e-02, 4.918998e-02, 1.006031e-02, -2.648272e-02
-&lt; 1.820000e-01, 0.000000e+00, 2.886451e-02, 2.032547e-02, 4.918998e-02, 1.005712e-02, -2.683018e-02
-&lt; 1.830000e-01, 0.000000e+00, 2.937784e-02, 1.981214e-02, 4.918998e-02, 1.005352e-02, -2.716064e-02
-&lt; 1.840000e-01, 0.000000e+00, 2.987766e-02, 1.931232e-02, 4.918998e-02, 1.004922e-02, -2.747347e-02
-&lt; 1.850000e-01, 0.000000e+00, 3.036180e-02, 1.882819e-02, 4.918998e-02, 1.004416e-02, -2.776832e-02
-&lt; 1.860000e-01, 0.000000e+00, 3.082811e-02, 1.836188e-02, 4.918998e-02, 1.003859e-02, -2.804514e-02
-&lt; 1.870000e-01, 0.000000e+00, 3.127450e-02, 1.791549e-02, 4.918998e-02, 1.003449e-02, -2.830407e-02
-&lt; 1.880000e-01, 0.000000e+00, 3.169893e-02, 1.749105e-02, 4.918998e-02, 1.003029e-02, -2.854528e-02
-&lt; 1.890000e-01, 0.000000e+00, 3.209947e-02, 1.709051e-02, 4.918998e-02, 1.002558e-02, -2.876879e-02
-&lt; 1.900000e-01, 0.000000e+00, 3.247424e-02, 1.671574e-02, 4.918998e-02, 1.002042e-02, -2.897437e-02
-&lt; 1.910000e-01, 0.000000e+00, 3.282145e-02, 1.636854e-02, 4.918998e-02, 1.001506e-02, -2.916153e-02
-&lt; 1.920000e-01, 0.000000e+00, 3.313937e-02, 1.605061e-02, 4.918998e-02, 1.001119e-02, -2.932967e-02
-&lt; 1.930000e-01, 0.000000e+00, 3.342643e-02, 1.576355e-02, 4.918998e-02, 1.000684e-02, -2.947822e-02
-&lt; 1.940000e-01, 0.000000e+00, 3.368115e-02, 1.550883e-02, 4.918998e-02, 1.003367e-02, -2.960682e-02
-&lt; 1.950000e-01, 0.000000e+00, 3.390217e-02, 1.528782e-02, 4.918998e-02, 1.006048e-02, -2.971541e-02
-&lt; 1.960000e-01, 0.000000e+00, 3.408823e-02, 1.510176e-02, 4.918998e-02, 1.007733e-02, -2.980420e-02
-&lt; 1.970000e-01, 0.000000e+00, 3.423821e-02, 1.495178e-02, 4.918998e-02, 1.010808e-02, -2.987354e-02
-&lt; 1.980000e-01, 0.000000e+00, 3.435115e-02, 1.483884e-02, 4.918998e-02, 1.012904e-02, -2.992372e-02
-&lt; 1.990000e-01, 0.000000e+00, 3.442622e-02, 1.476376e-02, 4.918998e-02, 1.013369e-02, -2.995485e-02
-&lt; 2.000000e-01, 0.000000e+00, 3.446275e-02, 1.472723e-02, 4.918998e-02, 1.012203e-02, -2.996678e-02
-&lt; 2.010000e-01, 0.000000e+00, 3.446018e-02, 1.472980e-02, 4.918998e-02, 1.009410e-02, -2.995914e-02
-&lt; 2.020000e-01, 0.000000e+00, 3.441813e-02, 1.477185e-02, 4.918998e-02, 1.004987e-02, -2.993151e-02
-&lt; 2.030000e-01, 0.000000e+00, 3.433639e-02, 1.485359e-02, 4.918998e-02, 1.000333e-02, -2.988359e-02
-&lt; 2.040000e-01, 0.000000e+00, 3.421491e-02, 1.497507e-02, 4.918998e-02, 1.001455e-02, -2.981534e-02
-&lt; 2.050000e-01, 0.000000e+00, 3.405379e-02, 1.513620e-02, 4.918998e-02, 1.002237e-02, -2.972700e-02
-&lt; 2.060000e-01, 0.000000e+00, 3.385326e-02, 1.533672e-02, 4.918998e-02, 1.002028e-02, -2.961903e-02
-&lt; 2.070000e-01, 0.000000e+00, 3.361378e-02, 1.557621e-02, 4.918998e-02, 1.002347e-02, -2.949194e-02
-&lt; 2.080000e-01, 0.000000e+00, 3.333592e-02, 1.585406e-02, 4.918998e-02, 1.002744e-02, -2.934617e-02
-&lt; 2.090000e-01, 0.000000e+00, 3.302047e-02, 1.616951e-02, 4.918998e-02, 1.003627e-02, -2.918187e-02
-&lt; 2.100000e-01, 0.000000e+00, 3.266832e-02, 1.652166e-02, 4.918998e-02, 1.004366e-02, -2.899899e-02
-&lt; 2.110000e-01, 0.000000e+00, 3.228053e-02, 1.690945e-02, 4.918998e-02, 1.004160e-02, -2.879732e-02
-&lt; 2.120000e-01, 0.000000e+00, 3.185834e-02, 1.733164e-02, 4.918998e-02, 1.004564e-02, -2.857666e-02
-&lt; 2.130000e-01, 0.000000e+00, 3.140314e-02, 1.778684e-02, 4.918998e-02, 1.004976e-02, -2.833699e-02
-&lt; 2.140000e-01, 0.000000e+00, 3.091647e-02, 1.827352e-02, 4.918998e-02, 1.005506e-02, -2.807858e-02
-&lt; 2.150000e-01, 0.000000e+00, 3.039996e-02, 1.879002e-02, 4.918998e-02, 1.006008e-02, -2.780195e-02
-&lt; 2.160000e-01, 0.000000e+00, 2.985544e-02, 1.933454e-02, 4.918998e-02, 1.006421e-02, -2.750778e-02
-&lt; 2.170000e-01, 0.000000e+00, 2.928485e-02, 1.990514e-02, 4.918998e-02, 1.006779e-02, -2.719672e-02
-&lt; 2.180000e-01, 0.000000e+00, 2.869025e-02, 2.049974e-02, 4.918998e-02, 1.007096e-02, -2.686926e-02
-&lt; 2.190000e-01, 0.000000e+00, 2.807383e-02, 2.111616e-02, 4.918998e-02, 1.007485e-02, -2.652566e-02
-&lt; 2.200000e-01, 0.000000e+00, 2.743785e-02, 2.175213e-02, 4.918998e-02, 1.007911e-02, -2.616593e-02
-&lt; 2.210000e-01, 0.000000e+00, 2.678471e-02, 2.240527e-02, 4.918998e-02, 1.008268e-02, -2.579003e-02
-&lt; 2.220000e-01, 0.000000e+00, 2.611689e-02, 2.307309e-02, 4.918998e-02, 1.008702e-02, -2.539799e-02
-&lt; 2.230000e-01, 0.000000e+00, 2.543697e-02, 2.375301e-02, 4.918998e-02, 1.009049e-02, -2.499009e-02
-&lt; 2.240000e-01, 0.000000e+00, 2.474756e-02, 2.444242e-02, 4.918998e-02, 1.009459e-02, -2.456685e-02
-&lt; 2.250000e-01, 0.000000e+00, 2.405136e-02, 2.513863e-02, 4.918998e-02, 1.009820e-02, -2.412905e-02
-&lt; 2.260000e-01, 0.000000e+00, 2.335110e-02, 2.583889e-02, 4.918998e-02, 1.010110e-02, -2.367750e-02
-&lt; 2.270000e-01, 0.000000e+00, 2.264958e-02, 2.654040e-02, 4.918998e-02, 1.010344e-02, -2.321296e-02
-&lt; 2.280000e-01, 0.000000e+00, 2.194964e-02, 2.724034e-02, 4.918998e-02, 1.010633e-02, -2.273594e-02
-&lt; 2.290000e-01, 0.000000e+00, 2.125408e-02, 2.793590e-02, 4.918998e-02, 1.010870e-02, -2.224672e-02
-&lt; 2.300000e-01, 0.000000e+00, 2.056575e-02, 2.862423e-02, 4.918998e-02, 1.011213e-02, -2.174544e-02
-&lt; 2.310000e-01, 0.000000e+00, 1.988748e-02, 2.930251e-02, 4.918998e-02, 1.011572e-02, -2.123219e-02
-&lt; 2.320000e-01, 0.000000e+00, 1.922210e-02, 2.996788e-02, 4.918998e-02, 1.011859e-02, -2.070724e-02
-&lt; 2.330000e-01, 0.000000e+00, 1.857241e-02, 3.061758e-02, 4.918998e-02, 1.012061e-02, -2.017110e-02
-&lt; 2.340000e-01, 0.000000e+00, 1.794113e-02, 3.124885e-02, 4.918998e-02, 1.012275e-02, -1.962454e-02
-&lt; 2.350000e-01, 0.000000e+00, 1.733097e-02, 3.185901e-02, 4.918998e-02, 1.012473e-02, -1.906849e-02
-&lt; 2.360000e-01, 0.000000e+00, 1.674458e-02, 3.244541e-02, 4.918998e-02, 1.012603e-02, -1.850384e-02
-&lt; 2.370000e-01, 0.000000e+00, 1.618452e-02, 3.300547e-02, 4.918998e-02, 1.012698e-02, -1.793136e-02
-&lt; 2.380000e-01, 0.000000e+00, 1.565326e-02, 3.353673e-02, 4.918998e-02, 1.012868e-02, -1.735155e-02
-&lt; 2.390000e-01, 0.000000e+00, 1.515317e-02, 3.403682e-02, 4.918998e-02, 1.012980e-02, -1.676471e-02
-&lt; 2.400000e-01, 0.000000e+00, 1.468652e-02, 3.450346e-02, 4.918998e-02, 1.013218e-02, -1.617104e-02
-&lt; 2.410000e-01, 0.000000e+00, 1.425549e-02, 3.493449e-02, 4.918998e-02, 1.013424e-02, -1.557079e-02
-&lt; 2.420000e-01, 0.000000e+00, 1.386211e-02, 3.532787e-02, 4.918998e-02, 1.013560e-02, -1.496441e-02
-&lt; 2.430000e-01, 0.000000e+00, 1.350826e-02, 3.568172e-02, 4.918998e-02, 1.013612e-02, -1.435262e-02
-&lt; 2.440000e-01, 0.000000e+00, 1.319568e-02, 3.599430e-02, 4.918998e-02, 1.013679e-02, -1.373634e-02
-&lt; 2.450000e-01, 0.000000e+00, 1.292597e-02, 3.626401e-02, 4.918998e-02, 1.013695e-02, -1.311656e-02
-&lt; 2.460000e-01, 0.000000e+00, 1.270058e-02, 3.648940e-02, 4.918998e-02, 1.013657e-02, -1.249418e-02
-&lt; 2.470000e-01, 0.000000e+00, 1.252078e-02, 3.666920e-02, 4.918998e-02, 1.013637e-02, -1.186989e-02
-&lt; 2.480000e-01, 0.000000e+00, 1.238764e-02, 3.680234e-02, 4.918998e-02, 1.013649e-02, -1.124416e-02
-&lt; 2.490000e-01, 0.000000e+00, 1.230208e-02, 3.688791e-02, 4.918998e-02, 1.013633e-02, -1.061726e-02
-&lt; 2.500000e-01, 0.000000e+00, 1.226482e-02, 3.692516e-02, 4.918998e-02, 1.013718e-02, -9.989451e-03
-&lt; 2.510000e-01, 0.000000e+00, 1.227642e-02, 3.691356e-02, 4.918998e-02, 1.013763e-02, -1.060057e-02
-&lt; 2.520000e-01, 0.000000e+00, 1.233721e-02, 3.685277e-02, 4.918998e-02, 1.013736e-02, -1.122864e-02
-&lt; 2.530000e-01, 0.000000e+00, 1.244733e-02, 3.674265e-02, 4.918998e-02, 1.013633e-02, -1.185486e-02
-&lt; 2.540000e-01, 0.000000e+00, 1.260673e-02, 3.658325e-02, 4.918998e-02, 1.013533e-02, -1.247942e-02
-&lt; 2.550000e-01, 0.000000e+00, 1.281516e-02, 3.637482e-02, 4.918998e-02, 1.013370e-02, -1.310102e-02
-&lt; 2.560000e-01, 0.000000e+00, 1.307219e-02, 3.611780e-02, 4.918998e-02, 1.013187e-02, -1.371935e-02
-&lt; 2.570000e-01, 0.000000e+00, 1.337714e-02, 3.581284e-02, 4.918998e-02, 1.013052e-02, -1.433413e-02
-&lt; 2.580000e-01, 0.000000e+00, 1.372916e-02, 3.546082e-02, 4.918998e-02, 1.012903e-02, -1.494518e-02
-&lt; 2.590000e-01, 0.000000e+00, 1.412721e-02, 3.506277e-02, 4.918998e-02, 1.012752e-02, -1.555234e-02
-&lt; 2.600000e-01, 0.000000e+00, 1.457006e-02, 3.461993e-02, 4.918998e-02, 1.012680e-02, -1.615410e-02
-&lt; 2.610000e-01, 0.000000e+00, 1.505627e-02, 3.413372e-02, 4.918998e-02, 1.012565e-02, -1.674946e-02
-&lt; 2.620000e-01, 0.000000e+00, 1.558422e-02, 3.360577e-02, 4.918998e-02, 1.012379e-02, -1.733757e-02
-&lt; 2.630000e-01, 0.000000e+00, 1.615209e-02, 3.303789e-02, 4.918998e-02, 1.012130e-02, -1.791791e-02
-&lt; 2.640000e-01, 0.000000e+00, 1.675793e-02, 3.243205e-02, 4.918998e-02, 1.011854e-02, -1.849027e-02
-&lt; 2.650000e-01, 0.000000e+00, 1.739960e-02, 3.179038e-02, 4.918998e-02, 1.011531e-02, -1.905389e-02
-&lt; 2.660000e-01, 0.000000e+00, 1.807480e-02, 3.111519e-02, 4.918998e-02, 1.011273e-02, -1.960855e-02
-&lt; 2.670000e-01, 0.000000e+00, 1.878105e-02, 3.040893e-02, 4.918998e-02, 1.011001e-02, -2.015403e-02
-&lt; 2.680000e-01, 0.000000e+00, 1.951576e-02, 2.967422e-02, 4.918998e-02, 1.010703e-02, -2.069011e-02
-&lt; 2.690000e-01, 0.000000e+00, 2.027620e-02, 2.891378e-02, 4.918998e-02, 1.010418e-02, -2.121629e-02
-&lt; 2.700000e-01, 0.000000e+00, 2.105952e-02, 2.813046e-02, 4.918998e-02, 1.010206e-02, -2.173140e-02
-&lt; 2.710000e-01, 0.000000e+00, 2.186275e-02, 2.732723e-02, 4.918998e-02, 1.009948e-02, -2.223456e-02
-&lt; 2.720000e-01, 0.000000e+00, 2.268280e-02, 2.650719e-02, 4.918998e-02, 1.009621e-02, -2.272502e-02
-&lt; 2.730000e-01, 0.000000e+00, 2.351650e-02, 2.567348e-02, 4.918998e-02, 1.009231e-02, -2.320237e-02
-&lt; 2.740000e-01, 0.000000e+00, 2.436063e-02, 2.482935e-02, 4.918998e-02, 1.008809e-02, -2.366644e-02
-&lt; 2.750000e-01, 0.000000e+00, 2.521189e-02, 2.397810e-02, 4.918998e-02, 1.008410e-02, -2.411684e-02
-&lt; 2.760000e-01, 0.000000e+00, 2.606690e-02, 2.312309e-02, 4.918998e-02, 1.008067e-02, -2.455347e-02
-&lt; 2.770000e-01, 0.000000e+00, 2.692225e-02, 2.226773e-02, 4.918998e-02, 1.007683e-02, -2.497616e-02
-&lt; 2.780000e-01, 0.000000e+00, 2.777454e-02, 2.141545e-02, 4.918998e-02, 1.007262e-02, -2.538456e-02
-&lt; 2.790000e-01, 0.000000e+00, 2.862032e-02, 2.056966e-02, 4.918998e-02, 1.006862e-02, -2.577824e-02
-&lt; 2.800000e-01, 0.000000e+00, 2.945617e-02, 1.973382e-02, 4.918998e-02, 1.006538e-02, -2.615627e-02
-&lt; 2.810000e-01, 0.000000e+00, 3.027865e-02, 1.891133e-02, 4.918998e-02, 1.006167e-02, -2.651792e-02
-&lt; 2.820000e-01, 0.000000e+00, 3.108437e-02, 1.810561e-02, 4.918998e-02, 1.005730e-02, -2.686263e-02
-&lt; 2.830000e-01, 0.000000e+00, 3.187000e-02, 1.731999e-02, 4.918998e-02, 1.005230e-02, -2.719011e-02
-&lt; 2.840000e-01, 0.000000e+00, 3.263224e-02, 1.655774e-02, 4.918998e-02, 1.004698e-02, -2.750031e-02
-&lt; 2.850000e-01, 0.000000e+00, 3.336788e-02, 1.582210e-02, 4.918998e-02, 1.004318e-02, -2.779336e-02
-&lt; 2.860000e-01, 0.000000e+00, 3.407378e-02, 1.511620e-02, 4.918998e-02, 1.003881e-02, -2.806916e-02
-&lt; 2.870000e-01, 0.000000e+00, 3.474690e-02, 1.444308e-02, 4.918998e-02, 1.003421e-02, -2.832761e-02
-&lt; 2.880000e-01, 0.000000e+00, 3.538432e-02, 1.380566e-02, 4.918998e-02, 1.002916e-02, -2.856836e-02
-&lt; 2.890000e-01, 0.000000e+00, 3.598325e-02, 1.320673e-02, 4.918998e-02, 1.002443e-02, -2.879091e-02
-&lt; 2.900000e-01, 0.000000e+00, 3.654103e-02, 1.264896e-02, 4.918998e-02, 1.002037e-02, -2.899476e-02
-&lt; 2.910000e-01, 0.000000e+00, 3.705511e-02, 1.213488e-02, 4.918998e-02, 1.001592e-02, -2.917946e-02
-&lt; 2.920000e-01, 0.000000e+00, 3.752315e-02, 1.166684e-02, 4.918998e-02, 1.001085e-02, -2.934460e-02
-&lt; 2.930000e-01, 0.000000e+00, 3.794296e-02, 1.124702e-02, 4.918998e-02, 1.005402e-02, -2.949011e-02
-&lt; 2.940000e-01, 0.000000e+00, 3.831255e-02, 1.087744e-02, 4.918998e-02, 1.009386e-02, -2.961612e-02
-&lt; 2.950000e-01, 0.000000e+00, 3.863007e-02, 1.055991e-02, 4.918998e-02, 1.012284e-02, -2.972291e-02
-&lt; 2.960000e-01, 0.000000e+00, 3.889390e-02, 1.029608e-02, 4.918998e-02, 1.013993e-02, -2.981085e-02
-&lt; 2.970000e-01, 0.000000e+00, 3.910263e-02, 1.008736e-02, 4.918998e-02, 1.015363e-02, -2.987968e-02
-&lt; 2.980000e-01, 0.000000e+00, 3.925505e-02, 9.934932e-03, 4.918998e-02, 1.017050e-02, -2.992914e-02
-&lt; 2.990000e-01, 0.000000e+00, 3.935018e-02, 9.839800e-03, 4.918998e-02, 1.017214e-02, -2.995885e-02
-&lt; 3.000000e-01, 0.000000e+00, 3.938725e-02, 9.802738e-03, 4.918998e-02, 1.015800e-02, -2.996849e-02
-&lt; 3.010000e-01, 0.000000e+00, 3.936570e-02, 9.824283e-03, 4.918998e-02, 1.012737e-02, -2.995815e-02
-&lt; 3.020000e-01, 0.000000e+00, 3.928525e-02, 9.904730e-03, 4.918998e-02, 1.007954e-02, -2.992750e-02
-&lt; 3.030000e-01, 0.000000e+00, 3.914584e-02, 1.004414e-02, 4.918998e-02, 1.001388e-02, -2.987670e-02
-&lt; 3.040000e-01, 0.000000e+00, 3.894763e-02, 1.024235e-02, 4.918998e-02, 1.001571e-02, -2.980613e-02
-&lt; 3.050000e-01, 0.000000e+00, 3.869101e-02, 1.049897e-02, 4.918998e-02, 1.002259e-02, -2.971626e-02
-&lt; 3.060000e-01, 0.000000e+00, 3.837663e-02, 1.081335e-02, 4.918998e-02, 1.001957e-02, -2.960770e-02
-&lt; 3.070000e-01, 0.000000e+00, 3.800538e-02, 1.118461e-02, 4.918998e-02, 1.002385e-02, -2.948014e-02
-&lt; 3.080000e-01, 0.000000e+00, 3.757837e-02, 1.161162e-02, 4.918998e-02, 1.002865e-02, -2.933342e-02
-&lt; 3.090000e-01, 0.000000e+00, 3.709694e-02, 1.209305e-02, 4.918998e-02, 1.003739e-02, -2.916735e-02
-&lt; 3.100000e-01, 0.000000e+00, 3.656265e-02, 1.262733e-02, 4.918998e-02, 1.004385e-02, -2.898197e-02
-&lt; 3.110000e-01, 0.000000e+00, 3.597731e-02, 1.321268e-02, 4.918998e-02, 1.004150e-02, -2.877762e-02
-&lt; 3.120000e-01, 0.000000e+00, 3.534293e-02, 1.384706e-02, 4.918998e-02, 1.004628e-02, -2.855414e-02
-&lt; 3.130000e-01, 0.000000e+00, 3.466173e-02, 1.452825e-02, 4.918998e-02, 1.005062e-02, -2.831197e-02
-&lt; 3.140000e-01, 0.000000e+00, 3.393614e-02, 1.525385e-02, 4.918998e-02, 1.005449e-02, -2.805168e-02
-&lt; 3.150000e-01, 0.000000e+00, 3.316875e-02, 1.602123e-02, 4.918998e-02, 1.006019e-02, -2.777407e-02
-&lt; 3.160000e-01, 0.000000e+00, 3.236238e-02, 1.682760e-02, 4.918998e-02, 1.006416e-02, -2.747964e-02
-&lt; 3.170000e-01, 0.000000e+00, 3.152002e-02, 1.766996e-02, 4.918998e-02, 1.006861e-02, -2.716815e-02
-&lt; 3.180000e-01, 0.000000e+00, 3.064480e-02, 1.854518e-02, 4.918998e-02, 1.007246e-02, -2.683960e-02
-&lt; 3.190000e-01, 0.000000e+00, 2.973999e-02, 1.944999e-02, 4.918998e-02, 1.007579e-02, -2.649401e-02
-&lt; 3.200000e-01, 0.000000e+00, 2.880904e-02, 2.038095e-02, 4.918998e-02, 1.007888e-02, -2.613194e-02
-&lt; 3.210000e-01, 0.000000e+00, 2.785549e-02, 2.133449e-02, 4.918998e-02, 1.008291e-02, -2.575361e-02
-&lt; 3.220000e-01, 0.000000e+00, 2.688303e-02, 2.230695e-02, 4.918998e-02, 1.008663e-02, -2.535920e-02
-&lt; 3.230000e-01, 0.000000e+00, 2.589543e-02, 2.329456e-02, 4.918998e-02, 1.008991e-02, -2.494935e-02
-&lt; 3.240000e-01, 0.000000e+00, 2.489651e-02, 2.429348e-02, 4.918998e-02, 1.009362e-02, -2.452482e-02
-&lt; 3.250000e-01, 0.000000e+00, 2.389020e-02, 2.529978e-02, 4.918998e-02, 1.009772e-02, -2.408679e-02
-&lt; 3.260000e-01, 0.000000e+00, 2.288049e-02, 2.630949e-02, 4.918998e-02, 1.010146e-02, -2.363533e-02
-&lt; 3.270000e-01, 0.000000e+00, 2.187140e-02, 2.731859e-02, 4.918998e-02, 1.010460e-02, -2.317043e-02
-&lt; 3.280000e-01, 0.000000e+00, 2.086694e-02, 2.832304e-02, 4.918998e-02, 1.010714e-02, -2.269224e-02
-&lt; 3.290000e-01, 0.000000e+00, 1.987115e-02, 2.931883e-02, 4.918998e-02, 1.011010e-02, -2.220103e-02
-&lt; 3.300000e-01, 0.000000e+00, 1.888807e-02, 3.030191e-02, 4.918998e-02, 1.011241e-02, -2.169790e-02
-&lt; 3.310000e-01, 0.000000e+00, 1.792171e-02, 3.126827e-02, 4.918998e-02, 1.011420e-02, -2.118268e-02
-&lt; 3.320000e-01, 0.000000e+00, 1.697603e-02, 3.221395e-02, 4.918998e-02, 1.011652e-02, -2.065598e-02
-&lt; 3.330000e-01, 0.000000e+00, 1.605492e-02, 3.313507e-02, 4.918998e-02, 1.011892e-02, -2.011861e-02
-&lt; 3.340000e-01, 0.000000e+00, 1.516219e-02, 3.402779e-02, 4.918998e-02, 1.012187e-02, -1.957154e-02
-&lt; 3.350000e-01, 0.000000e+00, 1.430160e-02, 3.488838e-02, 4.918998e-02, 1.012458e-02, -1.901603e-02
-&lt; 3.360000e-01, 0.000000e+00, 1.347679e-02, 3.571320e-02, 4.918998e-02, 1.012676e-02, -1.845177e-02
-&lt; 3.370000e-01, 0.000000e+00, 1.269124e-02, 3.649875e-02, 4.918998e-02, 1.012829e-02, -1.787902e-02
-&lt; 3.380000e-01, 0.000000e+00, 1.194832e-02, 3.724166e-02, 4.918998e-02, 1.013031e-02, -1.729808e-02
-&lt; 3.390000e-01, 0.000000e+00, 1.125125e-02, 3.793873e-02, 4.918998e-02, 1.013186e-02, -1.670970e-02
-&lt; 3.400000e-01, 0.000000e+00, 1.060310e-02, 3.858689e-02, 4.918998e-02, 1.013268e-02, -1.611469e-02
-&lt; 3.410000e-01, 0.000000e+00, 1.000674e-02, 3.918325e-02, 4.918998e-02, 1.013298e-02, -1.551310e-02
-&lt; 3.420000e-01, 0.000000e+00, 9.464844e-03, 3.972514e-02, 4.918998e-02, 1.013320e-02, -1.490573e-02
-&lt; 3.430000e-01, 0.000000e+00, 8.979894e-03, 4.021009e-02, 4.918998e-02, 1.013469e-02, -1.429347e-02
-&lt; 3.440000e-01, 0.000000e+00, 8.554159e-03, 4.063582e-02, 4.918998e-02, 1.013614e-02, -1.367776e-02
-&lt; 3.450000e-01, 0.000000e+00, 8.189695e-03, 4.100029e-02, 4.918998e-02, 1.013717e-02, -1.305905e-02
-&lt; 3.460000e-01, 0.000000e+00, 7.888311e-03, 4.130167e-02, 4.918998e-02, 1.013758e-02, -1.243730e-02
-&lt; 3.470000e-01, 0.000000e+00, 7.651565e-03, 4.153842e-02, 4.918998e-02, 1.013751e-02, -1.181284e-02
-&lt; 3.480000e-01, 0.000000e+00, 7.480770e-03, 4.170921e-02, 4.918998e-02, 1.013821e-02, -1.118611e-02
-&lt; 3.490000e-01, 0.000000e+00, 7.376997e-03, 4.181299e-02, 4.918998e-02, 1.013821e-02, -1.055843e-02
-&lt; 3.500000e-01, 0.000000e+00, 7.341051e-03, 4.184893e-02, 4.918998e-02, 1.013750e-02, -1.003107e-02
-&lt; 3.510000e-01, 0.000000e+00, 7.373458e-03, 4.181653e-02, 4.918998e-02, 1.013627e-02, -1.065862e-02
-&lt; 3.520000e-01, 0.000000e+00, 7.474469e-03, 4.171552e-02, 4.918998e-02, 1.013518e-02, -1.128578e-02
-&lt; 3.530000e-01, 0.000000e+00, 7.644073e-03, 4.154591e-02, 4.918998e-02, 1.013523e-02, -1.191296e-02
-&lt; 3.540000e-01, 0.000000e+00, 7.881997e-03, 4.130799e-02, 4.918998e-02, 1.013502e-02, -1.253811e-02
-&lt; 3.550000e-01, 0.000000e+00, 8.187683e-03, 4.100230e-02, 4.918998e-02, 1.013426e-02, -1.316034e-02
-&lt; 3.560000e-01, 0.000000e+00, 8.560282e-03, 4.062970e-02, 4.918998e-02, 1.013288e-02, -1.377895e-02
-&lt; 3.570000e-01, 0.000000e+00, 8.998670e-03, 4.019131e-02, 4.918998e-02, 1.013148e-02, -1.439394e-02
-&lt; 3.580000e-01, 0.000000e+00, 9.501471e-03, 3.968851e-02, 4.918998e-02, 1.013060e-02, -1.500524e-02
-&lt; 3.590000e-01, 0.000000e+00, 1.006705e-02, 3.912293e-02, 4.918998e-02, 1.012906e-02, -1.561105e-02
-&lt; 3.600000e-01, 0.000000e+00, 1.069353e-02, 3.849646e-02, 4.918998e-02, 1.012682e-02, -1.621076e-02
-&lt; 3.610000e-01, 0.000000e+00, 1.137872e-02, 3.781126e-02, 4.918998e-02, 1.012410e-02, -1.680396e-02
-&lt; 3.620000e-01, 0.000000e+00, 1.212023e-02, 3.706975e-02, 4.918998e-02, 1.012194e-02, -1.739111e-02
-&lt; 3.630000e-01, 0.000000e+00, 1.291539e-02, 3.627459e-02, 4.918998e-02, 1.012048e-02, -1.797178e-02
-&lt; 3.640000e-01, 0.000000e+00, 1.376132e-02, 3.542866e-02, 4.918998e-02, 1.011861e-02, -1.854427e-02
-&lt; 3.650000e-01, 0.000000e+00, 1.465493e-02, 3.453505e-02, 4.918998e-02, 1.011615e-02, -1.910784e-02
-&lt; 3.660000e-01, 0.000000e+00, 1.559293e-02, 3.359705e-02, 4.918998e-02, 1.011311e-02, -1.966195e-02
-&lt; 3.670000e-01, 0.000000e+00, 1.657185e-02, 3.261814e-02, 4.918998e-02, 1.011062e-02, -2.020716e-02
-&lt; 3.680000e-01, 0.000000e+00, 1.758803e-02, 3.160196e-02, 4.918998e-02, 1.010831e-02, -2.074257e-02
-&lt; 3.690000e-01, 0.000000e+00, 1.863760e-02, 3.055239e-02, 4.918998e-02, 1.010535e-02, -2.126682e-02
-&lt; 3.700000e-01, 0.000000e+00, 1.971650e-02, 2.947348e-02, 4.918998e-02, 1.010176e-02, -2.177939e-02
-&lt; 3.710000e-01, 0.000000e+00, 2.082056e-02, 2.836943e-02, 4.918998e-02, 1.009772e-02, -2.227998e-02
-&lt; 3.720000e-01, 0.000000e+00, 2.194552e-02, 2.724447e-02, 4.918998e-02, 1.009472e-02, -2.276955e-02
-&lt; 3.730000e-01, 0.000000e+00, 2.308708e-02, 2.610291e-02, 4.918998e-02, 1.009187e-02, -2.324675e-02
-&lt; 3.740000e-01, 0.000000e+00, 2.424085e-02, 2.494913e-02, 4.918998e-02, 1.008852e-02, -2.371044e-02
-&lt; 3.750000e-01, 0.000000e+00, 2.540231e-02, 2.378768e-02, 4.918998e-02, 1.008460e-02, -2.416009e-02
-&lt; 3.760000e-01, 0.000000e+00, 2.656678e-02, 2.262320e-02, 4.918998e-02, 1.008022e-02, -2.459537e-02
-&lt; 3.770000e-01, 0.000000e+00, 2.772956e-02, 2.146042e-02, 4.918998e-02, 1.007700e-02, -2.501745e-02
-&lt; 3.780000e-01, 0.000000e+00, 2.888595e-02, 2.030403e-02, 4.918998e-02, 1.007352e-02, -2.542449e-02
-&lt; 3.790000e-01, 0.000000e+00, 3.003135e-02, 1.915864e-02, 4.918998e-02, 1.006943e-02, -2.581575e-02
-&lt; 3.800000e-01, 0.000000e+00, 3.116124e-02, 1.802875e-02, 4.918998e-02, 1.006475e-02, -2.619086e-02
-&lt; 3.810000e-01, 0.000000e+00, 3.227114e-02, 1.691885e-02, 4.918998e-02, 1.005979e-02, -2.654973e-02
-&lt; 3.820000e-01, 0.000000e+00, 3.335654e-02, 1.583345e-02, 4.918998e-02, 1.005617e-02, -2.689365e-02
-&lt; 3.830000e-01, 0.000000e+00, 3.441290e-02, 1.477709e-02, 4.918998e-02, 1.005220e-02, -2.722056e-02
-&lt; 3.840000e-01, 0.000000e+00, 3.543571e-02, 1.375428e-02, 4.918998e-02, 1.004771e-02, -2.752998e-02
-&lt; 3.850000e-01, 0.000000e+00, 3.642064e-02, 1.276934e-02, 4.918998e-02, 1.004273e-02, -2.782162e-02
-&lt; 3.860000e-01, 0.000000e+00, 3.736362e-02, 1.182636e-02, 4.918998e-02, 1.003778e-02, -2.809572e-02
-&lt; 3.870000e-01, 0.000000e+00, 3.826080e-02, 1.092918e-02, 4.918998e-02, 1.003391e-02, -2.835304e-02
-&lt; 3.880000e-01, 0.000000e+00, 3.910848e-02, 1.008151e-02, 4.918998e-02, 1.002963e-02, -2.859183e-02
-&lt; 3.890000e-01, 0.000000e+00, 3.990303e-02, 9.286950e-03, 4.918998e-02, 1.002479e-02, -2.881171e-02
-&lt; 3.900000e-01, 0.000000e+00, 4.064097e-02, 8.549018e-03, 4.918998e-02, 1.001943e-02, -2.901251e-02
-&lt; 3.910000e-01, 0.000000e+00, 4.131896e-02, 7.871019e-03, 4.918998e-02, 1.001437e-02, -2.919482e-02
-&lt; 3.920000e-01, 0.000000e+00, 4.193398e-02, 7.256004e-03, 4.918998e-02, 1.006177e-02, -2.935893e-02
-&lt; 3.930000e-01, 0.000000e+00, 4.248323e-02, 6.706755e-03, 4.918998e-02, 1.011199e-02, -2.950349e-02
-&lt; 3.940000e-01, 0.000000e+00, 4.296419e-02, 6.225797e-03, 4.918998e-02, 1.015046e-02, -2.962829e-02
-&lt; 3.950000e-01, 0.000000e+00, 4.337460e-02, 5.815386e-03, 4.918998e-02, 1.017663e-02, -2.973334e-02
-&lt; 3.960000e-01, 0.000000e+00, 4.371250e-02, 5.477480e-03, 4.918998e-02, 1.019017e-02, -2.981959e-02
-&lt; 3.970000e-01, 0.000000e+00, 4.397626e-02, 5.213723e-03, 4.918998e-02, 1.019834e-02, -2.988681e-02
-&lt; 3.980000e-01, 0.000000e+00, 4.416451e-02, 5.025474e-03, 4.918998e-02, 1.021258e-02, -2.993397e-02
-&lt; 3.990000e-01, 0.000000e+00, 4.427614e-02, 4.913846e-03, 4.918998e-02, 1.021041e-02, -2.996088e-02
-&lt; 4.000000e-01, 0.000000e+00, 4.431026e-02, 4.879723e-03, 4.918998e-02, 1.019127e-02, -2.996761e-02
----
-&gt; time, wext, epot, ekin, total
-&gt; 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00, 0.000000e+00
-&gt; 1.000000e-03, 3.150066e-02, 4.218838e-04, 7.453281e-03, -2.362549e-02
-&gt; 2.000000e-03, 1.192525e-01, 9.239471e-03, 5.826194e-02, -5.175108e-02
-&gt; 3.000000e-03, 2.451748e-01, 5.000320e-02, 1.243353e-01, -7.083630e-02
-&gt; 4.000000e-03, 3.855903e-01, 1.333986e-01, 1.741088e-01, -7.808294e-02
-&gt; 5.000000e-03, 5.184902e-01, 2.347165e-01, 2.094486e-01, -7.432509e-02
-&gt; 6.000000e-03, 6.297949e-01, 3.146627e-01, 2.516047e-01, -6.352752e-02
-&gt; 7.000000e-03, 7.165161e-01, 3.573292e-01, 3.079512e-01, -5.123577e-02
-&gt; 8.000000e-03, 7.859144e-01, 3.788452e-01, 3.644949e-01, -4.257433e-02
-&gt; 9.000000e-03, 8.512332e-01, 4.017200e-01, 4.089786e-01, -4.053454e-02
-&gt; 1.000000e-02, 9.257974e-01, 4.325474e-01, 4.480928e-01, -4.515724e-02
-&gt; 1.100000e-02, 1.017757e+00, 4.683252e-01, 4.955768e-01, -5.385490e-02
-&gt; 1.200000e-02, 1.127365e+00, 5.131100e-01, 5.515759e-01, -6.267943e-02
-&gt; 1.300000e-02, 1.247606e+00, 5.758656e-01, 6.037449e-01, -6.799539e-02
-&gt; 1.400000e-02, 1.367643e+00, 6.533470e-01, 6.464022e-01, -6.789377e-02
-&gt; 1.500000e-02, 1.477531e+00, 7.263791e-01, 6.883326e-01, -6.281901e-02
-&gt; 1.600000e-02, 1.572215e+00, 7.782312e-01, 7.387665e-01, -5.521734e-02
-&gt; 1.700000e-02, 1.653281e+00, 8.111563e-01, 7.937167e-01, -4.840818e-02
-&gt; 1.800000e-02, 1.727882e+00, 8.399669e-01, 8.427397e-01, -4.517579e-02
-&gt; 1.900000e-02, 1.805457e+00, 8.739710e-01, 8.848233e-01, -4.666227e-02
-&gt; 2.000000e-02, 1.893690e+00, 9.123489e-01, 9.293492e-01, -5.199187e-02
-&gt; 2.100000e-02, 1.995420e+00, 9.551186e-01, 9.815613e-01, -5.874022e-02
-&gt; 2.200000e-02, 2.107699e+00, 1.008724e+00, 1.034961e+00, -6.401474e-02
-&gt; 2.300000e-02, 2.223299e+00, 1.076041e+00, 1.081583e+00, -6.567493e-02
-&gt; 2.400000e-02, 2.333920e+00, 1.146764e+00, 1.123970e+00, -6.318554e-02
-&gt; 2.500000e-02, 2.433705e+00, 1.205037e+00, 1.170900e+00, -5.776797e-02
-&gt; 2.600000e-02, 2.521589e+00, 1.245801e+00, 1.223971e+00, -5.181722e-02
-&gt; 2.700000e-02, 2.601550e+00, 1.278193e+00, 1.275502e+00, -4.785548e-02
-&gt; 2.800000e-02, 2.680748e+00, 1.312854e+00, 1.320419e+00, -4.747410e-02
-&gt; 2.900000e-02, 2.766404e+00, 1.351922e+00, 1.363778e+00, -5.070332e-02
-&gt; 3.000000e-02, 2.862766e+00, 1.393913e+00, 1.412797e+00, -5.605629e-02
-&gt; 3.100000e-02, 2.969426e+00, 1.442294e+00, 1.465927e+00, -6.120507e-02
-&gt; 3.200000e-02, 3.081646e+00, 1.502179e+00, 1.515482e+00, -6.398533e-02
-&gt; 3.300000e-02, 3.192495e+00, 1.569786e+00, 1.559409e+00, -6.329939e-02
-&gt; 3.400000e-02, 3.295832e+00, 1.632086e+00, 1.604202e+00, -5.954346e-02
-&gt; 3.500000e-02, 3.388872e+00, 1.679625e+00, 1.654852e+00, -5.439525e-02
-&gt; 3.600000e-02, 3.473261e+00, 1.715823e+00, 1.707368e+00, -5.006997e-02
-&gt; 3.700000e-02, 3.554256e+00, 1.750827e+00, 1.755056e+00, -4.837239e-02
-&gt; 3.800000e-02, 3.638402e+00, 1.789755e+00, 1.798698e+00, -4.994819e-02
-&gt; 3.900000e-02, 3.730739e+00, 1.831530e+00, 1.845165e+00, -5.404359e-02
-&gt; 4.000000e-02, 3.832709e+00, 1.876969e+00, 1.896879e+00, -5.886046e-02
-&gt; 4.100000e-02, 3.941643e+00, 1.931030e+00, 1.948271e+00, -6.234195e-02
-&gt; 4.200000e-02, 4.051987e+00, 1.994543e+00, 1.994397e+00, -6.304718e-02
-&gt; 4.300000e-02, 4.157725e+00, 2.058583e+00, 2.038398e+00, -6.074442e-02
-&gt; 4.400000e-02, 4.254935e+00, 2.111901e+00, 2.086554e+00, -5.647989e-02
-&gt; 4.500000e-02, 4.343396e+00, 2.152578e+00, 2.138712e+00, -5.210559e-02
-&gt; 4.600000e-02, 4.426601e+00, 2.188457e+00, 2.188666e+00, -4.947785e-02
-&gt; 4.700000e-02, 4.510195e+00, 2.226839e+00, 2.233684e+00, -4.967221e-02
-&gt; 4.800000e-02, 4.599536e+00, 2.268423e+00, 2.278567e+00, -5.254556e-02
-&gt; 4.900000e-02, 4.697431e+00, 2.312388e+00, 2.328220e+00, -5.682287e-02
-&gt; 5.000000e-02, 4.803003e+00, 2.362124e+00, 2.380218e+00, -6.066077e-02
-&gt; 5.100000e-02, 4.912132e+00, 2.421059e+00, 2.428633e+00, -6.243976e-02
-&gt; 5.200000e-02, 5.019273e+00, 2.484741e+00, 2.473086e+00, -6.144568e-02
-&gt; 5.300000e-02, 5.119831e+00, 2.542466e+00, 2.519211e+00, -5.815432e-02
-&gt; 5.400000e-02, 5.212094e+00, 2.588089e+00, 2.569998e+00, -5.400672e-02
-&gt; 5.500000e-02, 5.297904e+00, 2.625811e+00, 2.621313e+00, -5.077997e-02
-&gt; 5.600000e-02, 5.381808e+00, 2.663685e+00, 2.668296e+00, -4.982750e-02
-&gt; 5.700000e-02, 5.469084e+00, 2.704824e+00, 2.712747e+00, -5.151287e-02
-&gt; 5.800000e-02, 5.563480e+00, 2.748131e+00, 2.760276e+00, -5.507343e-02
-&gt; 5.900000e-02, 5.665658e+00, 2.794971e+00, 2.811722e+00, -5.896376e-02
-&gt; 6.000000e-02, 5.772957e+00, 2.849465e+00, 2.861968e+00, -6.152507e-02
-&gt; 6.100000e-02, 5.880589e+00, 2.911095e+00, 2.907803e+00, -6.169114e-02
-&gt; 6.200000e-02, 5.983701e+00, 2.971504e+00, 2.952767e+00, -5.943097e-02
-&gt; 6.300000e-02, 6.079440e+00, 3.022033e+00, 3.001663e+00, -5.574486e-02
-&gt; 6.400000e-02, 6.168136e+00, 3.062666e+00, 3.053247e+00, -5.222285e-02
-&gt; 6.500000e-02, 6.253105e+00, 3.100533e+00, 3.102212e+00, -5.035999e-02
-&gt; 6.600000e-02, 6.339201e+00, 3.140966e+00, 3.147312e+00, -5.092279e-02
-&gt; 6.700000e-02, 6.430720e+00, 3.183894e+00, 3.193191e+00, -5.363483e-02
-&gt; 6.800000e-02, 6.529590e+00, 3.229041e+00, 3.243239e+00, -5.731016e-02
-&gt; 6.900000e-02, 6.634582e+00, 3.279749e+00, 3.294462e+00, -6.037095e-02
-&gt; 7.000000e-02, 6.741879e+00, 3.338231e+00, 3.342124e+00, -6.152392e-02
-&gt; 7.100000e-02, 6.846741e+00, 3.399465e+00, 3.386970e+00, -6.030591e-02
-&gt; 7.200000e-02, 6.945528e+00, 3.454246e+00, 3.434013e+00, -5.726888e-02
-&gt; 7.300000e-02, 7.037239e+00, 3.498652e+00, 3.484857e+00, -5.373083e-02
-&gt; 7.400000e-02, 7.123898e+00, 3.537389e+00, 3.535305e+00, -5.120459e-02
-&gt; 7.500000e-02, 7.209651e+00, 3.577080e+00, 3.581820e+00, -5.075175e-02
-&gt; 7.600000e-02, 7.298976e+00, 3.619546e+00, 3.626892e+00, -5.253725e-02
-&gt; 7.700000e-02, 7.394768e+00, 3.663824e+00, 3.675172e+00, -5.577127e-02
-&gt; 7.800000e-02, 7.497133e+00, 3.711703e+00, 3.726372e+00, -5.905786e-02
-&gt; 7.900000e-02, 7.603376e+00, 3.766613e+00, 3.775767e+00, -6.099684e-02
-&gt; 8.000000e-02, 7.709185e+00, 3.826968e+00, 3.821437e+00, -6.077963e-02
-&gt; 8.100000e-02, 7.810487e+00, 3.884807e+00, 3.867154e+00, -5.852588e-02
-&gt; 8.200000e-02, 7.905178e+00, 3.933388e+00, 3.916569e+00, -5.522081e-02
-&gt; 8.300000e-02, 7.993998e+00, 3.974049e+00, 3.967664e+00, -5.228515e-02
-&gt; 8.400000e-02, 8.080178e+00, 4.013324e+00, 4.015889e+00, -5.096498e-02
-&gt; 8.500000e-02, 8.168034e+00, 4.055115e+00, 4.061116e+00, -5.180336e-02
-&gt; 8.600000e-02, 8.261119e+00, 4.098922e+00, 4.107779e+00, -5.441757e-02
-&gt; 8.700000e-02, 8.360715e+00, 4.144965e+00, 4.158077e+00, -5.767297e-02
-&gt; 8.800000e-02, 8.465314e+00, 4.196490e+00, 4.208649e+00, -6.017499e-02
-&gt; 8.900000e-02, 8.571296e+00, 4.254672e+00, 4.255758e+00, -6.086604e-02
-&gt; 9.000000e-02, 8.674490e+00, 4.314039e+00, 4.300978e+00, -5.947208e-02
-&gt; 9.100000e-02, 8.771960e+00, 4.366608e+00, 4.348742e+00, -5.661051e-02
-&gt; 9.200000e-02, 8.863245e+00, 4.410167e+00, 4.399561e+00, -5.351719e-02
-&gt; 9.300000e-02, 8.950521e+00, 4.449718e+00, 4.449289e+00, -5.151316e-02
-&gt; 9.400000e-02, 9.037652e+00, 4.490724e+00, 4.495488e+00, -5.144089e-02
-&gt; 9.500000e-02, 9.128523e+00, 4.534096e+00, 4.541117e+00, -5.331053e-02
-&gt; 9.600000e-02, 9.225381e+00, 4.579105e+00, 4.589972e+00, -5.630447e-02
-&gt; 9.700000e-02, 9.327900e+00, 4.627868e+00, 4.640897e+00, -5.913451e-02
-&gt; 9.800000e-02, 9.433341e+00, 4.683149e+00, 4.689596e+00, -6.059572e-02
-&gt; 9.900000e-02, 9.537749e+00, 4.742463e+00, 4.735207e+00, -6.007910e-02
-&gt; 1.000000e-01, 9.637649e+00, 4.798244e+00, 4.781579e+00, -5.782502e-02
-&gt; 1.010000e-01, 9.731523e+00, 4.845346e+00, 4.831364e+00, -5.481216e-02
-&gt; 1.020000e-01, 9.820438e+00, 4.886116e+00, 4.881989e+00, -5.233289e-02
-&gt; 1.030000e-01, 9.907566e+00, 4.926500e+00, 4.929627e+00, -5.143929e-02
-&gt; 1.040000e-01, 9.996810e+00, 4.969274e+00, 4.975039e+00, -5.249701e-02
-&gt; 1.050000e-01, 1.009113e+01, 5.013727e+00, 5.022368e+00, -5.503606e-02
-&gt; 1.060000e-01, 1.019130e+01, 5.060542e+00, 5.072799e+00, -5.795928e-02
-&gt; 1.070000e-01, 1.029558e+01, 5.112788e+00, 5.122778e+00, -6.001613e-02
-&gt; 1.080000e-01, 1.040051e+01, 5.170695e+00, 5.169474e+00, -6.033736e-02
-&gt; 1.090000e-01, 1.050236e+01, 5.228473e+00, 5.215085e+00, -5.880209e-02
-&gt; 1.100000e-01, 1.059877e+01, 5.279253e+00, 5.263440e+00, -5.608237e-02
-&gt; 1.110000e-01, 1.068972e+01, 5.322221e+00, 5.314153e+00, -5.334932e-02
-&gt; 1.120000e-01, 1.077751e+01, 5.362493e+00, 5.363249e+00, -5.176910e-02
-&gt; 1.130000e-01, 1.086577e+01, 5.404514e+00, 5.409252e+00, -5.200557e-02
-&gt; 1.140000e-01, 1.095790e+01, 5.448551e+00, 5.455412e+00, -5.394170e-02
-&gt; 1.150000e-01, 1.105563e+01, 5.494178e+00, 5.504713e+00, -5.673637e-02
-&gt; 1.160000e-01, 1.115826e+01, 5.543743e+00, 5.555323e+00, -5.918958e-02
-&gt; 1.170000e-01, 1.126302e+01, 5.599329e+00, 5.603434e+00, -6.025745e-02
-&gt; 1.180000e-01, 1.136626e+01, 5.657689e+00, 5.649078e+00, -5.949615e-02
-&gt; 1.190000e-01, 1.146500e+01, 5.711712e+00, 5.696046e+00, -5.724616e-02
-&gt; 1.200000e-01, 1.155821e+01, 5.757653e+00, 5.746081e+00, -5.448025e-02
-&gt; 1.210000e-01, 1.164723e+01, 5.798613e+00, 5.796234e+00, -5.238321e-02
-&gt; 1.220000e-01, 1.173517e+01, 5.839922e+00, 5.843403e+00, -5.184449e-02
-&gt; 1.230000e-01, 1.182558e+01, 5.883442e+00, 5.889059e+00, -5.308121e-02
-&gt; 1.240000e-01, 1.192093e+01, 5.928415e+00, 5.936968e+00, -5.555100e-02
-&gt; 1.250000e-01, 1.202156e+01, 5.975942e+00, 5.987430e+00, -5.818966e-02
-&gt; 1.260000e-01, 1.212555e+01, 6.028830e+00, 6.036852e+00, -5.986951e-02
-&gt; 1.270000e-01, 1.222956e+01, 6.086429e+00, 6.083253e+00, -5.988111e-02
-&gt; 1.280000e-01, 1.233028e+01, 6.142769e+00, 6.129276e+00, -5.823269e-02
-&gt; 1.290000e-01, 1.242581e+01, 6.192051e+00, 6.178117e+00, -5.564098e-02
-&gt; 1.300000e-01, 1.251650e+01, 6.234626e+00, 6.228653e+00, -5.321975e-02
-&gt; 1.310000e-01, 1.260475e+01, 6.275567e+00, 6.277183e+00, -5.200136e-02
-&gt; 1.320000e-01, 1.269399e+01, 6.318403e+00, 6.323095e+00, -5.249677e-02
-&gt; 1.330000e-01, 1.278721e+01, 6.362953e+00, 6.369772e+00, -5.448143e-02
-&gt; 1.340000e-01, 1.288565e+01, 6.409147e+00, 6.419406e+00, -5.709673e-02
-&gt; 1.350000e-01, 1.298834e+01, 6.459458e+00, 6.469663e+00, -5.922128e-02
-&gt; 1.360000e-01, 1.309249e+01, 6.515267e+00, 6.517276e+00, -5.995159e-02
-&gt; 1.370000e-01, 1.319472e+01, 6.572695e+00, 6.563036e+00, -5.898611e-02
-&gt; 1.380000e-01, 1.329247e+01, 6.625164e+00, 6.610552e+00, -5.674952e-02
-&gt; 1.390000e-01, 1.338513e+01, 6.670191e+00, 6.660730e+00, -5.420614e-02
-&gt; 1.400000e-01, 1.347427e+01, 6.711412e+00, 6.710409e+00, -5.244428e-02
-&gt; 1.410000e-01, 1.356294e+01, 6.753515e+00, 6.757212e+00, -5.221072e-02
-&gt; 1.420000e-01, 1.365438e+01, 6.797616e+00, 6.803165e+00, -5.359434e-02
-&gt; 1.430000e-01, 1.375061e+01, 6.843042e+00, 6.851576e+00, -5.599280e-02
-&gt; 1.440000e-01, 1.385161e+01, 6.891253e+00, 6.901981e+00, -5.837467e-02
-&gt; 1.450000e-01, 1.395530e+01, 6.944704e+00, 6.950878e+00, -5.972281e-02
-&gt; 1.460000e-01, 1.405849e+01, 7.001935e+00, 6.997088e+00, -5.946859e-02
-&gt; 1.470000e-01, 1.415820e+01, 7.056932e+00, 7.043541e+00, -5.773160e-02
-&gt; 1.480000e-01, 1.425298e+01, 7.104943e+00, 7.092775e+00, -5.526385e-02
-&gt; 1.490000e-01, 1.434348e+01, 7.147287e+00, 7.143069e+00, -5.312434e-02
-&gt; 1.500000e-01, 1.443218e+01, 7.188858e+00, 7.191096e+00, -5.222471e-02
-&gt; 1.510000e-01, 1.452231e+01, 7.232359e+00, 7.237011e+00, -5.294093e-02
-&gt; 1.520000e-01, 1.461647e+01, 7.277329e+00, 7.284188e+00, -5.495634e-02
-&gt; 1.530000e-01, 1.471553e+01, 7.324069e+00, 7.334055e+00, -5.740144e-02
-&gt; 1.540000e-01, 1.481823e+01, 7.375079e+00, 7.383926e+00, -5.922896e-02
-&gt; 1.550000e-01, 1.492181e+01, 7.431019e+00, 7.431126e+00, -5.966223e-02
-&gt; 1.560000e-01, 1.502311e+01, 7.487508e+00, 7.477074e+00, -5.852518e-02
-&gt; 1.570000e-01, 1.511998e+01, 7.538583e+00, 7.525088e+00, -5.631367e-02
-&gt; 1.580000e-01, 1.521219e+01, 7.582899e+00, 7.575314e+00, -5.397933e-02
-&gt; 1.590000e-01, 1.530148e+01, 7.624441e+00, 7.624522e+00, -5.252020e-02
-&gt; 1.600000e-01, 1.539084e+01, 7.667232e+00, 7.671055e+00, -5.255414e-02
-&gt; 1.610000e-01, 1.548321e+01, 7.711799e+00, 7.717348e+00, -5.405729e-02
-&gt; 1.620000e-01, 1.558021e+01, 7.757645e+00, 7.766188e+00, -5.637828e-02
-&gt; 1.630000e-01, 1.568150e+01, 7.806525e+00, 7.816457e+00, -5.852042e-02
-&gt; 1.640000e-01, 1.578489e+01, 7.860457e+00, 7.864864e+00, -5.956955e-02
-&gt; 1.650000e-01, 1.588731e+01, 7.917245e+00, 7.910980e+00, -5.908412e-02
-&gt; 1.660000e-01, 1.598612e+01, 7.970965e+00, 7.957874e+00, -5.728085e-02
-&gt; 1.670000e-01, 1.608025e+01, 8.017899e+00, 8.007409e+00, -5.493821e-02
-&gt; 1.680000e-01, 1.617062e+01, 8.060149e+00, 8.057407e+00, -5.306043e-02
-&gt; 1.690000e-01, 1.625976e+01, 8.102317e+00, 8.104996e+00, -5.244710e-02
-&gt; 1.700000e-01, 1.635072e+01, 8.146365e+00, 8.150998e+00, -5.335278e-02
-&gt; 1.710000e-01, 1.644573e+01, 8.191696e+00, 8.198651e+00, -5.538152e-02
-&gt; 1.720000e-01, 1.654530e+01, 8.238982e+00, 8.248656e+00, -5.765981e-02
-&gt; 1.730000e-01, 1.664797e+01, 8.290641e+00, 8.298119e+00, -5.921261e-02
-&gt; 1.740000e-01, 1.675098e+01, 8.346612e+00, 8.344990e+00, -5.938058e-02
-&gt; 1.750000e-01, 1.685143e+01, 8.402145e+00, 8.391188e+00, -5.809992e-02
-&gt; 1.760000e-01, 1.694753e+01, 8.451962e+00, 8.439647e+00, -5.592621e-02
-&gt; 1.770000e-01, 1.703937e+01, 8.495745e+00, 8.489833e+00, -5.379348e-02
-&gt; 1.780000e-01, 1.712885e+01, 8.537653e+00, 8.538581e+00, -5.261296e-02
-&gt; 1.790000e-01, 1.721886e+01, 8.581044e+00, 8.584937e+00, -5.288378e-02
-&gt; 1.800000e-01, 1.731208e+01, 8.625992e+00, 8.631604e+00, -5.448208e-02
-&gt; 1.810000e-01, 1.740976e+01, 8.672250e+00, 8.680795e+00, -5.671738e-02
-&gt; 1.820000e-01, 1.751127e+01, 8.721784e+00, 8.730859e+00, -5.863081e-02
-&gt; 1.830000e-01, 1.761434e+01, 8.776110e+00, 8.778820e+00, -5.940635e-02
-&gt; 1.840000e-01, 1.771602e+01, 8.832375e+00, 8.824930e+00, -5.871878e-02
-&gt; 1.850000e-01, 1.781401e+01, 8.884879e+00, 8.872264e+00, -5.686993e-02
-&gt; 1.860000e-01, 1.790758e+01, 8.930907e+00, 8.922012e+00, -5.465633e-02
-&gt; 1.870000e-01, 1.799788e+01, 8.973178e+00, 8.971673e+00, -5.302608e-02
-&gt; 1.880000e-01, 1.808747e+01, 9.015908e+00, 9.018892e+00, -5.267286e-02
-&gt; 1.890000e-01, 1.817920e+01, 9.060409e+00, 9.065054e+00, -5.374083e-02
-&gt; 1.900000e-01, 1.827499e+01, 9.106068e+00, 9.113152e+00, -5.576598e-02
-&gt; 1.910000e-01, 1.837499e+01, 9.153908e+00, 9.163205e+00, -5.787760e-02
-&gt; 1.920000e-01, 1.847759e+01, 9.206163e+00, 9.212250e+00, -5.917263e-02
-&gt; 1.930000e-01, 1.858004e+01, 9.262061e+00, 9.258876e+00, -5.910178e-02
-&gt; 1.940000e-01, 1.867969e+01, 9.316617e+00, 9.305374e+00, -5.770242e-02
-&gt; 1.950000e-01, 1.877510e+01, 9.365305e+00, 9.354218e+00, -5.557959e-02
-&gt; 1.960000e-01, 1.886664e+01, 9.408709e+00, 9.404287e+00, -5.364448e-02
-&gt; 1.970000e-01, 1.895634e+01, 9.451017e+00, 9.452597e+00, -5.272333e-02
-&gt; 1.980000e-01, 1.904700e+01, 9.494928e+00, 9.498863e+00, -5.320476e-02
-&gt; 1.990000e-01, 1.914100e+01, 9.540198e+00, 9.545924e+00, -5.487587e-02
-&gt; 2.000000e-01, 1.923928e+01, 9.586875e+00, 9.595389e+00, -5.701627e-02
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_reassign_material_4</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_reassign_material_4</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_reassign_material" "-e" "./test_solid_mechanics_model_reassign_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "4"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.843706</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>4</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_reassign_material" "-e" "./test_solid_mechanics_model_reassign_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "4"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_reassign_material for 4 procs
-Run /usr/bin/mpiexec -n 4 ./test_solid_mechanics_model_reassign_material
-OK: test passed!
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_reassign_material_2</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_reassign_material_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_reassign_material" "-e" "./test_solid_mechanics_model_reassign_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "2"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.845113</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_reassign_material" "-e" "./test_solid_mechanics_model_reassign_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "2"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_reassign_material for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_solid_mechanics_model_reassign_material
-OK: test passed!
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_reassign_material_1</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_reassign_material_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_reassign_material" "-e" "./test_solid_mechanics_model_reassign_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "1"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.824965</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_reassign_material" "-e" "./test_solid_mechanics_model_reassign_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "1"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_reassign_material for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_solid_mechanics_model_reassign_material
-OK: test passed!
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_material_eigenstrain</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_material_eigenstrain</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_material_eigenstrain" "-e" "./test_solid_mechanics_model_material_eigenstrain" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.894954</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_material_eigenstrain" "-e" "./test_solid_mechanics_model_material_eigenstrain" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_material_eigenstrain
-Run ./test_solid_mechanics_model_material_eigenstrain
-&lt;1690&gt;[R0|S1] {1547131924190753} /!\ No parameter named Plane_Stress registered in solid_mechanics_model:0:elastic. (parseParam(): /home/jenkins/workspace/akantu-private-master-5327/src/io/parser/parsable.cc:64)
-Node 11
-Node 25
-Node 2
-Node 24
-Node 10
-Node 32
-Node 8
-Node 23
-Node 29
-Node 16
-Node 6
-Node 7
-Node 9
-Node 3
-Node 31
-Node 34
-Node 17
-Node 20
-Node 22
-Node 0
-Node 30
-Node 33
-Node 18
-Node 37
-Node 36
-Node 19
-Node 15
-Node 12
-Node 4
-Node 21
-Node 5
-Node 27
-Node 1
-Node 13
-Node 35
-Node 28
-Node 26
-Node 14
-Converged in 1 (6.89868e-05)
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_selector</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_material_selector</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_selector" "-e" "./test_material_selector" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.799309</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_selector" "-e" "./test_material_selector" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_material_selector
-Run ./test_material_selector
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_solid_mechanics_model_gtest_4</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_gtest_4</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_gtest" "-e" "./test_solid_mechanics_model_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "4" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Timeout</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>0</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1500.11</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>4</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_gtest" "-e" "./test_solid_mechanics_model_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "4" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_gtest for 4 procs
-Run /usr/bin/mpiexec -n 4 ./test_solid_mechanics_model_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml
-[==========] Running 24 tests from 24 test cases.
-[----------] Global test environment set-up.
-[----------] 1 test from TestSMMFixtureBarExplicit/0, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;
-[ RUN ] TestSMMFixtureBarExplicit/0.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/0.Dynamics (335 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/0 (335 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/1, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)10&gt;
-[ RUN ] TestSMMFixtureBarExplicit/1.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/1.Dynamics (388 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/1 (388 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/2, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)11&gt;
-[ RUN ] TestSMMFixtureBarExplicit/2.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/2.Dynamics (618 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/2 (618 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/3, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)12&gt;
-[ RUN ] TestSMMFixtureBarExplicit/3.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/3.Dynamics (1330 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/3 (1330 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/4, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)13&gt;
-[ RUN ] TestSMMFixtureBarExplicit/4.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/4.Dynamics (296 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/4 (296 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/5, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)14&gt;
-[ RUN ] TestSMMFixtureBarExplicit/5.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/5.Dynamics (574 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/5 (574 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/6, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)15&gt;
-[ RUN ] TestSMMFixtureBarExplicit/6.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/6.Dynamics (2341 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/6 (2341 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/7, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)16&gt;
-[ RUN ] TestSMMFixtureBarExplicit/7.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/7.Dynamics (9453 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/7 (9453 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/8, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)17&gt;
-[ RUN ] TestSMMFixtureBarExplicit/8.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/8.Dynamics (1577 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/8 (1577 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/9, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)18&gt;
-[ RUN ] TestSMMFixtureBarExplicit/9.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/9.Dynamics (5443 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/9 (5443 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/10, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)19&gt;
-[ RUN ] TestSMMFixtureBarExplicit/10.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/10.Dynamics (583 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/10 (583 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/11, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)20&gt;
-[ RUN ] TestSMMFixtureBarExplicit/11.Dynamics
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_gtest_2</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_gtest_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_gtest" "-e" "./test_solid_mechanics_model_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>218.773</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_gtest" "-e" "./test_solid_mechanics_model_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_gtest for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_solid_mechanics_model_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml
-[==========] Running 24 tests from 24 test cases.
-[----------] Global test environment set-up.
-[----------] 1 test from TestSMMFixtureBarExplicit/0, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;
-[ RUN ] TestSMMFixtureBarExplicit/0.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/0.Dynamics (282 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/0 (282 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/1, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)10&gt;
-[ RUN ] TestSMMFixtureBarExplicit/1.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/1.Dynami...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_gtest_1</Name>
- <Path>./test/test_model/test_solid_mechanics_model</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_gtest_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_gtest" "-e" "./test_solid_mechanics_model_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>299.495</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_gtest" "-e" "./test_solid_mechanics_model_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model
-Executing the test test_solid_mechanics_model_gtest for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_solid_mechanics_model_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_gtest.xml
-[==========] Running 24 tests from 24 test cases.
-[----------] Global test environment set-up.
-[----------] 1 test from TestSMMFixtureBarExplicit/0, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;
-[ RUN ] TestSMMFixtureBarExplicit/0.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/0.Dynamics (231 ms)
-[----------] 1 test from TestSMMFixtureBarExplicit/0 (231 ms total)
-
-[----------] 1 test from TestSMMFixtureBarExplicit/1, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)10&gt;
-[ RUN ] TestSMMFixtureBarExplicit/1.Dynamics
-[ OK ] TestSMMFixtureBarExplicit/1.Dynami...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_local_material</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_local_material</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_local_material" "-e" "./test_local_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>8.16498</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_local_material" "-e" "./test_local_material" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials
-Executing the test test_local_material
-Run ./test_local_material
-Material local_damage [
- --p E [Young's modulus] : 4e+10
- rwp Sd : 2.748e+06
- rwp Yd : 100000
- r-p finite_deformation [Is finite deformation] : false
- iii inelastic_deformation [Is inelastic deformation] : false
- r-- kapa [Bulk coefficient] : 3.33333e+10
- r-- lambda [First Lamé coefficient] : 2.30769e+10
- r-- mu [Second Lamé coefficient] : 1.53846e+10
- r-p name : concrete
- --p nu [Poisson's ratio] : 0.3
- rwp rho [Density] : 3000
-]
-
-element 104 is correctly broken
-element 174 is correctly broken
-element 261 is correctly broken
-elemen...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_interpolate_stress</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_interpolate_stress</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_interpolate_stress" "-e" "./test_interpolate_stress" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>2.1274</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_interpolate_stress" "-e" "./test_interpolate_stress" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials
-Executing the test test_interpolate_stress
-Run ./test_interpolate_stress
-OK: Stress interpolation test passed.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_orthotropic</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_orthotropic</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_orthotropic" "-e" "./test_material_orthotropic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>60.2664</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_orthotropic" "-e" "./test_material_orthotropic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials
-Executing the test test_material_orthotropic
-Run ./test_material_orthotropic
-Solid Mechanics Model [
- + id : solid_mechanics_model
- + spatial dimension : 2
- + fem [
- FEEngineTemplate [
- + parent [
- FEEngine [
- + id : solid_mechanics_model:fem:SolidMechanicsFEEngine0
- + element dimension : 2
- + mesh [
- Mesh [
- + id : mesh
- + spatial dimension : 2
- + nodes [
- Array&lt;double&gt; [
- + id : mesh:coordinates
- + size : 3436
- + nb_component : 2
- + allocated size : 3436
- + memory size : 429.50KiByte
- + address : 0x55b25aad2020
- ]
- + connectivities [
- ElementTypeMapArray&lt;unsigned int&gt; [
- (not_ghost:_segment_2) [
- Array&lt;unsigned int&gt; [
- + id ...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_material_mazars</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_mazars</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_mazars" "-e" "./test_material_mazars" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Failed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>134</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.767223</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_mazars" "-e" "./test_material_mazars" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials
-Executing the test test_material_mazars
-Run ./test_material_mazars
-(terminate_handler(): /home/jenkins/workspace/akantu-private-master-5327/src/common/aka_error.cc:235)!! Uncaught exception of type akantu::debug::AssertException !!
-what(): "assert [this-&gt;size_ &gt; 0] The array "mesh:nodes_flags" is empty"
-[5b4962022198:03203] *** Process received signal ***
-[5b4962022198:03203] Signal: Aborted (6)
-[5b4962022198:03203] Signal code: (-6)
-[5b4962022198:03203] [ 0] /lib/x86_64-linux-gnu/libc.so.6(+0x378e0)[0x7fe6f6afc8e0]
-[5b4962022198:03203] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b)[0x7fe6f6afc85b]
-[5b4962022198:03203] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7fe6f6ae7535]
-[5b4962022198:03203] [ 3] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x8c63f)[0x7fe6f6eb163f]
-[5b4962022198:03203] [ 4] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x928d1)[0x7fe6f6eb78d1]
-[5b4962022198:03203] [ 5] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x92b04)[0x7fe6f6eb7b04]
-[5b4962022198:03203] [ 6] ./test_material_mazars(_ZNK6akantu5debug8Debugger20throwCustomExceptionINS0_15AssertExceptionEEEvRKT_RKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEESE_j+0x90)[0x561eecfa9ef0]
-[5b4962022198:03203] [ 7] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu5ArrayINS_8NodeFlagELb0EEclEjj+0x1b1)[0x7fe6faee943b]
-[5b4962022198:03203] [ 8] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNK6akantu4Mesh19isLocalOrMasterNodeEj+0x3a)[0x7fe6faedd29e]
-[5b4962022198:03203] [ 9] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(+0x16dc38d)[0x7fe6fb31838d]
-[5b4962022198:03203] [10] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu10DOFManager20registerDOFsInternalERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArrayIdLb1EEE+0x27e)[0x7fe6fb318818]
-[5b4962022198:03203] [11] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu10DOFManager12registerDOFsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArrayIdLb1EEERKNS_14DOFSupportTypeE+0x60)[0x7fe6fb318e80]
-[5b4962022198:03203] [12] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu17DOFManagerDefault12registerDOFsERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEERNS_5ArrayIdLb1EEERKNS_14DOFSupportTypeE+0x4a)[0x7fe6fb327502]
-[5b4962022198:03203] [13] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModel10initSolverENS_18TimeStepSolverTypeENS_19NonLinearSolverTypeE+0x4c8)[0x7fe6fb4c9c98]
-[5b4962022198:03203] [14] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu11ModelSolver12getNewSolverERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEENS_18TimeStepSolverTypeENS_19NonLinearSolverTypeE+0x243)[0x7fe6fb34c499]
-[5b4962022198:03203] [15] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu5Model13initNewSolverERKNS_14AnalysisMethodE+0xff)[0x7fe6fb3740cd]
-[5b4962022198:03203] [16] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu5Model12initFullImplERKNS_12ModelOptionsE+0x20c)[0x7fe6fb373d52]
-[5b4962022198:03203] [17] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModel12initFullImplERKNS_12ModelOptionsE+0x128)[0x7fe6fb4c8dfa]
-[5b4962022198:03203] [18] ./test_material_mazars(_ZN6akantu5Model8initFullIJEEENSt9enable_ifIXsrN3aka11conjunctionIJDpNS_17is_named_argumentINSt5decayIT_E4typeEEEEEE5valueEvE4typeEDpOS7_+0x4d)[0x561eecfab8f5]
-[5b4962022198:03203] [19] ./test_material_mazars(main+0x80f)[0x561eecfa3ea5]
-[5b4962022198:03203] [20] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xeb)[0x7fe6f6ae909b]
-[5b4962022198:03203] [21] ./test_material_mazars(_start+0x2a)[0x561eecfa35da]
-[5b4962022198:03203] *** End of error message ***
-/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh: line 26: 3203 Aborted (core dumped) $*
- 3204 Done | tee "${name}${sout}"
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_multi_material_elastic</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_multi_material_elastic</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_multi_material_elastic" "-e" "./test_multi_material_elastic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.813588</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_multi_material_elastic" "-e" "./test_multi_material_elastic" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials
-Executing the test test_multi_material_elastic
-Run ./test_multi_material_elastic
-&lt;3219&gt;[R0|S1] {1547134015573895} /!\ The group corner does not contain only boundaries elements (applyBC(): /home/jenkins/workspace/akantu-private-master-5327/src/model/boundary_condition_tmpl.hh:222)
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_gtest</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_gtest</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_gtest" "-e" "./test_material_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_material_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.822818</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_gtest" "-e" "./test_material_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_material_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials
-Executing the test test_material_gtest
-Run ./test_material_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_material_gtest.xml
-[==========] Running 32 tests from 11 test cases.
-[----------] Global test environment set-up.
-[----------] 4 tests from TestElasticMaterialFixture/0, where TypeParam = Traits&lt;akantu::MaterialElastic, 1u&gt;
-[ RUN ] TestElasticMaterialFixture/0.ComputeStress
-[ OK ] TestElasticMaterialFixture/0.ComputeStress (3 ms)
-[ RUN ] TestElasticMaterialFixture/0.EnergyDensity
-[ OK ] TestElasticMaterialFixture/0.EnergyDensity (1 ms)
-[ RUN ] TestElasticMaterialFixture/0.ComputeTangentModuli
-[ OK ] TestElasticMaterialFixture/0.ComputeTangentModuli (0 ms)
-[ RUN ] TestElasticMaterialFixture/0.ComputeCelerity
-[ OK ] TestElasticMaterialFixture/0.ComputeCelerity (1 ms)
-[----------]...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_standard_linear_solid_deviatoric_relaxation</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_standard_linear_solid_deviatoric_relaxation" "-e" "./test_material_standard_linear_solid_deviatoric_relaxation" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>11.8655</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_standard_linear_solid_deviatoric_relaxation" "-e" "./test_material_standard_linear_solid_deviatoric_relaxation" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic
-Executing the test test_material_standard_linear_solid_deviatoric_relaxation
-Run ./test_material_standard_linear_solid_deviatoric_relaxation
-Material sls_deviatoric [
- rwp E [Young's modulus] : 15
- r-- Einf [Stiffness of the elastic element] : 10
- rwp Eta [Viscosity] : 10
- rwp Ev [Stiffness of the viscous element] : 5
- rwp Plane_Stress [Is plane stress] : false
- rwp alpha [Thermal expansion coefficient] : 0
- rwp delta_T [Uniform temperature field] : InternalField [ solid_mechanics_model:0:sls_deviatoric:delta_T {1 types - 0 ghost types} ]
- r-p finite_deformation [Is finite deformation] : false
- iii inelastic_deformation [Is inelastic deformation] : false
- r-- kapa [Bulk coefficient] : 10
- r-- lambda [Firs...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_standard_linear_solid_deviatoric_relaxation_tension</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation_tension</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_standard_linear_solid_deviatoric_relaxation_tension" "-e" "./test_material_standard_linear_solid_deviatoric_relaxation_tension" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>11.3933</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_standard_linear_solid_deviatoric_relaxation_tension" "-e" "./test_material_standard_linear_solid_deviatoric_relaxation_tension" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic
-Executing the test test_material_standard_linear_solid_deviatoric_relaxation_tension
-Run ./test_material_standard_linear_solid_deviatoric_relaxation_tension
-Material sls_deviatoric [
- rwp E [Young's modulus] : 15
- r-- Einf [Stiffness of the elastic element] : 10
- rwp Eta [Viscosity] : 10
- rwp Ev [Stiffness of the viscous element] : 5
- rwp Plane_Stress [Is plane stress] : false
- rwp alpha [Thermal expansion coefficient] : 0
- rwp delta_T [Uniform temperature field] : InternalField [ solid_mechanics_model:0:sls_deviatoric:delta_T {1 types - 0 ghost types} ]
- r-p finite_deformation [Is finite deformation] : false
- iii inelastic_deformation [Is inelastic deformation] : false
- r-- kapa [Bulk coefficient] : 10
- r-...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_standard_linear_isotropic_hardening</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_standard_linear_isotropic_hardening</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_standard_linear_isotropic_hardening" "-e" "./test_material_standard_linear_isotropic_hardening" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_standard_linear_isotropic_hardening.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>23.368</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_standard_linear_isotropic_hardening" "-e" "./test_material_standard_linear_isotropic_hardening" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_standard_linear_isotropic_hardening.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening
-Executing the test test_material_standard_linear_isotropic_hardening
-Run ./test_material_standard_linear_isotropic_hardening
-0,0
-0.01,1
-0.02,2
-0.03,3
-0.04,4
-0.05,5
-0.06,6
-0.07,7
-0.08,8
-0.09,9
-0.1,10
-0.11,10.19
-0.12,10.22
-0.13,10.22
-0.14,10.22
-0.15,10.22
-0.16,10.22
-0.17,10.22
-0.18,10.22
-0.19,10.22
-Comparing last generated output to the reference file
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_viscoelasti_maxwell_relaxation</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell/test_material_viscoelasti_maxwell_relaxation</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_viscoelasti_maxwell_relaxation" "-e" "./test_material_viscoelasti_maxwell_relaxation" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>2.04167</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_viscoelasti_maxwell_relaxation" "-e" "./test_material_viscoelasti_maxwell_relaxation" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell
-Executing the test test_material_viscoelasti_maxwell_relaxation
-Run ./test_material_viscoelasti_maxwell_relaxation
-Material viscoelastic_maxwell [
- rwp E [Young's modulus] : 2.5e+07
- rwp Einf [Stiffness of the elastic element] : 1.5e+07
- rwp Eta [Viscosity of a Maxwell element] : [4e+07]
- rwp Ev [Stiffness of a Maxwell element] : [1e+07]
- rwp Plane_Stress [Is plane stress] : false
- rwp alpha [Thermal expansion coefficient] : 0
- rwp delta_T [Uniform temperature field] : InternalField [ solid_mechanics_model:0:viscoelastic_maxwell:delta_T {1 types - 0 ghost types} ]
- r-p finite_deformation [Is finite deformation] : false
- iii inelastic_deformation [Is inelastic deformation] : false
- r-- kapa [Bulk coefficient] : 8.33333...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_solid_mechanics_model_cohesive_gtest_1</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_cohesive</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_cohesive/test_solid_mechanics_model_cohesive_gtest_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_cohesive_gtest" "-e" "./test_solid_mechanics_model_cohesive_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_cohesive_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Failed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>134</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>3.08755</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_cohesive_gtest" "-e" "./test_solid_mechanics_model_cohesive_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_cohesive_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive
-Executing the test test_solid_mechanics_model_cohesive_gtest for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_solid_mechanics_model_cohesive_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_cohesive_gtest.xml
-[==========] Running 45 tests from 9 test cases.
-[----------] Global test environment set-up.
-[----------] 5 tests from TestSMMCFixture/0, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)1&gt;, std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;, std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt; &gt;
-[ RUN ] TestSMMCFixture/0.ExtrinsicModeI
-[ OK ] TestSMMCFixture/0.ExtrinsicModeI (302 ms)
-[ RUN ] TestSMMCFixture/0.ExtrinsicModeIFiniteDef
-unknown file: Failure
-C++ exception with description "assert [((i &lt; this-&gt;n[0]) &amp;&amp; (j &lt; this-&gt;n[1]))] Access out of the matrix! Index (1, 0) is out of the matrix of size (1, 1)" thrown in the test body.
-double free or corruption (!prev)
-[5b4962022198:03356] *** Process received signal ***
-[5b4962022198:03356] Signal: Aborted (6)
-[5b4962022198:03356] Signal code: (-6)
-[5b4962022198:03356] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x126b0)[0x7f547738e6b0]
-[5b4962022198:03356] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b)[0x7f5476ed285b]
-[5b4962022198:03356] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7f5476ebd535]
-[5b4962022198:03356] [ 3] /lib/x86_64-linux-gnu/libc.so.6(+0x79718)[0x7f5476f14718]
-[5b4962022198:03356] [ 4] /lib/x86_64-linux-gnu/libc.so.6(+0x7fe3a)[0x7f5476f1ae3a]
-[5b4962022198:03356] [ 5] /lib/x86_64-linux-gnu/libc.so.6(+0x8195c)[0x7f5476f1c95c]
-[5b4962022198:03356] [ 6] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu14ArrayDataLayerIdLNS_19ArrayAllocationTypeE1EE10deallocateEv+0x1c)[0x55d516a9011a]
-[5b4962022198:03356] [ 7] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu14ArrayDataLayerIdLNS_19ArrayAllocationTypeE1EED1Ev+0x26)[0x55d516a8c62e]
-[5b4962022198:03356] [ 8] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu5ArrayIdLb1EED2Ev+0x26)[0x55d516a87f9c]
-[5b4962022198:03356] [ 9] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu5ArrayIdLb1EED0Ev+0x18)[0x55d516a87fb8]
-[5b4962022198:03356] [10] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu12StaticMemory5sfreeERKjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x446)[0x7f547b5020e4]
-[5b4962022198:03356] [11] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu6MemoryD1Ev+0x24e)[0x7f547b5008e0]
-[5b4962022198:03356] [12] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19ElementTypeMapArrayIdNS_11ElementTypeEED1Ev+0x53)[0x7f547b2f2891]
-[5b4962022198:03356] [13] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu13InternalFieldIdED1Ev+0x7b)[0x7f547b313813]
-[5b4962022198:03356] [14] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu8MaterialD2Ev+0xf3)[0x7f547b98896f]
-[5b4962022198:03356] [15] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu15MaterialThermalILj1EED2Ev+0xd4)[0x7f547bae9efa]
-[5b4962022198:03356] [16] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu18PlaneStressToolboxILj1ENS_15MaterialThermalILj1EEEED2Ev+0xb0)[0x7f547baea11c]
-[5b4962022198:03356] [17] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu15MaterialElasticILj1EED1Ev+0xaf)[0x7f547baed597]
-[5b4962022198:03356] [18] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu15MaterialElasticILj1EED0Ev+0x18)[0x7f547baed5f8]
-[5b4962022198:03356] [19] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNKSt14default_deleteIN6akantu8MaterialEEclEPS1_+0x2e)[0x7f547b9c53f6]
-[5b4962022198:03356] [20] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNSt10unique_ptrIN6akantu8MaterialESt14default_deleteIS1_EED1Ev+0x49)[0x7f547b9c4f9d]
-[5b4962022198:03356] [21] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZSt8_DestroyISt10unique_ptrIN6akantu8MaterialESt14default_deleteIS2_EEEvPT_+0x18)[0x7f547b9c4adf]
-[5b4962022198:03356] [22] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNSt12_Destroy_auxILb0EE9__destroyIPSt10unique_ptrIN6akantu8MaterialESt14default_deleteIS4_EEEEvT_S9_+0x2e)[0x7f547b9c3cf3]
-[5b4962022198:03356] [23] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZSt8_DestroyIPSt10unique_ptrIN6akantu8MaterialESt14default_deleteIS2_EEEvT_S7_+0x23)[0x7f547b9c30fa]
-[5b4962022198:03356] [24] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZSt8_DestroyIPSt10unique_ptrIN6akantu8MaterialESt14default_deleteIS2_EES5_EvT_S7_RSaIT0_E+0x27)[0x7f547b9c25ff]
-[5b4962022198:03356] [25] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNSt6vectorISt10unique_ptrIN6akantu8MaterialESt14default_deleteIS2_EESaIS5_EED1Ev+0x35)[0x7f547b9bfe17]
-[5b4962022198:03356] [26] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModelD2Ev+0x567)[0x7f547b9a9469]
-[5b4962022198:03356] [27] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu27SolidMechanicsModelCohesiveD1Ev+0x1b0)[0x7f547b3af906]
-[5b4962022198:03356] [28] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu27SolidMechanicsModelCohesiveD0Ev+0x18)[0x7f547b3af99c]
-[5b4962022198:03356] [29] ./test_solid_mechanics_model_cohesive_gtest(_ZNKSt14default_deleteIN6akantu27SolidMechanicsModelCohesiveEEclEPS1_+0x2e)[0x55d516aa2490]
-[5b4962022198:03356] *** End of error message ***
---------------------------------------------------------------------------
-Primary job terminated normally, but 1 process returned
-a non-zero exit code. Per user-direction, the job has been aborted.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-mpiexec noticed that process rank 0 with PID 0 on node 5b4962022198 exited on signal 6 (Aborted).
---------------------------------------------------------------------------
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_solid_mechanics_model_cohesive_gtest_2</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_cohesive</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_cohesive/test_solid_mechanics_model_cohesive_gtest_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_cohesive_gtest" "-e" "./test_solid_mechanics_model_cohesive_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_cohesive_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Failed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>134</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>3.48547</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_cohesive_gtest" "-e" "./test_solid_mechanics_model_cohesive_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_cohesive_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive
-Executing the test test_solid_mechanics_model_cohesive_gtest for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_solid_mechanics_model_cohesive_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_cohesive_gtest.xml
-[==========] Running 45 tests from 9 test cases.
-[----------] Global test environment set-up.
-[----------] 5 tests from TestSMMCFixture/0, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)1&gt;, std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;, std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt; &gt;
-[ RUN ] TestSMMCFixture/0.ExtrinsicModeI
-[ OK ] TestSMMCFixture/0.ExtrinsicModeI (16 ms)
-[ RUN ] TestSMMCFixture/0.ExtrinsicModeIFiniteDef
-[ OK ] TestSMMCFixture/0.ExtrinsicModeIFiniteDef (7 ms)
-[ RUN ] TestSMMCFixture/0.ExtrinsicModeII
-[ OK ] TestSMMCFixture/0.ExtrinsicModeII (7 ms)
-[ RUN ] TestSMMCFixture/0.IntrinsicModeI
-[ OK ] TestSMMCFixture/0.IntrinsicModeI (6 ms)
-[ RUN ] TestSMMCFixture/0.IntrinsicModeII
-[ OK ] TestSMMCFixture/0.IntrinsicModeII (8 ms)
-[----------] 5 tests from TestSMMCFixture/0 (44 ms total)
-
-[----------] 5 tests from TestSMMCFixture/1, where TypeParam = std::tuple&lt;std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)2&gt;, std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)11&gt;, std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)11&gt; &gt;
-[ RUN ] TestSMMCFixture/1.ExtrinsicModeI
-[ OK ] TestSMMCFixture/1.ExtrinsicModeI (1611 ms)
-[ RUN ] TestSMMCFixture/1.ExtrinsicModeIFiniteDef
-(terminate_handler(): /home/jenkins/workspace/akantu-private-master-5327/src/common/aka_error.cc:232)!! Execution terminated for unknown reasons !!
-[5b4962022198:03371] *** Process received signal ***
-[5b4962022198:03371] Signal: Aborted (6)
-[5b4962022198:03371] Signal code: (-6)
-(terminate_handler(): /home/jenkins/workspace/akantu-private-master-5327/src/common/aka_error.cc:232)!! Execution terminated for unknown reasons !!
-[5b4962022198:03371] [ 0] [5b4962022198:03372] *** Process received signal ***
-/lib/x86_64-linux-gnu/libpthread.so.0(+0x126b0)[0x7fd6d158f6b0]
-[5b4962022198:03371] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b)[0x7fd6d10d385b]
-[5b4962022198:03371] [ 2] [5b4962022198:03372] Signal: Aborted (6)
-[5b4962022198:03372] Signal code: (-6)
-/lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7fd6d10be535]
-[5b4962022198:03371] [ 3] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x8c63f)[0x7fd6d148663f]
-[5b4962022198:03371] [ 4] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x928d1)[0x7fd6d148c8d1]
-[5b4962022198:03371] [ 5] [5b4962022198:03372] [ 0] /lib/x86_64-linux-gnu/libpthread.so.0(+0x126b0)[0x7ff6814a66b0]
-[5b4962022198:03372] [ 1] /lib/x86_64-linux-gnu/libc.so.6(gsignal+0x10b)[0x7ff680fea85b]
-[5b4962022198:03372] [ 2] /lib/x86_64-linux-gnu/libc.so.6(abort+0x121)[0x7ff680fd5535]
-[5b4962022198:03372] [ 3] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x8c63f)[0x7ff68139d63f]
-[5b4962022198:03372] [ 4] /lib/x86_64-linux-gnu/libstdc++.so.6(+0x928d1)[0x7ff6813a38d1]
-[5b4962022198:03372] [ 5] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu5debug17initSignalHandlerEv+0x0)[0x7fd6d56f5f58]
-[5b4962022198:03371] [ 6] /lib/x86_64-linux-gnu/libc.so.6(+0x378e0)[0x7fd6d10d38e0]
-[5b4962022198:03371] [ 7] /lib/x86_64-linux-gnu/libc.so.6(+0x83326)[0x7fd6d111f326]
-[5b4962022198:03371] [ 8] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu5debug17initSignalHandlerEv+0x0)[0x7ff68560cf58]
-[5b4962022198:03372] [ 6] /lib/x86_64-linux-gnu/libc.so.6(+0x378e0)[0x7ff680fea8e0]
-[5b4962022198:03372] [ 7] /lib/x86_64-linux-gnu/libc.so.6(+0x83326)[0x7ff681036326]
-[5b4962022198:03372] [ 8] /lib/x86_64-linux-gnu/libc.so.6(+0x83eb5)[0x7ff681036eb5]
-[5b4962022198:03372] [ 9] /lib/x86_64-linux-gnu/libc.so.6(realloc+0x34b)[0x7ff6810381fb]
-[5b4962022198:03372] [10] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu14ArrayDataLayerIdLNS_19ArrayAllocationTypeE1EE6resizeEj+0xec)[0x55b1cbacd072]
-[5b4962022198:03372] [11] /lib/x86_64-linux-gnu/libc.so.6(__libc_malloc+0x21a)[0x7fd6d112082a]
-[5b4962022198:03371] [ 9] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu14ArrayDataLayerIdLNS_19ArrayAllocationTypeE1EE8allocateEjj+0x28)[0x556d9a64f088]
-[5b4962022198:03371] [10] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu14ArrayDataLayerIdLNS_19ArrayAllocationTypeE1EEC1EjjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x82)[0x556d9a64b5e4]
-[5b4962022198:03371] [11] ./test_solid_mechanics_model_cohesive_gtest(_ZN6akantu5ArrayIdLb1EEC1EjjRKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x2c)[0x556d9a646f64]
-[5b4962022198:03371] [12] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu8Material22assembleInternalForcesILj2EEEvNS_9GhostTypeE+0x4dd)[0x7fd6d5b9962d]
-[5b4962022198:03371] [13] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu8FEEngine19filterElementalDataIdEEvRKNS_4MeshERKNS_5ArrayIT_XsrSt13is_arithmeticIS6_E5valueEEERS9_RKNS_11ElementTypeERKNS_9GhostTypeERKNS5_IjLb1EEE+0x2b1)[0x7ff68539d51d]
-[5b4962022198:03372] [12] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu8Material22assembleInternalForcesENS_9GhostTypeE+0x621)[0x7fd6d5b8b879]
-[5b4962022198:03371] [14] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModel22assembleInternalForcesEv+0x9b8)[0x7fd6d5badfce]
-[5b4962022198:03371] [15] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu27SolidMechanicsModelCohesive22assembleInternalForcesEv+0x293)[0x7fd6d55b4173]
-[5b4962022198:03371] [16] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNK6akantu15IntegratorGaussILNS_11ElementKindE1ENS_30DefaultIntegrationOrderFunctorEE9integrateILNS_11ElementTypeE11EEEvRKNS_5ArrayIdLb1EEERS7_jRKNS_9GhostTypeERKNS6_IjLb1EEE+0x4eb)[0x7ff685ae8b8f]
-[5b4962022198:03372] [13] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu9fe_engine7details15IntegrateHelperILNS_11ElementKindE1EE4callINS_15IntegratorGaussILS3_1ENS_30DefaultIntegrationOrderFunctorEEEEEvRKT_RKNS_5ArrayIdLb1EEERSD_jRKNS_11ElementTypeERKNS_9GhostTypeERKNSC_IjLb1EEE+0x13f)[0x7ff685ae3a86]
-[5b4962022198:03372] [14] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZNK6akantu16FEEngineTemplateINS_15IntegratorGaussENS_13ShapeLagrangeELNS_11ElementKindE1ENS_30DefaultIntegrationOrderFunctorEE9integrateERKNS_5ArrayIdLb1EEERS7_jRKNS_11ElementTypeERKNS_9GhostTypeERKNS6_IjLb1EEE+0x638)[0x7ff685adddec]
-[5b4962022198:03372] [15] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModel16assembleResidualEv+0x1e0)[0x7fd6d5bac6f0]
-[5b4962022198:03371] [17] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu8Material22assembleInternalForcesILj2EEEvNS_9GhostTypeE+0x959)[0x7ff685ab0aa9]
-[5b4962022198:03372] [16] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu8Material22assembleInternalForcesENS_9GhostTypeE+0x621)[0x7ff685aa2879]
-[5b4962022198:03372] [17] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu14TimeStepSolver16assembleResidualEv+0x1b0)[0x7fd6d5a3b608]
-[5b4962022198:03371] [18] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModel22assembleInternalForcesEv+0x9b8)[0x7ff685ac4fce]
-[5b4962022198:03372] [18] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu21TimeStepSolverDefault16assembleResidualEv+0x196)[0x7fd6d5a3fab6]
-[5b4962022198:03371] [19] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu27SolidMechanicsModelCohesive22assembleInternalForcesEv+0x293)[0x7ff6854cb173]
-[5b4962022198:03372] [19] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu21NonLinearSolverLumped5solveERNS_14SolverCallbackE+0xd2)[0x7fd6d5a37992]
-[5b4962022198:03371] [20] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu19SolidMechanicsModel16assembleResidualEv+0x1e0)[0x7ff685ac36f0]
-[5b4962022198:03372] [20] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu21TimeStepSolverDefault9solveStepERNS_14SolverCallbackE+0x77)[0x7fd6d5a3e885]
-[5b4962022198:03371] [21] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu14TimeStepSolver16assembleResidualEv+0x1b0)[0x7ff685952608]
-[5b4962022198:03372] [21] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu11ModelSolver9solveStepERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x200)[0x7fd6d5a2e014]
-[5b4962022198:03371] [22] ./test_solid_mechanics_model_cohesive_gtest(_ZN15TestSMMCFixtureISt5tupleIJSt17integral_constantIN6akantu11ElementTypeELS3_2EES1_IS3_LS3_11EES5_EEE5stepsERKNS2_6MatrixIdEE+0x262)[0x556d9a67f074]
-[5b4962022198:03371] [23] ./test_solid_mechanics_model_cohesive_gtest(_ZN15TestSMMCFixtureISt5tupleIJSt17integral_constantIN6akantu11ElementTypeELS3_2EES1_IS3_LS3_11EES5_EEE9testModeIEv+0x725)[0x556d9a678bf5]
-[5b4962022198:03371] [24] ./test_solid_mechanics_model_cohesive_gtest(_ZN44TestSMMCFixture_ExtrinsicModeIFiniteDef_TestISt5tupleIJSt17integral_constantIN6akantu11ElementTypeELS3_2EES1_IS3_LS3_11EES5_EEE8TestBodyEv+0x13d)[0x556d9a66b26b]
-[5b4962022198:03371] [25] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x65)[0x7fd6d1649820]
-[5b4962022198:03371] [26] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x5a)[0x7fd6d16434ed]
-[5b4962022198:03371] [27] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing4Test3RunEv+0xee)[0x7fd6d16224f8]
-[5b4962022198:03371] [28] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing8TestInfo3RunEv+0x10f)[0x7fd6d1622dcf]
-[5b4962022198:03371] [29] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing8TestCase3RunEv+0x107)[0x7fd6d1623449]
-[5b4962022198:03371] *** End of error message ***
-/home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu21TimeStepSolverDefault16assembleResidualEv+0x196)[0x7ff685956ab6]
-[5b4962022198:03372] [22] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu21NonLinearSolverLumped5solveERNS_14SolverCallbackE+0xd2)[0x7ff68594e992]
-[5b4962022198:03372] [23] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu21TimeStepSolverDefault9solveStepERNS_14SolverCallbackE+0x77)[0x7ff685955885]
-[5b4962022198:03372] [24] /home/jenkins/workspace/akantu-private-master-5327/build/src/libakantu.so.3.0(_ZN6akantu11ModelSolver9solveStepERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE+0x200)[0x7ff685945014]
-[5b4962022198:03372] [25] ./test_solid_mechanics_model_cohesive_gtest(_ZN15TestSMMCFixtureISt5tupleIJSt17integral_constantIN6akantu11ElementTypeELS3_2EES1_IS3_LS3_11EES5_EEE5stepsERKNS2_6MatrixIdEE+0x262)[0x55b1cbb00074]
-[5b4962022198:03372] [26] ./test_solid_mechanics_model_cohesive_gtest(_ZN15TestSMMCFixtureISt5tupleIJSt17integral_constantIN6akantu11ElementTypeELS3_2EES1_IS3_LS3_11EES5_EEE9testModeIEv+0x725)[0x55b1cbaf9bf5]
-[5b4962022198:03372] [27] ./test_solid_mechanics_model_cohesive_gtest(_ZN44TestSMMCFixture_ExtrinsicModeIFiniteDef_TestISt5tupleIJSt17integral_constantIN6akantu11ElementTypeELS3_2EES1_IS3_LS3_11EES5_EEE8TestBodyEv+0x13d)[0x55b1cbaec26b]
-[5b4962022198:03372] [28] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x65)[0x7ff681560820]
-[5b4962022198:03372] [29] /home/jenkins/workspace/akantu-private-master-5327/build/lib/libgtest.so(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc+0x5a)[0x7ff68155a4ed]
-[5b4962022198:03372] *** End of error message ***
---------------------------------------------------------------------------
-Primary job terminated normally, but 1 process returned
-a non-zero exit code. Per user-direction, the job has been aborted.
---------------------------------------------------------------------------
---------------------------------------------------------------------------
-mpiexec noticed that process rank 0 with PID 0 on node 5b4962022198 exited on signal 6 (Aborted).
---------------------------------------------------------------------------
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_material_cohesive_gtest</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_cohesive/test_materials</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_gtest</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_cohesive_gtest" "-e" "./test_material_cohesive_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_material_cohesive_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.841943</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_material_cohesive_gtest" "-e" "./test_material_cohesive_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_material_cohesive_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials
-Executing the test test_material_cohesive_gtest
-Run ./test_material_cohesive_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_material_cohesive_gtest.xml
-[==========] Running 9 tests from 3 test cases.
-[----------] Global test environment set-up.
-[----------] 3 tests from TestMaterialCohesiveLinearFixture/0, where TypeParam = std::integral_constant&lt;unsigned int, 1u&gt;
-[ RUN ] TestMaterialCohesiveLinearFixture/0.ModeI
-[ OK ] TestMaterialCohesiveLinearFixture/0.ModeI (6 ms)
-[ RUN ] TestMaterialCohesiveLinearFixture/0.ModeII
-[ OK ] TestMaterialCohesiveLinearFixture/0.ModeII (2 ms)
-[ RUN ] TestMaterialCohesiveLinearFixture/0.Cycles
-[ OK ] TestMaterialCohesiveLinearFixture/0.Cycles (8 ms)
-[----------] 3 tests from TestMaterialCohesiveLinearFixture/0 (16 ms total)
-
-[----------] 3 tests fr...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_cohesive_buildfragments</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_buildfragments</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_buildfragments/test_cohesive_buildfragments</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_cohesive_buildfragments" "-e" "./test_cohesive_buildfragments" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_buildfragments"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>3.04708</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_cohesive_buildfragments" "-e" "./test_cohesive_buildfragments" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_buildfragments"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_buildfragments
-Executing the test test_cohesive_buildfragments
-Run ./test_cohesive_buildfragments
-passing step 1/200
-passing step 2/200
-passing step 3/200
-passing step 4/200
-passing step 5/200
-passing step 6/200
-passing step 7/200
-passing step 8/200
-passing step 9/200
-passing step 10/200
-passing step 11/200
-passing step 12/200
-passing step 13/200
-passing step 14/200
-passing step 15/200
-passing step 16/200
-passing step 17/200
-passing step 18/200
-passing step 19/200
-passing step 20/200
-passing step 21/200
-passing step 22/200
-passing step 23/200
-passing step 24/200
-passing step 25/200
-passing step 26/200
-passing step 27/200
-passing step 28/200
-passing step 29/200
-passing step 30/200
-passing step 31/200
-passing step 32/200
-passing step 33/200
-passing step 34/200
-passing step 35/200
-passing step 36/200
-passing step 37/200
-passing step 38/200
-passing step 39/200
-passing...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_cohesive_insertion_along_physical_surfaces</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion/test_cohesive_insertion_along_physical_surfaces</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_cohesive_insertion_along_physical_surfaces" "-e" "./test_cohesive_insertion_along_physical_surfaces" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>4.60078</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_cohesive_insertion_along_physical_surfaces" "-e" "./test_cohesive_insertion_along_physical_surfaces" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion
-Executing the test test_cohesive_insertion_along_physical_surfaces
-Run ./test_cohesive_insertion_along_physical_surfaces
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_energies_gtest_1</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_energies</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_energies_gtest_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_energies_gtest" "-e" "./test_solid_mechanics_model_energies_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_energies" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_energies_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>51.0117</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_energies_gtest" "-e" "./test_solid_mechanics_model_energies_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_energies" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_energies_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_energies
-Executing the test test_solid_mechanics_model_energies_gtest for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_solid_mechanics_model_energies_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_energies_gtest.xml
-[==========] Running 60 tests from 24 test cases.
-[----------] Global test environment set-up.
-[----------] 4 tests from TestSMMFixture/0, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;
-[ RUN ] TestSMMFixture/0.LinearElasticPotentialEnergy
-[ OK ] TestSMMFixture/0.LinearElasticPotentialEnergy (37 ms)
-[ RUN ] TestSMMFixture/0.KineticEnergyImplicit
-[ OK ] TestSMMFixture/0.KineticEnergyImplicit (15 ms)
-[ RUN ] TestSMMFixture/0.KineticEnergyExplicit
-[ OK ] TestSMMFixture/0.KineticEnergyExplicit (9 ms)
-[ RUN ] TestSMMFixture/0.WorkQu...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_solid_mechanics_model_energies_gtest_2</Name>
- <Path>./test/test_model/test_solid_mechanics_model/test_energies</Path>
- <FullName>./test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_energies_gtest_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_energies_gtest" "-e" "./test_solid_mechanics_model_energies_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_energies" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_energies_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>69.4874</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_solid_mechanics_model_energies_gtest" "-e" "./test_solid_mechanics_model_energies_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_energies" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_energies_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_model/test_solid_mechanics_model/test_energies
-Executing the test test_solid_mechanics_model_energies_gtest for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_solid_mechanics_model_energies_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_solid_mechanics_model_energies_gtest.xml
-[==========] Running 60 tests from 24 test cases.
-[----------] Global test environment set-up.
-[----------] 4 tests from TestSMMFixture/0, where TypeParam = std::integral_constant&lt;akantu::ElementType, (akantu::ElementType)9&gt;
-[ RUN ] TestSMMFixture/0.LinearElasticPotentialEnergy
-[ OK ] TestSMMFixture/0.LinearElasticPotentialEnergy (64 ms)
-[ RUN ] TestSMMFixture/0.KineticEnergyImplicit
-[ OK ] TestSMMFixture/0.KineticEnergyImplicit (41 ms)
-[ RUN ] TestSMMFixture/0.KineticEnergyExplicit
-[ OK ] TestSMMFixture/0.KineticEnergyExplicit (19 ms)
-[ RUN ] TestSMMFixture/0.WorkQ...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_sparse_matrix_profile</Name>
- <Path>./test/test_solver</Path>
- <FullName>./test/test_solver/test_sparse_matrix_profile</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_matrix_profile" "-e" "./test_sparse_matrix_profile" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.837886</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_matrix_profile" "-e" "./test_sparse_matrix_profile" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver
-Executing the test test_sparse_matrix_profile
-Run ./test_sparse_matrix_profile
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_sparse_matrix_assemble</Name>
- <Path>./test/test_solver</Path>
- <FullName>./test/test_solver/test_sparse_matrix_assemble</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_matrix_assemble" "-e" "./test_sparse_matrix_assemble" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.844385</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_matrix_assemble" "-e" "./test_sparse_matrix_assemble" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver
-Executing the test test_sparse_matrix_assemble
-Run ./test_sparse_matrix_assemble
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="failed">
- <Name>test_sparse_matrix_product</Name>
- <Path>./test/test_solver</Path>
- <FullName>./test/test_solver/test_sparse_matrix_product</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_matrix_product" "-e" "./test_sparse_matrix_product" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_solver/test_sparse_matrix_product.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="text/string" name="Exit Code">
- <Value>Failed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Exit Value">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.802545</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_matrix_product" "-e" "./test_sparse_matrix_product" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_solver/test_sparse_matrix_product.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver
-Executing the test test_sparse_matrix_product
-Run ./test_sparse_matrix_product
-Creating a SparseMatrix
-Filling the matrix
-Computing x = A * x
-Gathering the results on proc 0
-Array&lt;double&gt; [
- + id : vector
- + size : 121
- + nb_component : 2
- + allocated size : 121
- + memory size : 15.12KiByte
- + values : {{2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}, {2, 2}}
-]
-
-Comparing last generated output to the reference file
-10c10
-&lt; + memory size : 15.12KiByte
----
-&gt; + memory size : 1.89KiByte
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_sparse_solver_mumps_4</Name>
- <Path>./test/test_solver</Path>
- <FullName>./test/test_solver/test_sparse_solver_mumps_4</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_solver_mumps" "-e" "./test_sparse_solver_mumps" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-N" "4"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.842327</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>4</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_solver_mumps" "-e" "./test_sparse_solver_mumps" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-N" "4"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver
-Executing the test test_sparse_solver_mumps for 4 procs
-Run /usr/bin/mpiexec -n 4 ./test_sparse_solver_mumps
-2 0 pos: 0.5 [5] [NON-XML-CHAR-0x5]
-2 1 pos: 0.6 [6]
-
-2 2 pos: 0.7 [7] [NON-XML-CHAR-0x3]
-2 3 pos: 0.4 [4]
-2 4 pos: 0.8 [8]
-3 0 pos: 0.7 [7] [NON-XML-CHAR-0x5]
-3 1 pos: 0.8 [8]
-
-3 2 pos: 0.9 [9]
-
-3 3 pos: 1 [10]
-
-3 4 pos: 0.6 [6]
-0 0 pos: 0.3 [3] [NON-XML-CHAR-0x3]
-0 1 pos: 0.4 [4]
-
-0 2 pos: 0.5 [5] [NON-XML-CHAR-0x3]
-0 3 pos: 0.2 [2]
-0 4 pos: 0.6 [6]
-1 0 pos: 0 [0]
-
-1 1 pos: 0.1 [1]
-
-1 2 pos: 0.2 [2]
-
-1 3 pos: 0.3 [3] [NON-XML-CHAR-0x5]
-1 4 pos: 0.4 [4]
-Array&lt;double&gt; [
- + id :
- + size : 11
- + nb_component : 1
- + allocated size : 11
- + memory size : 704.00Byte
- + values : {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}}
-]
-
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_sparse_solver_mumps_2</Name>
- <Path>./test/test_solver</Path>
- <FullName>./test/test_solver/test_sparse_solver_mumps_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_solver_mumps" "-e" "./test_sparse_solver_mumps" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-N" "2"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.801787</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_solver_mumps" "-e" "./test_sparse_solver_mumps" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-N" "2"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver
-Executing the test test_sparse_solver_mumps for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_sparse_solver_mumps
-1 0 pos: 0.5 [5] [NON-XML-CHAR-0x5]
-1 1 pos: 0.6 [6]
-
-1 2 pos: 0.7 [7]
-
-1 3 pos: 0.8 [8]
-
-1 4 pos: 0.9 [9]
-
-1 5 pos: 1 [10]
-
-1 6 pos: 0.4 [4]
-0 0 pos: 0 [0]
-
-0 1 pos: 0.1 [1]
-
-0 2 pos: 0.2 [2]
-
-0 3 pos: 0.3 [3]
-
-0 4 pos: 0.4 [4]
-
-0 5 pos: 0.5 [5] [NON-XML-CHAR-0x3]
-0 6 pos: 0.6 [6]
-Array&lt;double&gt; [
- + id :
- + size : 11
- + nb_component : 1
- + allocated size : 11
- + memory size : 704.00Byte
- + values : {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}}
-]
-
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_sparse_solver_mumps_1</Name>
- <Path>./test/test_solver</Path>
- <FullName>./test/test_solver/test_sparse_solver_mumps_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_solver_mumps" "-e" "./test_sparse_solver_mumps" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-N" "1"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.778809</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_sparse_solver_mumps" "-e" "./test_sparse_solver_mumps" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver" "-N" "1"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_solver
-Executing the test test_sparse_solver_mumps for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_sparse_solver_mumps
-0 0 pos: 0 [0]
-
-0 1 pos: 0.1 [1]
-
-0 2 pos: 0.2 [2]
-
-0 3 pos: 0.3 [3]
-
-0 4 pos: 0.4 [4]
-
-0 5 pos: 0.5 [5]
-
-0 6 pos: 0.6 [6]
-
-0 7 pos: 0.7 [7]
-
-0 8 pos: 0.8 [8]
-
-0 9 pos: 0.9 [9]
-
-0 10 pos: 1 [10]
-
-Array&lt;double&gt; [
- + id :
- + size : 11
- + nb_component : 1
- + allocated size : 11
- + memory size : 704.00Byte
- + values : {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, {11}}
-]
-
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_parser</Name>
- <Path>./test/test_io/test_parser</Path>
- <FullName>./test/test_io/test_parser/test_parser</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_parser" "-e" "./test_parser" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_io/test_parser" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_io/test_parser/test_parser.verified"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.802049</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_parser" "-e" "./test_parser" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_io/test_parser" "-r" "/home/jenkins/workspace/akantu-private-master-5327/test/test_io/test_parser/test_parser.verified"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_io/test_parser
-Executing the test test_parser
-Run ./test_parser
-123456==123456
-Section(global) global [
- Parameters [
- + debug_level: 1 (input_file.dat:2:1)
- + general: 50 (input_file.dat:22:1)
- + mat: [[ 1, 23+2, 5, toto ],[ 0, 10, general, 5+8] ] (input_file.dat:27:1)
- + rand1: 10 uniform [0.2, 0.5 ] (input_file.dat:30:1)
- + rand2: 10 weibull [0.2, 0.5 ] (input_file.dat:31:1)
- + rand3: 10 (input_file.dat:32:1)
- + seed: 123456 (input_file.dat:1:1)
- + toto: 2*pi + max(2, general) (input_file.dat:24:1)
- + vect: [ 1, 23+2, 5, toto ] (input_file.dat:26:1)
- ]
- Subsections [
- Section(material) elastic opt1 [
- Parameters [
- + E: 1 (input_file.dat:5:9)
- + X135: 1 + 3* debug_level (input_file.dat:6:9)
- + a: c (input_file.dat:11:9)
- + name: toto (input_file.dat:4:9)
- + yop: yop (input_file.dat:9:9)
- ]
- Subsections [
- Section(rules) material [
- Parameters [
- + E: 1 (input_file.dat:15:17)
- ...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_dumper</Name>
- <Path>./test/test_io/test_dumper</Path>
- <FullName>./test/test_io/test_dumper/test_dumper</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dumper" "-e" "./test_dumper" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_io/test_dumper"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.816862</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dumper" "-e" "./test_dumper" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_io/test_dumper"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_io/test_dumper
-Executing the test test_dumper
-Run ./test_dumper
-&lt;3667&gt;[R0|S1] {1547134207166258} /!\ The field element_type is not registered in this Dumper. Nothing to do. (unRegisterField(): /home/jenkins/workspace/akantu-private-master-5327/src/io/dumper/dumper_iohelper.cc:174)
-&lt;3667&gt;[R0|S1] {1547134207167258} /!\ The field element_type is not registered in this Dumper. Nothing to do. (unRegisterField(): /home/jenkins/workspace/akantu-private-master-5327/src/io/dumper/dumper_iohelper.cc:174)
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_dof_synchronizer_4</Name>
- <Path>./test/test_synchronizer</Path>
- <FullName>./test/test_synchronizer/test_dof_synchronizer_4</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_synchronizer" "-e" "./test_dof_synchronizer" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "4"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.813447</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>4</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_synchronizer" "-e" "./test_dof_synchronizer" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "4"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer
-Executing the test test_dof_synchronizer for 4 procs
-Run /usr/bin/mpiexec -n 4 ./test_dof_synchronizer
-Synchronizing a dof vector
-Synchronizing a dof vector
-Synchronizing a dof vector
-Synchronizing a dof vector
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_dof_synchronizer_2</Name>
- <Path>./test/test_synchronizer</Path>
- <FullName>./test/test_synchronizer/test_dof_synchronizer_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_synchronizer" "-e" "./test_dof_synchronizer" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "2"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.80606</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_synchronizer" "-e" "./test_dof_synchronizer" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "2"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer
-Executing the test test_dof_synchronizer for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_dof_synchronizer
-Synchronizing a dof vector
-Synchronizing a dof vector
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_dof_synchronizer_1</Name>
- <Path>./test/test_synchronizer</Path>
- <FullName>./test/test_synchronizer/test_dof_synchronizer_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_synchronizer" "-e" "./test_dof_synchronizer" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "1"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>0.801732</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_dof_synchronizer" "-e" "./test_dof_synchronizer" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "1"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer
-Executing the test test_dof_synchronizer for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_dof_synchronizer
-Synchronizing a dof vector
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_synchronizers_gtest_4</Name>
- <Path>./test/test_synchronizer</Path>
- <FullName>./test/test_synchronizer/test_synchronizers_gtest_4</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_synchronizers_gtest" "-e" "./test_synchronizers_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "4" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>6.67373</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>4</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_synchronizers_gtest" "-e" "./test_synchronizers_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "4" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer
-Executing the test test_synchronizers_gtest for 4 procs
-Run /usr/bin/mpiexec -n 4 ./test_synchronizers_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml
-[==========] Running 11 tests from 4 test cases.
-[----------] Global test environment set-up.
-[----------] 3 tests from TestElementSynchronizerFixture
-[ RUN ] TestElementSynchronizerFixture.SynchroneOnce
-[ OK ] TestElementSynchronizerFixture.SynchroneOnce (296 ms)
-[ RUN ] TestElementSynchronizerFixture.Synchrone
-[ OK ] TestElementSynchronizerFixture.Synchrone (286 ms)
-[ RUN ] TestElementSynchronizerFixture.Asynchrone
-[ OK ] TestElementSynchronizerFixture.Asynchrone (309 ms)
-[----------] 3 tests from TestElementSynchronizerFixture (892 ms total)
-
-[----------] 3 tests from TestNodeSynchronizerFixture
-[ RUN ] TestNodeSynchronizerFixture.SynchroneOnce
-[...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_synchronizers_gtest_2</Name>
- <Path>./test/test_synchronizer</Path>
- <FullName>./test/test_synchronizer/test_synchronizers_gtest_2</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_synchronizers_gtest" "-e" "./test_synchronizers_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>8.1844</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>2</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_synchronizers_gtest" "-e" "./test_synchronizers_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "2" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer
-Executing the test test_synchronizers_gtest for 2 procs
-Run /usr/bin/mpiexec -n 2 ./test_synchronizers_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml
-[==========] Running 11 tests from 4 test cases.
-[----------] Global test environment set-up.
-[----------] 3 tests from TestElementSynchronizerFixture
-[ RUN ] TestElementSynchronizerFixture.SynchroneOnce
-[ OK ] TestElementSynchronizerFixture.SynchroneOnce (306 ms)
-[ RUN ] TestElementSynchronizerFixture.Synchrone
-[ OK ] TestElementSynchronizerFixture.Synchrone (297 ms)
-[ RUN ] TestElementSynchronizerFixture.Asynchrone
-[ OK ] TestElementSynchronizerFixture.Asynchrone (304 ms)
-[----------] 3 tests from TestElementSynchronizerFixture (907 ms total)
-
-[----------] 3 tests from TestNodeSynchronizerFixture
-[ RUN ] TestNodeSynchronizerFixture.SynchroneOnce
-[...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_synchronizers_gtest_1</Name>
- <Path>./test/test_synchronizer</Path>
- <FullName>./test/test_synchronizer/test_synchronizers_gtest_1</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_synchronizers_gtest" "-e" "./test_synchronizers_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>9.47447</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_synchronizers_gtest" "-e" "./test_synchronizers_gtest" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-p" "/usr/bin/mpiexec -n" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer" "-N" "1" "--" "--gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_synchronizer
-Executing the test test_synchronizers_gtest for 1 procs
-Run /usr/bin/mpiexec -n 1 ./test_synchronizers_gtest --gtest_output=xml:/home/jenkins/workspace/akantu-private-master-5327/build/gtest_reports/test_synchronizers_gtest.xml
-[==========] Running 11 tests from 4 test cases.
-[----------] Global test environment set-up.
-[----------] 3 tests from TestElementSynchronizerFixture
-[ RUN ] TestElementSynchronizerFixture.SynchroneOnce
-[ OK ] TestElementSynchronizerFixture.SynchroneOnce (133 ms)
-[ RUN ] TestElementSynchronizerFixture.Synchrone
-[ OK ] TestElementSynchronizerFixture.Synchrone (128 ms)
-[ RUN ] TestElementSynchronizerFixture.Asynchrone
-[ OK ] TestElementSynchronizerFixture.Asynchrone (128 ms)
-[----------] 3 tests from TestElementSynchronizerFixture (389 ms total)
-
-[----------] 3 tests from TestNodeSynchronizerFixture
-[ RUN ] TestNodeSynchronizerFixture.SynchroneOnce
-[...
-The rest of the test output was removed since it exceeds the threshold of 1024 bytes.
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_multiple_init</Name>
- <Path>./test/test_python_interface</Path>
- <FullName>./test/test_python_interface/test_multiple_init</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_multiple_init" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface" "test_multiple_init.py"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1.07993</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_multiple_init" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface" "test_multiple_init.py"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface
-Executing the test test_multiple_init
-Run /usr/bin/python3 test_multiple_init.py
-First initialisation
-Second initialisation
-All right
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_mesh_interface</Name>
- <Path>./test/test_python_interface</Path>
- <FullName>./test/test_python_interface/test_mesh_interface</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_interface" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface" "test_mesh_interface.py"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1.03929</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_mesh_interface" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface" "test_mesh_interface.py"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface
-Executing the test test_mesh_interface
-Run /usr/bin/python3 test_mesh_interface.py
-</Value>
- </Measurement>
- </Results>
- </Test>
- <Test Status="passed">
- <Name>test_boundary_condition_functors</Name>
- <Path>./test/test_python_interface</Path>
- <FullName>./test/test_python_interface/test_boundary_condition_functors</FullName>
- <FullCommandLine>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_boundary_condition_functors" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface" "test_boundary_condition_functors.py"</FullCommandLine>
- <Results>
- <NamedMeasurement type="numeric/double" name="Execution Time">
- <Value>1.04731</Value>
- </NamedMeasurement>
- <NamedMeasurement type="numeric/double" name="Processors">
- <Value>1</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Completion Status">
- <Value>Completed</Value>
- </NamedMeasurement>
- <NamedMeasurement type="text/string" name="Command Line">
- <Value>/home/jenkins/workspace/akantu-private-master-5327/cmake/akantu_test_driver.sh "-n" "test_boundary_condition_functors" "-e" "/usr/bin/python3" "-E" "/home/jenkins/workspace/akantu-private-master-5327/build/akantu_environement.sh" "-w" "/home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface" "test_boundary_condition_functors.py"</Value>
- </NamedMeasurement>
- <Measurement>
- <Value>Entering directory /home/jenkins/workspace/akantu-private-master-5327/build/test/test_python_interface
-Executing the test test_boundary_condition_functors
-Run /usr/bin/python3 test_boundary_condition_functors.py
-&lt;3837&gt;[R0|S1] {1547134237081876} /!\ getForce was maintained for backward compatibility, use getExternalForce instead (getForce(): /home/jenkins/workspace/akantu-private-master-5327/src/model/solid_mechanics/solid_mechanics_model.hh:392)
-</Value>
- </Measurement>
- </Results>
- </Test>
- <EndDateTime>Jan 10 15:30 UTC</EndDateTime>
- <EndTestTime>1547134237</EndTestTime>
- <ElapsedMinutes>39</ElapsedMinutes>
- </Testing>
-</Site>
diff --git a/test/ci/scripts/harbomaster/__init__.py b/test/ci/scripts/harbomaster/__init__.py
index 31eec016b..752ceb589 100644
--- a/test/ci/scripts/harbomaster/__init__.py
+++ b/test/ci/scripts/harbomaster/__init__.py
@@ -1,26 +1,37 @@
+# ------------------------------------------------------------------------------
+__author__ = "Nicolas Richart"
+__copyright__ = "Copyright (C) 2019, EPFL (Ecole Polytechnique Fédérale" \
+ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
+ " en Mécanique des Solides)"
+__credits__ = ["Nicolas Richart", "Lucas Frerot"]
+__license__ = "L-GPLv3"
+__maintainer__ = "Nicolas Richart"
+__email__ = "nicolas.richart@epfl.ch"
+# ------------------------------------------------------------------------------
+
# for the module
import sys as __hbm_sys
def export(definition):
"""
Decorator to export definitions from sub-modules to the top-level package
:param definition: definition to be exported
:return: definition
"""
__module = __hbm_sys.modules[definition.__module__]
__pkg = __hbm_sys.modules[__module.__package__]
__pkg.__dict__[definition.__name__] = definition
if '__all__' not in __pkg.__dict__:
__pkg.__dict__['__all__'] = []
__pkg.__all__.append(definition.__name__)
return definition
-from . import ctestresults # noqa
+from . import testresults # noqa
from . import arclint # noqa
from . import hbm # noqa
diff --git a/test/ci/scripts/harbomaster/arclint.py b/test/ci/scripts/harbomaster/arclint.py
index 5da15b1cb..0d8ec8a1a 100644
--- a/test/ci/scripts/harbomaster/arclint.py
+++ b/test/ci/scripts/harbomaster/arclint.py
@@ -1,61 +1,72 @@
+# ------------------------------------------------------------------------------
+__author__ = "Nicolas Richart"
+__copyright__ = "Copyright (C) 2019, EPFL (Ecole Polytechnique Fédérale" \
+ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
+ " en Mécanique des Solides)"
+__credits__ = ["Nicolas Richart"]
+__license__ = "L-GPLv3"
+__maintainer__ = "Nicolas Richart"
+__email__ = "nicolas.richart@epfl.ch"
+# ------------------------------------------------------------------------------
+
import json
from .results import Results
from . import export
+
@export
class ARCLintJson:
STATUS = {'passed': Results.PASS,
- 'failed': Results.FAIL}
-
+ 'failed': Results.FAIL}
+
def __init__(self, filename):
self._file = open(filename, "r")
self._json = json.load(self._file)
-
+
def __iter__(self):
self._last_path_lints = []
self._lints = iter(self._json)
return self
-
+
def __next__(self):
class Lint:
def __init__(self, path, json):
self.json = json
self.json['path'] = path
if 'name' in json and 'code' in json and \
json['name'] == json['code']:
self.json['name'] = json['description']
del self.json['description']
-
+
def __getattr__(self, name):
if name == 'json':
return self.json
elif name in self.json:
return self.json[name]
else:
return None
-
+
def __str__(self):
return f'{self.path} => {self.name}'
lint = None
while not lint:
if len(self._last_path_lints) > 0:
lint = Lint(self._last_path,
self._last_path_lints.pop(0))
break
-
+
json = next(self._lints)
if type(json) != dict:
- raise RuntimeError("Wrong input type for the linter processor")
+ raise RuntimeError("Wrong input type for the linter processor")
self._last_path = list(json.keys())[0]
self._last_path_lints = json[self._last_path]
return lint
-
def __exit__(self, exc_type, exc_value, traceback):
self._file.close()
def __enter__(self):
return self
diff --git a/test/ci/scripts/harbomaster/ctestresults.py b/test/ci/scripts/harbomaster/ctestresults.py
deleted file mode 100644
index a087924e3..000000000
--- a/test/ci/scripts/harbomaster/ctestresults.py
+++ /dev/null
@@ -1,47 +0,0 @@
-import xml.etree.ElementTree as xml_etree
-from .results import Results
-from . import export
-
-@export
-class CTestResults:
- STATUS = {'passed': Results.PASS,
- 'failed': Results.FAIL}
-
- def __init__(self, filename):
- self._file = open(filename, "r")
- self._etree = xml_etree.parse(self._file)
- self._root = self._etree.getroot()
- self.test_format = 'CTest'
-
- def __iter__(self):
- self._tests = iter(self._root.findall('./Testing/Test'))
- return self
-
- def __next__(self):
- class Test:
- def __init__(self, element):
- self.name = element.find('Name').text
- self.path = element.find('FullName').text
- self.status = CTestResults.STATUS[element.attrib['Status']]
- self.duration = float(element.find("./Results/NamedMeasurement[@name='Execution Time']/Value").text)
- self.reason = None
- if self.status == Results.FAIL:
- self.reason = element.find("./Results/NamedMeasurement[@name='Exit Code']/Value").text
- if self.reason == "Timeout":
- self.status = Results.BROKEN
- else:
- self.reason = "{0} with exit code [{1}]\nSTDOUT:\n{2}".format(
- self.reason,
- element.find("./Results/NamedMeasurement[@name='Exit Value']/Value").text,
- '\n'.join((el.text for el in element.findall("./Results/Measurement/Value"))),
- )
-
- test = next(self._tests)
-
- return Test(test)
-
- def __exit__(self, exc_type, exc_value, traceback):
- self._file.close()
-
- def __enter__(self):
- return self
diff --git a/test/ci/scripts/harbomaster/hbm.py b/test/ci/scripts/harbomaster/hbm.py
index 28edd462c..1d30189ce 100644
--- a/test/ci/scripts/harbomaster/hbm.py
+++ b/test/ci/scripts/harbomaster/hbm.py
@@ -1,157 +1,168 @@
+# ------------------------------------------------------------------------------
+__author__ = "Nicolas Richart"
+__copyright__ = "Copyright (C) 2019, EPFL (Ecole Polytechnique Fédérale" \
+ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
+ " en Mécanique des Solides)"
+__credits__ = ["Nicolas Richart"]
+__license__ = "L-GPLv3"
+__maintainer__ = "Nicolas Richart"
+__email__ = "nicolas.richart@epfl.ch"
+# ------------------------------------------------------------------------------
+
from phabricator import Phabricator
import yaml
import base64
from . import export
from .results import Results
def get_phabricator_instance(ctx=None):
_phab = None
try:
_host = None
_username = None
_token = None
if ctx:
_host = ctx.pop('HOST', None)
_username = ctx.pop('USERNAME', None)
_token = ctx.pop('API_TOKEN', None)
-
+
_phab = Phabricator(host=_host,
username=_username,
token=_token)
_phab.update_interfaces()
# this request is just to make an actual connection
_phab.user.whoami()
except Exception as e:
print('Could not connect to phabricator, either give the' +
' connection with the default configuration of arc' +
' or in the backend configuration of the configuration' +
' file:\n' +
' in/out:\n' +
' username: mylogin\n' +
' host: https://c4science.ch/\n' +
' token: cli-g3amff25kdpnnv2tqvigmr4omnn7\n')
raise e
return _phab
@export
class Harbormaster:
STATUS = {Results.PASS: 'pass',
Results.FAIL: 'fail',
Results.BROKEN: 'broken',
Results.SKIP: 'skip',
Results.UNSTABLE: 'unsound'}
-
+
def __init__(self, **kwargs):
ctx = kwargs['ctx']
self.__phid = ctx['BUILD_TARGET_PHID']
self.__phab = get_phabricator_instance(**kwargs)
def _send_message(self, results):
self.__phab.harbormaster.sendmessage(buildTargetPHID=self.__phid,
type=self.STATUS[results])
def send_unit_tests(self, tests):
_unit_tests = []
_format = tests.test_format
_list_of_failed = {}
try:
_yaml = open(".tests_previous_state", 'r')
_previously_failed = yaml.load(_yaml)
if not _previously_failed:
_previously_failed = {}
_yaml.close()
except OSError:
_previously_failed = {}
-
+
for _test in tests:
status = self.STATUS[_test.status]
if (_test.status != Results.PASS and
(_test.name in _previously_failed and
(_previously_failed[_test.name] == self.STATUS[_test.status] or # noqa: E501
_previously_failed[_test.name] == 'unsound'))):
status = 'unsound'
_test_dict = {
'name': _test.name,
'result': status,
'format': _format
}
-
+
if _test.duration:
_test_dict['duration'] = _test.duration
if _test.path:
_test_dict['path'] = _test.path
if _test.reason:
_test_dict['details'] = _test.reason
-
+
if status != 'pass':
_list_of_failed[_test.name] = status
_unit_tests.append(_test_dict)
-
+
with open(".tests_previous_state", 'w+') as _cache_file:
yaml.dump(_list_of_failed,
_cache_file,
default_flow_style=False)
-
+
_msg = {'buildTargetPHID': self.__phid,
'type': 'work',
'unit': _unit_tests}
self.__phab.harbormaster.sendmessage(**_msg)
def send_lint(self, linter_processor):
_lints = []
for lint in linter_processor:
_lint = {}
for key in ['code', 'name', 'severity', 'path', 'line',
'char', 'description']:
val = getattr(lint, key)
if val:
_lint[key] = val
-
+
_lints.append(_lint)
-
+
_msg = {'buildTargetPHID': self.__phid,
'type': 'work',
'lint': _lints}
-
+
self.__phab.harbormaster.sendmessage(**_msg)
def send_uri(self, key, uri, name):
self.__phab.harbormaster.createartifact(buildTargetPHID=self.__phid,
artifactType='uri',
artifactKey=name,
artifactData={
'uri': uri,
'name': name,
'ui.external': True
})
-
+
def passed(self):
self._send_message(Results.PASS)
def failed(self):
self._send_message(Results.FAIL)
def upload_file(self, filename, name, view_phid=None):
with open(filename, 'rb') as f:
data = f.read()
base64_data = base64.b64encode(data)
_msg = {
'data_base64': base64_data.decode('ascii'),
'name': filename,
}
if view_phid:
_msg['viewPolicy'] = view_phid
_res = self.__phab.file.upload(**_msg)
-
+
print(f"{name} -> {_res}")
self.__phab.harbormaster.createartifact(
buildTargetPHID=self.__phid,
artifactType='file',
artifactKey=name,
artifactData={
'filePHID': _res.response
})
diff --git a/test/ci/scripts/harbomaster/results.py b/test/ci/scripts/harbomaster/results.py
index 3aeaca2c6..0bee299b7 100644
--- a/test/ci/scripts/harbomaster/results.py
+++ b/test/ci/scripts/harbomaster/results.py
@@ -1,8 +1,20 @@
+# ------------------------------------------------------------------------------
+__author__ = "Nicolas Richart"
+__copyright__ = "Copyright (C) 2019, EPFL (Ecole Polytechnique Fédérale" \
+ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
+ " en Mécanique des Solides)"
+__credits__ = ["Nicolas Richart"]
+__license__ = "L-GPLv3"
+__maintainer__ = "Nicolas Richart"
+__email__ = "nicolas.richart@epfl.ch"
+# ------------------------------------------------------------------------------
+
from enum import Enum
+
class Results(Enum):
PASS = 0
FAIL = 1
BROKEN = 2
SKIP = 3
UNSTABLE = 4
diff --git a/test/ci/scripts/harbomaster/testresults.py b/test/ci/scripts/harbomaster/testresults.py
new file mode 100644
index 000000000..483a4a886
--- /dev/null
+++ b/test/ci/scripts/harbomaster/testresults.py
@@ -0,0 +1,103 @@
+# ------------------------------------------------------------------------------
+__author__ = "Nicolas Richart"
+__copyright__ = "Copyright (C) 2019, EPFL (Ecole Polytechnique Fédérale" \
+ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
+ " en Mécanique des Solides)"
+__credits__ = ["Nicolas Richart", "Lucas Frerot"]
+__license__ = "L-GPLv3"
+__maintainer__ = "Nicolas Richart"
+__email__ = "nicolas.richart@epfl.ch"
+# ------------------------------------------------------------------------------
+
+import xml.etree.ElementTree as xml_etree
+from collections import namedtuple
+
+from .results import Results
+from . import export
+
+
+class TestResults:
+ STATUS = {'passed': Results.PASS,
+ 'failed': Results.FAIL}
+ Test = namedtuple('Test', 'name path status duration reason'.split())
+
+ def __init__(self, filename):
+ self._file = open(filename, "r")
+ self._etree = xml_etree.parse(self._file)
+ self._root = self._etree.getroot()
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ self._file.close()
+
+ def __enter__(self):
+ return self
+
+
+@export
+class CTestResults(TestResults):
+ def __init__(self, filename):
+ super().__init__(self, filename)
+ self.test_format = 'CTest'
+
+ def __iter__(self):
+ self._tests = iter(self._root.findall('./Testing/Test'))
+ return self
+
+ def __next__(self):
+ element = next(self._tests)
+
+ name = element.find('Name').text
+ path = element.find('FullName').text
+ status = CTestResults.STATUS[element.attrib['Status']]
+ duration = float(element.find(
+ "./Results/NamedMeasurement[@name='Execution Time']/Value").text)
+ reason = None
+
+ if status == Results.FAIL:
+ reason = element.find(
+ "./Results/NamedMeasurement[@name='Exit Code']/Value").text
+ if reason == "Timeout":
+ status = Results.BROKEN
+ else:
+ reason = "{0} with exit code [{1}]\nSTDOUT:\n{2}".format(
+ reason,
+ element.find(
+ "./Results/NamedMeasurement[@name='Exit Value']/Value").text, # noqa: E501
+ '\n'.join((el.text for el in element.findall("./Results/Measurement/Value"))), # noqa: E501
+ )
+
+ return self.Test(name, path, status, duration, reason)
+
+
+@export
+class JUnitTestResults(TestResults):
+ def __init__(self, filename):
+ super().__init__(self, filename)
+ self.test_format = 'JUnit'
+
+ def __iter__(self):
+ self._tests = iter(self._root.findall('testcase'))
+ return self
+
+ def __next__(self):
+ element = next(self._tests)
+
+ name = element.attrib['name']
+ path = element.attrib['file'] \
+ + ':{}'.format(element.attrib['line'])
+ duration = element.attrib['time']
+
+ failure = element.find('failure')
+ error = element.find('error')
+
+ if failure is not None and error is not None:
+ status = Results.PASS
+
+ elif error:
+ status = Results.BROKEN
+ reason = error.attrib['message'] + '\n' + error.attrib['type']
+ elif failure:
+ status = Results.FAIL
+ reason = failure.attrib['message'] + '\n' \
+ + failure.attrib['type']
+ return self.Test(name, path, status, duration, reason)
diff --git a/test/ci/scripts/hbm b/test/ci/scripts/hbm
index 494b55969..9b045363e 100755
--- a/test/ci/scripts/hbm
+++ b/test/ci/scripts/hbm
@@ -1,69 +1,98 @@
#!/usr/bin/env python3
+# ------------------------------------------------------------------------------
+__author__ = "Nicolas Richart"
+__copyright__ = "Copyright (C) 2019, EPFL (Ecole Polytechnique Fédérale" \
+ " de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
+ " en Mécanique des Solides)"
+__credits__ = ["Nicolas Richart"]
+__license__ = "L-GPLv3"
+__maintainer__ = "Nicolas Richart"
+__email__ = "nicolas.richart@epfl.ch"
+# ------------------------------------------------------------------------------
import click
import harbomaster
+
@click.group()
@click.option('-a', '--api-token', default=None, envvar='API_TOKEN')
@click.option('-h', '--host', default=None, envvar='PHABRICATOR_HOST')
@click.option('-b', '--build-target-phid', envvar='BUILD_TARGET_PHID')
@click.pass_context
def hbm(ctx, api_token, host, build_target_phid):
ctx.obj['API_TOKEN'] = api_token
ctx.obj['HOST'] = host
ctx.obj['BUILD_TARGET_PHID'] = build_target_phid
-
+
+
@hbm.command()
@click.option('-f', '--filename')
@click.pass_context
def send_ctest_results(ctx, filename):
try:
_hbm = harbomaster.Harbormaster(ctx=ctx.obj)
with harbomaster.CTestResults(filename) as tests:
_hbm.send_unit_tests(tests)
- except e:
+ except Exception:
pass
+
+@hbm.command()
+@click.option('-f', '--filename')
+@click.pass_context
+def send_junit_results(ctx, filename):
+ try:
+ _hbm = harbomaster.Harbormaster(ctx=ctx.obj)
+ with harbomaster.JUnitTestResults(filename) as tests:
+ _hbm.send_unit_tests(tests)
+ except Exception:
+ pass
+
+
@hbm.command()
@click.option('-f', '--filename')
@click.pass_context
def send_arc_lint(ctx, filename):
try:
_hbm = harbomaster.Harbormaster(ctx=ctx.obj)
with harbomaster.ARCLintJson(filename) as tests:
_hbm.send_lint(tests)
- except e:
+ except Exception:
pass
+
@hbm.command()
@click.option('-k', '--key')
@click.option('-u', '--uri')
@click.option('-l', '--label')
@click.pass_context
def send_uri(ctx, key, uri, label):
_hbm = harbomaster.Harbormaster(ctx=ctx.obj)
_hbm.send_uri(key, uri, label)
+
@hbm.command()
@click.option('-f', '--filename')
@click.option('-n', '--name')
@click.option('-v', '--view_policy', default=None)
@click.pass_context
def upload_file(ctx, filename, name, view_policy):
_hbm = harbomaster.Harbormaster(ctx=ctx.obj)
_hbm.upload_file(filename, name, view_policy)
-
+
+
@hbm.command()
@click.pass_context
def passed(ctx):
_hbm = harbomaster.Harbormaster(ctx=ctx.obj)
_hbm.passed()
+
@hbm.command()
@click.pass_context
def failed(ctx):
_hbm = harbomaster.Harbormaster(ctx=ctx.obj)
_hbm.failed()
-
+
if __name__ == '__main__':
hbm(obj={})
diff --git a/test/python_fe/__init__.py b/test/python_fe/__init__.py
index cd0379267..c778de567 100644
--- a/test/python_fe/__init__.py
+++ b/test/python_fe/__init__.py
@@ -1,44 +1,34 @@
-'''
- @package getmystuph
- @file __init__.py
- @copyright BSD
- @author Nicolas Richart <nicolas.richart@epfl.ch>
-
- @section COPYRIGHT
- Copyright (©) 2015 EPFL (Ecole Polytechnique Fédérale de Lausanne)
-
- This file is part of Akantu
-'''
import sys as __aka_sys
def export(definition):
"""
Decorator to export definitions from sub-modules to the top-level package
:param definition: definition to be exported
:return: definition
"""
__module = __aka_sys.modules[definition.__module__]
__pkg = __aka_sys.modules[__module.__package__]
__pkg.__dict__[definition.__name__] = definition
if '__all__' not in __pkg.__dict__:
__pkg.__dict__['__all__'] = []
__pkg.__all__.append(definition.__name__)
return definition
+
try:
from termcolor import colored
except ImportError:
# noinspection PyUnusedLocal
def colored(string, *args, **kwargs):
return string
__all__ = ['colored']
from . import truss_fe # NOQA: F401
from . import static_solver # NOQA: F401
from . import dynamic_solver # NOQA: F401
diff --git a/test/test_common/test_grid.cc b/test/test_common/test_grid.cc
index f470f20ce..d8064e146 100644
--- a/test/test_common/test_grid.cc
+++ b/test/test_common/test_grid.cc
@@ -1,85 +1,84 @@
/**
* @file test_grid.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Jul 15 2010
* @date last modification: Fri Dec 08 2017
*
* @brief Test the grid object
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_grid_dynamic.hh"
#include "mesh.hh"
#include "mesh_io.hh"
using namespace akantu;
int main(int argc, char * argv[]) {
const UInt spatial_dimension = 2;
akantu::initialize(argc, argv);
Mesh circle(spatial_dimension);
circle.read("circle.msh");
const auto & l = circle.getLocalLowerBounds();
const auto & u = circle.getLocalUpperBounds();
Real spacing[spatial_dimension] = {0.2, 0.2};
Vector<Real> s(spacing, spatial_dimension);
Vector<Real> c = u;
c += l;
c /= 2.;
SpatialGrid<Element> grid(spatial_dimension, s, c);
Vector<Real> bary(spatial_dimension);
Element el;
el.ghost_type = _not_ghost;
for (auto & type : circle.elementTypes(spatial_dimension)) {
UInt nb_element = circle.getNbElement(type);
el.type = type;
for (UInt e = 0; e < nb_element; ++e) {
el.element = e;
circle.getBarycenter(el, bary);
grid.insert(el, bary);
}
}
std::cout << grid << std::endl;
Mesh mesh(spatial_dimension, "save");
grid.saveAsMesh(mesh);
mesh.write("grid.msh");
-
akantu::finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_common/test_iterators.cc b/test/test_common/test_iterators.cc
index b6cedaaa7..f3b1e033b 100644
--- a/test/test_common/test_iterators.cc
+++ b/test/test_common/test_iterators.cc
@@ -1,328 +1,327 @@
/**
* @file test_zip_iterator.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jul 21 2017
* @date last modification: Fri Dec 08 2017
*
* @brief test the zip container and iterator
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_iterators.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <vector>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
template <class T> class A {
public:
A() = default;
A(T a) : a(a){};
A(const A & other)
: a(other.a), copy_counter(other.copy_counter + 1),
move_counter(other.move_counter) {}
A & operator=(const A & other) {
if (this != &other) {
a = other.a;
copy_counter = other.copy_counter + 1;
}
return *this;
}
A(A && other)
: a(std::move(other.a)), copy_counter(std::move(other.copy_counter)),
move_counter(std::move(other.move_counter) + 1) {}
A & operator=(A && other) {
if (this != &other) {
a = std::move(other.a);
copy_counter = std::move(other.copy_counter);
move_counter = std::move(other.move_counter) + 1;
}
return *this;
}
A & operator*=(const T & b) {
a *= b;
return *this;
}
T a;
size_t copy_counter{0};
size_t move_counter{0};
};
template <typename T> struct C {
struct iterator {
using reference = A<T>;
using difference_type = void;
using iterator_category = std::input_iterator_tag;
using value_type = A<T>;
using pointer = A<T> *;
iterator(T pos) : pos(std::move(pos)) {}
A<T> operator*() { return A<int>(pos); }
bool operator!=(const iterator & other) const { return pos != other.pos; }
bool operator==(const iterator & other) const { return pos == other.pos; }
iterator & operator++() {
++pos;
return *this;
}
T pos;
};
C(T begin_, T end_) : begin_(std::move(begin_)), end_(std::move(end_)) {}
iterator begin() { return iterator(begin_); }
iterator end() { return iterator(end_); }
T begin_, end_;
};
class TestZipFixutre : public ::testing::Test {
protected:
void SetUp() override {
a.reserve(size);
b.reserve(size);
for (size_t i = 0; i < size; ++i) {
a.emplace_back(i);
b.emplace_back(i + size);
}
}
template <typename A, typename B>
void check(A && a, B && b, size_t pos, size_t nb_copy, size_t nb_move) {
EXPECT_EQ(pos, a.a);
EXPECT_EQ(nb_copy, a.copy_counter);
EXPECT_EQ(nb_move, a.move_counter);
EXPECT_FLOAT_EQ(pos + this->size, b.a);
EXPECT_EQ(nb_copy, b.copy_counter);
EXPECT_EQ(nb_move, b.move_counter);
}
protected:
size_t size{20};
std::vector<A<int>> a;
std::vector<A<float>> b;
};
TEST_F(TestZipFixutre, SimpleTest) {
size_t i = 0;
for (auto && pair : zip(this->a, this->b)) {
this->check(std::get<0>(pair), std::get<1>(pair), i, 0, 0);
++i;
}
}
TEST_F(TestZipFixutre, ConstTest) {
size_t i = 0;
const auto & ca = this->a;
const auto & cb = this->b;
for (auto && pair : zip(ca, cb)) {
this->check(std::get<0>(pair), std::get<1>(pair), i, 0, 0);
EXPECT_EQ(true,
std::is_const<
std::remove_reference_t<decltype(std::get<0>(pair))>>::value);
EXPECT_EQ(true,
std::is_const<
std::remove_reference_t<decltype(std::get<1>(pair))>>::value);
++i;
}
}
TEST_F(TestZipFixutre, MixteTest) {
size_t i = 0;
const auto & cb = this->b;
for (auto && pair : zip(a, cb)) {
this->check(std::get<0>(pair), std::get<1>(pair), i, 0, 0);
EXPECT_EQ(false,
std::is_const<
std::remove_reference_t<decltype(std::get<0>(pair))>>::value);
EXPECT_EQ(true,
std::is_const<
std::remove_reference_t<decltype(std::get<1>(pair))>>::value);
++i;
}
}
TEST_F(TestZipFixutre, MoveTest) {
size_t i = 0;
for (auto && pair :
zip(C<int>(0, this->size), C<int>(this->size, 2 * this->size))) {
this->check(std::get<0>(pair), std::get<1>(pair), i, 0, 1);
++i;
}
}
TEST_F(TestZipFixutre, RandomAccess) {
auto begin = zip(a, b).begin();
auto && val5 = begin[5];
this->check(std::get<0>(val5), std::get<1>(val5), 5, 0, 0);
auto && val13 = begin[13];
this->check(std::get<0>(val13), std::get<1>(val13), 13, 0, 0);
}
TEST_F(TestZipFixutre, Cat) {
size_t i = 0;
- for (auto && data :
- make_zip_cat(zip(a, b), zip(a, b))) {
+ for (auto && data : make_zip_cat(zip(a, b), zip(a, b))) {
this->check(std::get<0>(data), std::get<1>(data), i, 0, 0);
this->check(std::get<2>(data), std::get<3>(data), i, 0, 0);
++i;
}
}
/* -------------------------------------------------------------------------- */
TEST(TestArangeIterator, Stop) {
size_t ref_i = 0;
for (auto i : arange(10)) {
EXPECT_EQ(ref_i, i);
++ref_i;
}
}
TEST(TestArangeIterator, StartStop) {
size_t ref_i = 1;
for (auto i : arange(1, 10)) {
EXPECT_EQ(ref_i, i);
++ref_i;
}
}
TEST(TestArangeIterator, StartStopStep) {
size_t ref_i = 1;
for (auto i : arange(1, 22, 2)) {
EXPECT_EQ(ref_i, i);
ref_i += 2;
}
}
TEST(TestArangeIterator, StartStopStepZipped) {
int ref_i1 = -1, ref_i2 = 1;
for (auto && i : zip(arange(-1, -10, -1), arange(1, 18, 2))) {
EXPECT_EQ(ref_i1, std::get<0>(i));
EXPECT_EQ(ref_i2, std::get<1>(i));
ref_i1 += -1;
ref_i2 += 2;
}
}
/* -------------------------------------------------------------------------- */
TEST(TestTransformAdaptor, Keys) {
std::map<std::string, int> map{
{"1", 1}, {"2", 2}, {"3", 3}, {"3", 3}, {"4", 4}};
char counter = '1';
for (auto && key : make_keys_adaptor(map)) {
EXPECT_EQ(counter, key[0]);
++counter;
}
}
TEST(TestTransformAdaptor, Values) {
std::map<std::string, int> map{
{"1", 1}, {"2", 2}, {"3", 3}, {"3", 3}, {"4", 4}};
int counter = 1;
for (auto && value : make_values_adaptor(map)) {
EXPECT_EQ(counter, value);
++counter;
}
}
static int plus1(int value) { return value + 1; }
struct Plus {
Plus(int a) : a(a) {}
int operator()(int b) { return a + b; }
private:
int a{0};
};
TEST(TestTransformAdaptor, Lambda) {
auto && container = arange(10);
for (auto && data :
zip(container, make_transform_adaptor(container, [](auto && value) {
return value + 1;
}))) {
EXPECT_EQ(std::get<0>(data) + 1, std::get<1>(data));
}
}
TEST(TestTransformAdaptor, LambdaLambda) {
std::map<std::string, int> map{
{"1", 1}, {"2", 2}, {"3", 3}, {"3", 3}, {"4", 4}};
int counter = 1;
for (auto && data : make_transform_adaptor(
make_values_adaptor(map), [](auto && value) { return value + 1; })) {
EXPECT_EQ(counter + 1, data);
++counter;
}
auto && container = arange(10);
for (auto && data :
zip(container, make_transform_adaptor(container, [](auto && value) {
return value + 1;
}))) {
EXPECT_EQ(std::get<0>(data) + 1, std::get<1>(data));
}
}
TEST(TestTransformAdaptor, Function) {
auto && container = arange(10);
for (auto && data :
zip(container, make_transform_adaptor(container, plus1))) {
EXPECT_EQ(std::get<0>(data) + 1, std::get<1>(data));
}
}
TEST(TestTransformAdaptor, Functor) {
auto && container = arange(10);
for (auto && data :
zip(container, make_transform_adaptor(container, Plus(1)))) {
EXPECT_EQ(std::get<0>(data) + 1, std::get<1>(data));
}
}
TEST(TestFilteredIterator, Simple) {
std::vector<int> values{0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
std::vector<int> filter{0, 2, 4, 10, 8, 6};
for (auto && data : zip(filter, make_filtered_adaptor(filter, values))) {
EXPECT_EQ(std::get<0>(data), std::get<1>(data));
}
}
diff --git a/test/test_common/test_tensors.cc b/test/test_common/test_tensors.cc
index 01acc27e6..6750220e1 100644
--- a/test/test_common/test_tensors.cc
+++ b/test/test_common/test_tensors.cc
@@ -1,594 +1,593 @@
/**
* @file test_tensors.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Nov 14 2017
* @date last modification: Mon Jan 22 2018
*
* @brief test the tensors types
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_array.hh"
-#include "aka_types.hh"
#include "aka_iterators.hh"
+#include "aka_types.hh"
/* -------------------------------------------------------------------------- */
#include <cstdlib>
#include <gtest/gtest.h>
#include <memory>
/* -------------------------------------------------------------------------- */
using namespace akantu;
namespace {
/* -------------------------------------------------------------------------- */
class TensorConstructorFixture : public ::testing::Test {
public:
void SetUp() override {
for (auto & r : reference) {
r = rand(); // google-test seeds srand()
}
}
void TearDown() override {}
template <typename V> void compareToRef(const V & v) {
for (int i = 0; i < size_; ++i) {
EXPECT_DOUBLE_EQ(reference[i], v.storage()[i]);
}
}
protected:
const int size_{24};
const std::array<int, 2> mat_size{{4, 6}};
// const std::array<int, 3> tens3_size{{4, 2, 3}};
std::array<double, 24> reference;
};
/* -------------------------------------------------------------------------- */
class TensorFixture : public TensorConstructorFixture {
public:
TensorFixture()
: vref(reference.data(), size_),
mref(reference.data(), mat_size[0], mat_size[1]) {}
protected:
Vector<double> vref;
Matrix<double> mref;
};
/* -------------------------------------------------------------------------- */
// Vector ----------------------------------------------------------------------
TEST_F(TensorConstructorFixture, VectorDefaultConstruct) {
Vector<double> v;
EXPECT_EQ(0, v.size());
EXPECT_EQ(nullptr, v.storage());
EXPECT_EQ(false, v.isWrapped());
}
TEST_F(TensorConstructorFixture, VectorConstruct1) {
double r = rand();
Vector<double> v(size_, r);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(false, v.isWrapped());
for (int i = 0; i < size_; ++i) {
EXPECT_DOUBLE_EQ(r, v(i));
EXPECT_DOUBLE_EQ(r, v[i]);
}
}
TEST_F(TensorConstructorFixture, VectorConstructWrapped) {
Vector<double> v(reference.data(), size_);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(true, v.isWrapped());
for (int i = 0; i < size_; ++i) {
EXPECT_DOUBLE_EQ(reference[i], v(i));
EXPECT_DOUBLE_EQ(reference[i], v[i]);
}
}
TEST_F(TensorConstructorFixture, VectorConstructInitializer) {
Vector<double> v{0., 1., 2., 3., 4., 5.};
EXPECT_EQ(6, v.size());
EXPECT_EQ(false, v.isWrapped());
for (int i = 0; i < 6; ++i) {
EXPECT_DOUBLE_EQ(i, v(i));
}
}
TEST_F(TensorConstructorFixture, VectorConstructCopy1) {
Vector<double> vref(reference.data(), reference.size());
Vector<double> v(vref);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(false, v.isWrapped());
compareToRef(v);
}
TEST_F(TensorConstructorFixture, VectorConstructCopy2) {
Vector<double> vref(reference.data(), reference.size());
Vector<double> v(vref, false);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(true, v.isWrapped());
compareToRef(v);
}
TEST_F(TensorConstructorFixture, VectorConstructProxy1) {
VectorProxy<double> vref(reference.data(), reference.size());
EXPECT_EQ(size_, vref.size());
compareToRef(vref);
Vector<double> v(vref);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(true, v.isWrapped());
compareToRef(v);
}
TEST_F(TensorConstructorFixture, VectorConstructProxy2) {
Vector<double> vref(reference.data(), reference.size());
VectorProxy<double> v(vref);
EXPECT_EQ(size_, v.size());
compareToRef(v);
}
/* -------------------------------------------------------------------------- */
TEST_F(TensorFixture, VectorEqual) {
Vector<double> v;
v = vref;
compareToRef(v);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(false, v.isWrapped());
}
TEST_F(TensorFixture, VectorEqualProxy) {
VectorProxy<double> vref_proxy(vref);
Vector<double> v;
v = vref;
compareToRef(v);
EXPECT_EQ(size_, v.size());
EXPECT_EQ(false, v.isWrapped());
}
TEST_F(TensorFixture, VectorEqualProxy2) {
Vector<double> v_store(size_, 0.);
VectorProxy<double> v(v_store);
v = vref;
compareToRef(v);
compareToRef(v_store);
}
/* -------------------------------------------------------------------------- */
TEST_F(TensorFixture, VectorSet) {
Vector<double> v(vref);
compareToRef(v);
double r = rand();
v.set(r);
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(r, v[i]);
}
TEST_F(TensorFixture, VectorClear) {
Vector<double> v(vref);
compareToRef(v);
v.clear();
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(0, v[i]);
}
/* -------------------------------------------------------------------------- */
TEST_F(TensorFixture, VectorDivide) {
Vector<double> v;
double r = rand();
v = vref / r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] / r, v[i]);
}
TEST_F(TensorFixture, VectorMultiply1) {
Vector<double> v;
double r = rand();
v = vref * r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * r, v[i]);
}
TEST_F(TensorFixture, VectorMultiply2) {
Vector<double> v;
double r = rand();
v = r * vref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * r, v[i]);
}
TEST_F(TensorFixture, VectorAddition) {
Vector<double> v;
v = vref + vref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * 2., v[i]);
}
TEST_F(TensorFixture, VectorSubstract) {
Vector<double> v;
v = vref - vref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(0., v[i]);
}
TEST_F(TensorFixture, VectorDivideEqual) {
Vector<double> v(vref);
double r = rand();
v /= r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] / r, v[i]);
}
TEST_F(TensorFixture, VectorMultiplyEqual1) {
Vector<double> v(vref);
double r = rand();
v *= r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * r, v[i]);
}
TEST_F(TensorFixture, VectorMultiplyEqual2) {
Vector<double> v(vref);
v *= v;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * reference[i], v[i]);
}
TEST_F(TensorFixture, VectorAdditionEqual) {
Vector<double> v(vref);
v += vref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * 2., v[i]);
}
TEST_F(TensorFixture, VectorSubstractEqual) {
Vector<double> v(vref);
v -= vref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(0., v[i]);
}
/* -------------------------------------------------------------------------- */
// Matrix ----------------------------------------------------------------------
TEST_F(TensorConstructorFixture, MatrixDefaultConstruct) {
Matrix<double> m;
EXPECT_EQ(0, m.size());
EXPECT_EQ(0, m.rows());
EXPECT_EQ(0, m.cols());
EXPECT_EQ(nullptr, m.storage());
EXPECT_EQ(false, m.isWrapped());
}
TEST_F(TensorConstructorFixture, MatrixConstruct1) {
double r = rand();
Matrix<double> m(mat_size[0], mat_size[1], r);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(false, m.isWrapped());
for (int i = 0; i < mat_size[0]; ++i) {
for (int j = 0; j < mat_size[1]; ++j) {
EXPECT_EQ(r, m(i, j));
EXPECT_EQ(r, m[i + j * mat_size[0]]);
}
}
}
TEST_F(TensorConstructorFixture, MatrixConstructWrapped) {
Matrix<double> m(reference.data(), mat_size[0], mat_size[1]);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(true, m.isWrapped());
for (int i = 0; i < mat_size[0]; ++i) {
for (int j = 0; j < mat_size[1]; ++j) {
EXPECT_DOUBLE_EQ(reference[i + j * mat_size[0]], m(i, j));
}
}
compareToRef(m);
}
TEST_F(TensorConstructorFixture, MatrixConstructInitializer) {
Matrix<double> m{{0., 1., 2.}, {3., 4., 5.}};
EXPECT_EQ(6, m.size());
EXPECT_EQ(2, m.rows());
EXPECT_EQ(3, m.cols());
EXPECT_EQ(false, m.isWrapped());
int c = 0;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 3; ++j, ++c) {
EXPECT_DOUBLE_EQ(c, m(i, j));
}
}
}
TEST_F(TensorConstructorFixture, MatrixConstructCopy1) {
Matrix<double> mref(reference.data(), mat_size[0], mat_size[1]);
Matrix<double> m(mref);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(false, m.isWrapped());
compareToRef(m);
}
TEST_F(TensorConstructorFixture, MatrixConstructCopy2) {
Matrix<double> mref(reference.data(), mat_size[0], mat_size[1]);
Matrix<double> m(mref);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(false, m.isWrapped());
compareToRef(m);
}
TEST_F(TensorConstructorFixture, MatrixConstructProxy1) {
MatrixProxy<double> mref(reference.data(), mat_size[0], mat_size[1]);
EXPECT_EQ(size_, mref.size());
EXPECT_EQ(mat_size[0], mref.size(0));
EXPECT_EQ(mat_size[1], mref.size(1));
compareToRef(mref);
Matrix<double> m(mref);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(true, m.isWrapped());
compareToRef(m);
}
TEST_F(TensorConstructorFixture, MatrixConstructProxy2) {
Matrix<double> mref(reference.data(), mat_size[0], mat_size[1]);
MatrixProxy<double> m(mref);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.size(0));
EXPECT_EQ(mat_size[1], m.size(1));
compareToRef(m);
}
/* -------------------------------------------------------------------------- */
TEST_F(TensorFixture, MatrixEqual) {
Matrix<double> m;
m = mref;
compareToRef(m);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(false, m.isWrapped());
}
TEST_F(TensorFixture, MatrixEqualProxy1) {
MatrixProxy<double> mref_proxy(mref);
Matrix<double> m;
m = mref;
compareToRef(m);
EXPECT_EQ(size_, m.size());
EXPECT_EQ(mat_size[0], m.rows());
EXPECT_EQ(mat_size[1], m.cols());
EXPECT_EQ(false, m.isWrapped());
}
TEST_F(TensorFixture, MatrixEqualProxy2) {
Matrix<double> m_store(mat_size[0], mat_size[1], 0.);
MatrixProxy<double> m(m_store);
m = mref;
compareToRef(m);
compareToRef(m_store);
}
TEST_F(TensorFixture, MatrixEqualSlice) {
Matrix<double> m(mat_size[0], mat_size[1], 0.);
for (unsigned int i = 0; i < m.cols(); ++i)
m(i) = Vector<Real>(mref(i));
compareToRef(m);
}
/* -------------------------------------------------------------------------- */
TEST_F(TensorFixture, MatrixSet) {
Matrix<double> m(mref);
compareToRef(m);
double r = rand();
m.set(r);
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(r, m[i]);
}
TEST_F(TensorFixture, MatrixClear) {
Matrix<double> m(mref);
compareToRef(m);
m.clear();
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(0, m[i]);
}
/* -------------------------------------------------------------------------- */
TEST_F(TensorFixture, MatrixDivide) {
Matrix<double> m;
double r = rand();
m = mref / r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] / r, m[i]);
}
TEST_F(TensorFixture, MatrixMultiply1) {
Matrix<double> m;
double r = rand();
m = mref * r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * r, m[i]);
}
TEST_F(TensorFixture, MatrixMultiply2) {
Matrix<double> m;
double r = rand();
m = r * mref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * r, m[i]);
}
TEST_F(TensorFixture, MatrixAddition) {
Matrix<double> m;
m = mref + mref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * 2., m[i]);
}
TEST_F(TensorFixture, MatrixSubstract) {
Matrix<double> m;
m = mref - mref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(0., m[i]);
}
TEST_F(TensorFixture, MatrixDivideEqual) {
Matrix<double> m(mref);
double r = rand();
m /= r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] / r, m[i]);
}
TEST_F(TensorFixture, MatrixMultiplyEqual1) {
Matrix<double> m(mref);
double r = rand();
m *= r;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * r, m[i]);
}
TEST_F(TensorFixture, MatrixAdditionEqual) {
Matrix<double> m(mref);
m += mref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(reference[i] * 2., m[i]);
}
TEST_F(TensorFixture, MatrixSubstractEqual) {
Matrix<double> m(mref);
m -= mref;
for (int i = 0; i < size_; ++i)
EXPECT_DOUBLE_EQ(0., m[i]);
}
TEST_F(TensorFixture, MatrixIterator) {
Matrix<double> m(mref);
UInt col_count = 0;
for (auto && col : m) {
Vector<Real> col_hand(m.storage() + col_count * m.rows(), m.rows());
Vector<Real> col_wrap(col);
auto comp = (col_wrap - col_hand).norm<L_inf>();
EXPECT_DOUBLE_EQ(0., comp);
++col_count;
}
}
TEST_F(TensorFixture, MatrixIteratorZip) {
Matrix<double> m1(mref);
Matrix<double> m2(mref);
UInt col_count = 0;
for (auto && col : zip(m1, m2)) {
Vector<Real> col1(std::get<0>(col));
Vector<Real> col2(std::get<1>(col));
auto comp = (col1 - col2).norm<L_inf>();
EXPECT_DOUBLE_EQ(0., comp);
++col_count;
}
}
-
#if defined(AKANTU_USE_LAPACK)
TEST_F(TensorFixture, MatrixEigs) {
Matrix<double> m{{0, 1, 0, 0}, {1., 0, 0, 0}, {0, 1, 0, 1}, {0, 0, 4, 0}};
Matrix<double> eig_vects(4, 4);
Vector<double> eigs(4);
m.eig(eigs, eig_vects);
Vector<double> eigs_ref{2, 1., -1., -2};
auto lambda_v = m * eig_vects;
for (int i = 0; i < 4; ++i) {
EXPECT_NEAR(eigs_ref(i), eigs(i), 1e-14);
for (int j = 0; j < 4; ++j) {
EXPECT_NEAR(lambda_v(i)(j), eigs(i) * eig_vects(i)(j), 1e-14);
}
}
}
#endif
/* -------------------------------------------------------------------------- */
} // namespace
diff --git a/test/test_fe_engine/py_engine/__init__.py b/test/test_fe_engine/py_engine/__init__.py
index 0ff4f9bcb..ad166ecf8 100644
--- a/test/test_fe_engine/py_engine/__init__.py
+++ b/test/test_fe_engine/py_engine/__init__.py
@@ -1,6 +1,6 @@
__all__ = []
-from .py_engine import *
-from . import py_engine as __pye
+from .py_engine import * # noqa: F401,F403
+from . import py_engine as __pye # noqa: F401
__all__.append(__pye.__all__)
diff --git a/test/test_fe_engine/py_engine/py_engine.py b/test/test_fe_engine/py_engine/py_engine.py
index 7767f9edc..8ee8fdc08 100644
--- a/test/test_fe_engine/py_engine/py_engine.py
+++ b/test/test_fe_engine/py_engine/py_engine.py
@@ -1,355 +1,364 @@
#!/usr/bin/env python3
+
# -*- coding: utf-8 -*-
# ------------------------------------------------------------------------------
__author__ = "Nicolas Richart"
__copyright__ = "Copyright (C) 2016-2018, EPFL (Ecole Polytechnique Fédérale" \
" de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
" en Mécanique des Solides)"
__credits__ = ["Nicolas Richart"]
__license__ = "L-GPLv3"
__maintainer__ = "Nicolas Richart"
__email__ = "nicolas.richart@epfl.ch"
# ------------------------------------------------------------------------------
__all__ = ['Shapes']
import numpy as np
import numpy.polynomial.polynomial as poly
-import akantu as aka
-class Shapes(object):
+# pylint: disable=missing-docstring, invalid-name, too-many-instance-attributes
+# flake8: noqa
+
+
+class Shapes:
+ """Python version of the shape functions for test purposes"""
+ # pylint: disable=bad-whitespace, line-too-long
+
NATURAL_COORDS = {
(1, 'quadrangle'): np.array([[-1.], [1.], [0.]]),
(2, 'quadrangle'): np.array([[-1., -1.], [ 1., -1.], [ 1., 1.], [-1., 1.],
[ 0., -1.], [ 1., 0.], [ 0., 1.], [-1., 0.]]),
(3, 'quadrangle'): np.array([[-1., -1., -1.], [ 1., -1., -1.], [ 1., 1., -1.], [-1., 1., -1.],
[-1., -1., 1.], [ 1., -1., 1.], [ 1., 1., 1.], [-1., 1., 1.],
[ 0., -1., -1.], [ 1., 0., -1.], [ 0., 1., -1.], [-1., 0., -1.],
[-1., -1., 0.], [ 1., -1., 0.], [ 1., 1., 0.], [-1., 1., 0.],
[ 0., -1., 1.], [ 1., 0., 1.], [ 0., 1., 1.], [-1., 0., 1.]]),
- (2, 'triangle'): np.array([[0., 0.], [1., 0.], [0., 1,], [.5, 0.], [.5, .5], [0., .5]]),
+ (2, 'triangle'): np.array([[0., 0.], [1., 0.], [0., 1], [.5, 0.], [.5, .5], [0., .5]]),
(3, 'triangle'): np.array([[0., 0., 0.], [1., 0., 0.], [0., 1., 0.], [0., 0., 1.],
[.5, 0., 0.], [.5, .5, 0.], [0., .5, 0.],
[0., 0., .5], [.5, 0., .5], [0., .5, .5]]),
(3, 'pentahedron'): np.array([[-1., 1., 0.], [-1., 0., 1.], [-1., 0., 0.],
[ 1., 1., 0.], [ 1., 0., 1.], [ 1., 0., 0.],
[-1., .5, .5], [-1., 0., .5], [-1., .5, 0.],
[ 0., 1., 0.], [ 0., 0., 1.], [ 0., 0., 0.],
[ 1., .5, .5], [ 1., 0., .5], [ 1., .5, 0.],
[ 0., .5, .5], [ 0., 0., .5], [ 0., .5, 0.]]),
}
QUADRATURE_W = {
(1, 'quadrangle', 1): np.array([2.]),
(1, 'quadrangle', 2): np.array([1., 1.]),
(2, 'triangle', 1): np.array([1./2.]),
(2, 'triangle', 2): np.array([1., 1., 1.])/6.,
(3, 'triangle', 1): np.array([1./6.]),
(3, 'triangle', 2): np.array([1., 1., 1., 1.])/24.,
(2, 'quadrangle', 1): np.array([1., 1., 1., 1.]),
(2, 'quadrangle', 2): np.array([1., 1., 1., 1.]),
(3, 'quadrangle', 1): np.array([1., 1., 1., 1.,
1., 1., 1., 1.]),
(3, 'quadrangle', 2): np.array([1., 1., 1., 1.,
1., 1., 1., 1.]),
(3, 'pentahedron', 1): np.array([1., 1., 1., 1., 1., 1.])/6.,
(3, 'pentahedron', 2): np.array([1., 1., 1., 1., 1., 1.])/6.,
}
_tet_a = (5. - np.sqrt(5.))/20.
_tet_b = (5. + 3.*np.sqrt(5.))/20.
QUADRATURE_G = {
(1, 'quadrangle', 1): np.array([[0.]]),
(1, 'quadrangle', 2): np.array([[-1.], [1.]])/np.sqrt(3.),
(2, 'triangle', 1): np.array([[1., 1.]])/3.,
(2, 'triangle', 2): np.array([[1./6., 1./6.], [2./3, 1./6], [1./6., 2./3.]]),
(3, 'triangle', 1): np.array([[1., 1., 1.]])/4.,
(3, 'triangle', 2): np.array([[_tet_a, _tet_a, _tet_a],
[_tet_b, _tet_a, _tet_a],
[_tet_a, _tet_b, _tet_a],
[_tet_a, _tet_a, _tet_b]]),
(2, 'quadrangle', 1): np.array([[-1., -1.], [ 1., -1.],
[-1., 1.], [ 1., 1.]])/np.sqrt(3.),
(2, 'quadrangle', 2): np.array([[-1., -1.], [ 1., -1.],
[-1., 1.], [ 1., 1.]])/np.sqrt(3.),
(3, 'quadrangle', 1): np.array([[-1., -1., -1.],
[ 1., -1., -1.],
[-1., 1., -1.],
[ 1., 1., -1.],
[-1., -1., 1.],
[ 1., -1., 1.],
[-1., 1., 1.],
[ 1., 1., 1.]])/np.sqrt(3.),
(3, 'quadrangle', 2): np.array([[-1., -1., -1.],
[ 1., -1., -1.],
[-1., 1., -1.],
[ 1., 1., -1.],
[-1., -1., 1.],
[ 1., -1., 1.],
[-1., 1., 1.],
[ 1., 1., 1.]])/np.sqrt(3.),
- # (3, 'pentahedron', 1): np.array([[-1./np.sqrt(3.), 0.5, 0.5],
- # [-1./np.sqrt(3.), 0. , 0.5],
- # [-1./np.sqrt(3.), 0.5, 0. ],
- # [ 1./np.sqrt(3.), 0.5, 0.5],
- # [ 1./np.sqrt(3.), 0. , 0.5],
- # [ 1./np.sqrt(3.), 0.5 ,0. ]]),
(3, 'pentahedron', 1): np.array([[-1./np.sqrt(3.), 1./6., 1./6.],
[-1./np.sqrt(3.), 2./3., 1./6.],
[-1./np.sqrt(3.), 1./6., 2./3.],
[ 1./np.sqrt(3.), 1./6., 1./6.],
[ 1./np.sqrt(3.), 2./3., 1./6.],
[ 1./np.sqrt(3.), 1./6., 2./3.]]),
(3, 'pentahedron', 2): np.array([[-1./np.sqrt(3.), 1./6., 1./6.],
[-1./np.sqrt(3.), 2./3., 1./6.],
[-1./np.sqrt(3.), 1./6., 2./3.],
[ 1./np.sqrt(3.), 1./6., 1./6.],
[ 1./np.sqrt(3.), 2./3., 1./6.],
[ 1./np.sqrt(3.), 1./6., 2./3.]]),
}
ELEMENT_TYPES = {
'_segment_2': ('quadrangle', 1, 'lagrange', 1, 2),
'_segment_3': ('quadrangle', 2, 'lagrange', 1, 3),
'_triangle_3': ('triangle', 1, 'lagrange', 2, 3),
'_triangle_6': ('triangle', 2, 'lagrange', 2, 6),
'_quadrangle_4': ('quadrangle', 1, 'serendip', 2, 4),
'_quadrangle_8': ('quadrangle', 2, 'serendip', 2, 8),
'_tetrahedron_4': ('triangle', 1, 'lagrange', 3, 4),
'_tetrahedron_10': ('triangle', 2, 'lagrange', 3, 10),
'_pentahedron_6': ('pentahedron', 1, 'lagrange', 3, 6),
'_pentahedron_15': ('pentahedron', 2, 'lagrange', 3, 15),
'_hexahedron_8': ('quadrangle', 1, 'serendip', 3, 8),
'_hexahedron_20': ('quadrangle', 2, 'serendip', 3, 20),
}
MONOMES = {(1, 'quadrangle'): np.array([[0], [1], [2], [3], [4], [5]]),
(2, 'triangle'): np.array([[0, 0], # 1
[1, 0], [0, 1], # x y
[2, 0], [1, 1], [0, 2]]), # x^2 x.y y^2
(2, 'quadrangle'): np.array([[0, 0],
[1, 0], [1, 1], [0, 1],
[2, 0], [2, 1], [1, 2], [0, 2]]),
(3, 'triangle'): np.array([[0, 0, 0],
[1, 0, 0], [0, 1, 0], [0, 0, 1],
[2, 0, 0], [1, 1, 0], [0, 2, 0], [0, 1, 1], [0, 0, 2],
[1, 0, 1]]),
(3, 'quadrangle'): np.array([[0, 0, 0],
[1, 0, 0], [0, 1, 0], [0, 0, 1],
[1, 1, 0], [1, 0, 1],
[0, 1, 1], [1, 1, 1],
[2, 0, 0], [0, 2, 0], [0, 0, 2],
[2, 1, 0], [2, 0, 1], [2, 1, 1],
[1, 2, 0], [0, 2, 1], [1, 2, 1],
- [1, 0, 2], [0, 1, 2], [1, 1, 2]]),
- }
+ [1, 0, 2], [0, 1, 2], [1, 1, 2]])}
SHAPES = {
(3, 'pentahedron', 1): np.array([
[[[ 0., 0.], [ 1., 0.]], [[ 0., 0.], [-1., 0.]]],
[[[ 0., 1.], [ 0., 0.]], [[ 0., -1.], [ 0., 0.]]],
[[[ 1., -1.], [-1., 0.]], [[-1., 1.], [ 1., 0.]]],
[[[ 0., 0.], [ 1., 0.]], [[ 0., 0.], [ 1., 0.]]],
[[[ 0., 1.], [ 0., 0.]], [[ 0., 1.], [ 0., 0.]]],
[[[ 1., -1.], [-1., 0.]], [[ 1., -1.], [-1., 0.]]]
])/2.,
(3, 'pentahedron', 2): np.array([
# 0
[[[ 0. , 0. , 0. ], [-1. , 0. , 0. ], [ 1. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0.5, 0. , 0. ], [-1. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0.5, 0. , 0. ], [ 0. , 0. , 0. ]]],
# 1
[[[ 0. , -1. , 1. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0.5, -1. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0.5, 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 2
[[[ 0. , -1. , 1. ], [-1. , 2. , 0. ], [ 1. , 0. , 0. ]],
[[-0.5, 1.5, -1. ], [ 1.5, -2. , 0. ], [-1. , 0. , 0. ]],
[[ 0.5, -0.5, 0. ], [-0.5, 0. , 0. ], [ 0. , 0. , 0. ]]],
# 3
[[[ 0. , 0. , 0. ], [-1. , 0. , 0. ], [ 1. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [-0.5, 0. , 0. ], [ 1. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0.5, 0. , 0. ], [ 0. , 0. , 0. ]]],
# 4
[[[ 0. , -1. , 1. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , -0.5, 1. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0.5, 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 5
[[[ 0. , -1. , 1. ], [-1. , 2. , 0. ], [ 1. , 0. , 0. ]],
[[ 0.5, -1.5, 1. ], [-1.5, 2. , 0. ], [ 1. , 0. , 0. ]],
[[ 0.5, -0.5, 0. ], [-0.5, 0. , 0. ], [ 0. , 0. , 0. ]]],
# 6
[[[ 0. , 0. , 0. ], [ 0. , 2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , -2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 7
[[[ 0. , 2. , -2. ], [ 0. , -2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , -2. , 2. ], [ 0. , 2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 8
[[[ 0. , 0. , 0. ], [ 2. , -2. , 0. ], [-2. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [-2. , 2. , 0. ], [ 2. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 9
[[[ 0. , 0. , 0. ], [ 1. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [-1. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 10
[[[ 0. , 1. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , -1. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 11
[[[ 1. , -1. , 0. ], [-1. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]],
[[-1. , 1. , 0. ], [ 1. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 12
[[[ 0. , 0. , 0. ], [ 0. , 2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 13
[[[ 0. , 2. , -2. ], [ 0. , -2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 2. , -2. ], [ 0. , -2. , 0. ], [ 0. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
# 14
[[[ 0. , 0. , 0. ], [ 2. , -2. , 0. ], [-2. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 2. , -2. , 0. ], [-2. , 0. , 0. ]],
[[ 0. , 0. , 0. ], [ 0. , 0. , 0. ], [ 0. , 0. , 0. ]]],
])}
+ # pylint: enable=bad-whitespace, line-too-long
- def __init__(self, element):
- self._shape, self._order, self._inter_poly, self._dim, self._nnodes = self.ELEMENT_TYPES[element]
+ def __init__(self, element):
+ self._shape, self._order, self._inter_poly, self._dim, \
+ self._nnodes = self.ELEMENT_TYPES[element]
self._ksi = self.NATURAL_COORDS[(self._dim, self._shape)][:self._nnodes]
self._g = self.QUADRATURE_G[(self._dim, self._shape, self._order)]
self._w = self.QUADRATURE_W[(self._dim, self._shape, self._order)]
+ self._poly_shape = ()
+ self._monome = []
def polyval(self, x, p):
- if 1 == self._dim:
+ if self._dim == 1:
return poly.polyval(x[0], p)
- if 2 == self._dim:
+ if self._dim == 2:
return poly.polyval2d(x[0], x[1], p)
- if 3 == self._dim:
+ if self._dim == 3:
return poly.polyval3d(x[0], x[1], x[2], p)
+ return None
def shape_from_monomes(self):
momo = self.MONOMES[(self._dim, self._shape)][:self._nnodes]
- _shape = list(momo[0])
+ _shapes = list(momo[0])
- for s in range(len(_shape)):
- _shape[s] = max(momo[:,s])+1
- self._poly_shape = tuple(_shape)
+ for s, _ in enumerate(_shapes):
+ _shapes[s] = max(momo[:, s])+1
+ self._poly_shape = tuple(_shapes)
self._monome = []
for m in momo:
p = np.zeros(self._poly_shape)
p[tuple(m)] = 1
self._monome.append(p)
# evaluate polynomial constant for shapes
_x = self._ksi
_xe = np.zeros((self._nnodes, self._nnodes))
for n in range(self._nnodes):
- _xe[:,n] = [self.polyval(_x[n], m) for m in self._monome]
+ _xe[:, n] = [self.polyval(_x[n], m) for m in self._monome]
_a = np.linalg.inv(_xe)
_n = np.zeros((self._nnodes,) + self._monome[0].shape)
# set shapes polynomials
for n in range(self._nnodes):
for m in range(len(self._monome)):
_n[n] += _a[n, m] * self._monome[m]
return _n
def compute_shapes(self):
if (self._dim, self._shape) in self.MONOMES:
return self.shape_from_monomes()
- else:
- _n = self.SHAPES[(self._dim, self._shape, self._order)]
- self._poly_shape = _n[0].shape
- return _n
+ _n = self.SHAPES[(self._dim, self._shape, self._order)]
+ self._poly_shape = _n[0].shape
+ return _n
+
+ # pylint: disable=too-many-locals,too-many-branches
def precompute(self, **kwargs):
- X = np.array(kwargs["X"], copy=False)
+ X = np.array(kwargs["X"], copy=False)
nb_element = X.shape[0]
X = X.reshape(nb_element, self._nnodes, self._dim)
_x = self._ksi
_n = self.compute_shapes()
# sanity check on shapes
for n in range(self._nnodes):
for m in range(self._nnodes):
v = self.polyval(_x[n], _n[m])
ve = 1. if n == m else 0.
test = np.isclose(v, ve)
if not test:
raise Exception("Most probably an error in the shapes evaluation")
# compute shapes derivatives
_b = np.zeros((self._dim, self._nnodes,) + self._poly_shape)
for d in range(self._dim):
for n in range(self._nnodes):
_der = poly.polyder(_n[n], axis=d)
_mshape = np.array(self._poly_shape)
_mshape[d] = _mshape[d] - _der.shape[d]
_mshape = tuple(_mshape)
_comp = np.zeros(_mshape)
- if 1 == self._dim:
+ if self._dim == 1:
_bt = np.hstack((_der, _comp))
else:
- if 0 == d:
+ if d == 0:
_bt = np.vstack((_der, _comp))
- if 1 == d:
+ if d == 1:
_bt = np.hstack((_der, _comp))
- if 2 == d:
+ if d == 2:
_bt = np.dstack((_der, _comp))
_b[d, n] = _bt
_nb_quads = len(self._g)
_nq = np.zeros((_nb_quads, self._nnodes))
_bq = np.zeros((_nb_quads, self._dim, self._nnodes))
# evaluate shapes and shapes derivatives on gauss points
for q in range(_nb_quads):
_g = self._g[q]
for n in range(self._nnodes):
_nq[q, n] = self.polyval(_g, _n[n])
for d in range(self._dim):
_bq[q, d, n] = self.polyval(_g, _b[d, n])
_j = np.array(kwargs['j'], copy=False).reshape((nb_element, _nb_quads))
- _B = np.array(kwargs['B'], copy=False).reshape((nb_element, _nb_quads, self._nnodes, self._dim))
+ _B = np.array(kwargs['B'], copy=False).reshape((nb_element, _nb_quads,
+ self._nnodes, self._dim))
_N = np.array(kwargs['N'], copy=False).reshape((nb_element, _nb_quads, self._nnodes))
_Q = kwargs['Q']
if np.linalg.norm(_Q - self._g.T) > 1e-15:
- raise Exception('Not using the same quadrature points norm({0} - {1}) = {2}'.format(_Q, self._g.T, np.linalg.norm(_Q - self._g.T)))
+ raise Exception('Not using the same quadrature'
+ ' points norm({0} - {1}) = {2}'.format(_Q, self._g.T,
+ np.linalg.norm(_Q - self._g.T)))
for e in range(nb_element):
for q in range(_nb_quads):
_J = np.matmul(_bq[q], X[e])
- if(np.linalg.norm(_N[e, q] - _nq[q]) > 1e-10):
+ if np.linalg.norm(_N[e, q] - _nq[q]) > 1e-10:
print(f"{e},{q}")
print(_N[e, q])
print(_nq[q])
_N[e, q] = _nq[q]
_tmp = np.matmul(np.linalg.inv(_J), _bq[q])
_B[e, q] = _tmp.T
_j[e, q] = np.linalg.det(_J) * self._w[q]
diff --git a/test/test_fe_engine/test_fe_engine_gauss_integration.cc b/test/test_fe_engine/test_fe_engine_gauss_integration.cc
index a50f476e7..35e20e831 100644
--- a/test/test_fe_engine/test_fe_engine_gauss_integration.cc
+++ b/test/test_fe_engine/test_fe_engine_gauss_integration.cc
@@ -1,154 +1,154 @@
/**
* @file test_fe_engine_gauss_integration.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue May 24 2016
* @date last modification: Mon Feb 19 2018
*
* @brief test integration on elements, this test consider that mesh is a cube
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_fe_engine_fixture.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
namespace {
/* -------------------------------------------------------------------------- */
template <size_t t> using degree_t = std::integral_constant<size_t, t>;
/* -------------------------------------------------------------------------- */
using TestDegreeTypes = std::tuple<degree_t<0>, degree_t<1>, degree_t<2>,
degree_t<3>, degree_t<4>, degree_t<5>>;
std::array<Polynomial<5>, 3> global_polys{
{{0.40062394, 0.13703225, 0.51731446, 0.87830084, 0.5410543, 0.71842292},
{0.41861835, 0.11080576, 0.49874043, 0.49077504, 0.85073835, 0.66259755},
{0.92620845, 0.7503478, 0.62962232, 0.31662719, 0.64069644, 0.30878135}}};
template <typename T>
class TestGaussIntegrationFixture
: public TestFEMFixture<std::tuple_element_t<0, T>> {
protected:
using parent = TestFEMFixture<std::tuple_element_t<0, T>>;
static constexpr size_t degree{std::tuple_element_t<1, T>::value};
public:
TestGaussIntegrationFixture() : integration_points_pos(0, parent::dim) {}
void SetUp() override {
parent::SetUp();
this->fem->initShapeFunctions();
auto integration_points =
this->fem->getIntegrator().template getIntegrationPoints <
parent::type,
degree == 0 ? 1 : degree > ();
nb_integration_points = integration_points.cols();
auto shapes_size = ElementClass<parent::type>::getShapeSize();
Array<Real> shapes(0, shapes_size);
this->fem->getShapeFunctions()
.template computeShapesOnIntegrationPoints<parent::type>(
this->mesh->getNodes(), integration_points, shapes, _not_ghost);
auto vect_size = this->nb_integration_points * this->nb_element;
integration_points_pos.resize(vect_size);
this->fem->getShapeFunctions()
.template interpolateOnIntegrationPoints<parent::type>(
this->mesh->getNodes(), integration_points_pos, this->dim, shapes);
for (size_t d = 0; d < this->dim; ++d) {
polys[d] = global_polys[d].extract(degree);
}
}
void testIntegrate() {
std::stringstream sstr;
sstr << this->type << ":" << this->degree;
SCOPED_TRACE(sstr.str().c_str());
auto vect_size = this->nb_integration_points * this->nb_element;
Array<Real> polynomial(vect_size);
size_t dim = parent::dim;
for (size_t d = 0; d < dim; ++d) {
auto poly = this->polys[d];
for (auto && pair :
zip(polynomial, make_view(this->integration_points_pos, dim))) {
auto && p = std::get<0>(pair);
auto & x = std::get<1>(pair);
p = poly(x(d));
}
auto res =
this->fem->getIntegrator()
.template integrate<parent::type, (degree == 0 ? 1 : degree)>(
polynomial);
auto expect = poly.integrate(this->lower(d), this->upper(d));
for (size_t o = 0; o < dim; ++o) {
if (o == d)
continue;
expect *= this->upper(d) - this->lower(d);
}
EXPECT_NEAR(expect, res, 5e-14);
}
}
protected:
UInt nb_integration_points;
std::array<Array<Real>, parent::dim> polynomial;
Array<Real> integration_points_pos;
std::array<Polynomial<5>, 3> polys;
};
template <typename T> constexpr size_t TestGaussIntegrationFixture<T>::degree;
/* -------------------------------------------------------------------------- */
/* Tests */
/* -------------------------------------------------------------------------- */
TYPED_TEST_SUITE_P(TestGaussIntegrationFixture);
TYPED_TEST_P(TestGaussIntegrationFixture, ArbitraryOrder) {
this->testIntegrate();
}
REGISTER_TYPED_TEST_SUITE_P(TestGaussIntegrationFixture, ArbitraryOrder);
using TestTypes = gtest_list_t<
tuple_split_t<50, cross_product_t<TestElementTypes, TestDegreeTypes>>>;
INSTANTIATE_TYPED_TEST_SUITE_P(Split1, TestGaussIntegrationFixture, TestTypes);
using TestTypesTail = gtest_list_t<
tuple_split_tail_t<50, cross_product_t<TestElementTypes, TestDegreeTypes>>>;
INSTANTIATE_TYPED_TEST_SUITE_P(Split2, TestGaussIntegrationFixture,
- TestTypesTail);
-}
+ TestTypesTail);
+} // namespace
diff --git a/test/test_fe_engine/test_fe_engine_precomputation.cc b/test/test_fe_engine/test_fe_engine_precomputation.cc
index 0ee453258..3e75e2ec7 100644
--- a/test/test_fe_engine/test_fe_engine_precomputation.cc
+++ b/test/test_fe_engine/test_fe_engine_precomputation.cc
@@ -1,116 +1,114 @@
/**
* @file test_fe_engine_precomputation.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Mon Jun 14 2010
* @date last modification: Mon Feb 19 2018
*
* @brief test of the fem class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "py_aka_array.hh"
#include "test_fe_engine_fixture.hh"
/* -------------------------------------------------------------------------- */
#include <pybind11/embed.h>
#include <pybind11/numpy.h>
/* -------------------------------------------------------------------------- */
using namespace akantu;
namespace py = pybind11;
using namespace py::literals;
-template<class T>
-decltype(auto) make_proxy(Array<T> & array) {
- return Proxy<Array<T>>(array);
+template <class T> decltype(auto) make_proxy(Array<T> & array) {
+ return detail::ArrayProxy<T>(array);
}
template <typename type_>
class TestFEMPyFixture : public TestFEMFixture<type_> {
using parent = TestFEMFixture<type_>;
public:
void SetUp() override {
parent::SetUp();
const auto & connectivities = this->mesh->getConnectivity(this->type);
const auto & nodes = this->mesh->getNodes().begin(this->dim);
coordinates = std::make_unique<Array<Real>>(
connectivities.size(), connectivities.getNbComponent() * this->dim);
for (auto && tuple :
zip(make_view(connectivities, connectivities.getNbComponent()),
make_view(*coordinates, this->dim,
connectivities.getNbComponent()))) {
const auto & conn = std::get<0>(tuple);
const auto & X = std::get<1>(tuple);
for (auto s : arange(conn.size())) {
Vector<Real>(X(s)) = Vector<Real>(nodes[conn(s)]);
}
}
}
void TearDown() override {
parent::TearDown();
coordinates.reset(nullptr);
}
protected:
std::unique_ptr<Array<Real>> coordinates;
};
TYPED_TEST_SUITE(TestFEMPyFixture, fe_engine_types);
TYPED_TEST(TestFEMPyFixture, Precompute) {
SCOPED_TRACE(std::to_string(this->type));
this->fem->initShapeFunctions();
const auto & N = this->fem->getShapeFunctions().getShapes(this->type);
const auto & B =
this->fem->getShapeFunctions().getShapesDerivatives(this->type);
const auto & j = this->fem->getIntegrator().getJacobians(this->type);
// Array<Real> ref_N(this->nb_quadrature_points_total, N.getNbComponent());
// Array<Real> ref_B(this->nb_quadrature_points_total, B.getNbComponent());
Array<Real> ref_j(this->nb_quadrature_points_total, j.getNbComponent());
auto ref_N(N);
auto ref_B(B);
py::module py_engine = py::module::import("py_engine");
auto py_shape = py_engine.attr("Shapes")(py::str(std::to_string(this->type)));
- auto kwargs = py::dict(
- "N"_a = ref_N, "B"_a = ref_B,
- "j"_a = ref_j, "X"_a = *this->coordinates,
- "Q"_a = this->fem->getIntegrationPoints(this->type));
+ auto kwargs = py::dict("N"_a = ref_N, "B"_a = ref_B, "j"_a = ref_j,
+ "X"_a = *this->coordinates,
+ "Q"_a = this->fem->getIntegrationPoints(this->type));
auto ret = py_shape.attr("precompute")(**kwargs);
auto check = [&](auto & ref_A, auto & A, const auto & id) {
SCOPED_TRACE(std::to_string(this->type) + " " + id);
for (auto && n : zip(make_view(ref_A, ref_A.getNbComponent()),
make_view(A, A.getNbComponent()))) {
auto diff = (std::get<0>(n) - std::get<1>(n)).template norm<L_inf>();
EXPECT_NEAR(0., diff, 1e-10);
}
};
check(ref_N, N, "N");
check(ref_B, B, "B");
check(ref_j, j, "j");
}
diff --git a/test/test_fe_engine/test_fe_engine_precomputation_bernoulli_3.cc b/test/test_fe_engine/test_fe_engine_precomputation_bernoulli_3.cc
index 1edead6c1..a23f9d630 100644
--- a/test/test_fe_engine/test_fe_engine_precomputation_bernoulli_3.cc
+++ b/test/test_fe_engine/test_fe_engine_precomputation_bernoulli_3.cc
@@ -1,105 +1,105 @@
/**
* @file test_fe_engine_precomputation_bernoulli_3.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Jan 24 2018
*
* @brief test of the fem class
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "fe_engine.hh"
#include "integrator_gauss.hh"
#include "shape_structural.hh"
/* -------------------------------------------------------------------------- */
#include <cmath>
#include <functional>
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/**
* Reference: p. 285, example 5.7 - A First Course in the Finite Elements Method
* Logan, 6th Edition, 2016
* ISBN-13: 978-1-305-63734-4
*/
Matrix<Real> rotationReference() {
return {{3. / 13, 4. / 13, 12. / 13},
{-4. / 5, 3. / 5, 0},
{-36. / 65, -48. / 65, 5. / 13}};
}
int main(int argc, char * argv[]) {
akantu::initialize(argc, argv);
// debug::setDebugLevel(dblTest);
constexpr ElementType type = _bernoulli_beam_3;
UInt dim = ElementClass<type>::getSpatialDimension();
Mesh mesh(dim);
// Pushing nodes
Vector<Real> node = {0, 0, 0};
mesh.getNodes().push_back(node);
node = {3, 4, 12};
mesh.getNodes().push_back(node);
// Pushing connectivity
mesh.addConnectivityType(type);
auto & connectivity = mesh.getConnectivity(type);
Vector<UInt> elem = {0, 1};
connectivity.push_back(elem);
// Pushing normals
- auto & normals =
- mesh.registerElementalData<Real>("extra_normal").alloc(0, dim, type, _not_ghost);
+ auto & normals = mesh.registerElementalData<Real>("extra_normal")
+ .alloc(0, dim, type, _not_ghost);
Vector<Real> normal = {-36. / 65, -48. / 65, 5. / 13};
normals.push_back(normal);
normals.push_back(normal);
using FE = FEEngineTemplate<IntegratorGauss, ShapeStructural, _ek_structural>;
using ShapeStruct = ShapeStructural<_ek_structural>;
auto fem = std::make_unique<FE>(mesh, dim, "test_fem");
fem->initShapeFunctions();
auto & shape = dynamic_cast<const ShapeStruct &>(fem->getShapeFunctions());
Matrix<Real> rot_ref = rotationReference();
Matrix<Real> solution(6, 6);
solution.block(rot_ref, 0, 0);
solution.block(rot_ref, 3, 3);
for (auto && rot : make_view(shape.getRotations(type), 6, 6)) {
if (!Math::are_vector_equal(6 * 6, solution.storage(), rot.storage()))
return 1;
}
/// TODO check shape functions and shape derivatives
finalize();
return 0;
}
diff --git a/test/test_fe_engine/test_integrate.cc b/test/test_fe_engine/test_integrate.cc
index 2125a9b13..fa7c9e52d 100644
--- a/test/test_fe_engine/test_integrate.cc
+++ b/test/test_fe_engine/test_integrate.cc
@@ -1,74 +1,73 @@
/**
* @file test_integrate.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Peter Spijker <peter.spijker@epfl.ch>
*
* @date creation: Fri Sep 03 2010
* @date last modification: Mon Feb 19 2018
*
* @brief test of the fem class
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_fe_engine_fixture.hh"
/* -------------------------------------------------------------------------- */
#include <cstdlib>
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
TYPED_TEST(TestFEMFixture, IntegrateConstant) {
this->fem->initShapeFunctions();
const auto type = this->type;
const auto & position = this->fem->getMesh().getNodes();
Array<Real> const_val(position.size(), 2, "const_val");
Array<Real> val_on_quad(this->nb_quadrature_points_total, 2, "val_on_quad");
Vector<Real> value{1, 2};
for (auto && const_ : make_view(const_val, 2)) {
const_ = value;
}
// interpolate function on quadrature points
this->fem->interpolateOnIntegrationPoints(const_val, val_on_quad, 2, type);
// integrate function on elements
Array<Real> int_val_on_elem(this->nb_element, 2, "int_val_on_elem");
this->fem->integrate(val_on_quad, int_val_on_elem, 2, type);
// get global integration value
Vector<Real> sum{0., 0.};
for (auto && int_ : make_view(int_val_on_elem, 2)) {
sum += int_;
}
auto diff = (value - sum).template norm<L_inf>();
EXPECT_NEAR(0, diff, 1e-14);
}
-
diff --git a/test/test_geometry/test_segment_intersection_tetrahedron_4.cc b/test/test_geometry/test_segment_intersection_tetrahedron_4.cc
index b34b246a9..2ac1ba4e5 100644
--- a/test/test_geometry/test_segment_intersection_tetrahedron_4.cc
+++ b/test/test_geometry/test_segment_intersection_tetrahedron_4.cc
@@ -1,143 +1,143 @@
/**
* @file test_segment_intersection_tetrahedron_4.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Fri Feb 27 2015
* @date last modification: Wed Jan 31 2018
*
* @brief Tests the intersection module with _tetrahedron_4 elements
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "mesh_segment_intersector.hh"
#include "mesh_geom_common.hh"
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
typedef cgal::Cartesian K;
typedef K::Point_3 Point;
typedef K::Segment_3 Segment;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize("", argc, argv);
debug::setDebugLevel(dblError);
Mesh mesh(3), interface_mesh(3, "interface_mesh");
mesh.read("test_geometry_tetrahedron.msh");
MeshSegmentIntersector<3, _tetrahedron_4> intersector(mesh, interface_mesh);
intersector.constructData();
// Testing a segment going through the cube
Point point(1., 1., 1.);
Segment segment(CGAL::ORIGIN, point);
intersector.computeIntersectionQuery(segment);
std::cout << "number of seg_2 : " << interface_mesh.getNbElement(_segment_2)
<< std::endl;
if (interface_mesh.getNbElement(_segment_2) != 2)
return EXIT_FAILURE;
Vector<Real> bary(2), bary1(2), bary2(2);
- Element test{ _segment_2, 0, _not_ghost};
+ Element test{_segment_2, 0, _not_ghost};
interface_mesh.getBarycenter(test, bary1);
test.element = 1;
interface_mesh.getBarycenter(test, bary2);
Real first_bary[] = {1. / 6., 1. / 6., 1. / 6.};
Real second_bary[] = {2. / 3., 2. / 3., 2. / 3.};
// We don't know the order of the elements, so here we test permutations
if (!((Math::are_vector_equal(3, bary1.storage(), first_bary) &&
Math::are_vector_equal(3, bary2.storage(), second_bary)) ||
(Math::are_vector_equal(3, bary1.storage(), second_bary) &&
Math::are_vector_equal(3, bary2.storage(), first_bary))))
return EXIT_FAILURE;
// Testing a segment completely inside one element
Point a(0.05, 0.05, 0.05), b(0.06, 0.06, 0.06);
Segment inside_segment(a, b);
intersector.computeIntersectionQuery(inside_segment);
test.element = interface_mesh.getNbElement(_segment_2) - 1;
interface_mesh.getBarycenter(test, bary);
Real third_bary[] = {0.055, 0.055, 0.055};
if (!Math::are_vector_equal(3, bary.storage(), third_bary))
return EXIT_FAILURE;
// Testing a segment whose end points are inside elements
Point c(0.1, 0.1, 0.1), d(0.9, 0.9, 0.9);
Segment crossing_segment(c, d);
intersector.computeIntersectionQuery(crossing_segment);
UInt el1 = interface_mesh.getNbElement(_segment_2) - 2;
UInt el2 = el1 + 1;
test.element = el1;
interface_mesh.getBarycenter(test, bary1);
test.element = el2;
interface_mesh.getBarycenter(test, bary2);
Real fourth_bary[] = {13. / 60., 13. / 60., 13. / 60.};
Real fifth_bary[] = {37. / 60., 37. / 60., 37. / 60.};
// We don't know the order of the elements, so here we test permutations
if (!((Math::are_vector_equal(3, bary1.storage(), fourth_bary) &&
Math::are_vector_equal(3, bary2.storage(), fifth_bary)) ||
(Math::are_vector_equal(3, bary1.storage(), fifth_bary) &&
Math::are_vector_equal(3, bary2.storage(), fourth_bary))))
return EXIT_FAILURE;
// Testing a segment along the edge of elements
Point e(1, 0, 0), f(0, 1, 0);
Segment edge_segment(e, f);
UInt current_nb_elements = interface_mesh.getNbElement(_segment_2);
intersector.computeIntersectionQuery(edge_segment);
if (interface_mesh.getNbElement(_segment_2) != current_nb_elements + 1)
return EXIT_FAILURE;
test.element = interface_mesh.getNbElement(_segment_2) - 1;
interface_mesh.getBarycenter(test, bary);
Real sixth_bary[] = {0.5, 0.5, 0};
if (!Math::are_vector_equal(3, bary.storage(), sixth_bary))
return EXIT_FAILURE;
return EXIT_SUCCESS;
}
diff --git a/test/test_gtest_main.cc b/test/test_gtest_main.cc
index 264c4d1a9..ac805bea7 100644
--- a/test/test_gtest_main.cc
+++ b/test/test_gtest_main.cc
@@ -1,83 +1,83 @@
/**
* @file test_gtest_main.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu Nov 09 2017
* @date last modification: Tue Jan 16 2018
*
* @brief Main function for gtest tests
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "communicator.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#if defined(AKANTU_TEST_USE_PYBIND11)
#include <pybind11/embed.h>
namespace py = pybind11;
#endif
/* -------------------------------------------------------------------------- */
namespace {
class AkaEnvironment : public ::testing::Environment {
public:
AkaEnvironment(int & argc, char **& argv) : argc(argc), argv(argv) {}
// Override this to define how to set up the environment.
void SetUp() override {
::akantu::initialize(argc, argv);
#if defined(AKANTU_USE_PYBIND11)
// py::initialize_interpreter();
#endif
}
// Override this to define how to tear down the environment.
void TearDown() override {
::akantu::finalize();
#if defined(AKANTU_USE_PYBIND11)
// py::finalize_interpreter();
#endif
}
protected:
int & argc;
char **& argv;
};
-}
+} // namespace
int main(int argc, char ** argv) {
#if defined(AKANTU_TEST_USE_PYBIND11)
py::scoped_interpreter guard{};
#endif
::testing::InitGoogleTest(&argc, argv);
::testing::AddGlobalTestEnvironment(new AkaEnvironment(argc, argv));
::testing::TestEventListeners & listeners =
::testing::UnitTest::GetInstance()->listeners();
if (::akantu::Communicator::getStaticCommunicator().whoAmI() != 0) {
delete listeners.Release(listeners.default_result_printer());
}
return RUN_ALL_TESTS();
}
diff --git a/test/test_gtest_utils.hh b/test/test_gtest_utils.hh
index 3058244ae..c861950d5 100644
--- a/test/test_gtest_utils.hh
+++ b/test/test_gtest_utils.hh
@@ -1,243 +1,248 @@
/**
* @file test_gtest_utils.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Nov 14 2017
* @date last modification: Wed Feb 21 2018
*
* @brief Utils to help write tests
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_iterators.hh"
/* -------------------------------------------------------------------------- */
#include <boost/preprocessor.hpp>
#include <gtest/gtest.h>
-#include <tuple>
-/* -------------------------------------------------------------------------- */
+// #include <tuple>
+// /* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TEST_GTEST_UTILS_HH__
#define __AKANTU_TEST_GTEST_UTILS_HH__
+#if !defined(TYPED_TEST_SUITE)
+#define TYPED_TEST_SUITE(...) TYPED_TEST_CASE(__VA_ARGS__)
+#endif
+
+
namespace {
/* -------------------------------------------------------------------------- */
template <::akantu::ElementType t>
using element_type_t = std::integral_constant<::akantu::ElementType, t>;
/* -------------------------------------------------------------------------- */
template <typename... T> struct gtest_list {};
template <typename... Ts> struct gtest_list<std::tuple<Ts...>> {
using type = ::testing::Types<Ts...>;
};
template <typename... T> using gtest_list_t = typename gtest_list<T...>::type;
/* -------------------------------------------------------------------------- */
template <typename... T> struct tuple_concat {};
template <typename... T1s, typename... T2s>
struct tuple_concat<std::tuple<T1s...>, std::tuple<T2s...>> {
using type = std::tuple<T1s..., T2s...>;
};
template <typename... T>
using tuple_concat_t = typename tuple_concat<T...>::type;
/* -------------------------------------------------------------------------- */
template <template <typename> class Pred, typename... Ts>
struct tuple_filter {};
template <template <typename> class Pred, typename T>
struct tuple_filter<Pred, std::tuple<T>> {
using type = std::conditional_t<Pred<T>::value, std::tuple<T>, std::tuple<>>;
};
template <template <typename> class Pred, typename T, typename... Ts>
struct tuple_filter<Pred, std::tuple<T, Ts...>> {
using type =
tuple_concat_t<typename tuple_filter<Pred, std::tuple<T>>::type,
typename tuple_filter<Pred, std::tuple<Ts...>>::type>;
};
template <template <typename> class Pred, typename... Ts>
using tuple_filter_t = typename tuple_filter<Pred, Ts...>::type;
/* -------------------------------------------------------------------------- */
template <size_t N, typename... Ts> struct tuple_split {};
template <size_t N, typename T, typename... Ts>
struct tuple_split<N, std::tuple<T, Ts...>> {
protected:
using split = tuple_split<N - 1, std::tuple<Ts...>>;
public:
using type = tuple_concat_t<std::tuple<T>, typename split::type>;
using type_tail = typename split::type_tail;
};
template <typename T, typename... Ts>
struct tuple_split<1, std::tuple<T, Ts...>> {
using type = std::tuple<T>;
using type_tail = std::tuple<Ts...>;
};
template <size_t N, typename... T>
using tuple_split_t = typename tuple_split<N, T...>::type;
template <size_t N, typename... T>
using tuple_split_tail_t = typename tuple_split<N, T...>::type_tail;
/* -------------------------------------------------------------------------- */
template <typename... T> struct cross_product {};
template <typename... T2s>
struct cross_product<std::tuple<>, std::tuple<T2s...>> {
using type = std::tuple<>;
};
template <typename T1, typename... T1s, typename... T2s>
struct cross_product<std::tuple<T1, T1s...>, std::tuple<T2s...>> {
using type = tuple_concat_t<
std::tuple<std::tuple<T1, T2s>...>,
typename cross_product<std::tuple<T1s...>, std::tuple<T2s...>>::type>;
};
template <typename... T>
using cross_product_t = typename cross_product<T...>::type;
/* -------------------------------------------------------------------------- */
} // namespace
#define OP_CAT(s, data, elem) BOOST_PP_CAT(_element_type, elem)
// creating a type instead of a using helps to debug
#define AKANTU_DECLARE_ELEMENT_TYPE_STRUCT(r, data, elem) \
struct BOOST_PP_CAT(_element_type, elem) \
: public element_type_t<::akantu::elem> {};
BOOST_PP_SEQ_FOR_EACH(AKANTU_DECLARE_ELEMENT_TYPE_STRUCT, _,
AKANTU_ALL_ELEMENT_TYPE)
#undef AKANTU_DECLARE_ELEMENT_TYPE_STRUCT
using TestElementTypesAll = std::tuple<BOOST_PP_SEQ_ENUM(
BOOST_PP_SEQ_TRANSFORM(OP_CAT, _, AKANTU_ek_regular_ELEMENT_TYPE))>;
#if defined(AKANTU_COHESIVE_ELEMENT)
using TestCohesiveElementTypes = std::tuple<BOOST_PP_SEQ_ENUM(
BOOST_PP_SEQ_TRANSFORM(OP_CAT, _, AKANTU_ek_cohesive_ELEMENT_TYPE))>;
#endif
#if defined(AKANTU_STRUCTURAL_MECHANICS)
using TestElementTypesStructural = std::tuple<BOOST_PP_SEQ_ENUM(
BOOST_PP_SEQ_TRANSFORM(OP_CAT, _, AKANTU_ek_structural_ELEMENT_TYPE))>;
#endif
using TestAllDimensions = std::tuple<std::integral_constant<unsigned int, 1>,
std::integral_constant<unsigned int, 2>,
std::integral_constant<unsigned int, 3>>;
template <typename T, ::akantu::ElementType type>
using is_element = aka::bool_constant<T::value == type>;
template <typename T>
using not_is_point_1 = aka::negation<is_element<T, ::akantu::_point_1>>;
using TestElementTypes = tuple_filter_t<not_is_point_1, TestElementTypesAll>;
#if defined(AKANTU_STRUCTURAL_MECHANICS)
using StructuralTestElementTypes =
tuple_filter_t<not_is_point_1, TestElementTypesStructural>;
#endif
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
template <size_t degree> class Polynomial {
public:
Polynomial() = default;
Polynomial(std::initializer_list<double> && init) {
for (auto && pair : akantu::zip(init, constants))
std::get<1>(pair) = std::get<0>(pair);
}
double operator()(double x) {
double res = 0.;
for (auto && vals : akantu::enumerate(constants)) {
double a;
int k;
std::tie(k, a) = vals;
res += a * std::pow(x, k);
}
return res;
}
Polynomial extract(size_t pdegree) {
Polynomial<degree> extract(*this);
for (size_t d = pdegree + 1; d < degree + 1; ++d)
extract.constants[d] = 0;
return extract;
}
auto integral() {
Polynomial<degree + 1> integral_;
integral_.set(0, 0.);
;
for (size_t d = 0; d < degree + 1; ++d) {
integral_.set(1 + d, get(d) / double(d + 1));
}
return integral_;
}
auto integrate(double a, double b) {
auto primitive = integral();
return (primitive(b) - primitive(a));
}
double get(int i) const { return constants[i]; }
void set(int i, double a) { constants[i] = a; }
protected:
std::array<double, degree + 1> constants;
};
template <size_t degree>
std::ostream & operator<<(std::ostream & stream, const Polynomial<degree> & p) {
for (size_t d = 0; d < degree + 1; ++d) {
if (d != 0)
stream << " + ";
stream << p.get(degree - d);
if (d != degree)
stream << "x ^ " << degree - d;
}
return stream;
}
/* -------------------------------------------------------------------------- */
#endif /* __AKANTU_TEST_GTEST_UTILS_HH__ */
diff --git a/test/test_io/test_dumper/test_dumper.cc b/test/test_io/test_dumper/test_dumper.cc
index a5edc9f48..c9fabdcda 100644
--- a/test/test_io/test_dumper/test_dumper.cc
+++ b/test/test_io/test_dumper/test_dumper.cc
@@ -1,157 +1,160 @@
/**
* @file test_dumper.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
*
* @date creation: Tue Sep 02 2014
* @date last modification: Mon Jan 22 2018
*
* @brief test dumper
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_iohelper_paraview.hh"
#include "dumper_nodal_field.hh"
#include "dumper_text.hh"
#include "dumper_variable.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize("input_file.dat", argc, argv);
UInt spatial_dimension = 3;
Mesh mesh(spatial_dimension);
mesh.read("test_dumper.msh");
SolidMechanicsModel model(mesh);
auto && mat_selector =
std::make_shared<MeshDataMaterialSelector<std::string>>("physical_names",
model);
model.setMaterialSelector(mat_selector);
model.initFull();
model.assembleInternalForces();
Real time_step = 0.1;
const Array<Real> & coord = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & bound = model.getBlockedDOFs();
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
Real dist = 0.;
for (UInt d = 0; d < spatial_dimension; ++d) {
dist += coord(n, d) * coord(n, d);
}
dist = sqrt(dist);
for (UInt d = 0; d < spatial_dimension; ++d) {
disp(n, d) = (d + 1) * dist;
bound(n, d) = bool((n % 2) + d);
}
}
// dump boundary bottom as reference
model.setGroupDirectory("paraview", "Bottom");
model.setGroupBaseName("paraview_bottom", "Bottom");
model.addDumpGroupField("displacement", "Bottom");
model.addDumpGroupField("blocked_dofs", "Bottom");
UInt nbp = 3;
DumperParaview prvdumper("paraview_bottom_parallel", "paraview", false);
iohelper::Dumper & prvdpr = prvdumper.getDumper();
for (UInt p = 0; p < nbp; ++p) {
prvdpr.setParallelContext(p, nbp, 0);
if (p != 0) {
prvdumper.unRegisterField("connectivities");
prvdumper.unRegisterField("element_type");
prvdumper.unRegisterField("positions");
prvdumper.unRegisterField("displacement");
}
- prvdumper.registerFilteredMesh(mesh,
- mesh.getElementGroup("Bottom").getElements(),
- mesh.getElementGroup("Bottom").getNodeGroup().getNodes());
- prvdumper.registerField("displacement",
- std::make_shared<dumper::NodalField<Real, true>>(
- model.getDisplacement(), 0, 0,
- &(mesh.getElementGroup("Bottom").getNodeGroup().getNodes())));
+ prvdumper.registerFilteredMesh(
+ mesh, mesh.getElementGroup("Bottom").getElements(),
+ mesh.getElementGroup("Bottom").getNodeGroup().getNodes());
+ prvdumper.registerField(
+ "displacement",
+ std::make_shared<dumper::NodalField<Real, true>>(
+ model.getDisplacement(), 0, 0,
+ &(mesh.getElementGroup("Bottom").getNodeGroup().getNodes())));
prvdumper.dump(0);
}
DumperText txtdumper("text_bottom", iohelper::_tdm_csv);
txtdumper.setDirectory("paraview");
txtdumper.setPrecision(8);
txtdumper.setTimeStep(time_step);
- txtdumper.registerFilteredMesh(mesh,
- mesh.getElementGroup("Bottom").getElements(),
- mesh.getElementGroup("Bottom").getNodeGroup().getNodes());
- txtdumper.registerField("displacement",
- std::make_shared<dumper::NodalField<Real, true>>(
- model.getDisplacement(), 0, 0,
- &(mesh.getElementGroup("Bottom").getNodeGroup().getNodes())));
- txtdumper.registerField("blocked_dofs",
- std::make_shared<dumper::NodalField<bool, true>>(
- model.getBlockedDOFs(), 0, 0,
- &(mesh.getElementGroup("Bottom").getNodeGroup().getNodes())));
+ txtdumper.registerFilteredMesh(
+ mesh, mesh.getElementGroup("Bottom").getElements(),
+ mesh.getElementGroup("Bottom").getNodeGroup().getNodes());
+ txtdumper.registerField(
+ "displacement",
+ std::make_shared<dumper::NodalField<Real, true>>(
+ model.getDisplacement(), 0, 0,
+ &(mesh.getElementGroup("Bottom").getNodeGroup().getNodes())));
+ txtdumper.registerField(
+ "blocked_dofs",
+ std::make_shared<dumper::NodalField<bool, true>>(
+ model.getBlockedDOFs(), 0, 0,
+ &(mesh.getElementGroup("Bottom").getNodeGroup().getNodes())));
Real pot_energy = 1.2345567891;
Vector<Real> gforces(2, 1.);
txtdumper.registerVariable(
"potential_energy", std::make_shared<dumper::Variable<Real>>(pot_energy));
txtdumper.registerVariable(
"global_forces",
std::make_shared<dumper::Variable<Vector<Real>>>(gforces));
// dump a first time before the main loop
model.dumpGroup("Bottom");
txtdumper.dump();
Real time = 0.;
for (UInt i = 1; i < 5; ++i) {
pot_energy += 2.;
gforces(0) += 0.1;
gforces(1) += 0.2;
// pre -> cor
// increment time after all steps of integration
time += time_step;
// dump after time increment
if (i % 2 == 0) {
txtdumper.dump(time, i);
model.dumpGroup("Bottom");
// parallel test
for (UInt p = 0; p < nbp; ++p) {
prvdpr.setParallelContext(p, nbp, 0);
prvdumper.dump(i);
}
}
}
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_mesh/test_mesh_periodic.cc b/test/test_mesh/test_mesh_periodic.cc
index c6ad6d5af..f66084b4e 100644
--- a/test/test_mesh/test_mesh_periodic.cc
+++ b/test/test_mesh/test_mesh_periodic.cc
@@ -1,139 +1,140 @@
/**
* @file test_mesh_periodic.cc
*
* @author Nicolas Richart
*
* @date creation Sun Feb 11 2018
*
* @brief test makePeriodic
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "data_accessor.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
//#include "mesh_partition_scotch.hh"
#include "periodic_node_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include "dumpable_inline_impl.hh"
//#include "dumper_element_partition.hh"
#include "dumper_iohelper_paraview.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char ** argv) {
initialize(argc, argv);
constexpr UInt dim = 3;
auto prank = Communicator::getStaticCommunicator().whoAmI();
// auto psize = Communicator::getStaticCommunicator().getNbProc();
Mesh mesh(dim);
if (prank == 0) {
mesh.read("cube_periodic.msh");
}
MeshAccessor mesh_accessor(mesh);
// mesh_accessor.wipePeriodicInfo();
// mesh.makePeriodic(_z);
// if (prank == 0) {
// MeshPartitionScotch partition(mesh, dim);
// partition.partitionate(psize);
// }
UInt offset = 0;
for (auto && type : mesh.elementTypes()) {
auto & g_ids = mesh.getDataPointer<UInt>("global_ids", type);
for (auto && data : enumerate(g_ids)) {
std::get<1>(data) = offset + std::get<0>(data);
}
offset += g_ids.size();
}
mesh.distribute();
mesh.makePeriodic(_x);
mesh.makePeriodic(_y);
mesh.makePeriodic(_z);
auto * dumper = new DumperParaview("periodic", "./paraview");
mesh.registerExternalDumper(*dumper, "periodic", true);
mesh.addDumpMesh(mesh);
if (mesh.isDistributed()) {
mesh.addDumpFieldExternalToDumper(
"periodic", "node_type",
const_cast<const Mesh &>(mesh).getNodesFlags());
}
mesh.dump();
Array<Int> periodic(mesh.getNbNodes(), 1, 0.);
Array<Int> masters(mesh.getNbNodes(), 1, 0.);
Array<Int> global_ids(mesh.getNbNodes(), 1, 0.);
UInt prev_node = -1;
UInt value = 0;
const auto & periodic_ms = mesh.getPeriodicMasterSlaves();
for (auto & pair : periodic_ms) {
if (prev_node != pair.first) {
++value;
}
prev_node = pair.first;
periodic(pair.first) = value;
periodic(pair.second) = value;
masters(pair.first) = 1;
global_ids(pair.first) = mesh.getNodeGlobalId(pair.second);
auto it = periodic_ms.find(pair.second);
if (it != periodic_ms.end()) {
AKANTU_EXCEPTION(pair.second << " is slave of " << pair.first
<< " and master of " << it->second);
}
}
mesh.addDumpFieldExternalToDumper("periodic", "periodic", periodic);
mesh.addDumpFieldExternalToDumper("periodic", "masters", masters);
mesh.addDumpFieldExternalToDumper("periodic", "global_ids", global_ids);
mesh.addDumpFieldExternalToDumper("periodic", "element_global_ids",
mesh.getData<UInt>("global_ids"));
mesh.dump();
Array<Int> data(mesh.getNbNodes(), 1, 0.);
mesh.addDumpFieldExternalToDumper("periodic", "data", data);
for (auto node : arange(mesh.getNbNodes())) {
if (mesh.isPeriodicMaster(node)) {
data(node) = 1 * (prank + 1);
if (mesh.isMasterNode(node) or mesh.isLocalNode(node)) {
data(node) = 10 * (prank + 1);
}
}
}
mesh.dump();
- // SimpleUIntDataAccessor<Int> data_accessor(data, SynchronizationTag::_user_1);
+ // SimpleUIntDataAccessor<Int> data_accessor(data,
+ // SynchronizationTag::_user_1);
// mesh.getPeriodicNodeSynchronizer().synchronizeOnce(data_accessor,
// SynchronizationTag::_user_1);
mesh.dump();
}
diff --git a/test/test_mesh_utils/test_mesh_iterators.cc b/test/test_mesh_utils/test_mesh_iterators.cc
index 15b8cbed9..0a4ce03ac 100644
--- a/test/test_mesh_utils/test_mesh_iterators.cc
+++ b/test/test_mesh_utils/test_mesh_iterators.cc
@@ -1,73 +1,74 @@
/**
* @file test_mesh_iterators.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 18 2010
* @date last modification: Wed Aug 16 2017
*
* @brief Test the mesh iterators
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_iterators.hh"
#include "element_group.hh"
#include "mesh.hh"
#include "mesh_iterators.hh"
#include "node_group.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize(argc, argv);
Mesh mesh(3);
const Mesh & cmesh = mesh;
mesh.read("iterators_mesh.msh");
- std::cout << "ElementGroups" << std::endl;
+ std::cout << "ElementGroups" << std::endl;
for (auto && element_group : mesh.iterateElementGroups()) {
- std::cout << element_group.getName() << " " << element_group.getDimension() << std::endl;
+ std::cout << element_group.getName() << " " << element_group.getDimension()
+ << std::endl;
}
- std::cout << "NodeGroups" << std::endl;
+ std::cout << "NodeGroups" << std::endl;
for (auto && node_group : cmesh.iterateNodeGroups()) {
std::cout << node_group.getName() << std::endl;
}
- std::cout << "enumerate(ElementGroups)" << std::endl;
+ std::cout << "enumerate(ElementGroups)" << std::endl;
for (auto && element_group : enumerate(mesh.iterateElementGroups())) {
std::cout << std::get<0>(element_group) << " "
<< std::get<1>(element_group).getName() << std::endl;
}
// for (auto && node_group :
// counting(NodeGroupsIterable(cmesh))) {
// std::cout << std::get<0>(node_group) << " " <<
// std::get<1>(node_group).getName() << std::endl;
// }
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_model/patch_tests/patch_test_linear_anisotropic.cc b/test/test_model/patch_tests/patch_test_linear_anisotropic.cc
index 915b3e886..95a961de1 100644
--- a/test/test_model/patch_tests/patch_test_linear_anisotropic.cc
+++ b/test/test_model/patch_tests/patch_test_linear_anisotropic.cc
@@ -1,223 +1,224 @@
/**
* @file patch_test_linear_anisotropic_explicit.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Till Junge <till.junge@epfl.ch>
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Cyprien Wolff <cyprien.wolff@epfl.ch>
*
* @date creation: Tue Dec 05 2017
* @date last modification: Tue Feb 13 2018
*
* @brief patch test for elastic material in solid mechanics model
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
-#include "patch_test_linear_solid_mechanics_fixture.hh"
#include "non_linear_solver.hh"
+#include "patch_test_linear_solid_mechanics_fixture.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
// Stiffness tensor, rotated by hand
/* -------------------------------------------------------------------------- */
TYPED_TEST(TestPatchTestSMMLinear, AnisotropicExplicit) {
Real C[3][3][3][3] = {
{{{112.93753505, 1.85842452538e-10, -4.47654358027e-10},
{1.85847317471e-10, 54.2334345331, -3.69840984824},
{-4.4764768395e-10, -3.69840984824, 56.848605217}},
{{1.85847781609e-10, 25.429294233, -3.69840984816},
{25.429294233, 3.31613847493e-10, -8.38797920011e-11},
{-3.69840984816, -8.38804581349e-11, -1.97875715813e-10}},
{{-4.47654358027e-10, -3.69840984816, 28.044464917},
{-3.69840984816, 2.09374961813e-10, 9.4857455224e-12},
{28.044464917, 9.48308098714e-12, -2.1367885239e-10}}},
{{{1.85847781609e-10, 25.429294233, -3.69840984816},
{25.429294233, 3.31613847493e-10, -8.38793479119e-11},
{-3.69840984816, -8.38795699565e-11, -1.97876381947e-10}},
{{54.2334345331, 3.31617400207e-10, 2.09372075233e-10},
{3.3161562385e-10, 115.552705733, -3.15093728886e-10},
{2.09372075233e-10, -3.15090176173e-10, 54.2334345333}},
{{-3.69840984824, -8.38795699565e-11, 9.48219280872e-12},
{-8.38795699565e-11, -3.1509195253e-10, 25.4292942335},
{9.48441325477e-12, 25.4292942335, 3.69840984851}}},
{{{-4.47653469848e-10, -3.69840984816, 28.044464917},
{-3.69840984816, 2.09374073634e-10, 9.48752187924e-12},
{28.044464917, 9.48552347779e-12, -2.1367885239e-10}},
{{-3.69840984824, -8.3884899027e-11, 9.48219280872e-12},
{-8.3884899027e-11, -3.150972816e-10, 25.4292942335},
{9.48041645188e-12, 25.4292942335, 3.69840984851}},
{{56.848605217, -1.97875493768e-10, -2.13681516925e-10},
{-1.97877270125e-10, 54.2334345333, 3.69840984851},
{-2.13683293282e-10, 3.69840984851, 112.93753505}}}};
if (this->dim == 2) {
for (UInt i = 0; i < this->dim; ++i) {
for (UInt j = 0; j < this->dim; ++j) {
for (UInt k = 0; k < this->dim; ++k) {
for (UInt l = 0; l < this->dim; ++l) {
C[i][j][k][l] = 0;
}
}
}
}
C[0][0][0][0] = C[1][1][1][1] = 112.93753504999995;
C[0][0][1][1] = C[1][1][0][0] = 51.618263849999984;
- C[0][1][0][1] = C[1][0][0][1] = C[0][1][1][0] = C[1][0][1][0] = 22.814123549999987;
+ C[0][1][0][1] = C[1][0][0][1] = C[0][1][1][0] = C[1][0][1][0] =
+ 22.814123549999987;
}
if (this->dim == 1) {
C[0][0][0][0] = 105.092023;
}
this->initModel(_explicit_lumped_mass,
"material_anisotropic_" + std::to_string(this->dim) + ".dat");
const auto & coordinates = this->mesh->getNodes();
auto & displacement = this->model->getDisplacement();
// set the position of all nodes to the static solution
for (auto && tuple : zip(make_view(coordinates, this->dim),
make_view(displacement, this->dim))) {
this->setLinearDOF(std::get<1>(tuple), std::get<0>(tuple));
}
for (UInt s = 0; s < 100; ++s) {
this->model->solveStep();
}
auto ekin = this->model->getEnergy("kinetic");
EXPECT_NEAR(0, ekin, 1e-16);
auto & mat = this->model->getMaterial(0);
this->checkDOFs(displacement);
this->checkGradient(mat.getGradU(this->type), displacement);
this->result_tolerance = 1e-11;
this->checkResults(
[&](const Matrix<Real> & pstrain) {
auto strain = (pstrain + pstrain.transpose()) / 2.;
decltype(strain) stress(this->dim, this->dim);
for (UInt i = 0; i < this->dim; ++i) {
for (UInt j = 0; j < this->dim; ++j) {
stress(i, j) = 0;
for (UInt k = 0; k < this->dim; ++k) {
for (UInt l = 0; l < this->dim; ++l) {
stress(i, j) += C[i][j][k][l] * strain(k, l);
}
}
}
}
return stress;
},
mat.getStress(this->type), displacement);
}
-
TYPED_TEST(TestPatchTestSMMLinear, AnisotropicStatic) {
Real C[3][3][3][3] = {
{{{112.93753505, 1.85842452538e-10, -4.47654358027e-10},
{1.85847317471e-10, 54.2334345331, -3.69840984824},
{-4.4764768395e-10, -3.69840984824, 56.848605217}},
{{1.85847781609e-10, 25.429294233, -3.69840984816},
{25.429294233, 3.31613847493e-10, -8.38797920011e-11},
{-3.69840984816, -8.38804581349e-11, -1.97875715813e-10}},
{{-4.47654358027e-10, -3.69840984816, 28.044464917},
{-3.69840984816, 2.09374961813e-10, 9.4857455224e-12},
{28.044464917, 9.48308098714e-12, -2.1367885239e-10}}},
{{{1.85847781609e-10, 25.429294233, -3.69840984816},
{25.429294233, 3.31613847493e-10, -8.38793479119e-11},
{-3.69840984816, -8.38795699565e-11, -1.97876381947e-10}},
{{54.2334345331, 3.31617400207e-10, 2.09372075233e-10},
{3.3161562385e-10, 115.552705733, -3.15093728886e-10},
{2.09372075233e-10, -3.15090176173e-10, 54.2334345333}},
{{-3.69840984824, -8.38795699565e-11, 9.48219280872e-12},
{-8.38795699565e-11, -3.1509195253e-10, 25.4292942335},
{9.48441325477e-12, 25.4292942335, 3.69840984851}}},
{{{-4.47653469848e-10, -3.69840984816, 28.044464917},
{-3.69840984816, 2.09374073634e-10, 9.48752187924e-12},
{28.044464917, 9.48552347779e-12, -2.1367885239e-10}},
{{-3.69840984824, -8.3884899027e-11, 9.48219280872e-12},
{-8.3884899027e-11, -3.150972816e-10, 25.4292942335},
{9.48041645188e-12, 25.4292942335, 3.69840984851}},
{{56.848605217, -1.97875493768e-10, -2.13681516925e-10},
{-1.97877270125e-10, 54.2334345333, 3.69840984851},
{-2.13683293282e-10, 3.69840984851, 112.93753505}}}};
if (this->dim == 2) {
for (UInt i = 0; i < this->dim; ++i) {
for (UInt j = 0; j < this->dim; ++j) {
for (UInt k = 0; k < this->dim; ++k) {
for (UInt l = 0; l < this->dim; ++l) {
C[i][j][k][l] = 0;
}
}
}
}
C[0][0][0][0] = C[1][1][1][1] = 112.93753504999995;
C[0][0][1][1] = C[1][1][0][0] = 51.618263849999984;
- C[0][1][0][1] = C[1][0][0][1] = C[0][1][1][0] = C[1][0][1][0] = 22.814123549999987;
+ C[0][1][0][1] = C[1][0][0][1] = C[0][1][1][0] = C[1][0][1][0] =
+ 22.814123549999987;
}
if (this->dim == 1) {
C[0][0][0][0] = 105.092023;
}
-
+
this->initModel(_static,
"material_anisotropic_" + std::to_string(this->dim) + ".dat");
-
+
auto & solver = this->model->getNonLinearSolver();
solver.set("max_iterations", 2);
solver.set("threshold", 2e-4);
solver.set("convergence_type", SolveConvergenceCriteria::_residual);
this->model->solveStep();
auto & mat = this->model->getMaterial(0);
const auto & displacement = this->model->getDisplacement();
this->checkDOFs(displacement);
this->checkGradient(mat.getGradU(this->type), displacement);
this->result_tolerance = 1e-11;
this->checkResults(
[&](const Matrix<Real> & pstrain) {
auto strain = (pstrain + pstrain.transpose()) / 2.;
decltype(strain) stress(this->dim, this->dim);
for (UInt i = 0; i < this->dim; ++i) {
for (UInt j = 0; j < this->dim; ++j) {
stress(i, j) = 0;
for (UInt k = 0; k < this->dim; ++k) {
for (UInt l = 0; l < this->dim; ++l) {
stress(i, j) += C[i][j][k][l] * strain(k, l);
}
}
}
}
return stress;
},
mat.getStress(this->type), displacement);
}
diff --git a/test/test_model/patch_tests/patch_test_linear_fixture.hh b/test/test_model/patch_tests/patch_test_linear_fixture.hh
index 146adb141..547807a67 100644
--- a/test/test_model/patch_tests/patch_test_linear_fixture.hh
+++ b/test/test_model/patch_tests/patch_test_linear_fixture.hh
@@ -1,183 +1,183 @@
/**
* @file patch_test_linear_fixture.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Jan 30 2018
* @date last modification: Wed Jan 31 2018
*
* @brief Fixture for linear patch tests
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "element_group.hh"
#include "mesh_utils.hh"
#include "model.hh"
#include "test_gtest_utils.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <vector>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_PATCH_TEST_LINEAR_FIXTURE_HH__
#define __AKANTU_PATCH_TEST_LINEAR_FIXTURE_HH__
//#define DEBUG_TEST
using namespace akantu;
template <typename type_, typename M>
class TestPatchTestLinear : public ::testing::Test {
public:
static constexpr ElementType type = type_::value;
static constexpr size_t dim = ElementClass<type>::getSpatialDimension();
virtual void SetUp() {
mesh = std::make_unique<Mesh>(dim);
mesh->read(std::to_string(type) + ".msh");
MeshUtils::buildFacets(*mesh);
mesh->createBoundaryGroupFromGeometry();
model = std::make_unique<M>(*mesh);
}
virtual void TearDown() {
model.reset(nullptr);
mesh.reset(nullptr);
}
virtual void initModel(const AnalysisMethod & method,
const std::string & material_file) {
debug::setDebugLevel(dblError);
getStaticParser().parse(material_file);
this->model->initFull(_analysis_method = method);
this->applyBC();
if (method != _static)
this->model->setTimeStep(0.8 * this->model->getStableTimeStep());
}
virtual void applyBC() {
auto & boundary = this->model->getBlockedDOFs();
for (auto & eg : mesh->iterateElementGroups()) {
for (const auto & node : eg.getNodeGroup()) {
for (UInt s = 0; s < boundary.getNbComponent(); ++s) {
boundary(node, s) = true;
}
}
}
}
virtual void applyBConDOFs(const Array<Real> & dofs) {
const auto & coordinates = this->mesh->getNodes();
for (auto & eg : this->mesh->iterateElementGroups()) {
for (const auto & node : eg.getNodeGroup()) {
this->setLinearDOF(dofs.begin(dofs.getNbComponent())[node],
coordinates.begin(this->dim)[node]);
}
}
}
template <typename V> Matrix<Real> prescribed_gradient(const V & dof) {
Matrix<Real> gradient(dof.getNbComponent(), dim);
for (UInt i = 0; i < gradient.rows(); ++i) {
for (UInt j = 0; j < gradient.cols(); ++j) {
gradient(i, j) = alpha(i, j + 1);
}
}
return gradient;
}
template <typename Gradient, typename DOFs>
void checkGradient(const Gradient & gradient, const DOFs & dofs) {
auto pgrad = prescribed_gradient(dofs);
for (auto & grad :
make_view(gradient, gradient.getNbComponent() / dim, dim)) {
auto diff = grad - pgrad;
auto gradient_error =
diff.template norm<L_inf>() / grad.template norm<L_inf>();
EXPECT_NEAR(0, gradient_error, gradient_tolerance);
}
}
- template <typename presult_func_t, typename Result, typename DOFs>
+ template <typename presult_func_t, typename Result, typename DOFs>
void checkResults(presult_func_t && presult_func, const Result & results,
const DOFs & dofs) {
auto presult = presult_func(prescribed_gradient(dofs));
for (auto & result :
make_view(results, results.getNbComponent() / dim, dim)) {
auto diff = result - presult;
auto result_error =
diff.template norm<L_inf>() / presult.template norm<L_inf>();
EXPECT_NEAR(0, result_error, result_tolerance);
}
}
template <typename V1, typename V2>
void setLinearDOF(V1 && dof, V2 && coord) {
for (UInt i = 0; i < dof.size(); ++i) {
dof(i) = this->alpha(i, 0);
for (UInt j = 0; j < coord.size(); ++j) {
dof(i) += this->alpha(i, j + 1) * coord(j);
}
}
}
template <typename V> void checkDOFs(V && dofs) {
const auto & coordinates = mesh->getNodes();
Vector<Real> ref_dof(dofs.getNbComponent());
for (auto && tuple : zip(make_view(coordinates, dim),
make_view(dofs, dofs.getNbComponent()))) {
setLinearDOF(ref_dof, std::get<0>(tuple));
auto diff = std::get<1>(tuple) - ref_dof;
auto dofs_error = diff.template norm<L_inf>();
EXPECT_NEAR(0, dofs_error, dofs_tolerance);
}
}
protected:
std::unique_ptr<Mesh> mesh;
std::unique_ptr<M> model;
Matrix<Real> alpha{{0.01, 0.02, 0.03, 0.04},
{0.05, 0.06, 0.07, 0.08},
{0.09, 0.10, 0.11, 0.12}};
Real gradient_tolerance{1e-13};
Real result_tolerance{1e-13};
Real dofs_tolerance{1e-15};
};
template <typename type_, typename M>
constexpr ElementType TestPatchTestLinear<type_, M>::type;
template <typename tuple_, typename M>
constexpr size_t TestPatchTestLinear<tuple_, M>::dim;
#endif /* __AKANTU_PATCH_TEST_LINEAR_FIXTURE_HH__ */
diff --git a/test/test_model/test_common/test_dof_manager.cc b/test/test_model/test_common/test_dof_manager.cc
index 4b312bde5..2f6733684 100644
--- a/test/test_model/test_common/test_dof_manager.cc
+++ b/test/test_model/test_common/test_dof_manager.cc
@@ -1,295 +1,293 @@
/**
* @file test_dof_manager.cc
*
* @author Nicolas Richart
*
* @date creation Wed Jan 30 2019
*
* @brief test the dof managers
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <dof_manager.hh>
#include <mesh_partition_scotch.hh>
#include <mesh_utils.hh>
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <numeric>
#include <string>
#include <type_traits>
/* -------------------------------------------------------------------------- */
enum DOFManagerType { _dmt_default, _dmt_petsc };
// defined as struct to get there names in gtest outputs
struct _dof_manager_default
: public std::integral_constant<DOFManagerType, _dmt_default> {};
struct _dof_manager_petsc
: public std::integral_constant<DOFManagerType, _dmt_petsc> {};
using dof_manager_types = ::testing::Types<
#ifdef AKANTU_USE_PETSC
_dof_manager_petsc,
#endif
_dof_manager_default>;
namespace std {
std::string to_string(const DOFManagerType & type) {
std::unordered_map<DOFManagerType, std::string> map{
#ifdef AKANTU_USE_PETSC
{_dmt_petsc, "petsc"},
#endif
{_dmt_default, "default"},
};
return map.at(type);
}
} // namespace std
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
namespace akantu {
class DOFManagerTester {
public:
DOFManagerTester(std::unique_ptr<DOFManager> dof_manager)
: dof_manager(std::move(dof_manager)) {}
DOFManager & operator*() { return *dof_manager; }
DOFManager * operator->() { return dof_manager.get(); }
void getArrayPerDOFs(const ID & id, SolverVector & vector,
Array<Real> & array) {
dof_manager->getArrayPerDOFs(id, vector, array);
}
SolverVector & residual() { return *dof_manager->residual; }
private:
std::unique_ptr<DOFManager> dof_manager;
};
} // namespace akantu
template <class T> class DOFManagerFixture : public ::testing::Test {
public:
constexpr static DOFManagerType type = T::value;
constexpr static UInt dim = 3;
void SetUp() override {
mesh = std::make_unique<Mesh>(this->dim);
auto & communicator = Communicator::getStaticCommunicator();
if (communicator.whoAmI() == 0) {
mesh->read("mesh.msh");
}
mesh->distribute();
nb_nodes = this->mesh->getNbNodes();
nb_total_nodes = this->mesh->getNbGlobalNodes();
auto && range_nodes = arange(nb_nodes);
nb_pure_local =
std::accumulate(range_nodes.begin(), range_nodes.end(), 0,
[&](auto && init, auto && val) {
return init + mesh->isLocalOrMasterNode(val);
});
}
void TearDown() override {
mesh.reset();
dof1.reset();
dof2.reset();
}
decltype(auto) alloc() {
std::unordered_map<DOFManagerType, std::string> types{
{_dmt_default, "default"}, {_dmt_petsc, "petsc"}};
return DOFManagerTester(DOFManagerFactory::getInstance().allocate(
types[T::value], *mesh, "dof_manager", 0));
}
decltype(auto) registerDOFs(DOFSupportType dst1, DOFSupportType dst2) {
auto dof_manager = DOFManagerTester(this->alloc());
auto n1 = dst1 == _dst_nodal ? nb_nodes : nb_pure_local;
this->dof1 = std::make_unique<Array<Real>>(n1, 3);
dof_manager->registerDOFs("dofs1", *this->dof1, dst1);
EXPECT_EQ(dof_manager.residual().size(), nb_total_nodes * 3);
auto n2 = dst2 == _dst_nodal ? nb_nodes : nb_pure_local;
this->dof2 = std::make_unique<Array<Real>>(n2, 5);
dof_manager->registerDOFs("dofs2", *this->dof2, dst2);
EXPECT_EQ(dof_manager.residual().size(), nb_total_nodes * 8);
return dof_manager;
}
protected:
Int nb_nodes{0}, nb_total_nodes{0}, nb_pure_local{0};
std::unique_ptr<Mesh> mesh;
std::unique_ptr<Array<Real>> dof1;
std::unique_ptr<Array<Real>> dof2;
};
template <class T> constexpr DOFManagerType DOFManagerFixture<T>::type;
template <class T> constexpr UInt DOFManagerFixture<T>::dim;
TYPED_TEST_SUITE(DOFManagerFixture, dof_manager_types);
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, Construction) {
auto dof_manager = this->alloc();
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, DoubleConstruction) {
auto dof_manager = this->alloc();
dof_manager = this->alloc();
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, RegisterGenericDOF1) {
auto dof_manager = this->alloc();
Array<Real> dofs(this->nb_pure_local, 3);
dof_manager->registerDOFs("dofs1", dofs, _dst_generic);
EXPECT_GE(dof_manager.residual().size(), this->nb_total_nodes * 3);
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, RegisterNodalDOF1) {
auto dof_manager = this->alloc();
Array<Real> dofs(this->nb_nodes, 3);
dof_manager->registerDOFs("dofs1", dofs, _dst_nodal);
EXPECT_GE(dof_manager.residual().size(), this->nb_total_nodes * 3);
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, RegisterGenericDOF2) {
this->registerDOFs(_dst_generic, _dst_generic);
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, RegisterNodalDOF2) {
this->registerDOFs(_dst_nodal, _dst_nodal);
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, RegisterMixedDOF) {
auto dof_manager = this->registerDOFs(_dst_nodal, _dst_generic);
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, AssembleVector) {
auto dof_manager = this->registerDOFs(_dst_nodal, _dst_generic);
dof_manager.residual().clear();
for (auto && data :
enumerate(make_view(*this->dof1, this->dof1->getNbComponent()))) {
auto n = std::get<0>(data);
auto & l = std::get<1>(data);
l.set(1. * this->mesh->isLocalOrMasterNode(n));
}
this->dof2->set(2.);
dof_manager->assembleToResidual("dofs1", *this->dof1);
dof_manager->assembleToResidual("dofs2", *this->dof2);
this->dof1->set(0.);
this->dof2->set(0.);
dof_manager.getArrayPerDOFs("dofs1", dof_manager.residual(), *this->dof1);
for (auto && data :
enumerate(make_view(*this->dof1, this->dof1->getNbComponent()))) {
if (this->mesh->isLocalOrMasterNode(std::get<0>(data))) {
const auto & l = std::get<1>(data);
auto e = (l - Vector<Real>{1., 1., 1.}).norm();
ASSERT_EQ(e, 0.);
}
}
dof_manager.getArrayPerDOFs("dofs2", dof_manager.residual(), *this->dof2);
for (auto && l : make_view(*this->dof2, this->dof2->getNbComponent())) {
auto e = (l - Vector<Real>{2., 2., 2., 2., 2.}).norm();
ASSERT_EQ(e, 0.);
}
}
/* -------------------------------------------------------------------------- */
TYPED_TEST(DOFManagerFixture, AssembleMatrixNodal) {
auto dof_manager = this->registerDOFs(_dst_nodal, _dst_nodal);
auto && K = dof_manager->getNewMatrix("K", _symmetric);
K.clear();
auto && elemental_matrix = std::make_unique<Array<Real>>(
this->mesh->getNbElement(this->dim), 8 * 3 * 8 * 3);
for (auto && m : make_view(*elemental_matrix, 8 * 3, 8 * 3)) {
m.set(1.);
}
dof_manager->assembleElementalMatricesToMatrix(
"K", "dofs1", *elemental_matrix, _hexahedron_8);
elemental_matrix = std::make_unique<Array<Real>>(
this->mesh->getNbElement(this->dim), 8 * 5 * 8 * 5);
for (auto && m : make_view(*elemental_matrix, 8 * 5, 8 * 5)) {
m.set(1.);
}
dof_manager->assembleElementalMatricesToMatrix(
"K", "dofs2", *elemental_matrix, _hexahedron_8);
CSR<Element> node_to_elem;
MeshUtils::buildNode2Elements(*this->mesh, node_to_elem, this->dim);
dof_manager.residual().clear();
for (auto && data :
- enumerate(zip(make_view(*this->dof1, this->dof1->getNbComponent()),
- make_view(*this->dof2, this->dof2->getNbComponent())))) {
+ enumerate(zip(make_view(*this->dof1, this->dof1->getNbComponent()),
+ make_view(*this->dof2, this->dof2->getNbComponent())))) {
auto n = std::get<0>(data);
auto & l1 = std::get<0>(std::get<1>(data));
auto & l2 = std::get<1>(std::get<1>(data));
auto v = 1. * this->mesh->isLocalOrMasterNode(n);
l1.set(v);
l2.set(v);
}
dof_manager->assembleToResidual("dofs1", *this->dof1);
dof_manager->assembleToResidual("dofs2", *this->dof2);
-
-
+
for (auto && n : arange(this->nb_nodes)) {
if (not this->mesh->isLocalOrMasterNode(n)) {
-
}
}
}
diff --git a/test/test_model/test_common/test_model_solver/test_dof_manager_default.cc b/test/test_model/test_common/test_model_solver/test_dof_manager_default.cc
index f3915e537..aed4614fb 100644
--- a/test/test_model/test_common/test_model_solver/test_dof_manager_default.cc
+++ b/test/test_model/test_common/test_model_solver/test_dof_manager_default.cc
@@ -1,130 +1,130 @@
/**
* @file test_dof_manager_default.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Feb 26 2016
* @date last modification: Thu Feb 01 2018
*
* @brief Test default dof manager
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dof_manager_default.hh"
#include "solver_callback.hh"
#include "sparse_matrix_aij.hh"
#include "time_step_solver.hh"
using namespace akantu;
/**
* =\o-----o-----o-> F
* | |
* |---- L ----|
*/
class MySolverCallback : public SolverCallback {
public:
MySolverCallback(Real F, DOFManagerDefault & dof_manager, UInt nb_dofs = 3)
: dof_manager(dof_manager), dispacement(nb_dofs, 1, "disp"),
blocked(nb_dofs, 1), forces(nb_dofs, 1), nb_dofs(nb_dofs) {
dof_manager.registerDOFs("disp", dispacement, _dst_generic);
dof_manager.registerBlockedDOFs("disp", blocked);
dispacement.set(0.);
forces.set(0.);
blocked.set(false);
forces(nb_dofs - 1, _x) = F;
blocked(0, _x) = true;
}
void assembleMatrix(const ID & matrix_id) {
if (matrix_id != "K")
return;
auto & K = dynamic_cast<SparseMatrixAIJ &>(dof_manager.getMatrix("K"));
K.clear();
for (UInt i = 1; i < nb_dofs - 1; ++i)
K.add(i, i, 2.);
for (UInt i = 0; i < nb_dofs - 1; ++i)
K.add(i, i + 1, -1.);
K.add(0, 0, 1);
K.add(nb_dofs - 1, nb_dofs - 1, 1);
// K *= 1 / L_{el}
K *= nb_dofs - 1;
}
MatrixType getMatrixType(const ID & matrix_id) {
if (matrix_id == "K")
return _symmetric;
return _mt_not_defined;
}
void assembleLumpedMatrix(const ID &) {}
void assembleResidual() { dof_manager.assembleToResidual("disp", forces); }
void predictor() {}
void corrector() {}
DOFManagerDefault & dof_manager;
Array<Real> dispacement;
Array<bool> blocked;
Array<Real> forces;
UInt nb_dofs;
};
int main(int argc, char * argv[]) {
initialize(argc, argv);
DOFManagerDefault dof_manager("test_dof_manager");
MySolverCallback callback(10., dof_manager, 11);
NonLinearSolver & nls =
dof_manager.getNewNonLinearSolver("my_nls", NonLinearSolverType::_linear);
- TimeStepSolver & tss =
- dof_manager.getNewTimeStepSolver("my_tss", TimeStepSolverType::_static, nls, callback);
+ TimeStepSolver & tss = dof_manager.getNewTimeStepSolver(
+ "my_tss", TimeStepSolverType::_static, nls, callback);
tss.setIntegrationScheme("disp", IntegrationSchemeType::_pseudo_time);
tss.solveStep(callback);
dof_manager.getMatrix("K").saveMatrix("K_dof_manager_default.mtx");
Array<Real>::const_scalar_iterator disp_it = callback.dispacement.begin();
Array<Real>::const_scalar_iterator force_it = callback.forces.begin();
Array<bool>::const_scalar_iterator blocked_it = callback.blocked.begin();
std::cout << std::setw(8) << "disp"
<< " " << std::setw(8) << "force"
<< " " << std::setw(8) << "blocked" << std::endl;
for (; disp_it != callback.dispacement.end();
++disp_it, ++force_it, ++blocked_it) {
std::cout << std::setw(8) << *disp_it << " " << std::setw(8) << *force_it
<< " " << std::setw(8) << std::boolalpha << *blocked_it
<< std::endl;
}
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_common/test_model_solver/test_model_solver.cc b/test/test_model/test_common/test_model_solver/test_model_solver.cc
index 1db74aea2..6cd817b21 100644
--- a/test/test_model/test_common/test_model_solver/test_model_solver.cc
+++ b/test/test_model/test_common/test_model_solver/test_model_solver.cc
@@ -1,175 +1,177 @@
/**
* @file test_model_solver.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Apr 13 2016
* @date last modification: Thu Feb 01 2018
*
* @brief Test default dof manager
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_random_generator.hh"
#include "dof_manager.hh"
#include "dof_synchronizer.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
#include "model_solver.hh"
#include "non_linear_solver.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
#include "test_model_solver_my_model.hh"
/* -------------------------------------------------------------------------- */
#include <cmath>
/* -------------------------------------------------------------------------- */
using namespace akantu;
static void genMesh(Mesh & mesh, UInt nb_nodes);
static void printResults(MyModel & model, UInt nb_nodes);
Real F = -10;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
UInt prank = Communicator::getStaticCommunicator().whoAmI();
std::cout << std::setprecision(7);
ID dof_manager_type = "default";
#if defined(DOF_MANAGER_TYPE)
dof_manager_type = DOF_MANAGER_TYPE;
#endif
-
+
UInt global_nb_nodes = 100;
Mesh mesh(1);
RandomGenerator<UInt>::seed(1);
if (prank == 0) {
genMesh(mesh, global_nb_nodes);
}
-
+
// std::cout << prank << RandGenerator<Real>::seed() << std::endl;
mesh.distribute();
MyModel model(F, mesh, false, dof_manager_type);
- model.getNewSolver("static", TimeStepSolverType::_static, NonLinearSolverType::_newton_raphson);
- model.setIntegrationScheme("static", "disp", IntegrationSchemeType::_pseudo_time);
+ model.getNewSolver("static", TimeStepSolverType::_static,
+ NonLinearSolverType::_newton_raphson);
+ model.setIntegrationScheme("static", "disp",
+ IntegrationSchemeType::_pseudo_time);
NonLinearSolver & solver = model.getDOFManager().getNonLinearSolver("static");
solver.set("max_iterations", 2);
model.solveStep();
printResults(model, global_nb_nodes);
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
void genMesh(Mesh & mesh, UInt nb_nodes) {
MeshAccessor mesh_accessor(mesh);
Array<Real> & nodes = mesh_accessor.getNodes();
Array<UInt> & conn = mesh_accessor.getConnectivity(_segment_2);
nodes.resize(nb_nodes);
mesh_accessor.setNbGlobalNodes(nb_nodes);
for (UInt n = 0; n < nb_nodes; ++n) {
nodes(n, _x) = n * (1. / (nb_nodes - 1));
}
conn.resize(nb_nodes - 1);
for (UInt n = 0; n < nb_nodes - 1; ++n) {
conn(n, 0) = n;
conn(n, 1) = n + 1;
}
mesh_accessor.makeReady();
}
/* -------------------------------------------------------------------------- */
void printResults(MyModel & model, UInt /*nb_nodes*/) {
// if (model.mesh.isDistributed()) {
// UInt prank = model.mesh.getCommunicator().whoAmI();
// auto & sync = dynamic_cast<DOFManagerDefault &>(model.getDOFManager())
// .getSynchronizer();
// if (prank == 0) {
// Array<Real> global_displacement(nb_nodes);
// Array<Real> global_forces(nb_nodes);
// Array<bool> global_blocked(nb_nodes);
// sync.gather(model.forces, global_forces);
// sync.gather(model.displacement, global_displacement);
// sync.gather(model.blocked, global_blocked);
// auto force_it = global_forces.begin();
// auto disp_it = global_displacement.begin();
// auto blocked_it = global_blocked.begin();
// std::cout << "node"
// << ", " << std::setw(8) << "disp"
// << ", " << std::setw(8) << "force"
// << ", " << std::setw(8) << "blocked" << std::endl;
// UInt node = 0;
// for (; disp_it != global_displacement.end();
// ++disp_it, ++force_it, ++blocked_it, ++node) {
// std::cout << node << ", " << std::setw(8) << *disp_it << ", "
// << std::setw(8) << *force_it << ", " << std::setw(8)
// << *blocked_it << std::endl;
// std::cout << std::flush;
// }
// } else {
// sync.gather(model.forces);
// sync.gather(model.displacement);
// sync.gather(model.blocked);
// }
// } else {
- auto force_it = model.forces.begin();
- auto disp_it = model.displacement.begin();
- auto blocked_it = model.blocked.begin();
-
- std::cout << "node"
- << ", " << std::setw(8) << "disp"
- << ", " << std::setw(8) << "force"
- << ", " << std::setw(8) << "blocked" << std::endl;
-
- UInt node = 0;
- for (; disp_it != model.displacement.end();
- ++disp_it, ++force_it, ++blocked_it, ++node) {
- std::cout << node << ", " << std::setw(8) << *disp_it << ", "
- << std::setw(8) << *force_it << ", " << std::setw(8)
- << *blocked_it << std::endl;
-
- std::cout << std::flush;
- }
-// }
+ auto force_it = model.forces.begin();
+ auto disp_it = model.displacement.begin();
+ auto blocked_it = model.blocked.begin();
+
+ std::cout << "node"
+ << ", " << std::setw(8) << "disp"
+ << ", " << std::setw(8) << "force"
+ << ", " << std::setw(8) << "blocked" << std::endl;
+
+ UInt node = 0;
+ for (; disp_it != model.displacement.end();
+ ++disp_it, ++force_it, ++blocked_it, ++node) {
+ std::cout << node << ", " << std::setw(8) << *disp_it << ", "
+ << std::setw(8) << *force_it << ", " << std::setw(8)
+ << *blocked_it << std::endl;
+
+ std::cout << std::flush;
+ }
+ // }
}
diff --git a/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.cc b/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.cc
index 1f41000db..0b1ac6bc1 100644
--- a/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.cc
+++ b/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.cc
@@ -1,245 +1,246 @@
/**
* @file test_model_solver_dynamic.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Apr 13 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Test default dof manager
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "element_group.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
#include "non_linear_solver.hh"
/* -------------------------------------------------------------------------- */
#include "dumpable_inline_impl.hh"
#include "dumper_element_partition.hh"
#include "dumper_iohelper_paraview.hh"
/* -------------------------------------------------------------------------- */
#include "test_model_solver_my_model.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
#ifndef EXPLICIT
#define EXPLICIT true
#endif
using namespace akantu;
class Sinusoidal : public BC::Dirichlet::DirichletFunctor {
public:
Sinusoidal(MyModel & model, Real amplitude, Real pulse_width, Real t)
: model(model), A(amplitude), k(2 * M_PI / pulse_width),
t(t), v{std::sqrt(model.E / model.rho)} {}
void operator()(UInt n, Vector<bool> & /*flags*/, Vector<Real> & disp,
const Vector<Real> & coord) const {
auto x = coord(_x);
model.velocity(n, _x) = k * v * A * sin(k * (x - v * t));
disp(_x) = A * cos(k * (x - v * t));
}
private:
MyModel & model;
Real A{1.};
Real k{2 * M_PI};
Real t{1.};
Real v{1.};
};
static void genMesh(Mesh & mesh, UInt nb_nodes);
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
UInt prank = Communicator::getStaticCommunicator().whoAmI();
UInt global_nb_nodes = 201;
UInt max_steps = 400;
Real time_step = 0.001;
Mesh mesh(1);
Real F = -9.81;
bool _explicit = EXPLICIT;
const Real pulse_width = 0.2;
const Real A = 0.01;
ID dof_manager_type = "default";
#if defined(DOF_MANAGER_TYPE)
dof_manager_type = DOF_MANAGER_TYPE;
#endif
-
+
if (prank == 0)
genMesh(mesh, global_nb_nodes);
mesh.distribute();
// mesh.makePeriodic(_x);
MyModel model(F, mesh, _explicit, dof_manager_type);
model.forces.clear();
model.blocked.clear();
model.applyBC(Sinusoidal(model, A, pulse_width, 0.), "all");
model.applyBC(BC::Dirichlet::FlagOnly(_x), "border");
if (!_explicit) {
model.getNewSolver("dynamic", TimeStepSolverType::_dynamic,
NonLinearSolverType::_newton_raphson);
model.setIntegrationScheme("dynamic", "disp",
IntegrationSchemeType::_trapezoidal_rule_2,
IntegrationScheme::_displacement);
} else {
model.getNewSolver("dynamic", TimeStepSolverType::_dynamic_lumped,
NonLinearSolverType::_lumped);
model.setIntegrationScheme("dynamic", "disp",
IntegrationSchemeType::_central_difference,
IntegrationScheme::_acceleration);
}
model.setTimeStep(time_step);
if (prank == 0) {
std::cout << std::scientific;
std::cout << std::setw(14) << "time"
<< "," << std::setw(14) << "wext"
<< "," << std::setw(14) << "epot"
<< "," << std::setw(14) << "ekin"
<< "," << std::setw(14) << "total"
<< "," << std::setw(14) << "max_disp"
<< "," << std::setw(14) << "min_disp" << std::endl;
}
Real wext = 0.;
model.getDOFManager().clearResidual();
model.assembleResidual();
Real epot = 0; // model.getPotentialEnergy();
Real ekin = 0; // model.getKineticEnergy();
Real einit = ekin + epot;
Real etot = ekin + epot - wext - einit;
Real max_disp = 0., min_disp = 0.;
for (auto && disp : model.displacement) {
max_disp = std::max(max_disp, disp);
min_disp = std::min(min_disp, disp);
}
if (prank == 0) {
std::cout << std::setw(14) << 0. << "," << std::setw(14) << wext << ","
<< std::setw(14) << epot << "," << std::setw(14) << ekin << ","
<< std::setw(14) << etot << "," << std::setw(14) << max_disp
<< "," << std::setw(14) << min_disp << std::endl;
}
#if EXPLICIT == false
NonLinearSolver & solver =
model.getDOFManager().getNonLinearSolver("dynamic");
solver.set("max_iterations", 20);
#endif
- auto * dumper = new DumperParaview("dynamic", "./paraview");
- mesh.registerExternalDumper(*dumper, "dynamic", true);
+ auto && dumper = std::make_shared<DumperParaview>("dynamic", "./paraview");
+ mesh.registerExternalDumper(dumper, "dynamic", true);
mesh.addDumpMesh(mesh);
mesh.addDumpFieldExternalToDumper("dynamic", "displacement",
model.displacement);
mesh.addDumpFieldExternalToDumper("dynamic", "velocity", model.velocity);
mesh.addDumpFieldExternalToDumper("dynamic", "forces", model.forces);
- mesh.addDumpFieldExternalToDumper("dynamic", "internal_forces", model.internal_forces);
+ mesh.addDumpFieldExternalToDumper("dynamic", "internal_forces",
+ model.internal_forces);
mesh.addDumpFieldExternalToDumper("dynamic", "acceleration",
model.acceleration);
mesh.dump();
for (UInt i = 1; i < max_steps + 1; ++i) {
model.applyBC(Sinusoidal(model, A, pulse_width, time_step * (i - 1)),
"border");
model.solveStep("dynamic");
mesh.dump();
epot = model.getPotentialEnergy();
ekin = model.getKineticEnergy();
wext += model.getExternalWorkIncrement();
etot = ekin + epot - wext - einit;
Real max_disp = 0., min_disp = 0.;
for (auto && disp : model.displacement) {
max_disp = std::max(max_disp, disp);
min_disp = std::min(min_disp, disp);
}
if (prank == 0) {
std::cout << std::setw(14) << time_step * i << "," << std::setw(14)
<< wext << "," << std::setw(14) << epot << "," << std::setw(14)
<< ekin << "," << std::setw(14) << etot << "," << std::setw(14)
<< max_disp << "," << std::setw(14) << min_disp << std::endl;
}
}
// output.close();
finalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
void genMesh(Mesh & mesh, UInt nb_nodes) {
MeshAccessor mesh_accessor(mesh);
Array<Real> & nodes = mesh_accessor.getNodes();
Array<UInt> & conn = mesh_accessor.getConnectivity(_segment_2);
nodes.resize(nb_nodes);
auto & all = mesh.createNodeGroup("all_nodes");
for (UInt n = 0; n < nb_nodes; ++n) {
nodes(n, _x) = n * (1. / (nb_nodes - 1));
all.add(n);
}
mesh.createElementGroupFromNodeGroup("all", "all_nodes");
conn.resize(nb_nodes - 1);
for (UInt n = 0; n < nb_nodes - 1; ++n) {
conn(n, 0) = n;
conn(n, 1) = n + 1;
}
Array<UInt> & conn_points = mesh_accessor.getConnectivity(_point_1);
conn_points.resize(2);
conn_points(0, 0) = 0;
conn_points(1, 0) = nb_nodes - 1;
auto & border = mesh.createElementGroup("border", 0);
border.add({_point_1, 0, _not_ghost}, true);
border.add({_point_1, 1, _not_ghost}, true);
mesh_accessor.makeReady();
}
diff --git a/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.py b/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.py
index 31b15aed8..16b064c5d 100644
--- a/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.py
+++ b/test/test_model/test_common/test_model_solver/test_model_solver_dynamic.py
@@ -1,55 +1,56 @@
#!/usr/bin/env python3
# ------------------------------------------------------------------------------
__author__ = "Nicolas Richart"
__copyright__ = "Copyright (C) 2016-2018, EPFL (Ecole Polytechnique Fédérale" \
" de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
" en Mécanique des Solides)"
__credits__ = ["Nicolas Richart"]
__license__ = "L-GPLv3"
__maintainer__ = "Nicolas Richart"
__email__ = "nicolas.richart@epfl.ch"
# ------------------------------------------------------------------------------
import numpy as np
import python_fe as pfe
import matplotlib.pyplot as plt
import matplotlib.animation as animation
# sim_u = np.genfromtxt("disp.csv", delimiter=",", names=True)
L = 1.
Ne = 200 # int(sim_u['node'][-1])
F = np.zeros(Ne + 1) # sim_u['force']
F[-1] = - 9.81
blocked = np.zeros(Ne + 1) # sim_u['blocked']
blocked[0] = 1
u = np.zeros(Ne + 1) # sim_u['disp']
trusses = pfe.TrussFE(Ne=Ne,
F={f: [np.where(F == f)] for f in np.unique(F)},
blocked=(np.where(blocked == 1),
u[blocked == 1]))
solver = pfe.DynamicSolver(trusses, delta_t=0.001)
# for s in range(200):
# solver.solveStep()
fig, ax = plt.subplots()
x = np.arange(Ne+1) * L / Ne # x-array
line, = ax.plot(x, trusses.u)
+
def animate(i):
solver.solveStep()
line.set_ydata(trusses.u) # update the data
plt.ylim(np.min(trusses.u), np.max(trusses.u))
return line,
ani = animation.FuncAnimation(fig, animate, np.arange(1, 200),
interval=25, blit=True)
plt.show()
diff --git a/test/test_model/test_common/test_model_solver/test_model_solver_dynamic_petsc.cc b/test/test_model/test_common/test_model_solver/test_model_solver_dynamic_petsc.cc
index 4099d1d7e..ce107cc59 100644
--- a/test/test_model/test_common/test_model_solver/test_model_solver_dynamic_petsc.cc
+++ b/test/test_model/test_common/test_model_solver/test_model_solver_dynamic_petsc.cc
@@ -1,838 +1,838 @@
/**
* @file test_model_solver_dynamic.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Apr 13 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Test default dof manager
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "element_group.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
#include "non_linear_solver.hh"
/* -------------------------------------------------------------------------- */
#include "boundary_condition_functor.hh"
#include "mpi_communicator_data.hh"
/* -------------------------------------------------------------------------- */
#include "dumpable_inline_impl.hh"
#include "dumper_element_partition.hh"
#include "dumper_iohelper_paraview.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
#include <petscmat.h>
#include <petscsnes.h>
#include <petscvec.h>
/* -------------------------------------------------------------------------- */
#ifndef EXPLICIT
#define EXPLICIT true
#endif
template <typename func>
void CHECK_ERR_CXX(func && func_, PetscErrorCode ierr) {
if (PetscUnlikely(ierr != 0)) {
const char * desc;
PetscErrorMessage(ierr, &desc, nullptr);
AKANTU_EXCEPTION("Error in PETSc call to \'" << func_ << "\': " << desc);
}
}
using namespace akantu;
static void genMesh(Mesh & mesh, UInt nb_nodes);
class MyModel {
public:
MyModel(Real F, Mesh & mesh, bool lumped)
: nb_dofs(mesh.getNbNodes()), nb_elements(mesh.getNbElement(_segment_2)),
lumped(lumped), E(1.), A(1.), rho(1.), mesh(mesh),
displacement(nb_dofs, 1, "disp"), velocity(nb_dofs, 1, "velo"),
acceleration(nb_dofs, 1, "accel"), blocked(nb_dofs, 1, "blocked"),
forces(nb_dofs, 1, "force_ext"),
internal_forces(nb_dofs, 1, "force_int"),
stresses(nb_elements, 1, "stress"), strains(nb_elements, 1, "strain"),
initial_lengths(nb_elements, 1, "L0") {
auto n_global = mesh.getNbGlobalNodes();
int n_local = 0;
std::vector<PetscInt> nodes_global_ids(nb_dofs);
for (auto && data : enumerate(nodes_global_ids)) {
auto n = std::get<0>(data);
n_local += mesh.isLocalOrMasterNode(n);
std::get<1>(data) = mesh.getNodeGlobalId(n);
}
mpi_comm = dynamic_cast<MPICommunicatorData &>(
mesh.getCommunicator().getCommunicatorData())
.getMPICommunicator();
MeshAccessor mesh_accessor(mesh);
ierr = ISLocalToGlobalMappingCreate(
mpi_comm, 1, mesh.getNbNodes(), nodes_global_ids.data(),
PETSC_COPY_VALUES, &petsc_local_to_global);
CHECK_ERR_CXX("ISLocalToGlobalMappingCreate", ierr);
auto setName = [](auto && Obj, auto && name) {
PetscObjectSetName(reinterpret_cast<PetscObject>(Obj), name);
};
ierr = VecCreate(mpi_comm, &rhs);
ierr = VecSetSizes(rhs, n_local, n_global);
ierr = VecSetFromOptions(rhs);
ierr = VecSetLocalToGlobalMapping(rhs, petsc_local_to_global);
setName(rhs, "rhs");
ierr = VecDuplicate(rhs, &x);
ierr = VecDuplicate(rhs, &x_save);
ierr = VecDuplicate(rhs, &dx);
ierr = VecDuplicate(rhs, &f_int);
ierr = VecDuplicate(rhs, &f_dirichlet);
setName(x, "x");
setName(x_save, "x save");
setName(dx, "dx");
setName(f_int, "f_int");
setName(f_dirichlet, "f_dirichlet");
ierr = MatCreate(mpi_comm, &M);
ierr = MatSetSizes(M, n_local, n_local, n_global, n_global);
ierr = MatSetFromOptions(M);
ierr = MatSetOption(M, MAT_SYMMETRIC, PETSC_TRUE);
ierr = MatSetOption(M, MAT_ROW_ORIENTED, PETSC_TRUE);
ierr = MatSetUp(M);
ierr = MatSetLocalToGlobalMapping(M, petsc_local_to_global,
petsc_local_to_global);
setName(M, "M");
assembleMass();
ierr = MatDuplicate(M, MAT_DO_NOT_COPY_VALUES, &K);
setName(K, "K");
ierr = MatDuplicate(M, MAT_DO_NOT_COPY_VALUES, &J);
setName(J, "J");
ierr = SNESCreate(mpi_comm, &snes);
ierr = SNESSetFromOptions(snes);
ierr = SNESSetFunction(snes, rhs, MyModel::FormFunction, this);
ierr = SNESSetJacobian(snes, J, J, MyModel::FormJacobian, this);
PetscViewerPushFormat(PETSC_VIEWER_STDOUT_WORLD, PETSC_VIEWER_ASCII_INDEX);
displacement.set(0.);
velocity.set(0.);
acceleration.set(0.);
forces.set(0.);
blocked.set(false);
blocked(0, 0) = true;
blocked(nb_dofs - 1, 0) = true;
displacement(0, 0) = 0;
displacement(nb_dofs - 1, 0) = 1;
for (auto && data :
zip(make_view(this->mesh.getConnectivity(_segment_2), 2),
make_view(this->initial_lengths))) {
const auto & conn = std::get<0>(data);
auto & L = std::get<1>(data);
auto p1 = this->mesh.getNodes()(conn(0), _x);
auto p2 = this->mesh.getNodes()(conn(1), _x);
L = std::abs(p2 - p1);
}
}
// static PetscErrorCode SNESMonitor(SNES snes,PetscInt its,PetscReal
// fnorm,void *ctx) {
// auto & _this = *reinterpret_cast<MyModel *>(ctx);
// //SNESMonitorDefault(snes, its, fnorm, PETSC_VIEWER_STDOUT_WORLD);
// }
static PetscErrorCode FormFunction(SNES /*snes*/, Vec /*dx*/, Vec /*f*/,
void * ctx) {
auto & _this = *reinterpret_cast<MyModel *>(ctx);
_this.assembleResidual();
return 0;
}
static PetscErrorCode FormJacobian(SNES /*snes*/, Vec /*dx*/, Mat /*J*/,
Mat /*P*/, void * ctx) {
auto & _this = *reinterpret_cast<MyModel *>(ctx);
_this.assembleJacobian();
return 0;
}
~MyModel() {
ierr = MatDestroy(&M);
ierr = MatDestroy(&K);
ierr = MatDestroy(&J);
ierr = VecDestroy(&rhs);
ierr = VecDestroy(&x);
ierr = VecDestroy(&dx);
ierr = VecDestroy(&x_save);
ierr = VecDestroy(&f_int);
PetscFinalize();
}
void solveStep() {
std::cout << "solveStep" << std::endl;
copy(x_save, displacement);
ierr = SNESSolve(snes, NULL, dx);
CHECK_ERR_CXX("SNESSolve", ierr);
setSolutionToDisplacement();
assembleResidual();
}
void applyBC() {
std::vector<PetscInt> rows;
for (auto && data : enumerate(blocked)) {
if (std::get<1>(data)) {
rows.push_back(std::get<0>(data));
}
}
copy(x, displacement);
ierr = MatZeroRowsColumnsLocal(J, rows.size(), rows.data(), 1., x,
f_dirichlet);
VecView(f_dirichlet, PETSC_VIEWER_STDOUT_WORLD);
CHECK_ERR_CXX("MatZeroRowsColumnsLocal", ierr);
}
void setSolutionToDisplacement() {
std::cout << "setSolutionToDisplacement" << std::endl;
ierr = VecWAXPY(x, 1, x_save, dx);
copy(displacement, x);
}
void assembleJacobian() {
std::cout << "assembleJacobian" << std::endl;
setSolutionToDisplacement();
assembleStiffness();
ierr = MatZeroEntries(J);
CHECK_ERR_CXX("MatZeroEntries", ierr);
ierr = MatAXPY(J, 1., K, SAME_NONZERO_PATTERN);
CHECK_ERR_CXX("MatAXPY", ierr);
MatView(J, PETSC_VIEWER_STDOUT_WORLD);
applyBC();
MatView(J, PETSC_VIEWER_STDOUT_WORLD);
}
void assembleMass() {
std::cout << "assembleMass" << std::endl;
ierr = MatZeroEntries(M);
CHECK_ERR_CXX("MatZeroEntries", ierr);
Array<Real> m_all_el(this->nb_elements, 4);
Matrix<Real> m(2, 2);
m(0, 0) = m(1, 1) = 2;
m(0, 1) = m(1, 0) = 1;
// under integrated
// m(0, 0) = m(1, 1) = 3./2.;
// m(0, 1) = m(1, 0) = 3./2.;
// lumping the mass matrix
// m(0, 0) += m(0, 1);
// m(1, 1) += m(1, 0);
// m(0, 1) = m(1, 0) = 0;
for (auto && data :
zip(make_view(this->mesh.getConnectivity(_segment_2), 2),
make_view(m_all_el, 2, 2))) {
const auto & conn = std::get<0>(data);
auto & m_el = std::get<1>(data);
UInt n1 = conn(0);
UInt n2 = conn(1);
Real p1 = this->mesh.getNodes()(n1, _x);
Real p2 = this->mesh.getNodes()(n2, _x);
Real L = std::abs(p2 - p1);
m_el = m;
m_el *= rho * A * L / 6.;
Vector<Int> conn_int(conn.size());
for (auto && data : zip(conn_int, conn)) {
std::get<0>(data) = std::get<1>(data);
}
ierr = MatSetValuesLocal(M, conn_int.size(), conn_int.storage(),
conn_int.size(), conn_int.storage(), m.storage(),
ADD_VALUES);
}
ierr = MatAssemblyBegin(M, MAT_FINAL_ASSEMBLY);
ierr = MatAssemblyEnd(M, MAT_FINAL_ASSEMBLY);
ierr = MatSetOption(M, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
PetscViewer viewer;
ierr = PetscViewerASCIIOpen(mpi_comm, "M.mtx", &viewer);
PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATRIXMARKET);
ierr = MatView(M, viewer);
PetscViewerPopFormat(viewer);
ierr = PetscViewerDestroy(&viewer);
// this->getDOFManager().assembleElementalMatricesToMatrix(
// "M", "disp", m_all_el, _segment_2);
is_mass_assembled = true;
}
// MatrixType getMatrixType(const ID &) { return _symmetric; }
// void assembleMatrix(const ID & matrix_id) {
// if (matrix_id == "K") {
// if (not is_stiffness_assembled)
// this->assembleStiffness();
// } else if (matrix_id == "M") {
// if (not is_mass_assembled)
// this->assembleMass();
// } else if (matrix_id == "C") {
// // pass, no damping matrix
// } else {
// AKANTU_EXCEPTION("This solver does not know what to do with a matrix "
// << matrix_id);
// }
// }
void assembleLumpedMatrix(const ID & matrix_id) {
std::cout << "assembleLumpedMatrix" << std::endl;
AKANTU_EXCEPTION("This solver does not know what to do with a matrix "
<< matrix_id);
}
void assembleStiffness() {
std::cout << "assembleStiffness" << std::endl;
// SparseMatrix & K = this->getDOFManager().getMatrix("K");
// K.clear();
ierr = MatZeroEntries(K);
CHECK_ERR_CXX("MatZeroEntries", ierr);
Matrix<Real> k(2, 2);
k(0, 0) = k(1, 1) = 1;
k(0, 1) = k(1, 0) = -1;
Array<Real> k_all_el(this->nb_elements, 4);
auto k_it = k_all_el.begin(2, 2);
auto cit = this->mesh.getConnectivity(_segment_2).begin(2);
auto cend = this->mesh.getConnectivity(_segment_2).end(2);
for (; cit != cend; ++cit, ++k_it) {
const auto & conn = *cit;
UInt n1 = conn(0);
UInt n2 = conn(1);
Real p1 = this->mesh.getNodes()(n1, _x);
Real p2 = this->mesh.getNodes()(n2, _x);
Real L = std::abs(p2 - p1);
auto & k_el = *k_it;
k_el = k;
k_el *= E * A / L;
Vector<Int> conn_int(conn.size());
for (auto && data : zip(conn_int, conn)) {
std::get<0>(data) = std::get<1>(data);
}
ierr = MatSetValuesLocal(K, conn_int.size(), conn_int.storage(),
conn_int.size(), conn_int.storage(),
k_el.storage(), ADD_VALUES);
}
ierr = MatAssemblyBegin(K, MAT_FINAL_ASSEMBLY);
CHECK_ERR_CXX("MatAssemblyBegin", ierr);
ierr = MatAssemblyEnd(K, MAT_FINAL_ASSEMBLY);
CHECK_ERR_CXX("MatAssemblyEnd", ierr);
ierr = MatSetOption(K, MAT_NEW_NONZERO_LOCATIONS, PETSC_FALSE);
CHECK_ERR_CXX("MatSetOption", ierr);
PetscViewer viewer;
ierr = PetscViewerASCIIOpen(mpi_comm, "K.mtx", &viewer);
CHECK_ERR_CXX("PetscViewerASCIIOpen", ierr);
PetscViewerPushFormat(viewer, PETSC_VIEWER_ASCII_MATRIXMARKET);
ierr = MatView(K, viewer);
CHECK_ERR_CXX("MatView", ierr);
PetscViewerPopFormat(viewer);
ierr = PetscViewerDestroy(&viewer);
CHECK_ERR_CXX("PetscViewerDestroy", ierr);
// this->getDOFManager().assembleElementalMatricesToMatrix(
// "K", "disp", k_all_el, _segment_2);
is_stiffness_assembled = true;
}
void copy(Array<Real> & y, Vec x) {
std::cout << "copy <-" << std::endl;
const PetscScalar * x_local;
ierr = VecGetArrayRead(x, &x_local);
for (auto && data : zip(y, range(x_local + 0, x_local + y.size()))) {
std::get<0>(data) = std::get<1>(data);
}
ierr = VecRestoreArrayRead(x, &x_local);
// VecView(x, PETSC_VIEWER_STDOUT_WORLD);
// std::cout << y.getID() << " " << Vector<Real>(y.storage(), y.size())
// << std::endl;
}
void print(const Array<Real> & x) const {
std::cout << x.getID() << " " << Vector<Real>(x.storage(), x.size())
<< std::endl;
}
void copy(Vec x, const Array<Real> & y) {
std::cout << "copy ->" << std::endl;
PetscScalar * x_local;
ierr = VecGetArray(x, &x_local);
for (auto && data : zip(y, range(x_local + 0, x_local + y.size()))) {
std::get<1>(data) = std::get<0>(data);
}
ierr = VecRestoreArray(x, &x_local);
// std::cout << y.getID() << " " << Vector<Real>(y.storage(), y.size())
// << std::endl;
// VecView(x, PETSC_VIEWER_STDOUT_WORLD);
}
void assembleResidual() {
std::cout << "assembleResidual" << std::endl;
// this->getDOFManager().assembleToResidual("disp", forces);
setSolutionToDisplacement();
copy(rhs, forces);
// VecAXPY(rhs, -1., f_dirichlet);
print(displacement);
this->assembleResidual(_not_ghost);
// this->synchronize(SynchronizationTag::_user_1);
// this->getDOFManager().assembleToResidual("disp", internal_forces, -1.);
VecAXPY(rhs, 1., f_int);
for (auto && data : enumerate(blocked)) {
- if(std::get<1>(data)) {
+ if (std::get<1>(data)) {
VecSetValueLocal(rhs, std::get<0>(data), 0., INSERT_VALUES);
}
}
VecAssemblyBegin(rhs);
VecAssemblyEnd(rhs);
VecView(rhs, PETSC_VIEWER_STDOUT_WORLD);
}
void assembleResidual(const GhostType & ghost_type) {
std::cout << "assembleResidual" << std::endl;
VecZeroEntries(f_int);
auto cit = this->mesh.getConnectivity(_segment_2, ghost_type).begin(2);
auto cend = this->mesh.getConnectivity(_segment_2, ghost_type).end(2);
auto strain_it = this->strains.begin();
auto stress_it = this->stresses.begin();
auto L_it = this->initial_lengths.begin();
for (; cit != cend; ++cit, ++strain_it, ++stress_it, ++L_it) {
const auto & conn = *cit;
UInt n1 = conn(0);
UInt n2 = conn(1);
Real u1 = this->displacement(n1, _x);
Real u2 = this->displacement(n2, _x);
*strain_it = (u2 - u1) / *L_it;
*stress_it = E * *strain_it;
Real f_n = A * *stress_it;
std::cout << n1 << "[" << u1 << "]"
<< " <-> " << n2 << "[" << u2 << "]"
<< " : " << f_n << std::endl;
ierr = VecSetValueLocal(f_int, n1, -f_n, ADD_VALUES);
ierr = VecSetValueLocal(f_int, n2, f_n, ADD_VALUES);
}
ierr = VecAssemblyBegin(f_int);
ierr = VecAssemblyEnd(f_int);
// this->getDOFManager().assembleElementalArrayLocalArray(
// forces_internal_el, internal_forces, _segment_2, ghost_type);
}
Real getPotentialEnergy() {
std::cout << "getPotentialEnergy" << std::endl;
copy(x, displacement);
Vec Ax;
ierr = VecDuplicate(x, &Ax);
ierr = MatMult(K, x, Ax);
PetscScalar res;
ierr = VecDot(x, Ax, &res);
return res / 2.;
}
Real getKineticEnergy() {
std::cout << "getKineticEnergy" << std::endl;
return 0;
}
// Real getExternalWorkIncrement() {
// Real res = 0;
// auto it = velocity.begin();
// auto end = velocity.end();
// auto if_it = internal_forces.begin();
// auto ef_it = forces.begin();
// auto b_it = blocked.begin();
// for (UInt node = 0; it != end; ++it, ++if_it, ++ef_it, ++b_it, ++node) {
// if (mesh.isLocalOrMasterNode(node))
// res += (*b_it ? -*if_it : *ef_it) * *it;
// }
// mesh.getCommunicator().allReduce(res, SynchronizerOperation::_sum);
// return res * this->getTimeStep();
// }
// void predictor() {}
// void corrector() {}
// /* ------------------------------------------------------------------------
// */ UInt getNbData(const Array<Element> & elements,
// const SynchronizationTag &) const {
// return elements.size() * sizeof(Real);
// }
// void packData(CommunicationBuffer & buffer, const Array<Element> &
// elements,
// const SynchronizationTag & tag) const {
// if (tag == SynchronizationTag::_user_1) {
// for (const auto & el : elements) {
// buffer << this->stresses(el.element);
// }
// }
// }
// void unpackData(CommunicationBuffer & buffer, const Array<Element> &
// elements,
// const SynchronizationTag & tag) {
// if (tag == SynchronizationTag::_user_1) {
// auto cit = this->mesh.getConnectivity(_segment_2, _ghost).begin(2);
// for (const auto & el : elements) {
// Real stress;
// buffer >> stress;
// Real f = A * stress;
// Vector<UInt> conn = cit[el.element];
// this->internal_forces(conn(0), _x) += -f;
// this->internal_forces(conn(1), _x) += f;
// }
// }
// }
Real getExternalWorkIncrement() {
std::cout << "getExternalWorkIncrement" << std::endl;
return 0.;
}
template <class Functor> void applyBC(Functor && func, const ID & group_id) {
auto & group = mesh.getElementGroup(group_id).getNodeGroup().getNodes();
auto blocked_dofs = make_view(blocked, 1).begin();
auto disps = make_view(displacement, 1).begin();
auto poss = make_view(mesh.getNodes(), 1).begin();
for (auto && node : group) {
auto disp = Vector<Real>(disps[node]);
auto pos = Vector<Real>(poss[node]);
auto flags = Vector<bool>(blocked_dofs[node]);
func(node, flags, disp, pos);
}
}
const Mesh & getMesh() const { return mesh; }
UInt getSpatialDimension() const { return 1; }
auto & getBlockedDOFs() { return blocked; }
void setTimeStep(Real dt) {
std::cout << "setTimeStep" << std::endl;
this->dt = dt;
}
private:
PetscErrorCode ierr{0};
MPI_Comm mpi_comm;
ISLocalToGlobalMapping petsc_local_to_global;
UInt nb_dofs;
UInt nb_elements;
bool lumped;
bool is_stiffness_assembled{false};
bool is_mass_assembled{false};
bool is_lumped_mass_assembled{false};
Mat K{nullptr}, J{nullptr}, M{nullptr};
Vec rhs{nullptr}, x{nullptr}, x_save{nullptr}, dx{nullptr}, f_int{nullptr},
f_dirichlet{nullptr};
SNES snes;
Real dt{0};
Array<Real> save_displacement;
public:
Real E, A, rho;
Mesh & mesh;
Array<Real> displacement;
Array<Real> velocity;
Array<Real> acceleration;
Array<bool> blocked;
Array<Real> forces;
Array<Real> internal_forces;
Array<Real> stresses;
Array<Real> strains;
Array<Real> initial_lengths;
};
/* -------------------------------------------------------------------------- */
class Sinusoidal : public BC::Dirichlet::DirichletFunctor {
public:
Sinusoidal(MyModel & model, Real amplitude, Real pulse_width, Real t)
: model(model), A(amplitude), k(2 * M_PI / pulse_width),
t(t), v{std::sqrt(model.E / model.rho)} {}
void operator()(UInt n, Vector<bool> & /*flags*/, Vector<Real> & disp,
const Vector<Real> & coord) const {
auto x = coord(_x);
model.velocity(n, _x) = k * v * A * sin(k * (x - v * t));
disp(_x) = A * cos(k * (x - v * t));
}
private:
MyModel & model;
Real A{1.};
Real k{2 * M_PI};
Real t{1.};
Real v{1.};
};
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
PetscInitialize(&argc, &argv, nullptr, nullptr);
UInt prank = Communicator::getStaticCommunicator().whoAmI();
UInt global_nb_nodes = 3;
UInt max_steps = 400;
Real time_step = 0.001;
Mesh mesh(1);
Real F = -9.81;
bool _explicit = EXPLICIT;
- //const Real pulse_width = 0.2;
+ // const Real pulse_width = 0.2;
const Real A = 0.01;
if (prank == 0)
genMesh(mesh, global_nb_nodes);
mesh.distribute();
// mesh.makePeriodic(_x);
MyModel model(F, mesh, _explicit);
// model.forces.clear();
// model.blocked.clear();
// model.applyBC(Sinusoidal(model, A, pulse_width, 0.), "all");
// model.applyBC(BC::Dirichlet::FlagOnly(_x), "border");
// if (!_explicit) {
// model.getNewSolver("dynamic", TimeStepSolverType::_dynamic,
// NonLinearSolverType::_newton_raphson);
// model.setIntegrationScheme("dynamic", "disp",
// IntegrationSchemeType::_trapezoidal_rule_2,
// IntegrationScheme::_displacement);
// } else {
// model.getNewSolver("dynamic", TimeStepSolverType::_dynamic_lumped,
// NonLinearSolverType::_lumped);
// model.setIntegrationScheme("dynamic", "disp",
// IntegrationSchemeType::_central_difference,
// IntegrationScheme::_acceleration);
// }
model.setTimeStep(time_step);
if (prank == 0) {
std::cout << std::scientific;
std::cout << std::setw(14) << "time"
<< "," << std::setw(14) << "wext"
<< "," << std::setw(14) << "epot"
<< "," << std::setw(14) << "ekin"
<< "," << std::setw(14) << "total"
<< "," << std::setw(14) << "max_disp"
<< "," << std::setw(14) << "min_disp" << std::endl;
}
Real wext = 0.;
// model.getDOFManager().clearResidual();
// model.assembleResidual();
Real epot = 0; // model.getPotentialEnergy();
Real ekin = 0; // model.getKineticEnergy();
Real einit = ekin + epot;
Real etot = ekin + epot - wext - einit;
Real max_disp = 0., min_disp = 0.;
for (auto && disp : model.displacement) {
max_disp = std::max(max_disp, disp);
min_disp = std::min(min_disp, disp);
}
if (prank == 0) {
std::cout << std::setw(14) << 0. << "," << std::setw(14) << wext << ","
<< std::setw(14) << epot << "," << std::setw(14) << ekin << ","
<< std::setw(14) << etot << "," << std::setw(14) << max_disp
<< "," << std::setw(14) << min_disp << std::endl;
}
// #if EXPLICIT == false
// NonLinearSolver & solver =
// model.getDOFManager().getNonLinearSolver("dynamic");
// solver.set("max_iterations", 20);
// #endif
auto * dumper = new DumperParaview("dynamic", "./paraview");
mesh.registerExternalDumper(*dumper, "dynamic", true);
mesh.addDumpMesh(mesh);
mesh.addDumpFieldExternalToDumper("dynamic", "displacement",
model.displacement);
mesh.addDumpFieldExternalToDumper("dynamic", "velocity", model.velocity);
mesh.addDumpFieldExternalToDumper("dynamic", "forces", model.forces);
mesh.addDumpFieldExternalToDumper("dynamic", "acceleration",
model.acceleration);
mesh.dump();
max_steps = 1;
for (UInt i = 1; i < max_steps + 1; ++i) {
// model.applyBC(Sinusoidal(model, A, pulse_width, time_step * (i - 1)),
// "border");
model.solveStep();
mesh.dump();
epot = model.getPotentialEnergy();
ekin = model.getKineticEnergy();
wext += model.getExternalWorkIncrement();
etot = ekin + epot - wext - einit;
Real max_disp = 0., min_disp = 0.;
for (auto && disp : model.displacement) {
max_disp = std::max(max_disp, disp);
min_disp = std::min(min_disp, disp);
}
if (prank == 0) {
std::cout << std::setw(14) << time_step * i << "," << std::setw(14)
<< wext << "," << std::setw(14) << epot << "," << std::setw(14)
<< ekin << "," << std::setw(14) << etot << "," << std::setw(14)
<< max_disp << "," << std::setw(14) << min_disp << std::endl;
}
}
// output.close();
// finalize();
// PetscFinalize();
return EXIT_SUCCESS;
}
/* -------------------------------------------------------------------------- */
void genMesh(Mesh & mesh, UInt nb_nodes) {
MeshAccessor mesh_accessor(mesh);
Array<Real> & nodes = mesh_accessor.getNodes();
Array<UInt> & conn = mesh_accessor.getConnectivity(_segment_2);
nodes.resize(nb_nodes);
- //auto & all = mesh.createNodeGroup("all_nodes");
+ // auto & all = mesh.createNodeGroup("all_nodes");
for (UInt n = 0; n < nb_nodes; ++n) {
nodes(n, _x) = n * (1. / (nb_nodes - 1));
- //all.add(n);
+ // all.add(n);
}
- //mesh.createElementGroupFromNodeGroup("all", "all_nodes");
+ // mesh.createElementGroupFromNodeGroup("all", "all_nodes");
conn.resize(nb_nodes - 1);
for (UInt n = 0; n < nb_nodes - 1; ++n) {
conn(n, 0) = n;
conn(n, 1) = n + 1;
}
// Array<UInt> & conn_points = mesh_accessor.getConnectivity(_point_1);
// conn_points.resize(2);
// conn_points(0, 0) = 0;
// conn_points(1, 0) = nb_nodes - 1;
// auto & border = mesh.createElementGroup("border", 0);
// border.add({_point_1, 0, _not_ghost}, true);
// border.add({_point_1, 1, _not_ghost}, true);
mesh_accessor.makeReady();
}
diff --git a/test/test_model/test_common/test_model_solver/test_model_solver_my_model.hh b/test/test_model/test_common/test_model_solver/test_model_solver_my_model.hh
index 43b3daa26..1510350a5 100644
--- a/test/test_model/test_common/test_model_solver/test_model_solver_my_model.hh
+++ b/test/test_model/test_common/test_model_solver/test_model_solver_my_model.hh
@@ -1,450 +1,451 @@
/**
* @file test_model_solver_my_model.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Apr 13 2016
* @date last modification: Tue Feb 20 2018
*
* @brief Test default dof manager
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_iterators.hh"
#include "boundary_condition.hh"
#include "communicator.hh"
#include "data_accessor.hh"
#include "dof_manager_default.hh"
#include "element_synchronizer.hh"
#include "mesh.hh"
#include "model_solver.hh"
#include "periodic_node_synchronizer.hh"
#include "solver_vector_default.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
namespace akantu {
#ifndef __AKANTU_TEST_MODEL_SOLVER_MY_MODEL_HH__
#define __AKANTU_TEST_MODEL_SOLVER_MY_MODEL_HH__
/**
* =\o-----o-----o-> F
* | |
* |---- L ----|
*/
class MyModel : public ModelSolver,
public BoundaryCondition<MyModel>,
public DataAccessor<Element> {
public:
- MyModel(Real F, Mesh & mesh, bool lumped, const ID & dof_manager_type = "default")
+ MyModel(Real F, Mesh & mesh, bool lumped,
+ const ID & dof_manager_type = "default")
: ModelSolver(mesh, ModelType::_model, "model_solver", 0),
nb_dofs(mesh.getNbNodes()), nb_elements(mesh.getNbElement(_segment_2)),
lumped(lumped), E(1.), A(1.), rho(1.), mesh(mesh),
displacement(nb_dofs, 1, "disp"), velocity(nb_dofs, 1, "velo"),
acceleration(nb_dofs, 1, "accel"), blocked(nb_dofs, 1, "blocked"),
forces(nb_dofs, 1, "force_ext"),
internal_forces(nb_dofs, 1, "force_int"),
stresses(nb_elements, 1, "stress"), strains(nb_elements, 1, "strain"),
initial_lengths(nb_elements, 1, "L0") {
this->initBC(*this, displacement, forces);
this->initDOFManager(dof_manager_type);
this->getDOFManager().registerDOFs("disp", displacement, _dst_nodal);
this->getDOFManager().registerDOFsDerivative("disp", 1, velocity);
this->getDOFManager().registerDOFsDerivative("disp", 2, acceleration);
this->getDOFManager().registerBlockedDOFs("disp", blocked);
displacement.set(0.);
velocity.set(0.);
acceleration.set(0.);
forces.set(0.);
blocked.set(false);
UInt global_nb_nodes = mesh.getNbGlobalNodes();
for (auto && n : arange(nb_dofs)) {
auto global_id = mesh.getNodeGlobalId(n);
if (global_id == (global_nb_nodes - 1))
forces(n, _x) = F;
if (global_id == 0)
blocked(n, _x) = true;
}
auto cit = this->mesh.getConnectivity(_segment_2).begin(2);
auto cend = this->mesh.getConnectivity(_segment_2).end(2);
auto L_it = this->initial_lengths.begin();
for (; cit != cend; ++cit, ++L_it) {
const Vector<UInt> & conn = *cit;
UInt n1 = conn(0);
UInt n2 = conn(1);
Real p1 = this->mesh.getNodes()(n1, _x);
Real p2 = this->mesh.getNodes()(n2, _x);
*L_it = std::abs(p2 - p1);
}
this->registerDataAccessor(*this);
this->registerSynchronizer(
const_cast<ElementSynchronizer &>(this->mesh.getElementSynchronizer()),
SynchronizationTag::_user_1);
}
void assembleLumpedMass() {
auto & M = this->getDOFManager().getLumpedMatrix("M");
M.clear();
this->assembleLumpedMass(_not_ghost);
if (this->mesh.getNbElement(_segment_2, _ghost) > 0)
this->assembleLumpedMass(_ghost);
is_lumped_mass_assembled = true;
}
void assembleLumpedMass(const GhostType & ghost_type) {
Array<Real> M(nb_dofs, 1, 0.);
Array<Real> m_all_el(this->mesh.getNbElement(_segment_2, ghost_type), 2);
for (auto && data :
zip(make_view(this->mesh.getConnectivity(_segment_2), 2),
make_view(m_all_el, 2))) {
const auto & conn = std::get<0>(data);
auto & m_el = std::get<1>(data);
UInt n1 = conn(0);
UInt n2 = conn(1);
Real p1 = this->mesh.getNodes()(n1, _x);
Real p2 = this->mesh.getNodes()(n2, _x);
Real L = std::abs(p2 - p1);
Real M_n = rho * A * L / 2;
m_el(0) = m_el(1) = M_n;
}
this->getDOFManager().assembleElementalArrayLocalArray(
m_all_el, M, _segment_2, ghost_type);
this->getDOFManager().assembleToLumpedMatrix("disp", M, "M");
}
void assembleMass() {
SparseMatrix & M = this->getDOFManager().getMatrix("M");
M.clear();
Array<Real> m_all_el(this->nb_elements, 4);
Matrix<Real> m(2, 2);
m(0, 0) = m(1, 1) = 2;
m(0, 1) = m(1, 0) = 1;
// under integrated
// m(0, 0) = m(1, 1) = 3./2.;
// m(0, 1) = m(1, 0) = 3./2.;
// lumping the mass matrix
// m(0, 0) += m(0, 1);
// m(1, 1) += m(1, 0);
// m(0, 1) = m(1, 0) = 0;
for (auto && data :
zip(make_view(this->mesh.getConnectivity(_segment_2), 2),
make_view(m_all_el, 2, 2))) {
const auto & conn = std::get<0>(data);
auto & m_el = std::get<1>(data);
UInt n1 = conn(0);
UInt n2 = conn(1);
Real p1 = this->mesh.getNodes()(n1, _x);
Real p2 = this->mesh.getNodes()(n2, _x);
Real L = std::abs(p2 - p1);
m_el = m;
m_el *= rho * A * L / 6.;
}
this->getDOFManager().assembleElementalMatricesToMatrix(
"M", "disp", m_all_el, _segment_2);
is_mass_assembled = true;
}
MatrixType getMatrixType(const ID &) override { return _symmetric; }
void assembleMatrix(const ID & matrix_id) override {
if (matrix_id == "K") {
if (not is_stiffness_assembled)
this->assembleStiffness();
} else if (matrix_id == "M") {
if (not is_mass_assembled)
this->assembleMass();
} else if (matrix_id == "C") {
// pass, no damping matrix
} else {
AKANTU_EXCEPTION("This solver does not know what to do with a matrix "
<< matrix_id);
}
}
void assembleLumpedMatrix(const ID & matrix_id) override {
if (matrix_id == "M") {
if (not is_lumped_mass_assembled)
this->assembleLumpedMass();
} else {
AKANTU_EXCEPTION("This solver does not know what to do with a matrix "
<< matrix_id);
}
}
void assembleStiffness() {
SparseMatrix & K = this->getDOFManager().getMatrix("K");
K.clear();
Matrix<Real> k(2, 2);
k(0, 0) = k(1, 1) = 1;
k(0, 1) = k(1, 0) = -1;
Array<Real> k_all_el(this->nb_elements, 4);
auto k_it = k_all_el.begin(2, 2);
auto cit = this->mesh.getConnectivity(_segment_2).begin(2);
auto cend = this->mesh.getConnectivity(_segment_2).end(2);
for (; cit != cend; ++cit, ++k_it) {
const auto & conn = *cit;
UInt n1 = conn(0);
UInt n2 = conn(1);
Real p1 = this->mesh.getNodes()(n1, _x);
Real p2 = this->mesh.getNodes()(n2, _x);
Real L = std::abs(p2 - p1);
auto & k_el = *k_it;
k_el = k;
k_el *= E * A / L;
}
this->getDOFManager().assembleElementalMatricesToMatrix(
"K", "disp", k_all_el, _segment_2);
is_stiffness_assembled = true;
}
void assembleResidual() override {
this->getDOFManager().assembleToResidual("disp", forces);
internal_forces.clear();
this->assembleResidual(_not_ghost);
this->synchronize(SynchronizationTag::_user_1);
this->getDOFManager().assembleToResidual("disp", internal_forces, -1.);
}
void assembleResidual(const GhostType & ghost_type) {
Array<Real> forces_internal_el(
this->mesh.getNbElement(_segment_2, ghost_type), 2);
auto cit = this->mesh.getConnectivity(_segment_2, ghost_type).begin(2);
auto cend = this->mesh.getConnectivity(_segment_2, ghost_type).end(2);
auto f_it = forces_internal_el.begin(2);
auto strain_it = this->strains.begin();
auto stress_it = this->stresses.begin();
auto L_it = this->initial_lengths.begin();
for (; cit != cend; ++cit, ++f_it, ++strain_it, ++stress_it, ++L_it) {
const auto & conn = *cit;
UInt n1 = conn(0);
UInt n2 = conn(1);
Real u1 = this->displacement(n1, _x);
Real u2 = this->displacement(n2, _x);
*strain_it = (u2 - u1) / *L_it;
*stress_it = E * *strain_it;
Real f_n = A * *stress_it;
Vector<Real> & f = *f_it;
f(0) = -f_n;
f(1) = f_n;
}
this->getDOFManager().assembleElementalArrayLocalArray(
forces_internal_el, internal_forces, _segment_2, ghost_type);
}
Real getPotentialEnergy() {
Real res = 0;
if (not lumped) {
res = this->mulVectMatVect(this->displacement, "K", this->displacement);
} else {
auto strain_it = this->strains.begin();
auto stress_it = this->stresses.begin();
auto strain_end = this->strains.end();
auto L_it = this->initial_lengths.begin();
for (; strain_it != strain_end; ++strain_it, ++stress_it, ++L_it) {
res += *strain_it * *stress_it * A * *L_it;
}
mesh.getCommunicator().allReduce(res, SynchronizerOperation::_sum);
}
return res / 2.;
}
Real getKineticEnergy() {
Real res = 0;
if (not lumped) {
res = this->mulVectMatVect(this->velocity, "M", this->velocity);
} else {
Array<Real> & m = dynamic_cast<SolverVectorDefault &>(
this->getDOFManager().getLumpedMatrix("M"));
auto it = velocity.begin();
auto end = velocity.end();
auto m_it = m.begin();
for (UInt node = 0; it != end; ++it, ++m_it, ++node) {
if (mesh.isLocalOrMasterNode(node))
res += *m_it * *it * *it;
}
mesh.getCommunicator().allReduce(res, SynchronizerOperation::_sum);
}
return res / 2.;
}
Real getExternalWorkIncrement() {
Real res = 0;
auto it = velocity.begin();
auto end = velocity.end();
auto if_it = internal_forces.begin();
auto ef_it = forces.begin();
auto b_it = blocked.begin();
for (UInt node = 0; it != end; ++it, ++if_it, ++ef_it, ++b_it, ++node) {
if (mesh.isLocalOrMasterNode(node))
res += (*b_it ? -*if_it : *ef_it) * *it;
}
mesh.getCommunicator().allReduce(res, SynchronizerOperation::_sum);
return res * this->getTimeStep();
}
Real mulVectMatVect(const Array<Real> & x, const ID & A_id,
const Array<Real> & y) {
Array<Real> Ay(nb_dofs);
this->getDOFManager().assembleMatMulVectToArray("disp", A_id, y, Ay);
Real res = 0.;
for (auto && data : zip(arange(nb_dofs), make_view(Ay), make_view(x))) {
res += std::get<2>(data) * std::get<1>(data) *
mesh.isLocalOrMasterNode(std::get<0>(data));
}
mesh.getCommunicator().allReduce(res, SynchronizerOperation::_sum);
return res;
}
/* ------------------------------------------------------------------------ */
UInt getNbData(const Array<Element> & elements,
const SynchronizationTag &) const override {
return elements.size() * sizeof(Real);
}
void packData(CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) const override {
if (tag == SynchronizationTag::_user_1) {
for (const auto & el : elements) {
buffer << this->stresses(el.element);
}
}
}
void unpackData(CommunicationBuffer & buffer, const Array<Element> & elements,
const SynchronizationTag & tag) override {
if (tag == SynchronizationTag::_user_1) {
auto cit = this->mesh.getConnectivity(_segment_2, _ghost).begin(2);
for (const auto & el : elements) {
Real stress;
buffer >> stress;
Real f = A * stress;
Vector<UInt> conn = cit[el.element];
this->internal_forces(conn(0), _x) += -f;
this->internal_forces(conn(1), _x) += f;
}
}
}
const Mesh & getMesh() const { return mesh; }
UInt getSpatialDimension() const { return 1; }
auto & getBlockedDOFs() { return blocked; }
private:
UInt nb_dofs;
UInt nb_elements;
bool lumped;
bool is_stiffness_assembled{false};
bool is_mass_assembled{false};
bool is_lumped_mass_assembled{false};
public:
Real E, A, rho;
Mesh & mesh;
Array<Real> displacement;
Array<Real> velocity;
Array<Real> acceleration;
Array<bool> blocked;
Array<Real> forces;
Array<Real> internal_forces;
Array<Real> stresses;
Array<Real> strains;
Array<Real> initial_lengths;
};
#endif /* __AKANTU_TEST_MODEL_SOLVER_MY_MODEL_HH__ */
} // namespace akantu
diff --git a/test/test_model/test_common/test_non_local_toolbox/plot_neighborhoods.py b/test/test_model/test_common/test_non_local_toolbox/plot_neighborhoods.py
index b9263975b..ddc71bd64 100644
--- a/test/test_model/test_common/test_non_local_toolbox/plot_neighborhoods.py
+++ b/test/test_model/test_common/test_non_local_toolbox/plot_neighborhoods.py
@@ -1,102 +1,109 @@
#!/usr/bin/env python
# ------------------------------------------------------------------------------
__author__ = "Aurelia Isabel Cuba Ramos"
__copyright__ = "Copyright (C) 2016-2018, EPFL (Ecole Polytechnique Fédérale" \
" de Lausanne) Laboratory (LSMS - Laboratoire de Simulation" \
" en Mécanique des Solides)"
__credits__ = ["Aurelia Isabel Cuba Ramos"]
__license__ = "L-GPLv3"
__maintainer__ = "Nicolas Richart"
__email__ = "nicolas.richart@epfl.ch"
# ------------------------------------------------------------------------------
from matplotlib import rc
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
-import numpy as np
import sys
from matplotlib.backends.backend_pdf import PdfPages
-#--------------------------------------------------------------------------------
+
+# ------------------------------------------------------------------------------
def readFile(filename):
quad_x_coords = list()
quad_y_coords = list()
with open(filename) as fh:
for line in fh:
if line.strip().startswith("#"):
- nb_quads = 0
line = fh.next()
- x, y = [float(s) for s in line[1:-3].split(", ")]
+ x, y = [float(s) for s in line[1:-3].split(", ")]
quad_x_coords.append(float(x))
quad_y_coords.append(float(y))
return quad_x_coords, quad_y_coords
-#--------------------------------------------------------------------------------
+
+# ------------------------------------------------------------------------------
def readNeighborhoods(filename):
neighborhoods = dict()
with open(filename) as fh:
first_line = fh.readline()
key = int(first_line[0:-1].split(" ")[-1])
current_list = list()
for line in fh:
if line.strip().startswith("#"):
- neighborhoods[key] = current_list
+ neighborhoods[key] = current_list
key = int(line[0:-1].split(" ")[-1])
current_list = list()
else:
- coord = [float(s) for s in line[1:-3].split(", ")]
+ coord = [float(s) for s in line[1:-3].split(", ")]
current_list.append(coord)
neighborhoods[key] = current_list
return neighborhoods
-#--------------------------------------------------------------------------------
-def plotNeighborhood(quad_x_coords, quad_y_coords, neighborhood, r):
- nb_quads = len(quad_x_coords)
+# ------------------------------------------------------------------------------
+def plotNeighborhood(quad_x_coords, quad_y_coords, neighborhood, r):
ax = plt.subplot(111)
- plt.axis([-1,1,-1,1])
+ plt.axis([-1, 1, -1, 1])
# plot all quads
- ax.plot(quad_x_coords,quad_y_coords,label='free',linestyle='None',marker="+",markeredgewidth = 0.2, markersize = 4)
+ ax.plot(quad_x_coords, quad_y_coords, label='free',
+ linestyle='None', marker="+", markeredgewidth=0.2, markersize=4)
# plot center of neighborhood and circle
x = neighborhood[0][0]
y = neighborhood[0][1]
- ax.plot(x,y,label='free',marker="+",markeredgewidth = 0.2, markersize = 4, color='r')
- circ=plt.Circle((x,y), radius=r, color='g', fill=False)
+ ax.plot(x, y, label='free', marker="+", markeredgewidth=0.2,
+ markersize=4, color='r')
+ circ = plt.Circle((x, y), radius=r, color='g', fill=False)
ax.add_patch(circ)
formatter = ticker.ScalarFormatter()
- formatter.set_powerlimits((-2,2))
+ formatter.set_powerlimits((-2, 2))
ax.xaxis.set_major_formatter(formatter)
# plot all the neighbors
- for i in range(1,len(neighborhood)):
- ax.plot(neighborhood[i][0],neighborhood[i][1],label='free',linestyle='None',marker="x",markeredgewidth = 0.2, markersize = 4, color ='y')
+ for i in range(1, len(neighborhood)):
+ ax.plot(neighborhood[i][0], neighborhood[i][1], label='free',
+ linestyle='None', marker="x", markeredgewidth=0.2,
+ markersize=4, color='y')
- ax.grid(b=True, which='major', color='0.75', linestyle='-',linewidth=0.5)
- ax.grid(b=True, which='minor', color='0.75', linestyle='-',linewidth=0.5)
+ ax.grid(b=True, which='major', color='0.75',
+ linestyle='-', linewidth=0.5)
+ ax.grid(b=True, which='minor', color='0.75',
+ linestyle='-', linewidth=0.5)
-#--------------------------------------------------------------------------------
+# ------------------------------------------------------------------------------
def main():
non_local_radius = 0.5
rc('text', usetex=True)
rc('font', family='serif', size=8, serif='Times')
neighborhood_file = sys.argv[1]
quad_x_coords, quad_y_coords = readFile(neighborhood_file)
nb_quads = len(quad_x_coords)
neighborhoods = readNeighborhoods(neighborhood_file)
with PdfPages('resulting_neighborhoods.pdf') as pdf:
for i in range(nb_quads):
plt.figure(1, figsize=(7/2.54, 7/2.54))
- plotNeighborhood(quad_x_coords, quad_y_coords, neighborhoods[i], non_local_radius)
+ plotNeighborhood(quad_x_coords, quad_y_coords,
+ neighborhoods[i], non_local_radius)
pdf.savefig()
plt.close()
+
if __name__ == "__main__":
main()
diff --git a/test/test_model/test_common/test_non_local_toolbox/test_build_neighborhood_parallel.cc b/test/test_model/test_common/test_non_local_toolbox/test_build_neighborhood_parallel.cc
index 4bd5bb7cc..7da3c04a8 100644
--- a/test/test_model/test_common/test_non_local_toolbox/test_build_neighborhood_parallel.cc
+++ b/test/test_model/test_common/test_non_local_toolbox/test_build_neighborhood_parallel.cc
@@ -1,188 +1,189 @@
/**
* @file test_build_neighborhood_parallel.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sat Sep 26 2015
* @date last modification: Tue Feb 20 2018
*
* @brief test in parallel for the class NonLocalNeighborhood
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_iohelper_paraview.hh"
#include "non_local_neighborhood_base.hh"
#include "solid_mechanics_model.hh"
#include "test_material.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
akantu::initialize("material_parallel_test.dat", argc, argv);
const auto & comm = Communicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
// some configuration variables
const UInt spatial_dimension = 2;
// mesh creation and read
Mesh mesh(spatial_dimension);
if (prank == 0) {
mesh.read("parallel_test.msh");
}
mesh.distribute();
/// model creation
SolidMechanicsModel model(mesh);
/// dump the ghost elements before the non-local part is intialized
DumperParaview dumper_ghost("ghost_elements");
dumper_ghost.registerMesh(mesh, spatial_dimension, _ghost);
if (psize > 1) {
dumper_ghost.dump();
}
/// creation of material selector
auto && mat_selector =
std::make_shared<MeshDataMaterialSelector<std::string>>("physical_names",
model);
model.setMaterialSelector(mat_selector);
/// dump material index in paraview
model.addDumpField("partitions");
model.dump();
/// model initialization changed to use our material
model.initFull();
/// dump the ghost elements after ghosts for non-local have been added
if (psize > 1)
dumper_ghost.dump();
model.addDumpField("grad_u");
model.addDumpField("grad_u non local");
model.addDumpField("material_index");
/// apply constant strain field everywhere in the plate
Matrix<Real> applied_strain(spatial_dimension, spatial_dimension);
applied_strain.clear();
for (UInt i = 0; i < spatial_dimension; ++i)
applied_strain(i, i) = 2.;
ElementType element_type = _triangle_3;
GhostType ghost_type = _not_ghost;
/// apply constant grad_u field in all elements
for (UInt m = 0; m < model.getNbMaterials(); ++m) {
auto & mat = model.getMaterial(m);
auto & grad_u = const_cast<Array<Real> &>(
mat.getInternal<Real>("grad_u")(element_type, ghost_type));
auto grad_u_it = grad_u.begin(spatial_dimension, spatial_dimension);
auto grad_u_end = grad_u.end(spatial_dimension, spatial_dimension);
for (; grad_u_it != grad_u_end; ++grad_u_it)
(*grad_u_it) = -1. * applied_strain;
}
/// double the strain in the center: find the closed gauss point to the center
/// compute the quadrature points
ElementTypeMapReal quad_coords("quad_coords");
quad_coords.initialize(mesh, _nb_component = spatial_dimension,
_spatial_dimension = spatial_dimension,
_with_nb_element = true);
model.getFEEngine().computeIntegrationPointsCoordinates(quad_coords);
Vector<Real> center(spatial_dimension, 0.);
Real min_distance = 2;
IntegrationPoint q_min;
- for (auto type : mesh.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
+ for (auto type :
+ mesh.elementTypes(spatial_dimension, _not_ghost, _ek_regular)) {
UInt nb_elements = mesh.getNbElement(type, _not_ghost);
UInt nb_quads = model.getFEEngine().getNbIntegrationPoints(type);
Array<Real> & coords = quad_coords(type, _not_ghost);
auto coord_it = coords.begin(spatial_dimension);
for (UInt e = 0; e < nb_elements; ++e) {
for (UInt q = 0; q < nb_quads; ++q, ++coord_it) {
Real dist = center.distance(*coord_it);
if (dist < min_distance) {
min_distance = dist;
q_min.element = e;
q_min.num_point = q;
q_min.global_num = nb_elements * nb_quads + q;
q_min.type = type;
}
}
}
}
Real global_min = min_distance;
comm.allReduce(global_min, SynchronizerOperation::_min);
if (Math::are_float_equal(global_min, min_distance)) {
UInt mat_index = model.getMaterialByElement(q_min.type, _not_ghost)
.begin()[q_min.element];
Material & mat = model.getMaterial(mat_index);
UInt nb_quads = model.getFEEngine().getNbIntegrationPoints(q_min.type);
UInt local_el_index =
model.getMaterialLocalNumbering(q_min.type, _not_ghost)
.begin()[q_min.element];
UInt local_num = (local_el_index * nb_quads) + q_min.num_point;
Array<Real> & grad_u = const_cast<Array<Real> &>(
mat.getInternal<Real>("grad_u")(q_min.type, _not_ghost));
Array<Real>::iterator<Matrix<Real>> grad_u_it =
grad_u.begin(spatial_dimension, spatial_dimension);
grad_u_it += local_num;
Matrix<Real> & g_u = *grad_u_it;
g_u += applied_strain;
}
/// compute the non-local strains
model.assembleInternalForces();
model.dump();
/// damage the element with higher grad_u completely, so that it is
/// not taken into account for the averaging
if (Math::are_float_equal(global_min, min_distance)) {
UInt mat_index = model.getMaterialByElement(q_min.type, _not_ghost)
.begin()[q_min.element];
Material & mat = model.getMaterial(mat_index);
UInt nb_quads = model.getFEEngine().getNbIntegrationPoints(q_min.type);
UInt local_el_index =
model.getMaterialLocalNumbering(q_min.type, _not_ghost)
.begin()[q_min.element];
UInt local_num = (local_el_index * nb_quads) + q_min.num_point;
Array<Real> & damage = const_cast<Array<Real> &>(
mat.getInternal<Real>("damage")(q_min.type, _not_ghost));
Real * dam_ptr = damage.storage();
dam_ptr += local_num;
*dam_ptr = 0.9;
}
/// compute the non-local strains
model.assembleInternalForces();
model.dump();
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_common/test_non_local_toolbox/test_non_local_averaging.cc b/test/test_model/test_common/test_non_local_toolbox/test_non_local_averaging.cc
index 1ffb013b5..c773675cf 100644
--- a/test/test_model/test_common/test_non_local_toolbox/test_non_local_averaging.cc
+++ b/test/test_model/test_common/test_non_local_toolbox/test_non_local_averaging.cc
@@ -1,110 +1,111 @@
/**
* @file test_non_local_averaging.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sat Sep 26 2015
* @date last modification: Tue Dec 05 2017
*
* @brief test for non-local averaging of strain
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "dumper_paraview.hh"
#include "non_local_manager.hh"
#include "non_local_neighborhood.hh"
#include "solid_mechanics_model.hh"
#include "test_material.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
akantu::initialize("material_avg.dat", argc, argv);
// some configuration variables
const UInt spatial_dimension = 2;
ElementType element_type = _quadrangle_4;
GhostType ghost_type = _not_ghost;
// mesh creation and read
Mesh mesh(spatial_dimension);
mesh.read("plate.msh");
/// model creation
SolidMechanicsModel model(mesh);
/// creation of material selector
auto && mat_selector =
std::make_shared<MeshDataMaterialSelector<std::string>>("physical_names",
model);
model.setMaterialSelector(mat_selector);
/// model initialization changed to use our material
model.initFull();
/// dump material index in paraview
model.addDumpField("material_index");
model.addDumpField("grad_u");
model.addDumpField("grad_u non local");
model.dump();
/// apply constant strain field everywhere in the plate
Matrix<Real> applied_strain(spatial_dimension, spatial_dimension);
applied_strain.clear();
for (UInt i = 0; i < spatial_dimension; ++i)
applied_strain(i, i) = 2.;
/// apply constant grad_u field in all elements
for (auto & mat : model.getMaterials()) {
- auto & grad_us = mat.getInternal<Real>("eigen_grad_u")(element_type, ghost_type);
+ auto & grad_us =
+ mat.getInternal<Real>("eigen_grad_u")(element_type, ghost_type);
for (auto & grad_u :
make_view(grad_us, spatial_dimension, spatial_dimension)) {
grad_u = -1. * applied_strain;
}
}
/// compute the non-local strains
model.assembleInternalForces();
model.dump();
/// verify the result: non-local averaging over constant field must
/// yield same constant field
Real test_result = 0.;
Matrix<Real> difference(spatial_dimension, spatial_dimension, 0.);
for (auto & mat : model.getMaterials()) {
auto & grad_us_nl =
mat.getInternal<Real>("grad_u non local")(element_type, ghost_type);
for (auto & grad_u_nl :
make_view(grad_us_nl, spatial_dimension, spatial_dimension)) {
difference = grad_u_nl - applied_strain;
test_result += difference.norm<L_2>();
}
}
if (test_result > 10.e-13) {
AKANTU_EXCEPTION("the total norm is: " << test_result);
}
return 0;
}
diff --git a/test/test_model/test_solid_mechanics_model/CMakeLists.txt b/test/test_model/test_solid_mechanics_model/CMakeLists.txt
index f8c43e58e..335e778f8 100644
--- a/test/test_model/test_solid_mechanics_model/CMakeLists.txt
+++ b/test/test_model/test_solid_mechanics_model/CMakeLists.txt
@@ -1,73 +1,73 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
#
# @date creation: Fri Sep 03 2010
# @date last modification: Tue Jan 30 2018
#
# @brief configuratio for SolidMechanicsModel tests
#
# @section LICENSE
#
# Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#
#===============================================================================
add_akantu_test(test_materials "test_materials")
add_akantu_test(test_cohesive "cohesive_test")
add_akantu_test(test_embedded_interface "test_embedded_interface")
add_akantu_test(test_energies "test energies")
#===============================================================================
#===============================================================================
add_mesh(test_cube3d_two_mat_mesh cube_two_materials.geo 3 1)
register_test(test_solid_mechanics_model_reassign_material
SOURCES test_solid_mechanics_model_reassign_material.cc
DEPENDS test_cube3d_two_mat_mesh
FILES_TO_COPY two_materials.dat
PACKAGE parallel implicit
PARALLEL
)
#===============================================================================
register_test(test_solid_mechanics_model_material_eigenstrain
SOURCES test_solid_mechanics_model_material_eigenstrain.cc
FILES_TO_COPY cube_3d_tet_4.msh; material_elastic_plane_strain.dat
PACKAGE implicit
)
#===============================================================================
register_test(test_material_selector
SOURCES test_material_selector.cc
- FILES_TO_COPY material_selector.dat
+ FILES_TO_COPY material_selector.dat material_selector.msh
PACKAGE core
)
#===============================================================================
# dynamics tests
#===============================================================================
register_gtest_sources(
SOURCES test_solid_mechanics_model_dynamics.cc
FILES_TO_COPY test_solid_mechanics_model_dynamics_material.dat
PACKAGE core
)
register_gtest_test(test_solid_mechanics_model
DEPENDS ${PATCH_TEST_BAR_MESHES}
#bar_segment_2 bar_segment_3
#bar_triangle_3 bar_triangle_6
#bar_quadrangle_4 bar_quadrangle_8
#bar_tetrahedron_4 bar_tetrahedron_10
#bar_hexahedron_8 bar_hexahedron_20
#bar_pentahedron_6 bar_pentahedron_15
PARALLEL
)
diff --git a/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_fixture.hh b/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_fixture.hh
index 0e1722fcf..a854c4f51 100644
--- a/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_fixture.hh
+++ b/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_fixture.hh
@@ -1,338 +1,343 @@
/**
* @file test_cohesive_fixture.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Jan 10 2018
* @date last modification: Tue Feb 20 2018
*
* @brief Coehsive element test fixture
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "solid_mechanics_model_cohesive.hh"
#include "test_gtest_utils.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <vector>
/* -------------------------------------------------------------------------- */
#ifndef __AKANTU_TEST_COHESIVE_FIXTURE_HH__
#define __AKANTU_TEST_COHESIVE_FIXTURE_HH__
using namespace akantu;
template <::akantu::AnalysisMethod t>
using analysis_method_t = std::integral_constant<::akantu::AnalysisMethod, t>;
class StrainIncrement : public BC::Functor {
public:
StrainIncrement(const Matrix<Real> & strain, BC::Axis dir)
: strain_inc(strain), dir(dir) {}
void operator()(UInt /*node*/, Vector<bool> & flags, Vector<Real> & primal,
const Vector<Real> & coord) const {
if (std::abs(coord(dir)) < 1e-8) {
return;
}
flags.set(true);
primal += strain_inc * coord;
}
static const BC::Functor::Type type = BC::Functor::_dirichlet;
private:
Matrix<Real> strain_inc;
BC::Axis dir;
};
template <typename param_> class TestSMMCFixture : public ::testing::Test {
public:
static constexpr ElementType cohesive_type =
std::tuple_element_t<0, param_>::value;
static constexpr ElementType type_1 = std::tuple_element_t<1, param_>::value;
static constexpr ElementType type_2 = std::tuple_element_t<2, param_>::value;
static constexpr size_t dim =
ElementClass<cohesive_type>::getSpatialDimension();
void SetUp() override {
mesh = std::make_unique<Mesh>(this->dim);
if (Communicator::getStaticCommunicator().whoAmI() == 0) {
ASSERT_NO_THROW({ mesh->read(this->mesh_name); });
}
mesh->distribute();
}
void TearDown() override {
model.reset(nullptr);
mesh.reset(nullptr);
}
void createModel() {
model = std::make_unique<SolidMechanicsModelCohesive>(*mesh);
model->initFull(_analysis_method = this->analysis_method,
_is_extrinsic = this->is_extrinsic);
auto time_step = this->model->getStableTimeStep() * 0.01;
this->model->setTimeStep(time_step);
if (dim == 1) {
surface = 1;
group_size = 1;
return;
- }
+ }
auto facet_type = mesh->getFacetType(this->cohesive_type);
auto & fe_engine = model->getFEEngineBoundary();
auto & group = mesh->getElementGroup("insertion").getElements(facet_type);
Array<Real> ones(fe_engine.getNbIntegrationPoints(facet_type) *
group.size());
ones.set(1.);
surface = fe_engine.integrate(ones, facet_type, _not_ghost, group);
mesh->getCommunicator().allReduce(surface, SynchronizerOperation::_sum);
group_size = group.size();
mesh->getCommunicator().allReduce(group_size, SynchronizerOperation::_sum);
#define debug_ 0
#if debug_
this->model->addDumpFieldVector("displacement");
this->model->addDumpFieldVector("velocity");
this->model->addDumpFieldVector("internal_force");
this->model->addDumpFieldVector("external_force");
this->model->addDumpField("blocked_dofs");
this->model->addDumpField("stress");
this->model->addDumpField("strain");
this->model->assembleInternalForces();
this->model->setBaseNameToDumper("cohesive elements", "cohesive_elements");
this->model->addDumpFieldVectorToDumper("cohesive elements",
"displacement");
this->model->addDumpFieldToDumper("cohesive elements", "damage");
this->model->addDumpFieldToDumper("cohesive elements", "tractions");
this->model->addDumpFieldToDumper("cohesive elements", "opening");
this->model->dump();
this->model->dump("cohesive elements");
#endif
}
void setInitialCondition(const Matrix<Real> & strain) {
for (auto && data :
zip(make_view(this->mesh->getNodes(), this->dim),
make_view(this->model->getDisplacement(), this->dim))) {
const auto & pos = std::get<0>(data);
auto & disp = std::get<1>(data);
disp = strain * pos;
}
}
bool checkDamaged() {
UInt nb_damaged = 0;
auto & damage =
model->getMaterial("insertion").getArray<Real>("damage", cohesive_type);
for (auto d : damage) {
if (d >= .99)
++nb_damaged;
}
return (nb_damaged == group_size);
}
void steps(const Matrix<Real> & strain) {
StrainIncrement functor((1. / 300) * strain, this->dim == 1 ? _x : _y);
- for (auto _[[gnu::unused]] : arange(nb_steps)) {
+ for (auto _ [[gnu::unused]] : arange(nb_steps)) {
this->model->applyBC(functor, "loading");
this->model->applyBC(functor, "fixed");
if (this->is_extrinsic)
this->model->checkCohesiveStress();
this->model->solveStep();
#if debug_
this->model->dump();
this->model->dump("cohesive elements");
#endif
}
}
void checkInsertion() {
auto nb_cohesive_element = this->mesh->getNbElement(cohesive_type);
mesh->getCommunicator().allReduce(nb_cohesive_element,
SynchronizerOperation::_sum);
EXPECT_EQ(nb_cohesive_element, group_size);
}
void checkDissipated(Real expected_density) {
Real edis = this->model->getEnergy("dissipated");
EXPECT_NEAR(this->surface * expected_density, edis, 5e-1);
}
void testModeI() {
this->createModel();
auto & mat_el = this->model->getMaterial("body");
auto speed = mat_el.getPushWaveSpeed(Element());
auto direction = _y;
- if(dim == 1) direction = _x;
- auto length = mesh->getUpperBounds()(direction) - mesh->getLowerBounds()(direction);
+ if (dim == 1)
+ direction = _x;
+ auto length =
+ mesh->getUpperBounds()(direction) - mesh->getLowerBounds()(direction);
nb_steps = length / 2. / speed / model->getTimeStep();
SCOPED_TRACE(std::to_string(this->dim) + "D - " + std::to_string(type_1) +
":" + std::to_string(type_2));
auto & mat_co = this->model->getMaterial("insertion");
Real sigma_c = mat_co.get("sigma_c");
Real E = mat_el.get("E");
Real nu = mat_el.get("nu");
Matrix<Real> strain;
if (dim == 1) {
strain = {{1.}};
} else if (dim == 2) {
strain = {{-nu, 0.}, {0., 1. - nu}};
strain *= (1. + nu);
} else if (dim == 3) {
strain = {{-nu, 0., 0.}, {0., 1., 0.}, {0., 0., -nu}};
}
strain *= sigma_c / E;
this->setInitialCondition((1 - 1e-5) * strain);
this->steps(1e-2 * strain);
}
void testModeII() {
this->createModel();
auto & mat_el = this->model->getMaterial("body");
Real speed;
try {
- speed = mat_el.getShearWaveSpeed(Element()); // the slowest speed if exists
- } catch(...) {
+ speed =
+ mat_el.getShearWaveSpeed(Element()); // the slowest speed if exists
+ } catch (...) {
speed = mat_el.getPushWaveSpeed(Element());
}
auto direction = _y;
- if(dim == 1) direction = _x;
- auto length = mesh->getUpperBounds()(direction) - mesh->getLowerBounds()(direction);
+ if (dim == 1)
+ direction = _x;
+ auto length =
+ mesh->getUpperBounds()(direction) - mesh->getLowerBounds()(direction);
nb_steps = 2 * length / 2. / speed / model->getTimeStep();
SCOPED_TRACE(std::to_string(this->dim) + "D - " + std::to_string(type_1) +
":" + std::to_string(type_2));
if (this->dim > 1)
this->model->applyBC(BC::Dirichlet::FlagOnly(_y), "sides");
if (this->dim > 2)
this->model->applyBC(BC::Dirichlet::FlagOnly(_z), "sides");
auto & mat_co = this->model->getMaterial("insertion");
Real sigma_c = mat_co.get("sigma_c");
Real beta = mat_co.get("beta");
// Real G_c = mat_co.get("G_c");
Real E = mat_el.get("E");
Real nu = mat_el.get("nu");
Matrix<Real> strain;
if (dim == 1) {
strain = {{1.}};
} else if (dim == 2) {
strain = {{0., 1.}, {0., 0.}};
strain *= (1. + nu);
} else if (dim == 3) {
strain = {{0., 1., 0.}, {0., 0., 0.}, {0., 0., 0.}};
strain *= (1. + nu);
}
strain *= 2 * beta * beta * sigma_c / E;
- //nb_steps *= 5;
+ // nb_steps *= 5;
this->setInitialCondition((1. - 1e-5) * strain);
this->steps(0.005 * strain);
}
protected:
std::unique_ptr<Mesh> mesh;
std::unique_ptr<SolidMechanicsModelCohesive> model;
std::string mesh_name{std::to_string(cohesive_type) + std::to_string(type_1) +
(type_1 == type_2 ? "" : std::to_string(type_2)) +
".msh"};
bool is_extrinsic;
AnalysisMethod analysis_method;
Real surface{0};
UInt nb_steps{1000};
UInt group_size{10000};
};
/* -------------------------------------------------------------------------- */
template <typename param_>
constexpr ElementType TestSMMCFixture<param_>::cohesive_type;
template <typename param_>
constexpr ElementType TestSMMCFixture<param_>::type_1;
template <typename param_>
constexpr ElementType TestSMMCFixture<param_>::type_2;
template <typename param_> constexpr size_t TestSMMCFixture<param_>::dim;
/* -------------------------------------------------------------------------- */
using IsExtrinsicTypes = std::tuple<std::true_type, std::false_type>;
using AnalysisMethodTypes =
std::tuple<analysis_method_t<_explicit_lumped_mass>>;
using coh_types = gtest_list_t<std::tuple<
std::tuple<_element_type_cohesive_1d_2, _element_type_segment_2,
_element_type_segment_2>,
std::tuple<_element_type_cohesive_2d_4, _element_type_triangle_3,
_element_type_triangle_3>,
std::tuple<_element_type_cohesive_2d_4, _element_type_quadrangle_4,
_element_type_quadrangle_4>,
std::tuple<_element_type_cohesive_2d_4, _element_type_triangle_3,
_element_type_quadrangle_4>,
std::tuple<_element_type_cohesive_2d_6, _element_type_triangle_6,
_element_type_triangle_6>,
std::tuple<_element_type_cohesive_2d_6, _element_type_quadrangle_8,
_element_type_quadrangle_8>,
std::tuple<_element_type_cohesive_2d_6, _element_type_triangle_6,
_element_type_quadrangle_8>,
std::tuple<_element_type_cohesive_3d_6, _element_type_tetrahedron_4,
_element_type_tetrahedron_4>,
std::tuple<_element_type_cohesive_3d_12, _element_type_tetrahedron_10,
_element_type_tetrahedron_10> /*,
std::tuple<_element_type_cohesive_3d_8, _element_type_hexahedron_8,
_element_type_hexahedron_8>,
std::tuple<_element_type_cohesive_3d_16, _element_type_hexahedron_20,
_element_type_hexahedron_20>*/>>;
TYPED_TEST_SUITE(TestSMMCFixture, coh_types);
#endif /* __AKANTU_TEST_COHESIVE_FIXTURE_HH__ */
diff --git a/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion/test_cohesive_insertion_along_physical_surfaces.cc b/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion/test_cohesive_insertion_along_physical_surfaces.cc
index 7d5b87332..4263df19a 100644
--- a/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion/test_cohesive_insertion_along_physical_surfaces.cc
+++ b/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_insertion/test_cohesive_insertion_along_physical_surfaces.cc
@@ -1,92 +1,92 @@
/**
* @file test_cohesive_insertion_along_physical_surfaces.cc
*
* @author Fabian Barras <fabian.barras@epfl.ch>
*
* @date creation: Fri Aug 07 2015
* @date last modification: Mon Dec 18 2017
*
* @brief Test intrinsic insertion of cohesive elements along physical surfaces
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material.hh"
#include "material_cohesive.hh"
#include "mesh.hh"
#include "mesh_io.hh"
#include "mesh_io_msh.hh"
#include "mesh_utils.hh"
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <iostream>
#include <limits>
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize("input_file.dat", argc, argv);
Math::setTolerance(1e-15);
const UInt spatial_dimension = 3;
Mesh mesh(spatial_dimension);
mesh.read("3d_spherical_inclusion.msh");
SolidMechanicsModelCohesive model(mesh);
auto && material_selector =
std::make_shared<MeshDataMaterialCohesiveSelector>(model);
material_selector->setFallback(model.getMaterialSelector());
model.setMaterialSelector(material_selector);
model.initFull(_analysis_method = _static);
std::vector<std::string> surfaces_name = {"interface", "coh1", "coh2",
"coh3", "coh4", "coh5"};
UInt nb_surf = surfaces_name.size();
- for(auto & type : mesh.elementTypes(spatial_dimension, _not_ghost, _ek_cohesive)) {
+ for (auto & type :
+ mesh.elementTypes(spatial_dimension, _not_ghost, _ek_cohesive)) {
for (UInt i = 0; i < nb_surf; ++i) {
UInt expected_insertion = mesh.getElementGroup(surfaces_name[i])
.getElements(mesh.getFacetType(type))
.size();
UInt inserted_elements =
model.getMaterial(surfaces_name[i]).getElementFilter()(type).size();
- if(not (expected_insertion == inserted_elements)) {
- std::cout << "!!! Mismatch in insertion of surface named "
- << surfaces_name[i] << " --> "
- << inserted_elements
- << " inserted elements out of "
- << expected_insertion << std::endl;
+ if (not(expected_insertion == inserted_elements)) {
+ std::cout << "!!! Mismatch in insertion of surface named "
+ << surfaces_name[i] << " --> " << inserted_elements
+ << " inserted elements out of " << expected_insertion
+ << std::endl;
return 1;
}
}
}
return 0;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_linear_friction/test_cohesive_friction.cc b/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_linear_friction/test_cohesive_friction.cc
index ba0b14bfe..c7e9cb656 100644
--- a/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_linear_friction/test_cohesive_friction.cc
+++ b/test/test_model/test_solid_mechanics_model/test_cohesive/test_cohesive_linear_friction/test_cohesive_friction.cc
@@ -1,236 +1,240 @@
/**
* @file test_cohesive_friction.cc
*
* @author Mauro Corrado <mauro.corrado@epfl.ch>
*
* @date creation: Thu Jan 14 2016
* @date last modification: Tue Feb 20 2018
*
* @brief testing the correct behavior of the friction law included in
* the cohesive linear law, in implicit
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include <cmath>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <string>
#include <time.h>
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
initialize("material.dat", argc, argv);
Math::setTolerance(1.e-15);
UInt spatial_dimension = 2;
const ElementType type = _cohesive_2d_4;
Mesh mesh(spatial_dimension);
mesh.read("mesh_cohesive_friction.msh");
// Create the model
SolidMechanicsModelCohesive model(mesh);
// Model initialization
model.initFull(SolidMechanicsModelCohesiveOptions(_static, true));
// CohesiveElementInserter inserter(mesh);
model.limitInsertion(_y, -0.001, 0.001);
model.updateAutomaticInsertion();
Real eps = 1e-10;
Array<Real> & pos = mesh.getNodes();
Array<Real> & disp = model.getDisplacement();
Array<bool> & boun = model.getBlockedDOFs();
const Array<Real> & residual = model.getInternalForce();
Array<Real> & cohe_opening = const_cast<Array<Real> &>(
model.getMaterial("interface").getInternal<Real>("opening")(type));
Array<Real> & friction_force = const_cast<Array<Real> &>(
model.getMaterial("interface").getInternal<Real>("friction_force")(type));
// Boundary conditions
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (pos(i, 1) < -0.49 || pos(i, 1) > 0.49) {
boun(i, 0) = true;
boun(i, 1) = true;
}
}
bool passed = true;
Real tolerance = 1e-13;
Real error;
bool load_reduction = false;
Real tol_increase_factor = 1e5;
Real increment = 1.0e-4;
model.synchronizeBoundaries();
model.updateResidual();
/* -------------------------------------------- */
/* LOADING PHASE to introduce cohesive elements */
/* -------------------------------------------- */
for (UInt nstep = 0; nstep < 100; ++nstep) {
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (pos(n, 1) > 0.49)
disp(n, 1) += increment;
}
- model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ model.solveStepCohesive<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
tolerance, error, 25, load_reduction, tol_increase_factor);
if (error > tolerance) {
AKANTU_ERROR("Convergence not reached in the mode I loading phase");
passed = false;
}
}
/* --------------------------------------------------------- */
/* UNLOADING PHASE to bring cohesive elements in compression */
/* --------------------------------------------------------- */
for (UInt nstep = 0; nstep < 110; ++nstep) {
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (pos(n, 1) > 0.49)
disp(n, 1) -= increment;
}
- model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ model.solveStepCohesive<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
tolerance, error, 25, load_reduction, tol_increase_factor);
if (error > tolerance) {
AKANTU_ERROR("Convergence not reached in the mode I unloading phase");
passed = false;
}
}
/* -------------------------------------------------- */
/* SHEAR PHASE - displacement towards right */
/* -------------------------------------------------- */
increment *= 2;
for (UInt nstep = 0; nstep < 30; ++nstep) {
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (pos(n, 1) > 0.49)
disp(n, 0) += increment;
}
- model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ model.solveStepCohesive<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
tolerance, error, 25, load_reduction, tol_increase_factor);
if (error > tolerance) {
AKANTU_ERROR("Convergence not reached in the shear loading phase");
passed = false;
}
}
/* ---------------------------------------------------*/
/* Check the horizontal component of the reaction */
/* ---------------------------------------------------*/
// Friction + mode II cohesive behavior
Real reac_X = 0.;
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (pos(i, 1) > 0.49)
reac_X += residual(i, 0);
}
if (std::abs(reac_X - (-13.987451183762181)) > eps)
passed = false;
// Only friction
Real friction = friction_force(0, 0) + friction_force(1, 0);
if (std::abs(friction - (-12.517967866999832)) > eps)
passed = false;
/* -------------------------------------------------- */
/* SHEAR PHASE - displacement back to zero */
/* -------------------------------------------------- */
for (UInt nstep = 0; nstep < 30; ++nstep) {
for (UInt n = 0; n < mesh.getNbNodes(); ++n) {
if (pos(n, 1) > 0.49)
disp(n, 0) -= increment;
}
- model.solveStepCohesive<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(
+ model.solveStepCohesive<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(
tolerance, error, 25, load_reduction, tol_increase_factor);
if (error > tolerance) {
AKANTU_ERROR("Convergence not reached in the shear unloading phase");
passed = false;
}
}
/* ------------------------------------------------------- */
/* Check the horizontal component of the reaction and */
/* the residual relative sliding in the cohesive elements */
/* ------------------------------------------------------- */
// Friction + mode II cohesive behavior
reac_X = 0.;
for (UInt i = 0; i < mesh.getNbNodes(); ++i) {
if (pos(i, 1) > 0.49)
reac_X += residual(i, 0);
}
if (std::abs(reac_X - 12.400313187122208) > eps)
passed = false;
// Only friction
friction = 0.;
friction = friction_force(0, 0) + friction_force(1, 0);
if (std::abs(friction - 12.523300983293165) > eps)
passed = false;
// Residual sliding
Real sliding[2];
sliding[0] = cohe_opening(0, 0);
sliding[1] = cohe_opening(1, 0);
if (std::abs(sliding[0] - (-0.00044246686809147357)) > eps)
passed = false;
if (passed)
return EXIT_SUCCESS;
else
return EXIT_FAILURE;
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_fixture.hh b/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_fixture.hh
index 462b9c52b..8effa8279 100644
--- a/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_fixture.hh
+++ b/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_fixture.hh
@@ -1,311 +1,312 @@
/**
* @file test_material_cohesive_fixture.hh
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Feb 21 2018
*
* @brief Test the traction separations laws for cohesive elements
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model_cohesive.hh"
/* -------------------------------------------------------------------------- */
#include "test_gtest_utils.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <gtest/gtest.h>
/* -------------------------------------------------------------------------- */
using namespace akantu;
//#define debug_
/* -------------------------------------------------------------------------- */
template <template <UInt> class Mat, typename dim_>
class TestMaterialCohesiveFixture : public ::testing::Test {
public:
static constexpr UInt dim = dim_::value;
using Material = Mat<dim>;
void SetUp() override {
mesh = std::make_unique<Mesh>(dim);
model = std::make_unique<SolidMechanicsModelCohesive>(*mesh);
material = std::make_unique<Material>(*model);
material->SetUps();
openings = std::make_unique<Array<Real>>(0, dim);
tractions = std::make_unique<Array<Real>>(0, dim);
reset();
gen.seed(::testing::GTEST_FLAG(random_seed));
normal = getRandomNormal();
tangents = getRandomTangents();
}
void TearDown() override {
material.reset(nullptr);
model.reset(nullptr);
mesh.reset(nullptr);
openings.reset(nullptr);
tractions.reset(nullptr);
}
void reset() {
openings->resize(1);
tractions->resize(1);
openings->clear();
tractions->clear();
}
/* ------------------------------------------------------------------------ */
void addOpening(const Vector<Real> & direction, Real start, Real stop,
UInt nb_steps) {
for (auto s : arange(nb_steps)) {
auto opening =
direction * (start + (stop - start) / Real(nb_steps) * Real(s + 1));
openings->push_back(opening);
}
tractions->resize(openings->size());
}
/* ------------------------------------------------------------------------ */
Vector<Real> getRandomVector() {
std::uniform_real_distribution<Real> dis;
Vector<Real> vector(dim);
for (auto s : arange(dim))
vector(s) = dis(gen);
return vector;
}
Vector<Real> getRandomNormal() {
auto normal = getRandomVector();
normal.normalize();
#if defined(debug_)
normal.set(0.);
normal(0) = 1.;
#endif
return normal;
}
Matrix<Real> getRandomTangents() {
auto dim = normal.size();
Matrix<Real> tangent(dim, dim - 1);
if (dim == 2) {
Math::normal2(normal.storage(), tangent(0).storage());
}
if (dim == 3) {
auto v = getRandomVector();
tangent(0) = (v - v.dot(normal) * normal).normalize();
Math::normal3(normal.storage(), tangent(0).storage(),
tangent(1).storage());
}
#if defined(debug_)
if (dim == 2)
tangent(0) = Vector<Real>{0., 1};
if (dim == 3)
tangent = Matrix<Real>{{0., 0.}, {1., 0.}, {0., 1.}};
#endif
return tangent;
}
/* ------------------------------------------------------------------------ */
void output_csv() {
const ::testing::TestInfo * const test_info =
::testing::UnitTest::GetInstance()->current_test_info();
std::ofstream cout(std::string(test_info->name()) + ".csv");
auto print_vect_name = [&](auto name) {
for (auto s : arange(dim)) {
if (s != 0) {
cout << ", ";
}
cout << name << "_" << s;
}
};
auto print_vect = [&](const auto & vect) {
cout << vect.dot(normal);
if (dim > 1)
cout << ", " << vect.dot(tangents(0));
if (dim > 2)
cout << ", " << vect.dot(tangents(1));
};
cout << "delta, ";
print_vect_name("opening");
cout << ", ";
print_vect_name("traction");
cout << std::endl;
for (auto && data : zip(make_view(*this->openings, this->dim),
make_view(*this->tractions, this->dim))) {
const auto & opening = std::get<0>(data);
auto & traction = std::get<1>(data);
cout << this->material->delta(opening, normal) << ", ";
print_vect(opening);
cout << ", ";
print_vect(traction);
cout << std::endl;
}
}
/* ------------------------------------------------------------------------ */
Real dissipated() {
Vector<Real> prev_opening(dim, 0.);
Vector<Real> prev_traction(dim, 0.);
Real etot = 0.;
Real erev = 0.;
for (auto && data : zip(make_view(*this->openings, this->dim),
make_view(*this->tractions, this->dim))) {
const auto & opening = std::get<0>(data);
const auto & traction = std::get<1>(data);
etot += (opening - prev_opening).dot(traction + prev_traction) / 2.;
erev = traction.dot(opening) / 2.;
prev_opening = opening;
prev_traction = traction;
}
return etot - erev;
}
/* ------------------------------------------------------------------------ */
void checkModeI(Real max_opening, Real expected_dissipated) {
this->material->insertion_stress_ = this->material->sigma_c_ * normal;
addOpening(normal, 0., max_opening, 100);
this->material->computeTractions(*openings, normal, *tractions);
for (auto && data : zip(make_view(*this->openings, this->dim),
make_view(*this->tractions, this->dim))) {
const auto & opening = std::get<0>(data);
auto & traction = std::get<1>(data);
auto T = traction.dot(normal);
EXPECT_NEAR(0, (traction - T * normal).norm(), 1e-9);
auto T_expected =
this->material->tractionModeI(opening, normal).dot(normal);
EXPECT_NEAR(T_expected, T, 1e-9);
}
EXPECT_NEAR(expected_dissipated, dissipated(), 1e-5);
this->output_csv();
}
/* ------------------------------------------------------------------------ */
void checkModeII(Real max_opening) {
if (this->dim == 1) {
SUCCEED();
return;
}
std::uniform_real_distribution<Real> dis;
auto direction = Vector<Real>(tangents(0));
auto alpha = dis(gen) + 0.1;
auto beta = dis(gen) + 0.2;
#ifndef debug_
direction = alpha * Vector<Real>(tangents(0));
if (dim > 2)
direction += beta * Vector<Real>(tangents(1));
direction = direction.normalize();
#endif
beta = this->material->get("beta");
- this->material->insertion_stress_ = beta * this->material->sigma_c_ * direction;
+ this->material->insertion_stress_ =
+ beta * this->material->sigma_c_ * direction;
addOpening(direction, 0., max_opening, 100);
this->material->computeTractions(*openings, normal, *tractions);
for (auto && data : zip(make_view(*this->openings, this->dim),
make_view(*this->tractions, this->dim))) {
const auto & opening = std::get<0>(data);
const auto & traction = std::get<1>(data);
// In ModeII normal traction should be 0
ASSERT_NEAR(0, traction.dot(normal), 1e-9);
// Normal opening is null
ASSERT_NEAR(0, opening.dot(normal), 1e-16);
auto T = traction.dot(direction);
auto T_expected =
this->material->tractionModeII(opening, normal).dot(direction);
EXPECT_NEAR(T_expected, T, 1e-9);
}
// EXPECT_NEAR(expected_dissipated, dissipated(), 1e-5);
this->output_csv();
}
protected:
Vector<Real> normal;
Matrix<Real> tangents;
std::unique_ptr<Mesh> mesh;
std::unique_ptr<SolidMechanicsModelCohesive> model;
std::unique_ptr<Material> material;
std::unique_ptr<Array<Real>> openings;
std::unique_ptr<Array<Real>> tractions;
std::mt19937 gen;
};
template <template <UInt> class Mat, UInt dim>
struct TestMaterialCohesive : public Mat<dim> {
TestMaterialCohesive(SolidMechanicsModel & model)
: Mat<dim>(model, "test"), insertion_stress_(dim, 0.) {}
virtual void SetUp() {}
virtual void resetInternal() {}
void SetUps() {
this->initMaterial();
this->SetUp();
this->updateInternalParameters();
this->resetInternals();
}
void resetInternals() { this->resetInternal(); }
virtual void computeTractions(Array<Real> & /*openings*/,
const Vector<Real> & /*normal*/,
Array<Real> & /*tractions*/) {}
Vector<Real> insertion_stress_;
Real sigma_c_{0};
bool is_extrinsic{true};
};
template <template <UInt> class Mat, typename dim_>
constexpr UInt TestMaterialCohesiveFixture<Mat, dim_>::dim;
diff --git a/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_linear.cc b/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_linear.cc
index 3924efe3e..f75f3a8a6 100644
--- a/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_linear.cc
+++ b/test/test_model/test_solid_mechanics_model/test_cohesive/test_materials/test_material_cohesive_linear.cc
@@ -1,193 +1,193 @@
/**
* @file test_material_cohesive_linear.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Feb 21 2018
*
* @brief Test material cohesive linear
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_material_cohesive_fixture.hh"
/* -------------------------------------------------------------------------- */
#include "material_cohesive_linear.hh"
/* -------------------------------------------------------------------------- */
template <UInt dim>
struct TestMaterialCohesiveLinear
: public TestMaterialCohesive<MaterialCohesiveLinear, dim> {
TestMaterialCohesiveLinear(SolidMechanicsModel & model)
: TestMaterialCohesive<MaterialCohesiveLinear, dim>(model) {}
void SetUp() override {
this->is_extrinsic = true;
this->beta = 2.;
this->kappa = 2;
this->G_c = 10.;
this->sigma_c_ = 1e6;
this->penalty = 1e11;
this->delta_c_ = 2. * this->G_c / this->sigma_c_;
}
void resetInternal() override {
normal_opening = Vector<Real>(dim, 0.);
tangential_opening = Vector<Real>(dim, 0.);
contact_traction = Vector<Real>(dim, 0.);
contact_opening = Vector<Real>(dim, 0.);
}
void computeTractions(Array<Real> & openings, const Vector<Real> & normal,
Array<Real> & tractions) override {
for (auto && data :
zip(make_view(openings, dim), make_view(tractions, dim))) {
auto & opening = std::get<0>(data);
auto & traction = std::get<1>(data);
this->computeTractionOnQuad(
traction, opening, normal, delta_max, this->delta_c_,
this->insertion_stress_, this->sigma_c_, normal_opening,
tangential_opening, normal_opening_norm, tangential_opening_norm,
damage, penetration, contact_traction, contact_opening);
opening += contact_opening;
traction += contact_traction;
}
}
Real delta(const Vector<Real> & opening, const Vector<Real> & normal) {
auto beta = this->beta;
auto kappa = this->kappa;
auto normal_opening = opening.dot(normal) * normal;
auto tangential_opening = opening - normal_opening;
return std::sqrt(std::pow(normal_opening.norm(), 2) +
std::pow(tangential_opening.norm() * beta / kappa, 2));
}
Vector<Real> traction(const Vector<Real> & opening,
const Vector<Real> & normal) {
auto delta_c = this->delta_c_;
auto sigma_c = this->sigma_c_;
auto beta = this->beta;
auto kappa = this->kappa;
auto normal_opening = opening.dot(normal) * normal;
auto tangential_opening = opening - normal_opening;
auto delta_ = this->delta(opening, normal);
if (delta_ < 1e-16) {
return this->insertion_stress_;
}
if (opening.dot(normal) / delta_c < -Math::getTolerance()) {
ADD_FAILURE() << "This is contact";
return Vector<Real>(dim, 0.);
}
auto T = sigma_c * (delta_c - delta_) / delta_c / delta_ *
(normal_opening + tangential_opening * beta * beta / kappa);
return T;
}
Vector<Real> tractionModeI(const Vector<Real> & opening,
const Vector<Real> & normal) {
return traction(opening, normal);
}
Vector<Real> tractionModeII(const Vector<Real> & opening,
const Vector<Real> & normal) {
return traction(opening, normal);
}
public:
Real delta_c_{0};
Real delta_max{0.};
Real normal_opening_norm{0};
Real tangential_opening_norm{0};
Real damage{0};
bool penetration{false};
Real etot{0.};
Real edis{0.};
Vector<Real> normal_opening;
Vector<Real> tangential_opening;
Vector<Real> contact_traction;
Vector<Real> contact_opening;
};
template <typename dim_>
using TestMaterialCohesiveLinearFixture =
TestMaterialCohesiveFixture<TestMaterialCohesiveLinear, dim_>;
using coh_types = gtest_list_t<TestAllDimensions>;
TYPED_TEST_SUITE(TestMaterialCohesiveLinearFixture, coh_types);
TYPED_TEST(TestMaterialCohesiveLinearFixture, ModeI) {
this->checkModeI(this->material->delta_c_, this->material->get("G_c"));
Real G_c = this->material->get("G_c");
EXPECT_NEAR(G_c, this->dissipated(), 1e-6);
}
TYPED_TEST(TestMaterialCohesiveLinearFixture, ModeII) {
this->checkModeII(this->material->delta_c_);
- if(this->dim != 1) {
+ if (this->dim != 1) {
Real G_c = this->material->get("G_c");
Real beta = this->material->get("beta");
Real dis = beta * G_c;
EXPECT_NEAR(dis, this->dissipated(), 1e-6);
}
}
TYPED_TEST(TestMaterialCohesiveLinearFixture, Cycles) {
auto delta_c = this->material->delta_c_;
auto sigma_c = this->material->sigma_c_;
this->material->insertion_stress_ = this->normal * sigma_c;
this->addOpening(this->normal, 0, 0.1 * delta_c, 100);
this->addOpening(this->normal, 0.1 * delta_c, 0., 100);
this->addOpening(this->normal, 0., 0.5 * delta_c, 100);
this->addOpening(this->normal, 0.5 * delta_c, -1.e-5, 100);
this->addOpening(this->normal, -1.e-5, 0.9 * delta_c, 100);
this->addOpening(this->normal, 0.9 * delta_c, 0., 100);
this->addOpening(this->normal, 0., delta_c, 100);
this->material->computeTractions(*this->openings, this->normal,
*this->tractions);
Real G_c = this->material->get("G_c");
EXPECT_NEAR(G_c, this->dissipated(), 2e-3); // due to contact dissipation at 0
this->output_csv();
}
diff --git a/test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_linear_elastic_potential_energy.cc b/test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_linear_elastic_potential_energy.cc
index b8861800b..112f2b75c 100644
--- a/test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_linear_elastic_potential_energy.cc
+++ b/test/test_model/test_solid_mechanics_model/test_energies/test_solid_mechanics_model_linear_elastic_potential_energy.cc
@@ -1,115 +1,115 @@
/**
* @file test_solid_mechanics_model_linear_elastic_potential_energy.cc
*
* @author Tobias Brink <tobias.brink@epfl.ch>
*
* @date creation: Tue Nov 14 2017
* @date last modification: Fri Jan 26 2018
*
* @brief test potential energy of the linear elasticity model
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
* @section description
*
* This test uses a linear elastic material with density = 1, Young's
* modulus = 1, and Poisson's ratio = 0 and applies a linear
* displacement from 0 to ε in x direction. The resulting potential
* energy density should be 0.5*Y*ε² = ε²/2. Since the mesh always has
* a volume of 1, the energy density equals the total energy. We test
* 3 different strains.
*
*/
/* -------------------------------------------------------------------------- */
#include "../test_solid_mechanics_model_fixture.hh"
#include "sparse_matrix.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
namespace {
TYPED_TEST(TestSMMFixture, LinearElasticPotentialEnergy) {
const auto spatial_dimension = this->spatial_dimension;
this->initModel("test_solid_mechanics_model_linear_elastic_"
"potential_energy_material.dat",
_static);
const auto & lower = this->mesh->getLowerBounds();
const auto & upper = this->mesh->getUpperBounds();
auto length = upper(_x) - lower(_x);
const auto & pos = this->mesh->getNodes();
auto & disp = this->model->getDisplacement();
auto & boun = this->model->getBlockedDOFs();
std::vector<Real> strains{0.0, 0.1, 0.2, 0.3};
for (auto && eps : strains) {
/// boundary conditions
for (auto && pair : zip(make_view(pos, spatial_dimension),
make_view(disp, spatial_dimension),
make_view(boun, spatial_dimension))) {
const auto & posv = std::get<0>(pair);
auto & dispv = std::get<1>(pair);
auto & bounv = std::get<2>(pair);
auto reduced_x = (posv(_x) - lower(_x)) / length;
dispv(_x) = reduced_x * eps;
bounv(_x) = true;
if (posv(_x) < (lower(_x) + 1e-6)) {
if ((spatial_dimension > 1) and (posv(_y) < (lower(_y) + 1e-6))) {
bounv(_y) = true;
if ((spatial_dimension > 2) and (posv(_z) < (lower(_z) + 1e-6))) {
bounv(_z) = true;
}
}
}
}
if (this->dump_paraview) {
this->model->dump();
}
/// "solve" a step (solution is imposed)
try {
this->model->solveStep();
} catch (...) {
const auto & A = this->model->getDOFManager().getMatrix("J");
auto prank = this->mesh->getCommunicator().whoAmI();
A.saveMatrix("solver_mumps" + std::to_string(prank) + ".mtx");
throw;
}
if (this->dump_paraview) {
const auto & A = this->model->getDOFManager().getMatrix("J");
auto prank = this->mesh->getCommunicator().whoAmI();
A.saveMatrix("solver_mumps" + std::to_string(prank) + ".mtx");
}
/// compare energy to analytical solution
auto E_ref = 0.5 * eps * eps;
auto E_pot = this->model->getEnergy("potential");
EXPECT_NEAR(E_ref, E_pot, 1e-8);
}
}
-} // namespace akantu
+} // namespace
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/CMakeLists.txt b/test/test_model/test_solid_mechanics_model/test_materials/CMakeLists.txt
index d2c720afb..a6d1ecc42 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/CMakeLists.txt
+++ b/test/test_model/test_solid_mechanics_model/test_materials/CMakeLists.txt
@@ -1,91 +1,92 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
#
# @date creation: Fri Oct 22 2010
# @date last modification: Mon Jan 29 2018
#
# @brief configuration for materials tests
#
# @section LICENSE
#
# Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne) Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
# @section DESCRIPTION
#
#===============================================================================
#add_mesh(test_local_material_barre_trou_mesh barre_trou.geo 2 2)
add_mesh(test_local_material_barre_trou_mesh mesh_section_gap.geo 2 2)
register_test(test_local_material
SOURCES test_local_material.cc local_material_damage.cc
EXTRA_FILES local_material_damage.hh local_material_damage_inline_impl.cc
DEPENDS test_local_material_barre_trou_mesh
FILES_TO_COPY material.dat
DIRECTORIES_TO_CREATE paraview
PACKAGE core
)
# ==============================================================================
add_mesh(test_interpolate_stress_mesh interpolation.geo 3 2)
register_test(test_interpolate_stress test_interpolate_stress.cc
FILES_TO_COPY material_interpolate.dat
DEPENDS test_interpolate_stress_mesh
DIRECTORIES_TO_CREATE paraview
PACKAGE lapack core
)
#===============================================================================
add_mesh(test_material_orthotropic_square_mesh square.geo 2 1)
register_test(test_material_orthotropic
SOURCES test_material_orthotropic.cc
DEPENDS test_material_orthotropic_square_mesh
FILES_TO_COPY orthotropic.dat
DIRECTORIES_TO_CREATE paraview
PACKAGE core lapack
)
#===============================================================================
register_test(test_material_mazars
SOURCES test_material_mazars.cc
FILES_TO_COPY material_mazars.dat
DIRECTORIES_TO_CREATE paraview
PACKAGE core lapack
UNSTABLE
)
# ==============================================================================
add_akantu_test(test_material_viscoelastic "test the visco elastic materials")
add_akantu_test(test_material_non_local "test the non-local materials")
-add_akantu_test(test_material_elasto_plastic_linear_isotropic_hardening "test the elasto plastic with linear isotropic hardening materials")
+add_akantu_test(test_material_elasto_plastic_linear_isotropic_hardening
+ "test the elasto plastic with linear isotropic hardening materials")
add_akantu_test(test_material_viscoelastic_maxwell "test the viscoelastic maxwell material")
# ==============================================================================
add_mesh(test_multi_material_elastic_mesh test_multi_material_elastic.geo 2 1)
register_test(test_multi_material_elastic
SOURCES test_multi_material_elastic.cc
FILES_TO_COPY test_multi_material_elastic.dat
DEPENDS test_multi_material_elastic_mesh
PACKAGE implicit)
# ==============================================================================
# Material unit tests
# ==============================================================================
register_gtest_sources(SOURCES test_elastic_materials.cc PACKAGE core)
register_gtest_sources(SOURCES test_finite_def_materials.cc PACKAGE core)
register_gtest_sources(SOURCES test_damage_materials.cc PACKAGE core python_interface
LINK_LIBRARIES pyakantu
FILES_TO_COPY py_mazars.py)
register_gtest_sources(SOURCES test_plastic_materials.cc PACKAGE core)
register_gtest_sources(SOURCES test_material_thermal.cc PACKAGE core)
register_gtest_test(test_material)
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/py_mazars.py b/test/test_model/test_solid_mechanics_model/test_materials/py_mazars.py
index 36bad52a3..977880e03 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/py_mazars.py
+++ b/test/test_model/test_solid_mechanics_model/test_materials/py_mazars.py
@@ -1,59 +1,60 @@
#!/usr/bin/env python3
import numpy as np
-import aka_test
class Mazars:
def __init__(self, **kwargs):
- self.K0 = kwargs.pop("K0", 1e-4);
- self.At = kwargs.pop("At", 1.0);
- self.Bt = kwargs.pop("Bt", 5e3);
- self.Ac = kwargs.pop("Ac", 0.8);
- self.Bc = kwargs.pop("Bc", 1391.3);
+ self.K0 = kwargs.pop("K0", 1e-4)
+ self.At = kwargs.pop("At", 1.0)
+ self.Bt = kwargs.pop("Bt", 5e3)
+ self.Ac = kwargs.pop("Ac", 0.8)
+ self.Bc = kwargs.pop("Bc", 1391.3)
- self.E = kwargs.pop("E", 25e9);
- self.nu = kwargs.pop("nu", 0.2);
+ self.E = kwargs.pop("E", 25e9)
+ self.nu = kwargs.pop("nu", 0.2)
self.dam = 0
- self.Gf = 0
+ self.Gf = 0
self.ε_p = 0
self.σ_p = 0
- def compute(self, **kwargs):
- epsilons = np.array(kwargs['epsilons'], copy=False)
- sigmas = np.array(kwargs['sigmas'], copy=False)
- damages = np.array(kwargs['damages'], copy=False)
-
- for t, ε in enumerate(epsilons):
- compute_step()
-
- self.Gf = self.Gf + (σ + σ_p) * (ε - ε_p) / 2.
- self.σ_p = σ
- self.ε_p = ε
-
- sigmas[t] = σ
- damages[t] = self.dam
- return self.Gf
-
def compute_step(self, ε, σ, dam, trace):
dam_t = 0
- dam_c = 0
+ # dam_c = 0
if trace:
import pdb
pdb.set_trace()
σ = self.E * ε
if ε > self.K0:
dam_t = 1 - self.K0*(1 - self.At)/ε - \
self.At * np.exp(-self.Bt*(ε - self.K0))
- dam_c = 1 - self.K0*(1 - self.Ac)/ε - \
- self.Ac * np.exp(-self.Bc*(ε - self.K0))
-
+ # dam_c = 1 - self.K0*(1 - self.Ac)/ε - \
+ # self.Ac * np.exp(-self.Bc*(ε - self.K0))
+
dam = max(dam, dam_t)
dam = min(dam, 1)
σ = (1 - dam) * σ
return σ, dam
+
+ # def compute(self, **kwargs):
+ # epsilons = np.array(kwargs['epsilons'], copy=False)
+ # sigmas = np.array(kwargs['sigmas'], copy=False)
+ # damages = np.array(kwargs['damages'], copy=False)
+
+ # for t, ε in enumerate(epsilons):
+ # σ = 0.
+ # dam = 0.
+ # self.compute_step(ε, σ, dam)
+
+ # self.Gf = self.Gf + (σ + σ_p) * (ε - ε_p) / 2.
+ # self.σ_p = σ
+ # self.ε_p = ε
+
+ # sigmas[t] = σ
+ # damages[t] = self.dam
+ # return self.Gf
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_elastic_materials.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_elastic_materials.cc
index ef18bf653..7491b88c8 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_elastic_materials.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_elastic_materials.cc
@@ -1,880 +1,884 @@
/**
* @file test_elastic_materials.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
* @author Enrico Milanese <enrico.milanese@epfl.ch>
*
* @date creation: Fri Nov 17 2017
* @date last modification: Tue Feb 20 2018
*
* @brief Tests the Elastic materials
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_elastic.hh"
#include "material_elastic_orthotropic.hh"
#include "solid_mechanics_model.hh"
#include "test_material_fixtures.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <type_traits>
/* -------------------------------------------------------------------------- */
using namespace akantu;
using mat_types =
::testing::Types<Traits<MaterialElastic, 1>, Traits<MaterialElastic, 2>,
Traits<MaterialElastic, 3>,
Traits<MaterialElasticOrthotropic, 2>,
Traits<MaterialElasticOrthotropic, 3>,
Traits<MaterialElasticLinearAnisotropic, 2>,
Traits<MaterialElasticLinearAnisotropic, 3>>;
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<1>>::setParams() {
Real E = 3.;
Real rho = 2;
setParam("E", E);
setParam("rho", rho);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<1>>::testComputeStress() {
Matrix<Real> eps = {{2}};
Matrix<Real> sigma(1, 1);
Real sigma_th = 2;
this->computeStressOnQuad(eps, sigma, sigma_th);
auto solution = E * eps(0, 0) + sigma_th;
EXPECT_NEAR(sigma(0, 0), solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<1>>::testEnergyDensity() {
Real eps = 2, sigma = 2;
Real epot = 0;
this->computePotentialEnergyOnQuad({{eps}}, {{sigma}}, epot);
Real solution = 2;
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElastic<1>>::testComputeTangentModuli() {
Matrix<Real> tangent(1, 1);
this->computeTangentModuliOnQuad(tangent);
EXPECT_NEAR(tangent(0, 0), E, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<1>>::testCelerity() {
auto wave_speed = this->getCelerity(Element());
auto solution = std::sqrt(E / rho);
EXPECT_NEAR(wave_speed, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<2>>::setParams() {
Real E = 1.;
Real nu = .3;
Real rho = 2;
setParam("E", E);
setParam("nu", nu);
setParam("rho", rho);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<2>>::testComputeStress() {
Real bulk_modulus_K = E / (3 * (1 - 2 * nu));
Real shear_modulus_mu = E / (2 * (1 + nu));
auto rotation_matrix = getRandomRotation();
auto grad_u = this->getComposedStrain(1.).block(0, 0, 2, 2);
auto grad_u_rot = this->applyRotation(grad_u, rotation_matrix);
Matrix<Real> sigma_rot(2, 2);
this->computeStressOnQuad(grad_u_rot, sigma_rot, sigma_th);
auto sigma = this->reverseRotation(sigma_rot, rotation_matrix);
auto identity = Matrix<Real>::eye(2, 1.);
auto strain = 0.5 * (grad_u + grad_u.transpose());
auto deviatoric_strain = strain - 1. / 3. * strain.trace() * identity;
auto sigma_expected = 2 * shear_modulus_mu * deviatoric_strain +
(sigma_th + 2. * bulk_modulus_K) * identity;
auto diff = sigma - sigma_expected;
Real stress_error = diff.norm<L_inf>() / sigma_expected.norm<L_inf>();
EXPECT_NEAR(stress_error, 0., 1e-13);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<2>>::testEnergyDensity() {
Matrix<Real> sigma = {{1, 2}, {2, 4}};
Matrix<Real> eps = {{1, 0}, {0, 1}};
Real epot = 0;
Real solution = 2.5;
this->computePotentialEnergyOnQuad(eps, sigma, epot);
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElastic<2>>::testComputeTangentModuli() {
Matrix<Real> tangent(3, 3);
/* Plane Strain */
// clang-format off
Matrix<Real> solution = {
{1 - nu, nu, 0},
{nu, 1 - nu, 0},
{0, 0, (1 - 2 * nu) / 2},
};
// clang-format on
solution *= E / ((1 + nu) * (1 - 2 * nu));
this->computeTangentModuliOnQuad(tangent);
Real tangent_error = (tangent - solution).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
/* Plane Stress */
this->plane_stress = true;
this->updateInternalParameters();
// clang-format off
solution = {
{1, nu, 0},
{nu, 1, 0},
{0, 0, (1 - nu) / 2},
};
// clang-format on
solution *= E / (1 - nu * nu);
this->computeTangentModuliOnQuad(tangent);
tangent_error = (tangent - solution).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<2>>::testCelerity() {
auto push_wave_speed = this->getPushWaveSpeed(Element());
auto celerity = this->getCelerity(Element());
Real K = E / (3 * (1 - 2 * nu));
Real mu = E / (2 * (1 + nu));
Real sol = std::sqrt((K + 4. / 3 * mu) / rho);
EXPECT_NEAR(push_wave_speed, sol, 1e-14);
EXPECT_NEAR(celerity, sol, 1e-14);
auto shear_wave_speed = this->getShearWaveSpeed(Element());
sol = std::sqrt(mu / rho);
EXPECT_NEAR(shear_wave_speed, sol, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<3>>::setParams() {
Real E = 1.;
Real nu = .3;
Real rho = 2;
setParam("E", E);
setParam("nu", nu);
setParam("rho", rho);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<3>>::testComputeStress() {
Real bulk_modulus_K = E / 3. / (1 - 2. * nu);
Real shear_modulus_mu = 0.5 * E / (1 + nu);
Matrix<Real> rotation_matrix = getRandomRotation();
auto grad_u = this->getComposedStrain(1.);
auto grad_u_rot = this->applyRotation(grad_u, rotation_matrix);
Matrix<Real> sigma_rot(3, 3);
this->computeStressOnQuad(grad_u_rot, sigma_rot, sigma_th);
auto sigma = this->reverseRotation(sigma_rot, rotation_matrix);
Matrix<Real> identity(3, 3);
identity.eye();
Matrix<Real> strain = 0.5 * (grad_u + grad_u.transpose());
Matrix<Real> deviatoric_strain = strain - 1. / 3. * strain.trace() * identity;
Matrix<Real> sigma_expected = 2 * shear_modulus_mu * deviatoric_strain +
(sigma_th + 3. * bulk_modulus_K) * identity;
auto diff = sigma - sigma_expected;
Real stress_error = diff.norm<L_inf>();
EXPECT_NEAR(stress_error, 0., 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<3>>::testEnergyDensity() {
Matrix<Real> sigma = {{1, 2, 3}, {2, 4, 5}, {3, 5, 6}};
Matrix<Real> eps = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
Real epot = 0;
Real solution = 5.5;
this->computePotentialEnergyOnQuad(eps, sigma, epot);
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElastic<3>>::testComputeTangentModuli() {
Matrix<Real> tangent(6, 6);
// clang-format off
Matrix<Real> solution = {
{1 - nu, nu, nu, 0, 0, 0},
{nu, 1 - nu, nu, 0, 0, 0},
{nu, nu, 1 - nu, 0, 0, 0},
{0, 0, 0, (1 - 2 * nu) / 2, 0, 0},
{0, 0, 0, 0, (1 - 2 * nu) / 2, 0},
{0, 0, 0, 0, 0, (1 - 2 * nu) / 2},
};
// clang-format on
solution *= E / ((1 + nu) * (1 - 2 * nu));
this->computeTangentModuliOnQuad(tangent);
Real tangent_error = (tangent - solution).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElastic<3>>::testCelerity() {
auto push_wave_speed = this->getPushWaveSpeed(Element());
auto celerity = this->getCelerity(Element());
Real K = E / (3 * (1 - 2 * nu));
Real mu = E / (2 * (1 + nu));
Real sol = std::sqrt((K + 4. / 3 * mu) / rho);
EXPECT_NEAR(push_wave_speed, sol, 1e-14);
EXPECT_NEAR(celerity, sol, 1e-14);
auto shear_wave_speed = this->getShearWaveSpeed(Element());
sol = std::sqrt(mu / rho);
EXPECT_NEAR(shear_wave_speed, sol, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElasticOrthotropic<2>>::setParams() {
// Note: for this test material and canonical basis coincide
Vector<Real> n1 = {1, 0};
Vector<Real> n2 = {0, 1};
Real E1 = 1.;
Real E2 = 2.;
Real nu12 = 0.1;
Real G12 = 2.;
Real rho = 2.5;
*this->dir_vecs[0] = n1;
*this->dir_vecs[1] = n2;
this->E1 = E1;
this->E2 = E2;
this->nu12 = nu12;
this->G12 = G12;
this->rho = rho;
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticOrthotropic<2>>::testComputeStress() {
UInt Dim = 2;
// material frame of reference is rotate by rotation_matrix starting from
// canonical basis
Matrix<Real> rotation_matrix = getRandomRotation();
// canonical basis as expressed in the material frame of reference, as
// required by MaterialElasticOrthotropic class (it is simply given by the
// columns of the rotation_matrix; the lines give the material basis expressed
// in the canonical frame of reference)
*this->dir_vecs[0] = rotation_matrix(0);
*this->dir_vecs[1] = rotation_matrix(1);
// set internal Cijkl matrix expressed in the canonical frame of reference
this->updateInternalParameters();
// gradient in material frame of reference
auto grad_u = this->getComposedStrain(2.).block(0, 0, 2, 2);
// gradient in canonical basis (we need to rotate *back* to the canonical
// basis)
auto grad_u_rot = this->reverseRotation(grad_u, rotation_matrix);
// stress in the canonical basis
Matrix<Real> sigma_rot(2, 2);
this->computeStressOnQuad(grad_u_rot, sigma_rot);
// stress in the material reference (we need to apply the rotation)
auto sigma = this->applyRotation(sigma_rot, rotation_matrix);
// construction of Cijkl engineering tensor in the *material* frame of
// reference
// ref: http://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php#Sect3_2_13
Real nu21 = nu12 * E2 / E1;
Real gamma = 1 / (1 - nu12 * nu21);
Matrix<Real> C_expected(2 * Dim, 2 * Dim, 0);
C_expected(0, 0) = gamma * E1;
C_expected(1, 1) = gamma * E2;
C_expected(2, 2) = G12;
C_expected(1, 0) = C_expected(0, 1) = gamma * E1 * nu21;
// epsilon is computed directly in the *material* frame of reference
Matrix<Real> epsilon = 0.5 * (grad_u + grad_u.transpose());
// sigma_expected is computed directly in the *material* frame of reference
Matrix<Real> sigma_expected(Dim, Dim);
for (UInt i = 0; i < Dim; ++i) {
for (UInt j = 0; j < Dim; ++j) {
sigma_expected(i, i) += C_expected(i, j) * epsilon(j, j);
}
}
sigma_expected(0, 1) = sigma_expected(1, 0) =
C_expected(2, 2) * 2 * epsilon(0, 1);
// sigmas are checked in the *material* frame of reference
auto diff = sigma - sigma_expected;
Real stress_error = diff.norm<L_inf>();
EXPECT_NEAR(stress_error, 0., 1e-13);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticOrthotropic<2>>::testEnergyDensity() {
Matrix<Real> sigma = {{1, 2}, {2, 4}};
Matrix<Real> eps = {{1, 0}, {0, 1}};
Real epot = 0;
Real solution = 2.5;
this->computePotentialEnergyOnQuad(eps, sigma, epot);
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticOrthotropic<2>>::testComputeTangentModuli() {
// construction of Cijkl engineering tensor in the *material* frame of
// reference
// ref: http://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php#Sect3_2_13
Real nu21 = nu12 * E2 / E1;
Real gamma = 1 / (1 - nu12 * nu21);
Matrix<Real> C_expected(3, 3);
C_expected(0, 0) = gamma * E1;
C_expected(1, 1) = gamma * E2;
C_expected(2, 2) = G12;
C_expected(1, 0) = C_expected(0, 1) = gamma * E1 * nu21;
Matrix<Real> tangent(3, 3);
this->computeTangentModuliOnQuad(tangent);
Real tangent_error = (tangent - C_expected).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElasticOrthotropic<2>>::testCelerity() {
// construction of Cijkl engineering tensor in the *material* frame of
// reference
// ref: http://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php#Sect3_2_13
Real nu21 = nu12 * E2 / E1;
Real gamma = 1 / (1 - nu12 * nu21);
Matrix<Real> C_expected(3, 3);
C_expected(0, 0) = gamma * E1;
C_expected(1, 1) = gamma * E2;
C_expected(2, 2) = G12;
C_expected(1, 0) = C_expected(0, 1) = gamma * E1 * nu21;
Vector<Real> eig_expected(3);
C_expected.eig(eig_expected);
auto celerity_expected = std::sqrt(eig_expected(0) / rho);
auto celerity = this->getCelerity(Element());
EXPECT_NEAR(celerity_expected, celerity, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElasticOrthotropic<3>>::setParams() {
Vector<Real> n1 = {1, 0, 0};
Vector<Real> n2 = {0, 1, 0};
Vector<Real> n3 = {0, 0, 1};
Real E1 = 1.;
Real E2 = 2.;
Real E3 = 3.;
Real nu12 = 0.1;
Real nu13 = 0.2;
Real nu23 = 0.3;
Real G12 = 2.;
Real G13 = 3.;
Real G23 = 1.;
Real rho = 2.3;
*this->dir_vecs[0] = n1;
*this->dir_vecs[1] = n2;
*this->dir_vecs[2] = n3;
this->E1 = E1;
this->E2 = E2;
this->E3 = E3;
this->nu12 = nu12;
this->nu13 = nu13;
this->nu23 = nu23;
this->G12 = G12;
this->G13 = G13;
this->G23 = G23;
this->rho = rho;
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticOrthotropic<3>>::testComputeStress() {
UInt Dim = 3;
// material frame of reference is rotate by rotation_matrix starting from
// canonical basis
Matrix<Real> rotation_matrix = getRandomRotation();
// canonical basis as expressed in the material frame of reference, as
// required by MaterialElasticOrthotropic class (it is simply given by the
// columns of the rotation_matrix; the lines give the material basis expressed
// in the canonical frame of reference)
*this->dir_vecs[0] = rotation_matrix(0);
*this->dir_vecs[1] = rotation_matrix(1);
*this->dir_vecs[2] = rotation_matrix(2);
// set internal Cijkl matrix expressed in the canonical frame of reference
this->updateInternalParameters();
// gradient in material frame of reference
auto grad_u = this->getComposedStrain(2.);
// gradient in canonical basis (we need to rotate *back* to the canonical
// basis)
auto grad_u_rot = this->reverseRotation(grad_u, rotation_matrix);
// stress in the canonical basis
Matrix<Real> sigma_rot(3, 3);
this->computeStressOnQuad(grad_u_rot, sigma_rot);
// stress in the material reference (we need to apply the rotation)
auto sigma = this->applyRotation(sigma_rot, rotation_matrix);
// construction of Cijkl engineering tensor in the *material* frame of
// reference
// ref: http://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php#Sect3_2_13
Real nu21 = nu12 * E2 / E1;
Real nu31 = nu13 * E3 / E1;
Real nu32 = nu23 * E3 / E2;
Real gamma = 1 / (1 - nu12 * nu21 - nu23 * nu32 - nu31 * nu13 -
2 * nu21 * nu32 * nu13);
Matrix<Real> C_expected(6, 6);
C_expected(0, 0) = gamma * E1 * (1 - nu23 * nu32);
C_expected(1, 1) = gamma * E2 * (1 - nu13 * nu31);
C_expected(2, 2) = gamma * E3 * (1 - nu12 * nu21);
C_expected(1, 0) = C_expected(0, 1) = gamma * E1 * (nu21 + nu31 * nu23);
C_expected(2, 0) = C_expected(0, 2) = gamma * E1 * (nu31 + nu21 * nu32);
C_expected(2, 1) = C_expected(1, 2) = gamma * E2 * (nu32 + nu12 * nu31);
C_expected(3, 3) = G23;
C_expected(4, 4) = G13;
C_expected(5, 5) = G12;
// epsilon is computed directly in the *material* frame of reference
Matrix<Real> epsilon = 0.5 * (grad_u + grad_u.transpose());
// sigma_expected is computed directly in the *material* frame of reference
Matrix<Real> sigma_expected(Dim, Dim);
for (UInt i = 0; i < Dim; ++i) {
for (UInt j = 0; j < Dim; ++j) {
sigma_expected(i, i) += C_expected(i, j) * epsilon(j, j);
}
}
sigma_expected(0, 1) = C_expected(5, 5) * 2 * epsilon(0, 1);
sigma_expected(0, 2) = C_expected(4, 4) * 2 * epsilon(0, 2);
sigma_expected(1, 2) = C_expected(3, 3) * 2 * epsilon(1, 2);
sigma_expected(1, 0) = sigma_expected(0, 1);
sigma_expected(2, 0) = sigma_expected(0, 2);
sigma_expected(2, 1) = sigma_expected(1, 2);
// sigmas are checked in the *material* frame of reference
auto diff = sigma - sigma_expected;
Real stress_error = diff.norm<L_inf>();
EXPECT_NEAR(stress_error, 0., 1e-13);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticOrthotropic<3>>::testEnergyDensity() {
Matrix<Real> sigma = {{1, 2, 3}, {2, 4, 5}, {3, 5, 6}};
Matrix<Real> eps = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
Real epot = 0;
Real solution = 5.5;
this->computePotentialEnergyOnQuad(eps, sigma, epot);
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticOrthotropic<3>>::testComputeTangentModuli() {
// Note: for this test material and canonical basis coincide
UInt Dim = 3;
// construction of Cijkl engineering tensor in the *material* frame of
// reference
// ref: http://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php#Sect3_2_13
Real nu21 = nu12 * E2 / E1;
Real nu31 = nu13 * E3 / E1;
Real nu32 = nu23 * E3 / E2;
Real gamma = 1 / (1 - nu12 * nu21 - nu23 * nu32 - nu31 * nu13 -
2 * nu21 * nu32 * nu13);
Matrix<Real> C_expected(2 * Dim, 2 * Dim, 0);
C_expected(0, 0) = gamma * E1 * (1 - nu23 * nu32);
C_expected(1, 1) = gamma * E2 * (1 - nu13 * nu31);
C_expected(2, 2) = gamma * E3 * (1 - nu12 * nu21);
C_expected(1, 0) = C_expected(0, 1) = gamma * E1 * (nu21 + nu31 * nu23);
C_expected(2, 0) = C_expected(0, 2) = gamma * E1 * (nu31 + nu21 * nu32);
C_expected(2, 1) = C_expected(1, 2) = gamma * E2 * (nu32 + nu12 * nu31);
C_expected(3, 3) = G23;
C_expected(4, 4) = G13;
C_expected(5, 5) = G12;
Matrix<Real> tangent(6, 6);
this->computeTangentModuliOnQuad(tangent);
Real tangent_error = (tangent - C_expected).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialElasticOrthotropic<3>>::testCelerity() {
// Note: for this test material and canonical basis coincide
UInt Dim = 3;
// construction of Cijkl engineering tensor in the *material* frame of
// reference
// ref: http://solidmechanics.org/Text/Chapter3_2/Chapter3_2.php#Sect3_2_13
Real nu21 = nu12 * E2 / E1;
Real nu31 = nu13 * E3 / E1;
Real nu32 = nu23 * E3 / E2;
Real gamma = 1 / (1 - nu12 * nu21 - nu23 * nu32 - nu31 * nu13 -
2 * nu21 * nu32 * nu13);
Matrix<Real> C_expected(2 * Dim, 2 * Dim, 0);
C_expected(0, 0) = gamma * E1 * (1 - nu23 * nu32);
C_expected(1, 1) = gamma * E2 * (1 - nu13 * nu31);
C_expected(2, 2) = gamma * E3 * (1 - nu12 * nu21);
C_expected(1, 0) = C_expected(0, 1) = gamma * E1 * (nu21 + nu31 * nu23);
C_expected(2, 0) = C_expected(0, 2) = gamma * E1 * (nu31 + nu21 * nu32);
C_expected(2, 1) = C_expected(1, 2) = gamma * E2 * (nu32 + nu12 * nu31);
C_expected(3, 3) = G23;
C_expected(4, 4) = G13;
C_expected(5, 5) = G12;
Vector<Real> eig_expected(6);
C_expected.eig(eig_expected);
auto celerity_expected = std::sqrt(eig_expected(0) / rho);
auto celerity = this->getCelerity(Element());
EXPECT_NEAR(celerity_expected, celerity, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<2>>::setParams() {
Matrix<Real> C = {
- {1.0, 0.3, 0.4}, {0.3, 2.0, 0.1}, {0.4, 0.1, 1.5},
+ {1.0, 0.3, 0.4},
+ {0.3, 2.0, 0.1},
+ {0.4, 0.1, 1.5},
};
for (auto i = 0u; i < C.rows(); ++i)
for (auto j = 0u; j < C.cols(); ++j)
this->Cprime(i, j) = C(i, j);
this->rho = 2.7;
// material frame of reference is rotate by rotation_matrix starting from
// canonical basis
Matrix<Real> rotation_matrix = getRandomRotation();
// canonical basis as expressed in the material frame of reference, as
// required by MaterialElasticLinearAnisotropic class (it is simply given by
// the columns of the rotation_matrix; the lines give the material basis
// expressed in the canonical frame of reference)
*this->dir_vecs[0] = rotation_matrix(0);
*this->dir_vecs[1] = rotation_matrix(1);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<2>>::testComputeStress() {
Matrix<Real> C = {
- {1.0, 0.3, 0.4}, {0.3, 2.0, 0.1}, {0.4, 0.1, 1.5},
+ {1.0, 0.3, 0.4},
+ {0.3, 2.0, 0.1},
+ {0.4, 0.1, 1.5},
};
Matrix<Real> rotation_matrix(2, 2);
rotation_matrix(0) = *this->dir_vecs[0];
rotation_matrix(1) = *this->dir_vecs[1];
// gradient in material frame of reference
auto grad_u = this->getComposedStrain(1.).block(0, 0, 2, 2);
// gradient in canonical basis (we need to rotate *back* to the canonical
// basis)
auto grad_u_rot = this->reverseRotation(grad_u, rotation_matrix);
// stress in the canonical basis
Matrix<Real> sigma_rot(2, 2);
this->computeStressOnQuad(grad_u_rot, sigma_rot);
// stress in the material reference (we need to apply the rotation)
auto sigma = this->applyRotation(sigma_rot, rotation_matrix);
// epsilon is computed directly in the *material* frame of reference
Matrix<Real> epsilon = 0.5 * (grad_u + grad_u.transpose());
Vector<Real> epsilon_voigt(3);
epsilon_voigt(0) = epsilon(0, 0);
epsilon_voigt(1) = epsilon(1, 1);
epsilon_voigt(2) = 2 * epsilon(0, 1);
// sigma_expected is computed directly in the *material* frame of reference
Vector<Real> sigma_voigt = C * epsilon_voigt;
Matrix<Real> sigma_expected(2, 2);
sigma_expected(0, 0) = sigma_voigt(0);
sigma_expected(1, 1) = sigma_voigt(1);
sigma_expected(0, 1) = sigma_expected(1, 0) = sigma_voigt(2);
// sigmas are checked in the *material* frame of reference
auto diff = sigma - sigma_expected;
Real stress_error = diff.norm<L_inf>();
EXPECT_NEAR(stress_error, 0., 1e-13);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<2>>::testEnergyDensity() {
Matrix<Real> sigma = {{1, 2}, {2, 4}};
Matrix<Real> eps = {{1, 0}, {0, 1}};
Real epot = 0;
Real solution = 2.5;
this->computePotentialEnergyOnQuad(eps, sigma, epot);
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<
MaterialElasticLinearAnisotropic<2>>::testComputeTangentModuli() {
Matrix<Real> tangent(3, 3);
this->computeTangentModuliOnQuad(tangent);
Real tangent_error = (tangent - C).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<2>>::testCelerity() {
Vector<Real> eig_expected(3);
C.eig(eig_expected);
auto celerity_expected = std::sqrt(eig_expected(0) / this->rho);
auto celerity = this->getCelerity(Element());
EXPECT_NEAR(celerity_expected, celerity, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<3>>::setParams() {
// Note: for this test material and canonical basis coincide
Matrix<Real> C = {
{1.0, 0.3, 0.4, 0.3, 0.2, 0.1}, {0.3, 2.0, 0.1, 0.2, 0.3, 0.2},
{0.4, 0.1, 1.5, 0.1, 0.4, 0.3}, {0.3, 0.2, 0.1, 2.4, 0.1, 0.4},
{0.2, 0.3, 0.4, 0.1, 0.9, 0.1}, {0.1, 0.2, 0.3, 0.4, 0.1, 1.2},
};
for (auto i = 0u; i < C.rows(); ++i)
for (auto j = 0u; j < C.cols(); ++j)
this->Cprime(i, j) = C(i, j);
this->rho = 2.9;
// material frame of reference is rotate by rotation_matrix starting from
// canonical basis
Matrix<Real> rotation_matrix = getRandomRotation();
// canonical basis as expressed in the material frame of reference, as
// required by MaterialElasticLinearAnisotropic class (it is simply given by
// the columns of the rotation_matrix; the lines give the material basis
// expressed in the canonical frame of reference)
*this->dir_vecs[0] = rotation_matrix(0);
*this->dir_vecs[1] = rotation_matrix(1);
*this->dir_vecs[2] = rotation_matrix(2);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<3>>::testComputeStress() {
Matrix<Real> C = {
{1.0, 0.3, 0.4, 0.3, 0.2, 0.1}, {0.3, 2.0, 0.1, 0.2, 0.3, 0.2},
{0.4, 0.1, 1.5, 0.1, 0.4, 0.3}, {0.3, 0.2, 0.1, 2.4, 0.1, 0.4},
{0.2, 0.3, 0.4, 0.1, 0.9, 0.1}, {0.1, 0.2, 0.3, 0.4, 0.1, 1.2},
};
Matrix<Real> rotation_matrix(3, 3);
rotation_matrix(0) = *this->dir_vecs[0];
rotation_matrix(1) = *this->dir_vecs[1];
rotation_matrix(2) = *this->dir_vecs[2];
// gradient in material frame of reference
auto grad_u = this->getComposedStrain(2.);
// gradient in canonical basis (we need to rotate *back* to the canonical
// basis)
auto grad_u_rot = this->reverseRotation(grad_u, rotation_matrix);
// stress in the canonical basis
Matrix<Real> sigma_rot(3, 3);
this->computeStressOnQuad(grad_u_rot, sigma_rot);
// stress in the material reference (we need to apply the rotation)
auto sigma = this->applyRotation(sigma_rot, rotation_matrix);
// epsilon is computed directly in the *material* frame of reference
Matrix<Real> epsilon = 0.5 * (grad_u + grad_u.transpose());
Vector<Real> epsilon_voigt(6);
epsilon_voigt(0) = epsilon(0, 0);
epsilon_voigt(1) = epsilon(1, 1);
epsilon_voigt(2) = epsilon(2, 2);
epsilon_voigt(3) = 2 * epsilon(1, 2);
epsilon_voigt(4) = 2 * epsilon(0, 2);
epsilon_voigt(5) = 2 * epsilon(0, 1);
// sigma_expected is computed directly in the *material* frame of reference
Vector<Real> sigma_voigt = C * epsilon_voigt;
Matrix<Real> sigma_expected(3, 3);
sigma_expected(0, 0) = sigma_voigt(0);
sigma_expected(1, 1) = sigma_voigt(1);
sigma_expected(2, 2) = sigma_voigt(2);
sigma_expected(1, 2) = sigma_expected(2, 1) = sigma_voigt(3);
sigma_expected(0, 2) = sigma_expected(2, 0) = sigma_voigt(4);
sigma_expected(0, 1) = sigma_expected(1, 0) = sigma_voigt(5);
// sigmas are checked in the *material* frame of reference
auto diff = sigma - sigma_expected;
Real stress_error = diff.norm<L_inf>();
EXPECT_NEAR(stress_error, 0., 1e-13);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<3>>::testEnergyDensity() {
Matrix<Real> sigma = {{1, 2, 3}, {2, 4, 5}, {3, 5, 6}};
Matrix<Real> eps = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
Real epot = 0;
Real solution = 5.5;
this->computePotentialEnergyOnQuad(eps, sigma, epot);
EXPECT_NEAR(epot, solution, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<
MaterialElasticLinearAnisotropic<3>>::testComputeTangentModuli() {
Matrix<Real> tangent(6, 6);
this->computeTangentModuliOnQuad(tangent);
Real tangent_error = (tangent - C).norm<L_2>();
EXPECT_NEAR(tangent_error, 0, 1e-14);
}
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialElasticLinearAnisotropic<3>>::testCelerity() {
Vector<Real> eig_expected(6);
C.eig(eig_expected);
auto celerity_expected = std::sqrt(eig_expected(0) / this->rho);
auto celerity = this->getCelerity(Element());
EXPECT_NEAR(celerity_expected, celerity, 1e-14);
}
/* -------------------------------------------------------------------------- */
namespace {
template <typename T>
class TestElasticMaterialFixture : public ::TestMaterialFixture<T> {};
TYPED_TEST_SUITE(TestElasticMaterialFixture, mat_types);
TYPED_TEST(TestElasticMaterialFixture, ComputeStress) {
this->material->testComputeStress();
}
TYPED_TEST(TestElasticMaterialFixture, EnergyDensity) {
this->material->testEnergyDensity();
}
TYPED_TEST(TestElasticMaterialFixture, ComputeTangentModuli) {
this->material->testComputeTangentModuli();
}
TYPED_TEST(TestElasticMaterialFixture, ComputeCelerity) {
this->material->testCelerity();
}
} // namespace
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_finite_def_materials.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_finite_def_materials.cc
index db3d82241..e02be1f79 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_finite_def_materials.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_finite_def_materials.cc
@@ -1,85 +1,85 @@
/**
* @file test_finite_def_materials.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Fri Nov 17 2017
* @date last modification: Tue Feb 20 2018
*
* @brief
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_neohookean.hh"
#include "solid_mechanics_model.hh"
#include "test_material_fixtures.hh"
#include <gtest/gtest.h>
#include <type_traits>
/* -------------------------------------------------------------------------- */
using namespace akantu;
-using mat_types = ::testing::Types<
- Traits<MaterialNeohookean, 1>, Traits<MaterialNeohookean, 2>,
- Traits<MaterialNeohookean, 3>>;
+using mat_types = ::testing::Types<Traits<MaterialNeohookean, 1>,
+ Traits<MaterialNeohookean, 2>,
+ Traits<MaterialNeohookean, 3>>;
/*****************************************************************/
template <> void FriendMaterial<MaterialNeohookean<3>>::testComputeStress() {
AKANTU_TO_IMPLEMENT();
}
/*****************************************************************/
template <>
void FriendMaterial<MaterialNeohookean<3>>::testComputeTangentModuli() {
AKANTU_TO_IMPLEMENT();
}
/*****************************************************************/
template <> void FriendMaterial<MaterialNeohookean<3>>::testEnergyDensity() {
AKANTU_TO_IMPLEMENT();
}
/*****************************************************************/
namespace {
template <typename T>
class TestFiniteDefMaterialFixture : public ::TestMaterialFixture<T> {};
TYPED_TEST_SUITE(TestFiniteDefMaterialFixture, mat_types);
TYPED_TEST(TestFiniteDefMaterialFixture, DISABLED_ComputeStress) {
this->material->testComputeStress();
}
TYPED_TEST(TestFiniteDefMaterialFixture, DISABLED_EnergyDensity) {
this->material->testEnergyDensity();
}
TYPED_TEST(TestFiniteDefMaterialFixture, DISABLED_ComputeTangentModuli) {
this->material->testComputeTangentModuli();
}
TYPED_TEST(TestFiniteDefMaterialFixture, DISABLED_DefComputeCelerity) {
this->material->testCelerity();
}
-}
+} // namespace
/*****************************************************************/
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_local_material.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_local_material.cc
index d11a955a4..42abaca0a 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_local_material.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_local_material.cc
@@ -1,130 +1,133 @@
/**
* @file test_local_material.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
* @author Marion Estelle Chambart <marion.chambart@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Thu Dec 14 2017
*
* @brief test of the class SolidMechanicsModel with custom local damage on a
* notched plate
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
#include "local_material_damage.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
int main(int argc, char * argv[]) {
akantu::initialize("material.dat", argc, argv);
UInt max_steps = 1100;
const UInt spatial_dimension = 2;
Mesh mesh(spatial_dimension);
mesh.read("mesh_section_gap.msh");
/// model initialization
MaterialFactory::getInstance().registerAllocator(
- "local_damage", [](UInt, const ID &, SolidMechanicsModel & model,
- const ID & id) -> std::unique_ptr<Material> {
+ "local_damage",
+ [](UInt, const ID &, SolidMechanicsModel & model,
+ const ID & id) -> std::unique_ptr<Material> {
return std::make_unique<LocalMaterialDamage>(model, id);
});
SolidMechanicsModel model(mesh);
model.initFull();
std::cout << model.getMaterial(0) << std::endl;
model.addDumpField("damage");
model.addDumpField("strain");
model.addDumpField("stress");
model.addDumpFieldVector("displacement");
model.addDumpFieldVector("external_force");
model.addDumpFieldVector("internal_force");
model.dump();
Real time_step = model.getStableTimeStep();
model.setTimeStep(time_step / 2.5);
/// Dirichlet boundary conditions
model.applyBC(BC::Dirichlet::FixedValue(0.0, _x), "Fixed");
// model.applyBC(BC::Dirichlet::FixedValue(0.0, _y), "Fixed");
Matrix<Real> stress(2, 2);
stress.eye(5e7);
model.applyBC(BC::Neumann::FromHigherDim(stress), "Traction");
for (UInt s = 0; s < max_steps; ++s)
model.solveStep();
model.dump();
// This should throw a bad_cast if not the proper material
- auto & mat = dynamic_cast<LocalMaterialDamage &>(model.getMaterial("concrete"));
+ auto & mat =
+ dynamic_cast<LocalMaterialDamage &>(model.getMaterial("concrete"));
const auto & filter = mat.getElementFilter();
for (auto & type : filter.elementTypes(spatial_dimension)) {
std::cout << mat.getDamage(type) << std::endl;
}
// This part of the test is to mesh dependent and as nothing to do with the
// fact that we can create a user defined material or not
-
+
// const auto & lower_bounds = mesh.getLowerBounds();
// const auto & upper_bounds = mesh.getUpperBounds();
// Real L = upper_bounds(_x) - lower_bounds(_x);
// Real H = upper_bounds(_y) - lower_bounds(_y);
// const auto & filter = model.getMaterial("concrete").getElementFilter();
// Vector<Real> barycenter(spatial_dimension);
// for (auto & type : filter.elementTypes(spatial_dimension)) {
// UInt nb_elem = mesh.getNbElement(type);
// const UInt nb_gp = model.getFEEngine().getNbIntegrationPoints(type);
// const auto & material_damage_array =
// model.getMaterial(0).getArray<Real>("damage", type);
// UInt cpt = 0;
// for (auto nel : arange(nb_elem)) {
// mesh.getBarycenter({type, nel, _not_ghost}, barycenter);
// if ((std::abs(barycenter(_x) - (L / 2) + 0.025) < 0.025) &&
// (std::abs(barycenter(_y) - (H / 2) + 0.045) < 0.045)) {
// if (material_damage_array(cpt, 0) < 0.9) {
// std::terminate();
// } else {
- // std::cout << "element " << nel << " is correctly broken" << std::endl;
+ // std::cout << "element " << nel << " is correctly broken" <<
+ // std::endl;
// }
// }
// cpt += nb_gp;
// }
- // }
+ // }
akantu::finalize();
return 0;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_elasto_plastic_linear_isotropic_hardening.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_elasto_plastic_linear_isotropic_hardening.cc
index abad2e026..a93481510 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_elasto_plastic_linear_isotropic_hardening.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_elasto_plastic_linear_isotropic_hardening/test_material_elasto_plastic_linear_isotropic_hardening.cc
@@ -1,91 +1,92 @@
/**
* @file test_material_elasto_plastic_linear_isotropic_hardening.cc
*
* @author Jaehyun Cho <jaehyun.cho@epfl.ch>
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Sun Oct 19 2014
* @date last modification: Mon Sep 11 2017
*
* @brief test for material type elasto plastic linear isotropic hardening
* using tension-compression test
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "non_linear_solver.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize("test_material_elasto_plastic_linear_isotropic_hardening.dat",
argc, argv);
const UInt spatial_dimension = 2;
const Real u_increment = 0.1;
const UInt steps = 20;
Mesh mesh(spatial_dimension);
mesh.read("test_material_elasto_plastic_linear_isotropic_hardening.msh");
SolidMechanicsModel model(mesh);
model.initFull(_analysis_method = _static);
auto & solver = model.getNonLinearSolver("static");
solver.set("max_iterations", 300);
solver.set("threshold", 1e-5);
model.applyBC(BC::Dirichlet::FixedValue(0.0, _x), "left");
model.applyBC(BC::Dirichlet::FixedValue(0.0, _y), "bottom");
std::cout.precision(4);
for (UInt i = 0; i < steps; ++i) {
model.applyBC(BC::Dirichlet::FixedValue(i * u_increment, _x), "right");
try {
model.solveStep();
} catch (debug::NLSNotConvergedException & e) {
std::cout << e.niter << " " << e.error << std::endl;
throw;
}
Real strainxx = i * u_increment / 10.;
- const Array<UInt> & edge_nodes = mesh.getElementGroup("right").getNodeGroup().getNodes();
+ const Array<UInt> & edge_nodes =
+ mesh.getElementGroup("right").getNodeGroup().getNodes();
Array<Real> & residual = model.getInternalForce();
Real reaction = 0;
for (UInt n = 0; n < edge_nodes.size(); n++) {
reaction -= residual(edge_nodes(n), 0);
}
std::cout << strainxx << "," << reaction << std::endl;
}
finalize();
return 0;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh b/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh
index b61960820..fd6ed3f9c 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_fixtures.hh
@@ -1,211 +1,211 @@
/**
* @file test_material_fixtures.hh
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Fri Nov 17 2017
* @date last modification: Tue Feb 20 2018
*
* @brief Fixture for material tests
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_elastic.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <random>
#include <type_traits>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
template <typename T> class FriendMaterial : public T {
public:
~FriendMaterial() = default;
FriendMaterial(SolidMechanicsModel & model, const ID & id = "material")
: T(model, id) {
gen.seed(::testing::GTEST_FLAG(random_seed));
}
virtual void testComputeStress() { AKANTU_TO_IMPLEMENT(); };
virtual void testComputeTangentModuli() { AKANTU_TO_IMPLEMENT(); };
virtual void testEnergyDensity() { AKANTU_TO_IMPLEMENT(); };
virtual void testCelerity() { AKANTU_TO_IMPLEMENT(); }
virtual void setParams() {}
virtual void SetUp() {
this->setParams();
this->initMaterial();
}
- virtual void TearDown() { }
+ virtual void TearDown() {}
inline Matrix<Real> getDeviatoricStrain(Real intensity);
inline Matrix<Real> getHydrostaticStrain(Real intensity);
inline Matrix<Real> getComposedStrain(Real intensity);
inline const Matrix<Real> reverseRotation(Matrix<Real> mat,
Matrix<Real> rotation_matrix) {
Matrix<Real> R = rotation_matrix;
Matrix<Real> m2 = mat * R;
Matrix<Real> m1 = R.transpose();
return m1 * m2;
};
inline const Matrix<Real> applyRotation(Matrix<Real> mat,
const Matrix<Real> rotation_matrix) {
Matrix<Real> R = rotation_matrix;
Matrix<Real> m2 = mat * R.transpose();
Matrix<Real> m1 = R;
return m1 * m2;
};
inline Vector<Real> getRandomVector();
inline Matrix<Real> getRandomRotation();
protected:
std::mt19937 gen;
};
/* -------------------------------------------------------------------------- */
template <typename T>
Matrix<Real> FriendMaterial<T>::getDeviatoricStrain(Real intensity) {
Matrix<Real> dev = {{0., 1., 2.}, {1., 0., 3.}, {2., 3., 0.}};
dev *= intensity;
return dev;
}
/* -------------------------------------------------------------------------- */
template <typename T>
Matrix<Real> FriendMaterial<T>::getHydrostaticStrain(Real intensity) {
Matrix<Real> dev = {{1, 0, 0}, {0, 1, 0}, {0, 0, 1}};
dev *= intensity;
return dev;
}
/* -------------------------------------------------------------------------- */
template <typename T>
Matrix<Real> FriendMaterial<T>::getComposedStrain(Real intensity) {
Matrix<Real> s = FriendMaterial<T>::getHydrostaticStrain(intensity) +
FriendMaterial<T>::getDeviatoricStrain(intensity);
s *= intensity;
return s;
}
/* -------------------------------------------------------------------------- */
template <typename T> Vector<Real> FriendMaterial<T>::getRandomVector() {
auto dim = this->spatial_dimension;
std::uniform_real_distribution<Real> dis;
Vector<Real> vector(dim, 0.);
- while(vector.norm() < 1e-9) {
+ while (vector.norm() < 1e-9) {
for (auto s : arange(dim))
vector(s) = dis(gen);
}
return vector;
}
/* -------------------------------------------------------------------------- */
template <typename T> Matrix<Real> FriendMaterial<T>::getRandomRotation() {
auto dim = this->spatial_dimension;
Matrix<Real> rotation(dim, dim);
Vector<Real> v1 = rotation(0);
v1 = getRandomVector().normalize();
if (dim == 2) {
Vector<Real> v1_ = {v1(0), v1(1), 0};
Vector<Real> v2_(3);
Vector<Real> v3_ = {0, 0, 1};
v2_.crossProduct(v3_, v1_);
Vector<Real> v2 = rotation(1);
v2(0) = v2_(0);
v2(1) = v2_(1);
}
if (dim == 3) {
auto v2 = getRandomVector();
- v2 = (v2 - v2.dot(v1) * v1).normalize();
+ v2 = (v2 - v2.dot(v1) * v1).normalize();
Vector<Real> v3(3);
v3.crossProduct(v1, v2);
rotation(1) = v2;
rotation(2) = v3;
}
//#define debug_
#if defined(debug_)
if (dim == 2)
rotation = Matrix<Real>{{1., 0.}, {0., 1.}};
if (dim == 3)
rotation = Matrix<Real>{{1., 0., 0.}, {0., 1., 0.}, {0., 0., 1.}};
#endif
rotation = rotation.transpose();
return rotation;
}
/* -------------------------------------------------------------------------- */
template <typename T, class Model>
class TestMaterialBaseFixture : public ::testing::Test {
public:
using mat_class = typename T::mat_class;
void SetUp() override {
constexpr auto spatial_dimension = T::Dim;
mesh = std::make_unique<Mesh>(spatial_dimension);
model = std::make_unique<Model>(*mesh);
material = std::make_unique<friend_class>(*model);
material->SetUp();
}
void TearDown() override {
material->TearDown();
material.reset(nullptr);
model.reset(nullptr);
mesh.reset(nullptr);
}
using friend_class = FriendMaterial<mat_class>;
protected:
std::unique_ptr<Mesh> mesh;
std::unique_ptr<Model> model;
std::unique_ptr<friend_class> material;
};
/* -------------------------------------------------------------------------- */
template <template <UInt> class T, UInt _Dim> struct Traits {
using mat_class = T<_Dim>;
static constexpr UInt Dim = _Dim;
};
/* -------------------------------------------------------------------------- */
template <typename T>
using TestMaterialFixture = TestMaterialBaseFixture<T, SolidMechanicsModel>;
/* -------------------------------------------------------------------------- */
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_mazars.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_material_mazars.cc
index fcf9aa9e7..aaf68f72e 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_mazars.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_mazars.cc
@@ -1,289 +1,289 @@
/**
* @file test_material_mazars.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Clement Roux <clement.roux@epfl.ch>
*
* @date creation: Thu Oct 08 2015
* @date last modification: Sun Jul 09 2017
*
* @brief test for material mazars, dissymmetric
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
-#include "solid_mechanics_model.hh"
#include "mesh_accessor.hh"
+#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
#include <fstream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
debug::setDebugLevel(akantu::dblWarning);
akantu::initialize("material_mazars.dat", argc, argv);
const UInt spatial_dimension = 3;
// ElementType type = _quadrangle_4;
ElementType type = _hexahedron_8;
Mesh mesh(spatial_dimension);
MeshAccessor mesh_accessor(mesh);
Array<Real> & nodes = mesh_accessor.getNodes();
Array<UInt> & connectivity = mesh_accessor.getConnectivity(type);
const Real width = 1;
UInt nb_dof = 0;
connectivity.resize(1);
if (type == _hexahedron_8) {
nb_dof = 8;
nodes.resize(nb_dof);
nodes(0, 0) = 0.;
nodes(0, 1) = 0.;
nodes(0, 2) = 0.;
nodes(1, 0) = width;
nodes(1, 1) = 0.;
nodes(1, 2) = 0.;
nodes(2, 0) = width;
nodes(2, 1) = width;
nodes(2, 2) = 0;
nodes(3, 0) = 0;
nodes(3, 1) = width;
nodes(3, 2) = 0;
nodes(4, 0) = 0.;
nodes(4, 1) = 0.;
nodes(4, 2) = width;
nodes(5, 0) = width;
nodes(5, 1) = 0.;
nodes(5, 2) = width;
nodes(6, 0) = width;
nodes(6, 1) = width;
nodes(6, 2) = width;
nodes(7, 0) = 0;
nodes(7, 1) = width;
nodes(7, 2) = width;
connectivity(0, 0) = 0;
connectivity(0, 1) = 1;
connectivity(0, 2) = 2;
connectivity(0, 3) = 3;
connectivity(0, 4) = 4;
connectivity(0, 5) = 5;
connectivity(0, 6) = 6;
connectivity(0, 7) = 7;
} else if (type == _quadrangle_4) {
nb_dof = 4;
nodes.resize(nb_dof);
nodes(0, 0) = 0.;
nodes(0, 1) = 0.;
nodes(1, 0) = width;
nodes(1, 1) = 0;
nodes(2, 0) = width;
nodes(2, 1) = width;
nodes(3, 0) = 0.;
nodes(3, 1) = width;
connectivity(0, 0) = 0;
connectivity(0, 1) = 1;
connectivity(0, 2) = 2;
connectivity(0, 3) = 3;
}
mesh_accessor.makeReady();
SolidMechanicsModel model(mesh);
model.initFull();
Material & mat = model.getMaterial(0);
std::cout << mat << std::endl;
/// boundary conditions
Array<Real> & disp = model.getDisplacement();
Array<Real> & velo = model.getVelocity();
Array<bool> & boun = model.getBlockedDOFs();
for (UInt i = 0; i < nb_dof; ++i) {
boun(i, 0) = true;
}
Real time_step = model.getStableTimeStep() * .5;
// Real time_step = 1e-5;
std::cout << "Time Step = " << time_step
<< "s - nb elements : " << mesh.getNbElement(type) << std::endl;
model.setTimeStep(time_step);
std::ofstream energy;
energy.open("energies_and_scalar_mazars.csv");
energy << "id,rtime,epot,ekin,u,wext,kin+pot,D,strain_xx,strain_yy,stress_xx,"
"stress_yy,edis,tot"
<< std::endl;
/// Set dumper
model.setBaseName("uniaxial_comp-trac_mazars");
model.addDumpFieldVector("displacement");
model.addDumpField("velocity");
model.addDumpField("acceleration");
model.addDumpField("damage");
model.addDumpField("strain");
model.addDumpField("stress");
model.addDumpField("partitions");
model.dump();
const Array<Real> & strain = mat.getGradU(type);
const Array<Real> & stress = mat.getStress(type);
const Array<Real> & damage = mat.getArray<Real>("damage", type);
/* ------------------------------------------------------------------------ */
/* Main loop */
/* ------------------------------------------------------------------------ */
Real wext = 0.;
Real sigma_max = 0, sigma_min = 0;
Real max_disp;
Real stress_xx_compression_1;
UInt nb_steps = 7e5 / 150;
Real adisp = 0;
for (UInt s = 0; s < nb_steps; ++s) {
if (s == 0) {
max_disp = 0.003;
adisp = -(max_disp * 8. / nb_steps) / 2.;
std::cout << "Step " << s << " compression: " << max_disp << std::endl;
}
if (s == (2 * nb_steps / 8)) {
stress_xx_compression_1 = stress(0, 0);
max_disp = 0 + max_disp;
adisp = max_disp * 8. / nb_steps;
std::cout << "Step " << s << " discharge" << std::endl;
}
if (s == (3 * nb_steps / 8)) {
max_disp = 0.004;
adisp = -max_disp * 8. / nb_steps;
std::cout << "Step " << s << " compression: " << max_disp << std::endl;
}
if (s == (4 * nb_steps / 8)) {
if (stress(0, 0) < stress_xx_compression_1) {
std::cout << "after this second compression step softening should have "
"started"
<< std::endl;
return EXIT_FAILURE;
}
max_disp = 0.0015 + max_disp;
adisp = max_disp * 8. / nb_steps;
std::cout << "Step " << s << " discharge tension: " << max_disp
<< std::endl;
}
if (s == (5 * nb_steps / 8)) {
max_disp = 0. + 0.0005;
adisp = -max_disp * 8. / nb_steps;
std::cout << "Step " << s << " discharge" << std::endl;
}
if (s == (6 * nb_steps / 8)) {
max_disp = 0.0035 - 0.001;
adisp = max_disp * 8. / nb_steps;
std::cout << "Step " << s << " tension: " << max_disp << std::endl;
}
if (s == (7 * nb_steps / 8)) {
// max_disp = max_disp;
adisp = -max_disp * 8. / nb_steps;
std::cout << "Step " << s << " discharge" << std::endl;
}
for (UInt i = 0; i < nb_dof; ++i) {
if (std::abs(nodes(i, 0) - width) <
std::numeric_limits<Real>::epsilon()) {
disp(i, 0) += adisp;
velo(i, 0) = adisp / time_step;
}
}
std::cout << "S: " << s << "/" << nb_steps << " inc disp: " << adisp
<< " disp: " << std::setw(5) << disp(2, 0) << "\r" << std::flush;
model.solveStep();
Real epot = model.getEnergy("potential");
Real ekin = model.getEnergy("kinetic");
Real edis = model.getEnergy("dissipated");
wext += model.getEnergy("external work");
sigma_max = std::max(sigma_max, stress(0, 0));
sigma_min = std::min(sigma_min, stress(0, 0));
if (s % 10 == 0)
energy << s << "," // 1
<< s * time_step << "," // 2
<< epot << "," // 3
<< ekin << "," // 4
<< disp(2, 0) << "," // 5
<< wext << "," // 6
<< epot + ekin << "," // 7
<< damage(0) << "," // 8
<< strain(0, 0) << "," // 9
<< strain(0, 3) << "," // 11
<< stress(0, 0) << "," // 10
<< stress(0, 3) << "," // 10
<< edis << "," // 12
<< epot + ekin + edis // 13
<< std::endl;
if (s % 100 == 0)
model.dump();
}
std::cout << std::endl
<< "sigma_max = " << sigma_max << ", sigma_min = " << sigma_min
<< std::endl;
/// Verif the maximal/minimal stress values
if ((std::abs(sigma_max) > std::abs(sigma_min)) or
(std::abs(sigma_max - 6.24e6) > 1e5) or
(std::abs(sigma_min + 2.943e7) > 1e6))
return EXIT_FAILURE;
energy.close();
akantu::finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_thermal.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_material_thermal.cc
index fbbeaad24..0363f3d6b 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_thermal.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_thermal.cc
@@ -1,105 +1,105 @@
/**
* @file test_material_thermal.cc
*
* @author Lucas Frerot <lucas.frerot@epfl.ch>
*
* @date creation: Wed Aug 04 2010
* @date last modification: Mon Jan 29 2018
*
* @brief Test the thermal material
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_thermal.hh"
#include "solid_mechanics_model.hh"
#include "test_material_fixtures.hh"
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <type_traits>
/* -------------------------------------------------------------------------- */
using namespace akantu;
using mat_types =
::testing::Types<Traits<MaterialThermal, 1>, Traits<MaterialThermal, 2>,
Traits<MaterialThermal, 3>>;
/* -------------------------------------------------------------------------- */
template <> void FriendMaterial<MaterialThermal<3>>::testComputeStress() {
Real E = 1.;
Real nu = .3;
Real alpha = 2;
setParam("E", E);
setParam("nu", nu);
setParam("alpha", alpha);
Real deltaT = 1;
Real sigma = 0;
this->computeStressOnQuad(sigma, deltaT);
Real solution = -E / (1 - 2 * nu) * alpha * deltaT;
auto error = std::abs(sigma - solution);
ASSERT_NEAR(error, 0, 1e-14);
}
template <> void FriendMaterial<MaterialThermal<2>>::testComputeStress() {
Real E = 1.;
Real nu = .3;
Real alpha = 2;
setParam("E", E);
setParam("nu", nu);
setParam("alpha", alpha);
Real deltaT = 1;
Real sigma = 0;
this->computeStressOnQuad(sigma, deltaT);
Real solution = -E / (1 - 2 * nu) * alpha * deltaT;
auto error = std::abs(sigma - solution);
ASSERT_NEAR(error, 0, 1e-14);
}
template <> void FriendMaterial<MaterialThermal<1>>::testComputeStress() {
Real E = 1.;
Real nu = .3;
Real alpha = 2;
setParam("E", E);
setParam("nu", nu);
setParam("alpha", alpha);
Real deltaT = 1;
Real sigma = 0;
this->computeStressOnQuad(sigma, deltaT);
Real solution = -E * alpha * deltaT;
auto error = std::abs(sigma - solution);
ASSERT_NEAR(error, 0, 1e-14);
}
namespace {
template <typename T>
class TestMaterialThermalFixture : public ::TestMaterialFixture<T> {};
TYPED_TEST_SUITE(TestMaterialThermalFixture, mat_types);
TYPED_TEST(TestMaterialThermalFixture, ThermalComputeStress) {
this->material->testComputeStress();
}
-}
+} // namespace
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation.cc
index 8cd0e2a78..525cce38b 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic/test_material_standard_linear_solid_deviatoric_relaxation.cc
@@ -1,171 +1,170 @@
/**
* @file test_material_standard_linear_solid_deviatoric_relaxation.cc
*
* @author David Simon Kammer <david.kammer@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Vladislav Yastrebov <vladislav.yastrebov@epfl.ch>
*
* @date creation: Mon Aug 09 2010
* @date last modification: Mon Jun 12 2017
*
* @brief test of the viscoelastic material: relaxation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <iostream>
#include <limits>
#include <sstream>
/* -------------------------------------------------------------------------- */
#include "solid_mechanics_model.hh"
using namespace akantu;
int main(int argc, char * argv[]) {
akantu::initialize("material_standard_linear_solid_deviatoric_relaxation.dat",
argc, argv);
akantu::debug::setDebugLevel(akantu::dblWarning);
// sim data
Real T = 10.;
Real eps = 0.001;
const UInt dim = 2;
Real sim_time = 25.;
Real time_factor = 0.1;
Real tolerance = 1e-7;
Mesh mesh(dim);
mesh.read("test_material_standard_linear_solid_deviatoric_relaxation.msh");
const ElementType element_type = _quadrangle_4;
SolidMechanicsModel model(mesh);
/* ------------------------------------------------------------------------ */
/* Initialization */
/* ------------------------------------------------------------------------ */
model.initFull();
std::cout << model.getMaterial(0) << std::endl;
model.assembleMassLumped();
std::stringstream filename_sstr;
filename_sstr
<< "test_material_standard_linear_solid_deviatoric_relaxation.out";
std::ofstream output_data;
output_data.open(filename_sstr.str().c_str());
output_data << "#[1]-time [2]-sigma_analytic [3+]-sigma_measurements"
<< std::endl;
Material & mat = model.getMaterial(0);
const Array<Real> & stress = mat.getStress(element_type);
Real Eta = mat.get("Eta");
Real EV = mat.get("Ev");
Real Einf = mat.get("Einf");
Real nu = mat.get("nu");
Real Ginf = Einf / (2 * (1 + nu));
Real G = EV / (2 * (1 + nu));
Real G0 = G + Ginf;
Real gamma = G / G0;
Real tau = Eta / EV;
Real gammainf = Ginf / G0;
UInt nb_nodes = mesh.getNbNodes();
const Array<Real> & coordinate = mesh.getNodes();
Array<Real> & displacement = model.getDisplacement();
/// Setting time step
Real time_step = model.getStableTimeStep() * time_factor;
std::cout << "Time Step = " << time_step << "s" << std::endl;
model.setTimeStep(time_step);
UInt max_steps = sim_time / time_step;
UInt out_interval = 1;
Real time = 0.;
/* ------------------------------------------------------------------------ */
/* Main loop */
/* ------------------------------------------------------------------------ */
for (UInt s = 0; s <= max_steps; ++s) {
if (s % 1000 == 0)
std::cerr << "passing step " << s << "/" << max_steps << std::endl;
time = s * time_step;
// impose displacement
Real epsilon = 0.;
if (time < T) {
epsilon = eps * time / T;
} else {
epsilon = eps;
}
for (UInt n = 0; n < nb_nodes; ++n) {
displacement(n, 0) = epsilon * coordinate(n, 1);
displacement(n, 1) = epsilon * coordinate(n, 0);
}
// compute stress
model.assembleInternalForces();
// print output
if (s % out_interval == 0) {
// analytical solution
Real solution = 0.;
if (time < T) {
solution = 2 * G0 * eps / T *
(gammainf * time + gamma * tau * (1 - exp(-time / tau)));
} else {
- solution =
- 2 * G0 * eps *
- (gammainf +
- gamma * tau / T * (exp((T - time) / tau) - exp(-time / tau)));
+ solution = 2 * G0 * eps *
+ (gammainf + gamma * tau / T *
+ (exp((T - time) / tau) - exp(-time / tau)));
}
output_data << s * time_step << " " << solution;
// data output
Array<Real>::const_matrix_iterator stress_it = stress.begin(dim, dim);
Array<Real>::const_matrix_iterator stress_end = stress.end(dim, dim);
for (; stress_it != stress_end; ++stress_it) {
output_data << " " << (*stress_it)(0, 1) << " " << (*stress_it)(1, 0);
// test error
Real rel_error_1 = std::abs(((*stress_it)(0, 1) - solution) / solution);
Real rel_error_2 = std::abs(((*stress_it)(1, 0) - solution) / solution);
if (rel_error_1 > tolerance || rel_error_2 > tolerance) {
std::cerr << "Relative error: " << rel_error_1 << " " << rel_error_2
<< std::endl;
return EXIT_FAILURE;
}
}
output_data << std::endl;
}
}
finalize();
std::cout << "Test successful!" << std::endl;
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell/test_material_viscoelastic_maxwell_relaxation.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell/test_material_viscoelastic_maxwell_relaxation.cc
index bd6af90dc..e6e5ac98a 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell/test_material_viscoelastic_maxwell_relaxation.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_material_viscoelastic_maxwell/test_material_viscoelastic_maxwell_relaxation.cc
@@ -1,196 +1,195 @@
/**
* @file test_material_viscoelastic_maxwell_relaxation.cc
*
* @author Emil Gallyamov <emil.gallyamov@epfl.ch>
*
* @date creation: Thu May 17 2018
* @date last modification:
*
* @brief test of the viscoelastic material: relaxation
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <iostream>
#include <limits>
#include <sstream>
/* -------------------------------------------------------------------------- */
#include "material_viscoelastic_maxwell.hh"
#include "non_linear_solver.hh"
#include "solid_mechanics_model.hh"
#include "sparse_matrix.hh"
using namespace akantu;
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
-int main(int argc, char *argv[]) {
+int main(int argc, char * argv[]) {
akantu::initialize("material_viscoelastic_maxwell.dat", argc, argv);
// sim data
Real eps = 0.1;
const UInt dim = 2;
Real sim_time = 100.;
Real T = 10.;
Real tolerance = 1e-6;
Mesh mesh(dim);
mesh.read("test_material_viscoelastic_maxwell.msh");
const ElementType element_type = _quadrangle_4;
SolidMechanicsModel model(mesh);
/* ------------------------------------------------------------------------ */
/* Initialization */
/* ------------------------------------------------------------------------ */
model.initFull(_analysis_method = _static);
std::cout << model.getMaterial(0) << std::endl;
std::stringstream filename_sstr;
filename_sstr << "test_material_viscoelastic_maxwell.out";
std::ofstream output_data;
output_data.open(filename_sstr.str().c_str());
- Material &mat = model.getMaterial(0);
+ Material & mat = model.getMaterial(0);
- const Array<Real> &stress = mat.getStress(element_type);
+ const Array<Real> & stress = mat.getStress(element_type);
Vector<Real> Eta = mat.get("Eta");
Vector<Real> Ev = mat.get("Ev");
Real Einf = mat.get("Einf");
Real nu = mat.get("nu");
Real lambda = Eta(0) / Ev(0);
Real pre_mult = 1 / (1 + nu) / (1 - 2 * nu);
Real time_step = 0.1;
UInt nb_nodes = mesh.getNbNodes();
- const Array<Real> &coordinate = mesh.getNodes();
- Array<Real> &displacement = model.getDisplacement();
- Array<bool> &blocked = model.getBlockedDOFs();
+ const Array<Real> & coordinate = mesh.getNodes();
+ Array<Real> & displacement = model.getDisplacement();
+ Array<bool> & blocked = model.getBlockedDOFs();
/// Setting time step
model.setTimeStep(time_step);
UInt max_steps = sim_time / time_step + 1;
Real time = 0.;
- auto &solver = model.getNonLinearSolver();
+ auto & solver = model.getNonLinearSolver();
solver.set("max_iterations", 200);
solver.set("threshold", 1e-7);
solver.set("convergence_type", SolveConvergenceCriteria::_residual);
/* ------------------------------------------------------------------------ */
/* Main loop */
/* ------------------------------------------------------------------------ */
for (UInt s = 0; s <= max_steps; ++s) {
std::cout << "Time Step = " << time_step << "s" << std::endl;
std::cout << "Time = " << time << std::endl;
// impose displacement
Real epsilon = 0;
if (time < T) {
epsilon = eps * time / T;
} else {
epsilon = eps;
}
for (UInt n = 0; n < nb_nodes; ++n) {
if (Math::are_float_equal(coordinate(n, 0), 0.0)) {
displacement(n, 0) = 0;
blocked(n, 0) = true;
displacement(n, 1) = epsilon * coordinate(n, 1);
blocked(n, 1) = true;
} else if (Math::are_float_equal(coordinate(n, 1), 0.0)) {
displacement(n, 0) = epsilon * coordinate(n, 0);
blocked(n, 0) = true;
displacement(n, 1) = 0;
blocked(n, 1) = true;
} else if (Math::are_float_equal(coordinate(n, 0), 0.001)) {
displacement(n, 0) = epsilon * coordinate(n, 0);
blocked(n, 0) = true;
displacement(n, 1) = epsilon * coordinate(n, 1);
blocked(n, 1) = true;
} else if (Math::are_float_equal(coordinate(n, 1), 0.001)) {
displacement(n, 0) = epsilon * coordinate(n, 0);
blocked(n, 0) = true;
displacement(n, 1) = epsilon * coordinate(n, 1);
blocked(n, 1) = true;
}
}
try {
model.solveStep();
- } catch (debug::Exception &e) {
+ } catch (debug::Exception & e) {
}
Int nb_iter = solver.get("nb_iterations");
Real error = solver.get("error");
bool converged = solver.get("converged");
if (converged) {
std::cout << "Converged in " << nb_iter << " iterations" << std::endl;
} else {
std::cout << "Didn't converge after " << nb_iter
<< " iterations. Error is " << error << std::endl;
return EXIT_FAILURE;
}
// analytical solution
Real solution_11 = 0.;
if (time < T) {
solution_11 = pre_mult * eps / T *
- (Einf * time + lambda * Ev(0) * (1 - exp(-time / lambda)));
+ (Einf * time + lambda * Ev(0) * (1 - exp(-time / lambda)));
} else {
- solution_11 = pre_mult * eps *
- (Einf +
- lambda * Ev(0) / T *
- (exp((T - time) / lambda) - exp(-time / lambda)));
+ solution_11 =
+ pre_mult * eps *
+ (Einf + lambda * Ev(0) / T *
+ (exp((T - time) / lambda) - exp(-time / lambda)));
}
// data output
- output_data << s * time_step << " " << epsilon << " " << solution_11;
+ output_data << s * time_step << " " << epsilon << " " << solution_11;
Array<Real>::const_matrix_iterator stress_it = stress.begin(dim, dim);
Array<Real>::const_matrix_iterator stress_end = stress.end(dim, dim);
for (; stress_it != stress_end; ++stress_it) {
output_data << " " << (*stress_it)(0, 0);
// test error
Real rel_error_11 =
std::abs(((*stress_it)(0, 0) - solution_11) / solution_11);
if (rel_error_11 > tolerance) {
std::cerr << "Relative error: " << rel_error_11 << std::endl;
return EXIT_FAILURE;
}
}
output_data << std::endl;
time += time_step;
-
}
output_data.close();
finalize();
std::cout << "Test successful!" << std::endl;
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc b/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc
index 1eed9fb47..956907d48 100644
--- a/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc
+++ b/test/test_model/test_solid_mechanics_model/test_materials/test_plastic_materials.cc
@@ -1,192 +1,192 @@
/**
* @file test_plastic_materials.cc
*
* @author Guillaume Anciaux <guillaume.anciaux@epfl.ch>
*
* @date creation: Fri Nov 17 2017
* @date last modification: Wed Feb 21 2018
*
* @brief Tests the plastic material
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "material_linear_isotropic_hardening.hh"
#include "solid_mechanics_model.hh"
#include "test_material_fixtures.hh"
#include <gtest/gtest.h>
#include <type_traits>
/* -------------------------------------------------------------------------- */
using namespace akantu;
using mat_types = ::testing::Types<
-// Traits<MaterialLinearIsotropicHardening, 1>,
-// Traits<MaterialLinearIsotropicHardening, 2>,
- Traits<MaterialLinearIsotropicHardening, 3>>;
+ // Traits<MaterialLinearIsotropicHardening, 1>,
+ // Traits<MaterialLinearIsotropicHardening, 2>,
+ Traits<MaterialLinearIsotropicHardening, 3>>;
/* -------------------------------------------------------------------------- */
template <>
void FriendMaterial<MaterialLinearIsotropicHardening<3>>::testComputeStress() {
Real E = 1.;
// Real nu = .3;
Real nu = 0.;
Real rho = 1.;
Real sigma_0 = 1.;
Real h = 0.;
Real bulk_modulus_K = E / 3. / (1 - 2. * nu);
Real shear_modulus_mu = 0.5 * E / (1 + nu);
setParam("E", E);
setParam("nu", nu);
setParam("rho", rho);
setParam("sigma_y", sigma_0);
setParam("h", h);
auto rotation_matrix = getRandomRotation();
Real max_strain = 10.;
Real strain_steps = 100;
Real dt = max_strain / strain_steps;
std::vector<double> steps(strain_steps);
std::iota(steps.begin(), steps.end(), 0.);
Matrix<Real> previous_grad_u_rot(3, 3, 0.);
Matrix<Real> previous_sigma(3, 3, 0.);
Matrix<Real> previous_sigma_rot(3, 3, 0.);
Matrix<Real> inelastic_strain_rot(3, 3, 0.);
Matrix<Real> inelastic_strain(3, 3, 0.);
Matrix<Real> previous_inelastic_strain(3, 3, 0.);
Matrix<Real> previous_inelastic_strain_rot(3, 3, 0.);
Matrix<Real> sigma_rot(3, 3, 0.);
Real iso_hardening = 0.;
Real previous_iso_hardening = 0.;
// hydrostatic loading (should not plastify)
for (auto && i : steps) {
auto t = i * dt;
auto grad_u = this->getHydrostaticStrain(t);
auto grad_u_rot = this->applyRotation(grad_u, rotation_matrix);
this->computeStressOnQuad(grad_u_rot, previous_grad_u_rot, sigma_rot,
previous_sigma_rot, inelastic_strain_rot,
previous_inelastic_strain_rot, iso_hardening,
previous_iso_hardening, 0., 0.);
auto sigma = this->reverseRotation(sigma_rot, rotation_matrix);
Matrix<Real> sigma_expected =
t * 3. * bulk_modulus_K * Matrix<Real>::eye(3, 1.);
Real stress_error = (sigma - sigma_expected).norm<L_inf>();
ASSERT_NEAR(stress_error, 0., 1e-13);
ASSERT_NEAR(inelastic_strain_rot.norm<L_inf>(), 0., 1e-13);
previous_grad_u_rot = grad_u_rot;
previous_sigma_rot = sigma_rot;
previous_inelastic_strain_rot = inelastic_strain_rot;
previous_iso_hardening = iso_hardening;
}
// deviatoric loading (should plastify)
// stress at onset of plastication
Real beta = sqrt(42);
Real t_P = sigma_0 / 2. / shear_modulus_mu / beta;
Matrix<Real> sigma_P = sigma_0 / beta * this->getDeviatoricStrain(1.);
for (auto && i : steps) {
auto t = i * dt;
auto grad_u = this->getDeviatoricStrain(t);
auto grad_u_rot = this->applyRotation(grad_u, rotation_matrix);
Real iso_hardening, previous_iso_hardening;
this->computeStressOnQuad(grad_u_rot, previous_grad_u_rot, sigma_rot,
previous_sigma_rot, inelastic_strain_rot,
previous_inelastic_strain_rot, iso_hardening,
previous_iso_hardening, 0., 0.);
auto sigma = this->reverseRotation(sigma_rot, rotation_matrix);
auto inelastic_strain =
this->reverseRotation(inelastic_strain_rot, rotation_matrix);
if (t < t_P) {
Matrix<Real> sigma_expected =
shear_modulus_mu * (grad_u + grad_u.transpose());
Real stress_error = (sigma - sigma_expected).norm<L_inf>();
ASSERT_NEAR(stress_error, 0., 1e-13);
ASSERT_NEAR(inelastic_strain_rot.norm<L_inf>(), 0., 1e-13);
} else if (t > t_P + dt) {
// skip the transition from non plastic to plastic
auto delta_lambda_expected =
dt / t * previous_sigma.doubleDot(grad_u + grad_u.transpose()) / 2.;
auto delta_inelastic_strain_expected =
delta_lambda_expected * 3. / 2. / sigma_0 * previous_sigma;
auto inelastic_strain_expected =
delta_inelastic_strain_expected + previous_inelastic_strain;
ASSERT_NEAR((inelastic_strain - inelastic_strain_expected).norm<L_inf>(),
0., 1e-13);
auto delta_sigma_expected =
2. * shear_modulus_mu *
(0.5 * dt / t * (grad_u + grad_u.transpose()) -
delta_inelastic_strain_expected);
auto delta_sigma = sigma - previous_sigma;
ASSERT_NEAR((delta_sigma_expected - delta_sigma).norm<L_inf>(), 0.,
1e-13);
}
previous_sigma = sigma;
previous_sigma_rot = sigma_rot;
previous_grad_u_rot = grad_u_rot;
previous_inelastic_strain = inelastic_strain;
previous_inelastic_strain_rot = inelastic_strain_rot;
}
}
namespace {
template <typename T>
class TestPlasticMaterialFixture : public ::TestMaterialFixture<T> {};
TYPED_TEST_SUITE(TestPlasticMaterialFixture, mat_types);
TYPED_TEST(TestPlasticMaterialFixture, ComputeStress) {
this->material->testComputeStress();
}
TYPED_TEST(TestPlasticMaterialFixture, DISABLED_EnergyDensity) {
this->material->testEnergyDensity();
}
TYPED_TEST(TestPlasticMaterialFixture, DISABLED_ComputeTangentModuli) {
this->material->testComputeTangentModuli();
}
TYPED_TEST(TestPlasticMaterialFixture, DISABLED_ComputeCelerity) {
this->material->testCelerity();
}
-}
+} // namespace
/*****************************************************************/
diff --git a/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_material_eigenstrain.cc b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_material_eigenstrain.cc
index 660021215..0965e4508 100644
--- a/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_material_eigenstrain.cc
+++ b/test/test_model/test_solid_mechanics_model/test_solid_mechanics_model_material_eigenstrain.cc
@@ -1,200 +1,201 @@
/**
* @file test_solid_mechanics_model_material_eigenstrain.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Sat Apr 16 2011
* @date last modification: Thu Feb 01 2018
*
* @brief test the internal field prestrain
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "mesh_utils.hh"
#include "non_linear_solver.hh"
#include "solid_mechanics_model.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
Real alpha[3][4] = {{0.01, 0.02, 0.03, 0.04},
{0.05, 0.06, 0.07, 0.08},
{0.09, 0.10, 0.11, 0.12}};
/* -------------------------------------------------------------------------- */
template <ElementType type> static Matrix<Real> prescribed_strain() {
UInt spatial_dimension = ElementClass<type>::getSpatialDimension();
Matrix<Real> strain(spatial_dimension, spatial_dimension);
for (UInt i = 0; i < spatial_dimension; ++i) {
for (UInt j = 0; j < spatial_dimension; ++j) {
strain(i, j) = alpha[i][j + 1];
}
}
return strain;
}
template <ElementType type>
static Matrix<Real> prescribed_stress(Matrix<Real> prescribed_eigengradu) {
UInt spatial_dimension = ElementClass<type>::getSpatialDimension();
Matrix<Real> stress(spatial_dimension, spatial_dimension);
// plane strain in 2d
Matrix<Real> strain(spatial_dimension, spatial_dimension);
Matrix<Real> pstrain;
pstrain = prescribed_strain<type>();
Real nu = 0.3;
Real E = 2.1e11;
Real trace = 0;
/// symetric part of the strain tensor
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j)
strain(i, j) = 0.5 * (pstrain(i, j) + pstrain(j, i));
// elastic strain is equal to elastic strain minus the eigenstrain
strain -= prescribed_eigengradu;
for (UInt i = 0; i < spatial_dimension; ++i)
trace += strain(i, i);
Real lambda = nu * E / ((1 + nu) * (1 - 2 * nu));
Real mu = E / (2 * (1 + nu));
if (spatial_dimension == 1) {
stress(0, 0) = E * strain(0, 0);
} else {
for (UInt i = 0; i < spatial_dimension; ++i)
for (UInt j = 0; j < spatial_dimension; ++j) {
stress(i, j) = (i == j) * lambda * trace + 2 * mu * strain(i, j);
}
}
return stress;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize("material_elastic_plane_strain.dat", argc, argv);
UInt dim = 3;
const ElementType element_type = _tetrahedron_4;
Matrix<Real> prescribed_eigengradu(dim, dim);
prescribed_eigengradu.set(0.1);
/// load mesh
Mesh mesh(dim);
mesh.read("cube_3d_tet_4.msh");
/// declaration of model
SolidMechanicsModel model(mesh);
/// model initialization
model.initFull(_analysis_method = _static);
- //model.getNewSolver("static", TimeStepSolverType::_static, NonLinearSolverType::_newton_raphson_modified);
+ // model.getNewSolver("static", TimeStepSolverType::_static,
+ // NonLinearSolverType::_newton_raphson_modified);
auto & solver = model.getNonLinearSolver("static");
solver.set("threshold", 2e-4);
solver.set("max_iterations", 2);
solver.set("convergence_type", SolveConvergenceCriteria::_residual);
const Array<Real> & coordinates = mesh.getNodes();
Array<Real> & displacement = model.getDisplacement();
Array<bool> & boundary = model.getBlockedDOFs();
MeshUtils::buildFacets(mesh);
mesh.createBoundaryGroupFromGeometry();
// Loop over (Sub)Boundar(ies)
for (auto & group : mesh.iterateElementGroups()) {
for (const auto & n : group.getNodeGroup()) {
std::cout << "Node " << n << std::endl;
for (UInt i = 0; i < dim; ++i) {
displacement(n, i) = alpha[i][0];
for (UInt j = 0; j < dim; ++j) {
displacement(n, i) += alpha[i][j + 1] * coordinates(n, j);
}
boundary(n, i) = true;
}
}
}
/* ------------------------------------------------------------------------ */
/* Apply eigenstrain in each element */
/* ------------------------------------------------------------------------ */
Array<Real> & eigengradu_vect =
model.getMaterial(0).getInternal<Real>("eigen_grad_u")(element_type);
auto eigengradu_it = eigengradu_vect.begin(dim, dim);
auto eigengradu_end = eigengradu_vect.end(dim, dim);
for (; eigengradu_it != eigengradu_end; ++eigengradu_it) {
*eigengradu_it = prescribed_eigengradu;
}
/* ------------------------------------------------------------------------ */
/* Static solve */
/* ------------------------------------------------------------------------ */
model.solveStep();
std::cout << "Converged in " << Int(solver.get("nb_iterations")) << " ("
<< Real(solver.get("error")) << ")" << std::endl;
/* ------------------------------------------------------------------------ */
/* Checks */
/* ------------------------------------------------------------------------ */
const Array<Real> & stress_vect =
model.getMaterial(0).getStress(element_type);
auto stress_it = stress_vect.begin(dim, dim);
auto stress_end = stress_vect.end(dim, dim);
Matrix<Real> presc_stress;
presc_stress = prescribed_stress<element_type>(prescribed_eigengradu);
Real stress_tolerance = 1e-13;
for (; stress_it != stress_end; ++stress_it) {
const auto & stress = *stress_it;
Matrix<Real> diff(dim, dim);
diff = stress;
diff -= presc_stress;
Real stress_error = diff.norm<L_inf>() / stress.norm<L_inf>();
if (stress_error > stress_tolerance) {
std::cerr << "stress error: " << stress_error << " > " << stress_tolerance
<< std::endl;
std::cerr << "stress: " << stress << std::endl
<< "prescribed stress: " << presc_stress << std::endl;
return EXIT_FAILURE;
} // else {
// std::cerr << "stress error: " << stress_error
// << " < " << stress_tolerance << std::endl;
// }
}
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_model/test_structural_mechanics_model/test_structural_mechanics_model_bernoulli_beam_dynamics.cc b/test/test_model/test_structural_mechanics_model/test_structural_mechanics_model_bernoulli_beam_dynamics.cc
index 6bc63cb0e..32ee9a326 100644
--- a/test/test_model/test_structural_mechanics_model/test_structural_mechanics_model_bernoulli_beam_dynamics.cc
+++ b/test/test_model/test_structural_mechanics_model/test_structural_mechanics_model_bernoulli_beam_dynamics.cc
@@ -1,207 +1,208 @@
/**
* @file test_structural_mechanics_model_bernoulli_beam_dynamics.cc
*
* @author Sébastien Hartmann <sebastien.hartmann@epfl.ch>
*
* @date creation: Mon Jul 07 2014
* @date last modification: Wed Feb 03 2016
*
* @brief Test for _bernouilli_beam in dynamic
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <fstream>
#include <limits>
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "material.hh"
#include "mesh.hh"
#include "mesh_io.hh"
#include "mesh_io_msh_struct.hh"
#include "structural_mechanics_model.hh"
#include <iostream>
using namespace akantu;
/* -------------------------------------------------------------------------- */
#define TYPE _bernoulli_beam_2
static Real analytical_solution(Real time, Real L, Real rho, Real E,
__attribute__((unused)) Real A, Real I,
Real F) {
Real omega = M_PI * M_PI / L / L * sqrt(E * I / rho);
Real sum = 0.;
UInt i = 5;
for (UInt n = 1; n <= i; n += 2) {
sum += (1. - cos(n * n * omega * time)) / pow(n, 4);
}
return 2. * F * pow(L, 3) / pow(M_PI, 4) / E / I * sum;
}
// load
const Real F = 0.5e4;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
Mesh beams(2);
debug::setDebugLevel(dblWarning);
const ElementType type = _bernoulli_beam_2;
/* --------------------------------------------------------------------------
*/
// Mesh
UInt nb_element = 8;
UInt nb_nodes = nb_element + 1;
Real total_length = 10.;
Real length = total_length / nb_element;
Real heigth = 1.;
Array<Real> & nodes = const_cast<Array<Real> &>(beams.getNodes());
nodes.resize(nb_nodes);
beams.addConnectivityType(type);
Array<UInt> & connectivity =
const_cast<Array<UInt> &>(beams.getConnectivity(type));
connectivity.resize(nb_element);
beams.initNormals();
Array<Real> & normals = const_cast<Array<Real> &>(beams.getNormals(type));
normals.resize(nb_element);
for (UInt i = 0; i < nb_nodes; ++i) {
nodes(i, 0) = i * length;
nodes(i, 1) = 0;
}
for (UInt i = 0; i < nb_element; ++i) {
connectivity(i, 0) = i;
connectivity(i, 1) = i + 1;
}
/* --------------------------------------------------------------------------
*/
// Materials
StructuralMechanicsModel model(beams);
StructuralMaterial mat1;
mat1.E = 120e6;
mat1.rho = 1000;
mat1.A = heigth;
mat1.I = heigth * heigth * heigth / 12;
model.addMaterial(mat1);
/* --------------------------------------------------------------------------
*/
// Forces
// model.initFull();
model.initFull(StructuralMechanicsModelOptions(_implicit_dynamic));
const Array<Real> & position = beams.getNodes();
Array<Real> & forces = model.getForce();
Array<Real> & displacement = model.getDisplacement();
Array<bool> & boundary = model.getBlockedDOFs();
UInt node_to_print = -1;
forces.clear();
displacement.clear();
// boundary.clear();
// model.getElementMaterial(type)(i,0) = 0;
// model.getElementMaterial(type)(i,0) = 1;
for (UInt i = 0; i < nb_element; ++i) {
model.getElementMaterial(type)(i, 0) = 0;
}
for (UInt n = 0; n < nb_nodes; ++n) {
Real x = position(n, 0);
// Real y = position(n, 1);
if (Math::are_float_equal(x, total_length / 2.)) {
forces(n, 1) = F;
node_to_print = n;
}
}
std::ofstream pos;
pos.open("position.csv");
if (!pos.good()) {
std::cerr << "Cannot open file" << std::endl;
exit(EXIT_FAILURE);
}
pos << "id,time,position,solution" << std::endl;
// model.computeForcesFromFunction<type>(load, _bft_traction)
/* --------------------------------------------------------------------------
*/
// Boundary conditions
// true ~ displacement is blocked
boundary(0, 0) = true;
boundary(0, 1) = true;
boundary(nb_nodes - 1, 1) = true;
/* --------------------------------------------------------------------------
*/
// "Solve"
Real time = 0;
model.assembleStiffnessMatrix();
model.assembleMass();
model.dump();
model.getStiffnessMatrix().saveMatrix("K.mtx");
model.getMassMatrix().saveMatrix("M.mt");
Real time_step = 1e-4;
model.setTimeStep(time_step);
std::cout << "Time"
<< " | "
<< "Mid-Span Displacement" << std::endl;
/// time loop
for (UInt s = 1; time < 0.64; ++s) {
- model.solveStep<_scm_newton_raphson_tangent, SolveConvergenceCriteria::_increment>(1e-12, 1000);
+ model.solveStep<_scm_newton_raphson_tangent,
+ SolveConvergenceCriteria::_increment>(1e-12, 1000);
pos << s << "," << time << "," << displacement(node_to_print, 1) << ","
<< analytical_solution(s * time_step, total_length, mat1.rho, mat1.E,
mat1.A, mat1.I, F)
<< std::endl;
// pos << s << "," << time << "," << displacement(node_to_print, 1) <<
// "," << analytical_solution(s*time_step) << std::endl;
time += time_step;
if (s % 100 == 0)
std::cout << time << " | " << displacement(node_to_print, 1)
<< std::endl;
model.dump();
}
pos.close();
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_python_interface/CMakeLists.txt b/test/test_python_interface/CMakeLists.txt
index 6bc80a4bf..3bcf21510 100644
--- a/test/test_python_interface/CMakeLists.txt
+++ b/test/test_python_interface/CMakeLists.txt
@@ -1,52 +1,53 @@
#===============================================================================
# @file CMakeLists.txt
#
# @author Fabian Barras <fabian.barras@epfl.ch>
# @author Lucas Frerot <lucas.frerot@epfl.ch>
#
# @date creation: Fri Sep 03 2010
# @date last modification: Mon Feb 05 2018
#
# @brief Python Interface tests
#
# @section LICENSE
#
# Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
# Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
#
# Akantu is free software: you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
# A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
# details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with Akantu. If not, see <http://www.gnu.org/licenses/>.
#
#===============================================================================
get_target_property(_srcs py11_akantu SOURCES)
foreach(_src ${_srcs})
list(APPEND py11_akantu_test_common_SRCS ${PROJECT_SOURCE_DIR}/python/${_src})
endforeach()
akantu_pybind11_add_module(py11_akantu_test_common MODULE
test_common.cc
${py11_akantu_test_common_SRCS})
target_link_libraries(py11_akantu_test_common
PRIVATE $<TARGET_PROPERTY:py11_akantu,LINK_LIBRARIES>)
target_include_directories(py11_akantu_test_common
PRIVATE $<TARGET_PROPERTY:py11_akantu,INCLUDE_DIRECTORIES>)
+
add_mesh(mesh_dcb_2d mesh_dcb_2d.geo 2 2)
register_test(test_python_interface
SCRIPT test_pybind.py
PYTHON
FILES_TO_COPY elastic.dat
DEPENDS mesh_dcb_2d py11_akantu_test_common
PACKAGE python_interface
)
diff --git a/test/test_python_interface/test_pybind.py b/test/test_python_interface/test_pybind.py
index ba2e014af..b6c33c9f3 100644
--- a/test/test_python_interface/test_pybind.py
+++ b/test/test_python_interface/test_pybind.py
@@ -1,200 +1,198 @@
#!/bin/env python
import pytest
-import os
-import subprocess
import numpy as np
import py11_akantu_test_common as aka
def test_array_size():
ptr, array = aka.createArray(1000, 3)
assert array.shape == (1000, 3)
def test_array_nocopy():
ptr, array = aka.createArray(1000, 3)
through_python = aka.getRawPointerArray(array)
assert(ptr == through_python)
def test_modify_array():
ptr, array = aka.createArray(3, 3)
array[0, :] = (1., 2., 3.)
array2 = aka.getArray(ptr)
assert(np.linalg.norm(array-array2) < 1e-15)
for i in [1, 2, 3]:
ptr, array = aka.createArray(10000, i)
array[:, :] = np.random.random((10000, i))
array2 = aka.getArray(ptr)
assert(np.linalg.norm(array-array2) < 1e-15)
def test_array_copy():
ptr, array = aka.createArray(1000, 3)
array2 = aka.copyArray(ptr)
ptr2 = aka.getRawPointerArray(array2)
assert(ptr != ptr2)
def test_vector_size():
ptr, vector = aka.createVector(3)
assert vector.shape == (3,)
def test_vector_nocopy():
ptr, vector = aka.createVector(3)
through_python = aka.getRawPointerVector(vector)
assert(ptr == through_python)
def test_modify_vector():
ptr, vector = aka.createVector(3)
vector[:] = (1., 2., 3.)
vector2 = aka.getVector(ptr)
assert(np.linalg.norm(vector-vector2) < 1e-15)
for i in np.arange(1, 10):
ptr, vector = aka.createVector(i)
vector[:] = np.random.random(i)
vector2 = aka.getVector(ptr)
assert(np.linalg.norm(vector-vector2) < 1e-15)
def test_vector_copy():
ptr, vector = aka.createVector(1000)
vector2 = aka.copyVector(ptr)
ptr2 = aka.getRawPointerVector(vector2)
assert(ptr != ptr2)
def test_matrix_size():
ptr, matrix = aka.createMatrix(3, 2)
assert matrix.shape == (3, 2)
def test_matrix_nocopy():
ptr, matrix = aka.createMatrix(3, 2)
through_python = aka.getRawPointerMatrix(matrix)
assert(ptr == through_python)
def test_modify_matrix():
ptr, matrix = aka.createMatrix(2, 3)
matrix[0, :] = (1., 2., 3.)
matrix2 = aka.getMatrix(ptr)
assert(np.linalg.norm(matrix-matrix2) < 1e-15)
for i in np.arange(1, 10):
for j in np.arange(1, 10):
ptr, matrix = aka.createMatrix(i, j)
matrix[:, :] = np.random.random((i, j))
matrix2 = aka.getMatrix(ptr)
assert(np.linalg.norm(matrix-matrix2) < 1e-15)
def test_matrix_copy():
ptr, matrix = aka.createMatrix(10, 3)
matrix2 = aka.copyMatrix(ptr)
ptr2 = aka.getRawPointerMatrix(matrix2)
assert(ptr != ptr2)
def test_multiple_init():
aka.parseInput("elastic.dat")
dcb_mesh = 'mesh_dcb_2d.msh'
print('First initialisation')
mesh = aka.Mesh(2)
mesh.read(dcb_mesh)
model = aka.SolidMechanicsModel(mesh)
model.initFull(aka.SolidMechanicsModelOptions(aka._static))
del model
del mesh
print('Second initialisation')
mesh = aka.Mesh(2)
mesh.read(dcb_mesh)
model = aka.SolidMechanicsModel(mesh)
model.initFull(aka.SolidMechanicsModelOptions(aka._static))
del model
del mesh
print('All right')
def test_boundary_condition_functors():
class FixedValue(aka.DirichletFunctor):
def __init__(self, value, axis):
super().__init__(axis)
self.value = value
self.axis = int(axis)
def __call__(self, node, flags, primal, coord):
primal[self.axis] = self.value
flags[self.axis] = True
class FromStress(aka.NeumannFunctor):
def __init__(self, stress):
super().__init__()
self.stress = stress
def __call__(self, quad_point, dual, coord, normals):
dual[:] = np.dot(self.stress, normals)
aka.parseInput("elastic.dat")
mesh = aka.Mesh(2)
mesh.read("mesh_dcb_2d.msh")
model = aka.SolidMechanicsModel(mesh, 2)
model.initFull()
model.applyBC(FixedValue(0.0, aka._x), "edge")
stress = np.array([[1, 0],
[0, 0]])
blocked_nodes = \
mesh.getElementGroup("edge").getNodeGroup().getNodes().flatten()
boundary = model.getBlockedDOFs()
# Testing that nodes are correctly blocked
for n in blocked_nodes:
assert boundary[n, 0]
boundary.fill(False)
model.applyBC(FromStress(stress), "edge")
force = model.getExternalForce()
# Checking that nodes have a force in the correct direction
for n in blocked_nodes:
assert force[n, 0] > 0
return 0
def test_mesh_interface():
mesh = aka.Mesh(2)
mesh.read("mesh_dcb_2d.msh")
# Tests the getNbElement() function
if mesh.getNbElement(aka._quadrangle_8) != mesh.getNbElement(2):
raise Exception("Number of elements wrong: "
" {0} != {1}".format(
mesh.getNbElement(aka._quadrangle_8),
mesh.getNbElement(2)))
def test_heat_transfer():
mesh = aka.Mesh(2)
model = aka.HeatTransferModel(mesh)
print(aka._explicit_lumped_mass)
model.initFull(aka._explicit_lumped_mass)
if __name__ == '__main__':
import sys
pytest.main(sys.argv)
diff --git a/test/test_solver/test_solver_petsc.cc b/test/test_solver/test_solver_petsc.cc
index 7253c5086..88ffa11df 100644
--- a/test/test_solver/test_solver_petsc.cc
+++ b/test/test_solver/test_solver_petsc.cc
@@ -1,172 +1,172 @@
/**
* @file test_solver_petsc.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
*
* @date creation: Mon Oct 13 2014
* @date last modification: Wed Nov 08 2017
*
* @brief test the PETSc solver interface
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include <cstdlib>
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_csr.hh"
#include "communicator.hh"
#include "dof_synchronizer.hh"
#include "element_synchronizer.hh"
#include "fe_engine.hh"
#include "mesh.hh"
#include "mesh_io.hh"
#include "mesh_utils.hh"
-#include "sparse_matrix_petsc.hh"
#include "solver_petsc.hh"
+#include "sparse_matrix_petsc.hh"
#include "mesh_partition_scotch.hh"
using namespace akantu;
int main(int argc, char * argv[]) {
initialize(argc, argv);
const ElementType element_type = _segment_2;
const GhostType ghost_type = _not_ghost;
UInt spatial_dimension = 1;
const auto & comm = akantu::Communicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
/// read the mesh and partition it
Mesh mesh(spatial_dimension);
/* ------------------------------------------------------------------------ */
/* Parallel initialization */
/* ------------------------------------------------------------------------ */
ElementSynchronizer * communicator = NULL;
if (prank == 0) {
/// creation mesh
mesh.read("1D_bar.msh");
MeshPartitionScotch * partition =
new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
communicator =
ElementSynchronizer::createDistributedSynchronizerMesh(mesh, partition);
delete partition;
} else {
communicator =
ElementSynchronizer::createDistributedSynchronizerMesh(mesh, NULL);
}
FEEngine * fem =
new FEEngineTemplate<IntegratorGauss, ShapeLagrange, _ek_regular>(
mesh, spatial_dimension, "my_fem");
DOFSynchronizer dof_synchronizer(mesh, spatial_dimension);
UInt nb_global_nodes = mesh.getNbGlobalNodes();
dof_synchronizer.initGlobalDOFEquationNumbers();
// fill the matrix with
UInt nb_element = mesh.getNbElement(element_type);
UInt nb_nodes_per_element = mesh.getNbNodesPerElement(element_type);
UInt nb_dofs_per_element = spatial_dimension * nb_nodes_per_element;
SparseMatrix K(nb_global_nodes * spatial_dimension, _symmetric);
K.buildProfile(mesh, dof_synchronizer, spatial_dimension);
Matrix<Real> element_input(nb_dofs_per_element, nb_dofs_per_element, 0);
for (UInt i = 0; i < nb_dofs_per_element; ++i) {
for (UInt j = 0; j < nb_dofs_per_element; ++j) {
element_input(i, j) = ((i == j) ? 1 : -1);
}
}
Array<Real> K_e =
Array<Real>(nb_element, nb_dofs_per_element * nb_dofs_per_element, "K_e");
Array<Real>::matrix_iterator K_e_it =
K_e.begin(nb_dofs_per_element, nb_dofs_per_element);
Array<Real>::matrix_iterator K_e_end =
K_e.end(nb_dofs_per_element, nb_dofs_per_element);
for (; K_e_it != K_e_end; ++K_e_it)
*K_e_it = element_input;
// assemble the test matrix
fem->assembleMatrix(K_e, K, spatial_dimension, element_type, ghost_type);
// apply boundary: block first node
const Array<Real> & position = mesh.getNodes();
UInt nb_nodes = mesh.getNbNodes();
Array<bool> boundary = Array<bool>(nb_nodes, spatial_dimension, false);
for (UInt i = 0; i < nb_nodes; ++i) {
if (std::abs(position(i, 0)) < Math::getTolerance())
boundary(i, 0) = true;
}
K.applyBoundary(boundary);
/// create the PETSc matrix for the solve step
PETScMatrix petsc_matrix(nb_global_nodes * spatial_dimension, _symmetric);
petsc_matrix.buildProfile(mesh, dof_synchronizer, spatial_dimension);
/// copy the stiffness matrix into the petsc matrix
petsc_matrix.add(K, 1);
// initialize internal forces: they are zero because imposed displacement is
// zero
Array<Real> internal_forces(nb_nodes, spatial_dimension, 0.);
// compute residual: apply nodal force on last node
Array<Real> residual(nb_nodes, spatial_dimension, 0.);
for (UInt i = 0; i < nb_nodes; ++i) {
if (std::abs(position(i, 0) - 10) < Math::getTolerance())
residual(i, 0) += 2;
}
residual -= internal_forces;
/// initialize solver and solution
Array<Real> solution(nb_nodes, spatial_dimension, 0.);
SolverPETSc solver(petsc_matrix);
solver.initialize();
solver.setOperators();
solver.setRHS(residual);
solver.solve(solution);
/// verify solution
Math::setTolerance(1e-11);
for (UInt i = 0; i < nb_nodes; ++i) {
if (!dof_synchronizer.isPureGhostDOF(i) &&
!Math::are_float_equal(2 * position(i, 0), solution(i, 0))) {
std::cout << "The solution is not correct!!!!" << std::endl;
finalize();
return EXIT_FAILURE;
}
}
delete communicator;
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_solver/test_sparse_matrix_product.cc b/test/test_solver/test_sparse_matrix_product.cc
index 764d90fa0..7bf4e30a9 100644
--- a/test/test_solver/test_sparse_matrix_product.cc
+++ b/test/test_solver/test_sparse_matrix_product.cc
@@ -1,121 +1,122 @@
/**
* @file test_sparse_matrix_product.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Jun 17 2011
* @date last modification: Wed Nov 08 2017
*
* @brief test the matrix vector product in parallel
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "dof_synchronizer.hh"
#include "element_synchronizer.hh"
#include "mesh.hh"
#include "mesh_partition_scotch.hh"
#include "sparse_matrix_aij.hh"
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
const UInt spatial_dimension = 2;
const UInt nb_dof = 2;
const auto & comm = Communicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
Mesh mesh(spatial_dimension);
mesh.read("bar.msh");
mesh.distribute();
UInt nb_nodes = mesh.getNbNodes();
DOFManagerDefault dof_manager(mesh, "test_dof_manager");
Array<Real> test_synchronize(nb_nodes, nb_dof, "Test vector");
dof_manager.registerDOFs("test_synchronize", test_synchronize, _dst_nodal);
if (prank == 0)
std::cout << "Creating a SparseMatrix" << std::endl;
- auto & A = dynamic_cast<SparseMatrixAIJ &>(dof_manager.getNewMatrix("A", _symmetric));
+ auto & A = dynamic_cast<SparseMatrixAIJ &>(
+ dof_manager.getNewMatrix("A", _symmetric));
Array<Real> dof_vector(nb_nodes, nb_dof, "vector");
if (prank == 0)
std::cout << "Filling the matrix" << std::endl;
for (UInt i = 0; i < nb_nodes * nb_dof; ++i) {
if (dof_manager.isLocalOrMasterDOF(i))
A.add(i, i, 2.);
}
std::stringstream str;
str << "Matrix_" << prank << ".mtx";
A.saveMatrix(str.str());
for (UInt n = 0; n < nb_nodes; ++n) {
for (UInt d = 0; d < nb_dof; ++d) {
dof_vector(n, d) = 1.;
}
}
Array<Real> dof_vector_tmp(dof_vector);
if (prank == 0)
std::cout << "Computing x = A * x" << std::endl;
A.matVecMul(dof_vector, dof_vector_tmp);
dof_vector.copy(dof_vector_tmp);
auto & sync =
dynamic_cast<DOFManagerDefault &>(dof_manager).getSynchronizer();
if (prank == 0)
std::cout << "Gathering the results on proc 0" << std::endl;
if (psize > 1) {
if (prank == 0) {
Array<Real> gathered;
sync.gather(dof_vector, gathered);
debug::setDebugLevel(dblTest);
std::cout << gathered << std::endl;
debug::setDebugLevel(dblWarning);
} else {
sync.gather(dof_vector);
}
} else {
debug::setDebugLevel(dblTest);
std::cout << dof_vector << std::endl;
debug::setDebugLevel(dblWarning);
}
finalize();
return 0;
}
diff --git a/test/test_solver/test_sparse_solver_mumps.cc b/test/test_solver/test_sparse_solver_mumps.cc
index 733218cb7..0cb7c6b8b 100644
--- a/test/test_solver/test_sparse_solver_mumps.cc
+++ b/test/test_solver/test_sparse_solver_mumps.cc
@@ -1,167 +1,168 @@
/**
* @file test_sparse_solver_mumps.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri May 19 2017
* @date last modification: Wed Nov 08 2017
*
* @brief test the matrix vector product in parallel
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "dof_synchronizer.hh"
#include "element_synchronizer.hh"
#include "mesh.hh"
#include "mesh_accessor.hh"
#include "mesh_partition_scotch.hh"
#include "sparse_matrix_aij.hh"
#include "sparse_solver_mumps.hh"
#include "terms_to_assemble.hh"
/* -------------------------------------------------------------------------- */
#include <iostream>
/* -------------------------------------------------------------------------- */
using namespace akantu;
/* -------------------------------------------------------------------------- */
void genMesh(Mesh & mesh, UInt nb_nodes);
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
const UInt spatial_dimension = 1;
const UInt nb_global_dof = 11;
const auto & comm = Communicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
Mesh mesh(spatial_dimension);
if (prank == 0) {
genMesh(mesh, nb_global_dof);
RandomGenerator<UInt>::seed(1496137735);
} else {
RandomGenerator<UInt>::seed(2992275470);
}
mesh.distribute();
UInt node = 0;
for (auto pos : mesh.getNodes()) {
std::cout << prank << " " << node << " pos: " << pos << " ["
<< mesh.getNodeGlobalId(node) << "] " << mesh.getNodeFlag(node)
<< std::endl;
++node;
}
UInt nb_nodes = mesh.getNbNodes();
DOFManagerDefault dof_manager(mesh, "test_dof_manager");
Array<Real> x(nb_nodes);
dof_manager.registerDOFs("x", x, _dst_nodal);
- const auto & local_equation_number = dof_manager.getLocalEquationsNumbers("x");
+ const auto & local_equation_number =
+ dof_manager.getLocalEquationsNumbers("x");
auto & A = dof_manager.getNewMatrix("A", _symmetric);
Array<Real> b(nb_nodes);
TermsToAssemble terms;
for (UInt i = 0; i < nb_nodes; ++i) {
if (dof_manager.isLocalOrMasterDOF(i)) {
auto li = local_equation_number(i);
auto gi = dof_manager.localToGlobalEquationNumber(li);
terms(i, i) = 1. / (1. + gi);
}
}
dof_manager.assemblePreassembledMatrix("x", "x", "A", terms);
std::stringstream str;
str << "Matrix_" << prank << ".mtx";
A.saveMatrix(str.str());
for (UInt n = 0; n < nb_nodes; ++n) {
b(n) = 1.;
}
SparseSolverMumps solver(dof_manager, "A");
solver.solve(x, b);
auto && check = [&](auto && xs) {
debug::setDebugLevel(dblTest);
std::cout << xs << std::endl;
debug::setDebugLevel(dblWarning);
UInt d = 1.;
for (auto x : xs) {
if (std::abs(x - d) / d > 1e-15)
AKANTU_EXCEPTION("Error in the solution: " << x << " != " << d << " ["
<< (std::abs(x - d) / d)
<< "].");
++d;
}
};
if (psize > 1) {
auto & sync =
dynamic_cast<DOFManagerDefault &>(dof_manager).getSynchronizer();
if (prank == 0) {
Array<Real> x_gathered(dof_manager.getSystemSize());
sync.gather(x, x_gathered);
check(x_gathered);
} else {
sync.gather(x);
}
} else {
check(x);
}
finalize();
return 0;
}
/* -------------------------------------------------------------------------- */
void genMesh(Mesh & mesh, UInt nb_nodes) {
MeshAccessor mesh_accessor(mesh);
Array<Real> & nodes = mesh_accessor.getNodes();
Array<UInt> & conn = mesh_accessor.getConnectivity(_segment_2);
nodes.resize(nb_nodes);
for (UInt n = 0; n < nb_nodes; ++n) {
nodes(n, _x) = n * (1. / (nb_nodes - 1));
}
conn.resize(nb_nodes - 1);
for (UInt n = 0; n < nb_nodes - 1; ++n) {
conn(n, 0) = n;
conn(n, 1) = n + 1;
}
mesh_accessor.makeReady();
}
diff --git a/test/test_synchronizer/test_communicator.cc b/test/test_synchronizer/test_communicator.cc
index 8ca8209cb..0aa0eb8fc 100644
--- a/test/test_synchronizer/test_communicator.cc
+++ b/test/test_synchronizer/test_communicator.cc
@@ -1,138 +1,138 @@
/**
* @file test_communicator.cc
*
* @author Nicolas Richart
*
* @date creation Thu Feb 21 2019
*
* @brief A Documented file.
*
* @section LICENSE
*
* Copyright (©) 2010-2011 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include <aka_iterators.hh>
#include <communication_tag.hh>
#include <communicator.hh>
/* -------------------------------------------------------------------------- */
#include <gtest/gtest.h>
#include <random>
/* -------------------------------------------------------------------------- */
using namespace akantu;
TEST(Communicator, Bcast) {
auto r = 0xdeadbeef;
auto & c = Communicator::getStaticCommunicator();
c.broadcast(r);
EXPECT_EQ(r, 0xdeadbeef);
}
TEST(Communicator, ReceiveAny) {
std::random_device rd;
std::mt19937 gen(rd());
std::uniform_int_distribution<> dis(1, 10);
std::vector<CommunicationRequest> reqs;
auto & c = Communicator::getStaticCommunicator();
auto && rank = c.whoAmI();
auto && size = c.getNbProc();
for (auto n : arange(100)) {
AKANTU_DEBUG_INFO("ROUND " << n);
auto tag = Tag::genTag(0, 1, 0);
if (rank == 0) {
std::vector<int> sends(size - 1);
for (auto & s : sends) {
s = dis(gen);
}
c.broadcast(sends);
AKANTU_DEBUG_INFO("Messages " << [&]() {
std::string msgs;
for (auto s : enumerate(sends)) {
if (std::get<0>(s) != 0)
msgs += ", ";
- msgs += std::to_string(std::get<0>(s) + 1) + ": "
- + std::to_string(std::get<1>(s));
+ msgs += std::to_string(std::get<0>(s) + 1) + ": " +
+ std::to_string(std::get<1>(s));
}
return msgs;
}());
-
+
int nb_recvs = 0;
for (auto && data : enumerate(sends)) {
auto & send = std::get<1>(data);
int p = std::get<0>(data) + 1;
if (send > 5) {
reqs.push_back(
c.asyncSend(send, p, tag, CommunicationMode::_synchronous));
}
if (p <= send) {
++nb_recvs;
}
}
c.receiveAnyNumber<int>(reqs,
[&](auto && proc, auto && msg) {
EXPECT_EQ(msg[0], sends[proc - 1] + 100 * proc);
EXPECT_LE(proc, sends[proc - 1]);
--nb_recvs;
},
tag);
EXPECT_EQ(nb_recvs, 0);
} else {
std::vector<int> recv(size - 1);
c.broadcast(recv);
AKANTU_DEBUG_INFO("Messages " << [&]() {
std::string msgs;
for (auto s : enumerate(recv)) {
if (std::get<0>(s) != 0)
msgs += ", ";
- msgs += std::to_string(std::get<0>(s) + 1) + ": "
- + std::to_string(std::get<1>(s));
+ msgs += std::to_string(std::get<0>(s) + 1) + ": " +
+ std::to_string(std::get<1>(s));
}
return msgs;
}());
auto send = recv[rank - 1] + 100 * rank;
if (rank <= recv[rank - 1]) {
reqs.push_back(
c.asyncSend(send, 0, tag, CommunicationMode::_synchronous));
}
bool has_recv = false;
c.receiveAnyNumber<int>(reqs,
[&](auto && proc, auto && msg) {
EXPECT_EQ(msg[0], recv[rank - 1]);
EXPECT_EQ(proc, 0);
has_recv = true;
},
tag);
bool should_recv = (recv[rank - 1] > 5);
EXPECT_EQ(has_recv, should_recv);
}
reqs.clear();
}
}
diff --git a/test/test_synchronizer/test_data_distribution.cc b/test/test_synchronizer/test_data_distribution.cc
index c8497a81e..948a12815 100644
--- a/test/test_synchronizer/test_data_distribution.cc
+++ b/test/test_synchronizer/test_data_distribution.cc
@@ -1,88 +1,88 @@
/**
* @file test_data_distribution.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Fri Sep 05 2014
* @date last modification: Fri Jan 26 2018
*
* @brief Test the mesh distribution on creation of a distributed synchonizer
*
* @section LICENSE
*
* Copyright (©) 2014-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_synchronizers_fixture.hh"
/* -------------------------------------------------------------------------- */
TEST_F(TestSynchronizerFixture, DataDistribution) {
auto & barycenters = this->mesh->getElementalData<Real>("barycenters");
auto spatial_dimension = this->mesh->getSpatialDimension();
barycenters.initialize(*this->mesh, _spatial_dimension = _all_dimensions,
_nb_component = spatial_dimension);
this->initBarycenters(barycenters, *this->mesh);
auto & gids = this->mesh->getNodalData<UInt>("gid");
gids.resize(this->mesh->getNbNodes());
- for(auto && data : enumerate(gids)) {
+ for (auto && data : enumerate(gids)) {
std::get<1>(data) = std::get<0>(data);
}
this->distribute();
for (auto && ghost_type : ghost_types) {
for (const auto & type :
this->mesh->elementTypes(_all_dimensions, ghost_type)) {
auto & barycenters =
this->mesh->getData<Real>("barycenters", type, ghost_type);
for (auto && data :
enumerate(make_view(barycenters, spatial_dimension))) {
Element element{type, UInt(std::get<0>(data)), ghost_type};
Vector<Real> barycenter(spatial_dimension);
this->mesh->getBarycenter(element, barycenter);
auto dist = (std::get<1>(data) - barycenter).template norm<L_inf>();
EXPECT_NEAR(dist, 0, 1e-7);
}
}
}
if (psize > 1) {
- for(auto && data : zip(gids, this->mesh->getGlobalNodesIds())) {
+ for (auto && data : zip(gids, this->mesh->getGlobalNodesIds())) {
EXPECT_EQ(std::get<0>(data), std::get<1>(data));
}
}
}
TEST_F(TestSynchronizerFixture, DataDistributionTags) {
this->distribute();
for (const auto & type : this->mesh->elementTypes(_all_dimensions)) {
auto & tags = this->mesh->getData<UInt>("tag_0", type);
Array<UInt>::const_vector_iterator tags_it = tags.begin(1);
Array<UInt>::const_vector_iterator tags_end = tags.end(1);
// The number of tags should match the number of elements on rank"
EXPECT_EQ(this->mesh->getNbElement(type), tags.size());
}
}
diff --git a/test/test_synchronizer/test_dof_synchronizer_communication.cc b/test/test_synchronizer/test_dof_synchronizer_communication.cc
index 94d332a82..bedc77416 100644
--- a/test/test_synchronizer/test_dof_synchronizer_communication.cc
+++ b/test/test_synchronizer/test_dof_synchronizer_communication.cc
@@ -1,108 +1,109 @@
/**
* @file test_dof_synchronizer_communication.cc
*
* @author Aurelia Isabel Cuba Ramos <aurelia.cubaramos@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Tue Dec 09 2014
* @date last modification: Wed Nov 08 2017
*
* @brief test to synchronize global equation numbers
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "dof_synchronizer.hh"
#include "element_synchronizer.hh"
#include "mesh.hh"
#include "mesh_partition_scotch.hh"
#include "synchronizer_registry.hh"
/* -------------------------------------------------------------------------- */
#ifdef AKANTU_USE_IOHELPER
#include "dumper_paraview.hh"
#endif // AKANTU_USE_IOHELPER
#include "test_dof_data_accessor.hh"
using namespace akantu;
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
initialize(argc, argv);
UInt spatial_dimension = 3;
Mesh mesh(spatial_dimension);
const auto & comm = Communicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
bool wait = true;
if (argc > 1) {
if (prank == 0)
while (wait)
;
}
ElementSynchronizer * communicator = NULL;
if (prank == 0) {
mesh.read("cube.msh");
MeshPartition * partition =
new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
communicator =
ElementSynchronizer::createDistributedSynchronizerMesh(mesh, partition);
delete partition;
} else {
communicator =
ElementSynchronizer::createDistributedSynchronizerMesh(mesh, NULL);
}
/* --------------------------------------------------------------------------
*/
/* test the communications of the dof synchronizer */
/* --------------------------------------------------------------------------
*/
std::cout << "Initializing the synchronizer" << std::endl;
DOFSynchronizer dof_synchronizer(mesh, spatial_dimension);
dof_synchronizer.initGlobalDOFEquationNumbers();
AKANTU_DEBUG_INFO("Creating TestDOFAccessor");
TestDOFAccessor test_dof_accessor(
dof_synchronizer.getGlobalDOFEquationNumbers());
SynchronizerRegistry synch_registry(test_dof_accessor);
- synch_registry.registerSynchronizer(dof_synchronizer, SynchronizationTag::_test);
+ synch_registry.registerSynchronizer(dof_synchronizer,
+ SynchronizationTag::_test);
AKANTU_DEBUG_INFO("Synchronizing tag");
synch_registry.synchronize(SynchronizationTag::_test);
delete communicator;
finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_synchronizer/test_facet_synchronizer.cc b/test/test_synchronizer/test_facet_synchronizer.cc
index 65ba946f8..bb4d1316e 100644
--- a/test/test_synchronizer/test_facet_synchronizer.cc
+++ b/test/test_synchronizer/test_facet_synchronizer.cc
@@ -1,95 +1,97 @@
/**
* @file test_facet_synchronizer.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
* @author Marco Vocialta <marco.vocialta@epfl.ch>
*
* @date creation: Wed Nov 05 2014
* @date last modification: Fri Jan 26 2018
*
* @brief Facet synchronizer test
*
* @section LICENSE
*
* Copyright (©) 2015-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_data_accessor.hh"
#include "test_synchronizers_fixture.hh"
/* -------------------------------------------------------------------------- */
#include "element_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <chrono>
#include <random>
#include <thread>
/* -------------------------------------------------------------------------- */
class TestFacetSynchronizerFixture : public TestSynchronizerFixture {
public:
void SetUp() override {
TestSynchronizerFixture::SetUp();
this->distribute();
this->mesh->initMeshFacets();
/// compute barycenter for each element
barycenters =
std::make_unique<ElementTypeMapArray<Real>>("barycenters", "", 0);
this->initBarycenters(*barycenters, this->mesh->getMeshFacets());
test_accessor =
std::make_unique<TestAccessor>(*this->mesh, *this->barycenters);
}
void TearDown() override {
barycenters.reset(nullptr);
test_accessor.reset(nullptr);
}
protected:
std::unique_ptr<ElementTypeMapArray<Real>> barycenters;
std::unique_ptr<TestAccessor> test_accessor;
};
/* -------------------------------------------------------------------------- */
TEST_F(TestFacetSynchronizerFixture, SynchroneOnce) {
auto & synchronizer = this->mesh->getMeshFacets().getElementSynchronizer();
synchronizer.synchronizeOnce(*this->test_accessor, SynchronizationTag::_test);
}
/* -------------------------------------------------------------------------- */
TEST_F(TestFacetSynchronizerFixture, Synchrone) {
auto & synchronizer = this->mesh->getMeshFacets().getElementSynchronizer();
synchronizer.synchronize(*this->test_accessor, SynchronizationTag::_test);
}
/* -------------------------------------------------------------------------- */
TEST_F(TestFacetSynchronizerFixture, Asynchrone) {
auto & synchronizer = this->mesh->getMeshFacets().getElementSynchronizer();
- synchronizer.asynchronousSynchronize(*this->test_accessor, SynchronizationTag::_test);
+ synchronizer.asynchronousSynchronize(*this->test_accessor,
+ SynchronizationTag::_test);
std::random_device r;
std::default_random_engine engine(r());
std::uniform_int_distribution<int> uniform_dist(10, 100);
std::chrono::microseconds delay(uniform_dist(engine));
std::this_thread::sleep_for(delay);
- synchronizer.waitEndSynchronize(*this->test_accessor, SynchronizationTag::_test);
+ synchronizer.waitEndSynchronize(*this->test_accessor,
+ SynchronizationTag::_test);
}
diff --git a/test/test_synchronizer/test_grid_synchronizer.cc b/test/test_synchronizer/test_grid_synchronizer.cc
index 45b4e0d28..a89c7ce26 100644
--- a/test/test_synchronizer/test_grid_synchronizer.cc
+++ b/test/test_synchronizer/test_grid_synchronizer.cc
@@ -1,309 +1,310 @@
/**
* @file test_grid_synchronizer.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 01 2010
* @date last modification: Tue Feb 20 2018
*
* @brief test the GridSynchronizer object
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "aka_common.hh"
#include "aka_grid_dynamic.hh"
#include "grid_synchronizer.hh"
#include "mesh.hh"
#include "mesh_partition.hh"
#include "synchronizer_registry.hh"
#include "test_data_accessor.hh"
#ifdef AKANTU_USE_IOHELPER
#include "io_helper.hh"
#endif // AKANTU_USE_IOHELPER
using namespace akantu;
const UInt spatial_dimension = 2;
typedef std::map<std::pair<Element, Element>, Real> pair_list;
#include "test_grid_tools.hh"
static void
updatePairList(const ElementTypeMapArray<Real> & barycenter,
const SpatialGrid<Element> & grid, Real radius,
pair_list & neighbors,
neighbors_map_t<spatial_dimension>::type & neighbors_map) {
AKANTU_DEBUG_IN();
GhostType ghost_type = _not_ghost;
Element e;
e.ghost_type = ghost_type;
// generate the pair of neighbor depending of the cell_list
ElementTypeMapArray<Real>::type_iterator it =
barycenter.firstType(_all_dimensions, ghost_type);
ElementTypeMapArray<Real>::type_iterator last_type =
barycenter.lastType(0, ghost_type);
for (; it != last_type; ++it) {
// loop over quad points
e.type = *it;
e.element = 0;
const Array<Real> & barycenter_vect = barycenter(*it, ghost_type);
UInt sp = barycenter_vect.getNbComponent();
Array<Real>::const_iterator<Vector<Real>> bary = barycenter_vect.begin(sp);
Array<Real>::const_iterator<Vector<Real>> bary_end =
barycenter_vect.end(sp);
for (; bary != bary_end; ++bary, e.element++) {
#if !defined(AKANTU_NDEBUG)
Point<spatial_dimension> pt1(*bary);
#endif
SpatialGrid<Element>::CellID cell_id = grid.getCellID(*bary);
SpatialGrid<Element>::neighbor_cells_iterator first_neigh_cell =
grid.beginNeighborCells(cell_id);
SpatialGrid<Element>::neighbor_cells_iterator last_neigh_cell =
grid.endNeighborCells(cell_id);
// loop over neighbors cells of the one containing the current element
for (; first_neigh_cell != last_neigh_cell; ++first_neigh_cell) {
SpatialGrid<Element>::Cell::const_iterator first_neigh_el =
grid.beginCell(*first_neigh_cell);
SpatialGrid<Element>::Cell::const_iterator last_neigh_el =
grid.endCell(*first_neigh_cell);
// loop over the quadrature point in the current cell of the cell list
for (; first_neigh_el != last_neigh_el; ++first_neigh_el) {
const Element & elem = *first_neigh_el;
Array<Real>::const_iterator<Vector<Real>> neigh_it =
barycenter(elem.type, elem.ghost_type).begin(sp);
const Vector<Real> & neigh_bary = neigh_it[elem.element];
Real distance = bary->distance(neigh_bary);
if (distance <= radius) {
#if !defined(AKANTU_NDEBUG)
Point<spatial_dimension> pt2(neigh_bary);
neighbors_map[pt1].push_back(pt2);
#endif
std::pair<Element, Element> pair = std::make_pair(e, elem);
pair_list::iterator p = neighbors.find(pair);
if (p != neighbors.end()) {
AKANTU_ERROR("Pair already registered ["
<< e << " " << elem << "] -> " << p->second << " "
<< distance);
} else {
neighbors[pair] = distance;
}
}
}
}
}
}
AKANTU_DEBUG_OUT();
}
/* -------------------------------------------------------------------------- */
/* Main */
/* -------------------------------------------------------------------------- */
int main(int argc, char * argv[]) {
akantu::initialize(argc, argv);
Real radius = 0.001;
Mesh mesh(spatial_dimension);
const auto & comm = Communicator::getStaticCommunicator();
Int psize = comm.getNbProc();
Int prank = comm.whoAmI();
ElementSynchronizer * dist = NULL;
if (prank == 0) {
mesh.read("bar.msh");
MeshPartition * partition =
new MeshPartitionScotch(mesh, spatial_dimension);
partition->partitionate(psize);
dist =
ElementSynchronizer::createDistributedSynchronizerMesh(mesh, partition);
delete partition;
} else {
dist = ElementSynchronizer::createDistributedSynchronizerMesh(mesh, NULL);
}
mesh.computeBoundingBox();
const Vector<Real> & lower_bounds = mesh.getLowerBounds();
const Vector<Real> & upper_bounds = mesh.getUpperBounds();
Vector<Real> center = 0.5 * (upper_bounds + lower_bounds);
Vector<Real> spacing(spatial_dimension);
for (UInt i = 0; i < spatial_dimension; ++i) {
spacing[i] = radius * 1.2;
}
SpatialGrid<Element> grid(spatial_dimension, spacing, center);
GhostType ghost_type = _not_ghost;
Mesh::type_iterator it = mesh.firstType(spatial_dimension, ghost_type);
Mesh::type_iterator last_type = mesh.lastType(spatial_dimension, ghost_type);
ElementTypeMapArray<Real> barycenters("", "");
mesh.initElementTypeMapArray(barycenters, spatial_dimension,
spatial_dimension);
Element e;
e.ghost_type = ghost_type;
for (; it != last_type; ++it) {
UInt nb_element = mesh.getNbElement(*it, ghost_type);
e.type = *it;
Array<Real> & barycenter = barycenters(*it, ghost_type);
barycenter.resize(nb_element);
Array<Real>::iterator<Vector<Real>> bary_it =
barycenter.begin(spatial_dimension);
for (UInt elem = 0; elem < nb_element; ++elem) {
mesh.getBarycenter(elem, *it, bary_it->storage(), ghost_type);
e.element = elem;
grid.insert(e, *bary_it);
++bary_it;
}
}
std::stringstream sstr;
sstr << "mesh_" << prank << ".msh";
mesh.write(sstr.str());
Mesh grid_mesh(spatial_dimension, "grid_mesh", 0);
std::stringstream sstr_grid;
sstr_grid << "grid_mesh_" << prank << ".msh";
grid.saveAsMesh(grid_mesh);
grid_mesh.write(sstr_grid.str());
std::cout << "Pouet 1" << std::endl;
AKANTU_DEBUG_INFO("Creating TestAccessor");
TestAccessor test_accessor(mesh, barycenters);
SynchronizerRegistry synch_registry(test_accessor);
GridSynchronizer * grid_communicator =
GridSynchronizer::createGridSynchronizer(mesh, grid);
std::cout << "Pouet 2" << std::endl;
ghost_type = _ghost;
it = mesh.firstType(spatial_dimension, ghost_type);
last_type = mesh.lastType(spatial_dimension, ghost_type);
e.ghost_type = ghost_type;
for (; it != last_type; ++it) {
UInt nb_element = mesh.getNbElement(*it, ghost_type);
e.type = *it;
Array<Real> & barycenter = barycenters(*it, ghost_type);
barycenter.resize(nb_element);
Array<Real>::iterator<Vector<Real>> bary_it =
barycenter.begin(spatial_dimension);
for (UInt elem = 0; elem < nb_element; ++elem) {
mesh.getBarycenter(elem, *it, bary_it->storage(), ghost_type);
e.element = elem;
grid.insert(e, *bary_it);
++bary_it;
}
}
Mesh grid_mesh_ghost(spatial_dimension, "grid_mesh_ghost", 0);
std::stringstream sstr_gridg;
sstr_gridg << "grid_mesh_ghost_" << prank << ".msh";
grid.saveAsMesh(grid_mesh_ghost);
grid_mesh_ghost.write(sstr_gridg.str());
std::cout << "Pouet 3" << std::endl;
neighbors_map_t<spatial_dimension>::type neighbors_map;
pair_list neighbors;
updatePairList(barycenters, grid, radius, neighbors, neighbors_map);
pair_list::iterator nit = neighbors.begin();
pair_list::iterator nend = neighbors.end();
std::stringstream sstrp;
sstrp << "pairs_" << prank;
std::ofstream fout(sstrp.str().c_str());
for (; nit != nend; ++nit) {
fout << "[" << nit->first.first << "," << nit->first.second << "] -> "
<< nit->second << std::endl;
}
std::string file = "neighbors_ref";
std::stringstream sstrf;
sstrf << file << "_" << psize << "_" << prank;
file = sstrf.str();
std::ofstream nout;
nout.open(file.c_str());
neighbors_map_t<spatial_dimension>::type::iterator it_n =
neighbors_map.begin();
neighbors_map_t<spatial_dimension>::type::iterator end_n =
neighbors_map.end();
for (; it_n != end_n; ++it_n) {
std::sort(it_n->second.begin(), it_n->second.end());
std::vector<Point<spatial_dimension>>::iterator it_v = it_n->second.begin();
std::vector<Point<spatial_dimension>>::iterator end_v = it_n->second.end();
nout << "####" << std::endl;
nout << it_n->second.size() << std::endl;
nout << it_n->first << std::endl;
nout << "#" << std::endl;
for (; it_v != end_v; ++it_v) {
nout << *it_v << std::endl;
}
}
fout.close();
synch_registry.registerSynchronizer(*dist, SynchronizationTag::_smm_mass);
- synch_registry.registerSynchronizer(*grid_communicator, SynchronizationTag::_test);
+ synch_registry.registerSynchronizer(*grid_communicator,
+ SynchronizationTag::_test);
AKANTU_DEBUG_INFO("Synchronizing tag on Dist");
synch_registry.synchronize(SynchronizationTag::_smm_mass);
AKANTU_DEBUG_INFO("Synchronizing tag on Grid");
synch_registry.synchronize(SynchronizationTag::_test);
delete grid_communicator;
delete dist;
akantu::finalize();
return EXIT_SUCCESS;
}
diff --git a/test/test_synchronizer/test_node_synchronizer.cc b/test/test_synchronizer/test_node_synchronizer.cc
index 61f0960d6..dcfcb8067 100644
--- a/test/test_synchronizer/test_node_synchronizer.cc
+++ b/test/test_synchronizer/test_node_synchronizer.cc
@@ -1,161 +1,164 @@
/**
* @file test_node_synchronizer.cc
*
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Thu May 11 2017
* @date last modification: Fri Jan 26 2018
*
* @brief test the default node synchronizer present in the mesh
*
* @section LICENSE
*
* Copyright (©) 2016-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_synchronizers_fixture.hh"
/* -------------------------------------------------------------------------- */
#include "communicator.hh"
#include "data_accessor.hh"
#include "mesh.hh"
#include "node_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <chrono>
#include <limits>
#include <random>
#include <thread>
/* -------------------------------------------------------------------------- */
using namespace akantu;
class DataAccessorTest : public DataAccessor<UInt> {
public:
explicit DataAccessorTest(Array<int> & data) : data(data) {}
UInt getNbData(const Array<UInt> & nodes, const SynchronizationTag &) const {
return nodes.size() * sizeof(int);
}
void packData(CommunicationBuffer & buffer, const Array<UInt> & nodes,
const SynchronizationTag &) const {
for (auto node : nodes) {
buffer << data(node);
}
}
void unpackData(CommunicationBuffer & buffer, const Array<UInt> & nodes,
const SynchronizationTag &) {
for (auto node : nodes) {
buffer >> data(node);
}
}
protected:
Array<int> & data;
};
class TestNodeSynchronizerFixture : public TestSynchronizerFixture {
public:
static constexpr int max_int = std::numeric_limits<int>::max();
void SetUp() override {
TestSynchronizerFixture::SetUp();
this->distribute();
UInt nb_nodes = this->mesh->getNbNodes();
node_data = std::make_unique<Array<int>>(nb_nodes);
for (auto && data : enumerate(*node_data)) {
auto n = std::get<0>(data);
auto & d = std::get<1>(data);
UInt gn = this->mesh->getNodeGlobalId(n);
if (this->mesh->isMasterNode(n))
d = gn;
else if (this->mesh->isLocalNode(n))
d = -gn;
else if (this->mesh->isSlaveNode(n))
d = max_int;
else
d = -max_int;
}
data_accessor = std::make_unique<DataAccessorTest>(*node_data);
}
void TearDown() override {
data_accessor.reset(nullptr);
node_data.reset(nullptr);
}
void checkData() {
for (auto && data : enumerate(*this->node_data)) {
auto n = std::get<0>(data);
auto & d = std::get<1>(data);
UInt gn = this->mesh->getNodeGlobalId(n);
if (this->mesh->isMasterNode(n))
EXPECT_EQ(d, gn);
else if (this->mesh->isLocalNode(n))
EXPECT_EQ(d, -gn);
else if (this->mesh->isSlaveNode(n))
EXPECT_EQ(d, gn);
else
EXPECT_EQ(d, -max_int);
}
}
protected:
std::unique_ptr<Array<int>> node_data;
std::unique_ptr<DataAccessorTest> data_accessor;
};
/* -------------------------------------------------------------------------- */
TEST_F(TestNodeSynchronizerFixture, SynchroneOnce) {
auto & synchronizer = this->mesh->getNodeSynchronizer();
synchronizer.synchronizeOnce(*this->data_accessor, SynchronizationTag::_test);
this->checkData();
}
/* -------------------------------------------------------------------------- */
TEST_F(TestNodeSynchronizerFixture, Synchrone) {
auto & node_synchronizer = this->mesh->getNodeSynchronizer();
- node_synchronizer.synchronize(*this->data_accessor, SynchronizationTag::_test);
+ node_synchronizer.synchronize(*this->data_accessor,
+ SynchronizationTag::_test);
this->checkData();
}
/* -------------------------------------------------------------------------- */
TEST_F(TestNodeSynchronizerFixture, Asynchrone) {
auto & synchronizer = this->mesh->getNodeSynchronizer();
- synchronizer.asynchronousSynchronize(*this->data_accessor, SynchronizationTag::_test);
+ synchronizer.asynchronousSynchronize(*this->data_accessor,
+ SynchronizationTag::_test);
std::random_device r;
std::default_random_engine engine(r());
std::uniform_int_distribution<int> uniform_dist(10, 100);
std::chrono::microseconds delay(uniform_dist(engine));
std::this_thread::sleep_for(delay);
- synchronizer.waitEndSynchronize(*this->data_accessor, SynchronizationTag::_test);
+ synchronizer.waitEndSynchronize(*this->data_accessor,
+ SynchronizationTag::_test);
this->checkData();
}
diff --git a/test/test_synchronizer/test_synchronizer_communication.cc b/test/test_synchronizer/test_synchronizer_communication.cc
index cfaed7d61..eba10d9b3 100644
--- a/test/test_synchronizer/test_synchronizer_communication.cc
+++ b/test/test_synchronizer/test_synchronizer_communication.cc
@@ -1,93 +1,95 @@
/**
* @file test_synchronizer_communication.cc
*
* @author Dana Christen <dana.christen@epfl.ch>
* @author Nicolas Richart <nicolas.richart@epfl.ch>
*
* @date creation: Wed Sep 01 2010
* @date last modification: Fri Jan 26 2018
*
* @brief test to synchronize barycenters
*
* @section LICENSE
*
* Copyright (©) 2010-2018 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*
*/
/* -------------------------------------------------------------------------- */
#include "test_data_accessor.hh"
#include "test_synchronizers_fixture.hh"
/* -------------------------------------------------------------------------- */
#include "element_synchronizer.hh"
/* -------------------------------------------------------------------------- */
#include <chrono>
#include <random>
#include <thread>
/* -------------------------------------------------------------------------- */
class TestElementSynchronizerFixture : public TestSynchronizerFixture {
public:
void SetUp() override {
TestSynchronizerFixture::SetUp();
this->distribute();
/// compute barycenter for each element
barycenters =
std::make_unique<ElementTypeMapArray<Real>>("barycenters", "", 0);
this->initBarycenters(*barycenters, *mesh);
test_accessor =
std::make_unique<TestAccessor>(*this->mesh, *this->barycenters);
}
void TearDown() override {
barycenters.reset(nullptr);
test_accessor.reset(nullptr);
}
protected:
std::unique_ptr<ElementTypeMapArray<Real>> barycenters;
std::unique_ptr<TestAccessor> test_accessor;
};
/* -------------------------------------------------------------------------- */
TEST_F(TestElementSynchronizerFixture, SynchroneOnce) {
auto & synchronizer = this->mesh->getElementSynchronizer();
synchronizer.synchronizeOnce(*this->test_accessor, SynchronizationTag::_test);
}
/* -------------------------------------------------------------------------- */
TEST_F(TestElementSynchronizerFixture, Synchrone) {
auto & synchronizer = this->mesh->getElementSynchronizer();
synchronizer.synchronize(*this->test_accessor, SynchronizationTag::_test);
}
/* -------------------------------------------------------------------------- */
TEST_F(TestElementSynchronizerFixture, Asynchrone) {
auto & synchronizer = this->mesh->getElementSynchronizer();
- synchronizer.asynchronousSynchronize(*this->test_accessor, SynchronizationTag::_test);
+ synchronizer.asynchronousSynchronize(*this->test_accessor,
+ SynchronizationTag::_test);
std::random_device r;
std::default_random_engine engine(r());
std::uniform_int_distribution<int> uniform_dist(10, 100);
std::chrono::microseconds delay(uniform_dist(engine));
std::this_thread::sleep_for(delay);
- synchronizer.waitEndSynchronize(*this->test_accessor, SynchronizationTag::_test);
+ synchronizer.waitEndSynchronize(*this->test_accessor,
+ SynchronizationTag::_test);
}
diff --git a/third-party/cmake/gtest.cmake b/third-party/cmake/gtest.cmake
index 8187efd7f..8a2f92eab 100644
--- a/third-party/cmake/gtest.cmake
+++ b/third-party/cmake/gtest.cmake
@@ -1,50 +1,48 @@
set(_working_dir ${PROJECT_BINARY_DIR}/third-party/src/gtest-download)
configure_file(${PROJECT_SOURCE_DIR}/third-party/gtest.cmake.in ${_working_dir}/CMakeLists.txt)
set(GTEST_ROOT ${PROJECT_BINARY_DIR}/third-party)
-find_package(GTest QUIET)
-
-if(NOT GTEST_FOUND)
- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/third-party/google-test)
- message(STATUS "Downloading googletest")
- execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
- RESULT_VARIABLE result WORKING_DIRECTORY ${_working_dir}
- OUTPUT_FILE ${_working_dir}/configure-out.log
- ERROR_FILE ${_working_dir}/configure-error.log)
-
- if(result)
- message(SEND_ERROR "CMake step for googletest failed: ${result}")
- return()
- endif()
-
- execute_process(COMMAND ${CMAKE_COMMAND} --build .
- RESULT_VARIABLE result WORKING_DIRECTORY ${_working_dir}
- OUTPUT_FILE ${_working_dir}/build-out.log
- ERROR_FILE ${_working_dir}/build-error.log)
-
- if(result)
- message(SEND_ERROR "Downloading googletest failed: ${result}")
- return()
- endif()
+
+if(NOT EXISTS ${PROJECT_SOURCE_DIR}/third-party/google-test)
+ message(STATUS "Downloading googletest")
+ execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
+ RESULT_VARIABLE result WORKING_DIRECTORY ${_working_dir}
+ OUTPUT_FILE ${_working_dir}/configure-out.log
+ ERROR_FILE ${_working_dir}/configure-error.log)
+
+ if(result)
+ message(SEND_ERROR "CMake step for googletest failed: ${result}")
+ return()
+ endif()
+
+ execute_process(COMMAND ${CMAKE_COMMAND} --build .
+ RESULT_VARIABLE result WORKING_DIRECTORY ${_working_dir}
+ OUTPUT_FILE ${_working_dir}/build-out.log
+ ERROR_FILE ${_working_dir}/build-error.log)
+
+ if(result)
+ message(SEND_ERROR "Downloading googletest failed: ${result}")
+ return()
endif()
+endif()
- set(gtest_build_tests OFF CACHE INTERNAL "" FORCE)
- set(BUILD_GTEST ON CACHE INTERNAL "" FORCE)
- set(BUILD_GMOCK OFF CACHE INTERNAL "" FORCE)
+set(gtest_build_tests OFF CACHE INTERNAL "" FORCE)
+set(BUILD_GTEST ON CACHE INTERNAL "" FORCE)
+set(BUILD_GMOCK OFF CACHE INTERNAL "" FORCE)
- set(Python_ADDITIONAL_VERSIONS ${AKANTU_PREFERRED_PYTHON_VERSION})
- add_subdirectory(third-party/google-test)
- set_property(TARGET gtest_main PROPERTY CXX_STANDARD 14)
- set_property(TARGET gtest PROPERTY CXX_STANDARD 14)
+set(Python_ADDITIONAL_VERSIONS ${AKANTU_PREFERRED_PYTHON_VERSION})
+add_subdirectory(third-party/google-test)
+set_property(TARGET gtest_main PROPERTY CXX_STANDARD 14)
+set_property(TARGET gtest PROPERTY CXX_STANDARD 14)
- add_library(GTest::Main ALIAS gtest_main)
- add_library(GTest::GTest ALIAS gtest)
+add_library(GTest::Main ALIAS gtest_main)
+add_library(GTest::GTest ALIAS gtest)
- set(gtest_FOUND TRUE CACHE INTERNAL "" FORCE)
- set(GTEST_INCLUDE_DIRS third-party/google-test/googletest/include CACHE INTERNAL "" FORCE)
- set(GTEST_LIBRARIES GTest::Main CACHE INTERNAL "" FORCE)
+set(gtest_FOUND TRUE CACHE INTERNAL "" FORCE)
+set(GTEST_INCLUDE_DIRS third-party/google-test/googletest/include CACHE INTERNAL "" FORCE)
+set(GTEST_LIBRARIES GTest::Main CACHE INTERNAL "" FORCE)
+
+mark_as_advanced(INSTALL_GTEST)
+mask_package_options(gtest)
- mark_as_advanced(INSTALL_GTEST)
- mask_package_options(gtest)
-endif()

Event Timeline