mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-26 05:50:32 +05:00
Merged master
This commit is contained in:
commit
6524c0c170
@ -76,7 +76,7 @@ stages:
|
||||
-DCMAKE_BUILD_TYPE=Release
|
||||
- cmake --build . --target INSTALL --config Release
|
||||
|
||||
build_netgen_win32:
|
||||
.build_netgen_win32:
|
||||
<<: *win32
|
||||
<<: *tbuild_netgen_win
|
||||
cache:
|
||||
@ -126,7 +126,7 @@ build_ubuntu_1604:
|
||||
- cd ..
|
||||
|
||||
# skip since we have no machine with 32 bits
|
||||
test_win32:
|
||||
.test_win32:
|
||||
<<: *win32
|
||||
<<: *test_win
|
||||
|
||||
@ -197,7 +197,7 @@ win64_cleanup:
|
||||
when: always
|
||||
allow_failure: true
|
||||
|
||||
win32_cleanup:
|
||||
.win32_cleanup:
|
||||
<<: *win32
|
||||
stage: cleanup
|
||||
tags:
|
||||
|
166
CMakeLists.txt
166
CMakeLists.txt
@ -16,19 +16,51 @@ option( USE_MPEG "enable video recording with FFmpeg, uses libavcodec" OFF )
|
||||
option( INTEL_MIC "cross compile for intel xeon phi")
|
||||
option( INSTALL_PROFILES "install environment variable settings to /etc/profile.d" OFF )
|
||||
option( USE_CCACHE "use ccache")
|
||||
option( USE_INTERNAL_TCL "Compile tcl files into the code and don't install them" ON)
|
||||
|
||||
option( USE_SUPERBUILD "use ccache" ON)
|
||||
|
||||
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_modules")
|
||||
|
||||
if(APPLE)
|
||||
set(INSTALL_DIR_DEFAULT /Applications/Netgen.app)
|
||||
else(APPLE)
|
||||
if(WIN32)
|
||||
set(INSTALL_DIR_DEFAULT "C:/netgen")
|
||||
else(WIN32)
|
||||
set(INSTALL_DIR_DEFAULT /opt/netgen)
|
||||
endif(WIN32)
|
||||
endif(APPLE)
|
||||
|
||||
if(INSTALL_DIR)
|
||||
message(WARNING "INSTALL_DIR is deprecated, use CMAKE_INSTALL_PREFIX instead")
|
||||
set(INSTALL_DIR_DEFAULT ${INSTALL_DIR})
|
||||
endif(INSTALL_DIR)
|
||||
|
||||
if(UNIX)
|
||||
message("Checking for write permissions in install directory...")
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX})
|
||||
execute_process(COMMAND test -w ${CMAKE_INSTALL_PREFIX} RESULT_VARIABLE res)
|
||||
if(res)
|
||||
message(WARNING "No write access at install directory, please set correct permissions")
|
||||
endif()
|
||||
endif(UNIX)
|
||||
|
||||
if (USE_SUPERBUILD)
|
||||
project (SUPERBUILD)
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR_DEFAULT}" CACHE PATH "Install directory" FORCE)
|
||||
endif()
|
||||
|
||||
# execute the superbuild (this script will be invoked again without the
|
||||
# USE_SUPERBUILD option this time)
|
||||
include (cmake/SuperBuild.cmake)
|
||||
return() # stop processing this file further
|
||||
else()
|
||||
project(Netgen)
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR_DEFAULT}" CACHE PATH "Install directory" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(NETGEN_VERSION_MAJOR 6)
|
||||
@ -37,7 +69,6 @@ string(TIMESTAMP NETGEN_VERSION_PATCH "%y%U%w" )
|
||||
set(NETGEN_VERSION "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}-dev")
|
||||
set(PACKAGE_VERSION "${NETGEN_VERSION_MAJOR}.${NETGEN_VERSION_MINOR}-${NETGEN_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_VERSION "${PACKAGE_VERSION}")
|
||||
# set(CPACK_DEBIAN_PACKAGE_VERSION "${PACKAGE_VERSION}"
|
||||
|
||||
|
||||
#######################################################################
|
||||
@ -69,48 +100,81 @@ if (ADDITIONAL_PATHS)
|
||||
set(CMAKE_PREFIX_PATH ${ADDITIONAL_PATHS})
|
||||
endif (ADDITIONAL_PATHS)
|
||||
|
||||
if(APPLE)
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
||||
else(APPLE)
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
||||
endif(APPLE)
|
||||
|
||||
#######################################################################
|
||||
# use rpath
|
||||
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
|
||||
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
|
||||
IF("${isSystemDir}" STREQUAL "-1")
|
||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
||||
ENDIF("${isSystemDir}" STREQUAL "-1")
|
||||
|
||||
#######################################################################
|
||||
# build options
|
||||
add_definitions(-DUSE_TIMEOFDAY)
|
||||
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/include")
|
||||
include_directories ("${PROJECT_SOURCE_DIR}/libsrc/include")
|
||||
include_directories ("${PROJECT_BINARY_DIR}")
|
||||
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
set(INCDIR include CACHE PATH "install directory for header files")
|
||||
set(NG_INSTALL_SUFFIX netgen CACHE STRING "Suffix appended to install directories (project name)")
|
||||
|
||||
if(APPLE)
|
||||
set(ng_install_dir_bin ../MacOS)
|
||||
set(ng_install_dir_lib ../MacOS)
|
||||
set(NG_INSTALL_DIR_BIN_DEFAULT Contents/MacOS)
|
||||
set(NG_INSTALL_DIR_LIB_DEFAULT Contents/MacOS)
|
||||
set(NG_INSTALL_DIR_CMAKE_DEFAULT Contents/Resources/CMake)
|
||||
set(NG_INSTALL_DIR_PYTHON_DEFAULT Contents/Resources/${PYTHON_PACKAGES_INSTALL_DIR})
|
||||
set(NG_INSTALL_DIR_RES_DEFAULT Contents/Resources/share)
|
||||
set(NG_INSTALL_DIR_INCLUDE_DEFAULT Contents/Resources/include)
|
||||
|
||||
set(NG_RPATH_TOKEN "@loader_path")
|
||||
else(APPLE)
|
||||
set(ng_install_dir_bin bin)
|
||||
set(ng_install_dir_lib lib)
|
||||
set(NG_INSTALL_DIR_BIN_DEFAULT bin)
|
||||
set(NG_INSTALL_DIR_LIB_DEFAULT lib)
|
||||
if(WIN32)
|
||||
set(NG_INSTALL_DIR_CMAKE_DEFAULT cmake)
|
||||
else(WIN32)
|
||||
set(NG_INSTALL_DIR_CMAKE_DEFAULT lib/cmake/${NG_INSTALL_SUFFIX})
|
||||
endif(WIN32)
|
||||
set(NG_INSTALL_DIR_PYTHON_DEFAULT ${PYTHON_PACKAGES_INSTALL_DIR})
|
||||
set(NG_INSTALL_DIR_RES_DEFAULT share)
|
||||
set(NG_INSTALL_DIR_INCLUDE_DEFAULT include)
|
||||
|
||||
set(NG_RPATH_TOKEN "\$ORIGIN")
|
||||
endif(APPLE)
|
||||
set(ng_install_dir EXPORT netgen-targets RUNTIME DESTINATION ${ng_install_dir_bin} COMPONENT netgen LIBRARY DESTINATION ${ng_install_dir_lib} COMPONENT netgen_devel ARCHIVE DESTINATION ${ng_install_dir_lib} COMPONENT netgen_devel)
|
||||
install(EXPORT netgen-targets DESTINATION share/cmake)
|
||||
|
||||
set(NG_INSTALL_DIR_PYTHON ${NG_INSTALL_DIR_PYTHON_DEFAULT} CACHE STRING "Install directory for Python files")
|
||||
set(NG_INSTALL_DIR_BIN ${NG_INSTALL_DIR_BIN_DEFAULT} CACHE STRING "Install directory for executables")
|
||||
set(NG_INSTALL_DIR_LIB ${NG_INSTALL_DIR_LIB_DEFAULT} CACHE STRING "Install directory for libraries")
|
||||
set(NG_INSTALL_DIR_INCLUDE ${NG_INSTALL_DIR_INCLUDE_DEFAULT} CACHE STRING "Install directory for header files")
|
||||
set(NG_INSTALL_DIR_CMAKE ${NG_INSTALL_DIR_CMAKE_DEFAULT} CACHE STRING "Install directory for CMake files")
|
||||
set(NG_INSTALL_DIR_RES ${NG_INSTALL_DIR_RES_DEFAULT} CACHE STRING "Install directory for resources")
|
||||
|
||||
get_filename_component(NETGEN_CMAKE_DIR_ABSOLUTE ${NG_INSTALL_DIR_CMAKE} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
get_filename_component(NETGEN_BINARY_DIR_ABSOLUTE ${NG_INSTALL_DIR_BIN} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
get_filename_component(NETGEN_LIBRARY_DIR_ABSOLUTE ${NG_INSTALL_DIR_LIB} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
get_filename_component(NETGEN_INCLUDE_DIR_ABSOLUTE ${NG_INSTALL_DIR_INCLUDE} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
get_filename_component(NETGEN_PYTHON_DIR_ABSOLUTE ${NG_INSTALL_DIR_PYTHON} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
get_filename_component(NETGEN_RESOURCE_DIR_ABSOLUTE ${NG_INSTALL_DIR_RES} ABSOLUTE BASE_DIR ${CMAKE_INSTALL_PREFIX})
|
||||
|
||||
file(RELATIVE_PATH NETGEN_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${CMAKE_INSTALL_PREFIX})
|
||||
file(RELATIVE_PATH NETGEN_BINARY_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_BINARY_DIR_ABSOLUTE})
|
||||
file(RELATIVE_PATH NETGEN_LIBRARY_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_LIBRARY_DIR_ABSOLUTE})
|
||||
file(RELATIVE_PATH NETGEN_INCLUDE_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_INCLUDE_DIR_ABSOLUTE})
|
||||
file(RELATIVE_PATH NETGEN_PYTHON_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_PYTHON_DIR_ABSOLUTE})
|
||||
file(RELATIVE_PATH NETGEN_RESOURCE_DIR ${NETGEN_CMAKE_DIR_ABSOLUTE} ${NETGEN_RESOURCE_DIR_ABSOLUTE})
|
||||
|
||||
file(RELATIVE_PATH NETGEN_RPATH ${NETGEN_BINARY_DIR_ABSOLUTE} ${NETGEN_LIBRARY_DIR_ABSOLUTE})
|
||||
file(RELATIVE_PATH NETGEN_PYTHON_RPATH_BIN ${NETGEN_PYTHON_DIR_ABSOLUTE} ${NETGEN_BINARY_DIR_ABSOLUTE})
|
||||
file(RELATIVE_PATH NETGEN_PYTHON_RPATH ${NETGEN_PYTHON_DIR_ABSOLUTE} ${NETGEN_LIBRARY_DIR_ABSOLUTE})
|
||||
if(WIN32)
|
||||
set(NETGEN_PYTHON_RPATH ${NETGEN_PYTHON_RPATH_BIN})
|
||||
endif(WIN32)
|
||||
|
||||
set(NG_INSTALL_DIR EXPORT netgen-targets RUNTIME DESTINATION ${NG_INSTALL_DIR_BIN} COMPONENT netgen LIBRARY DESTINATION ${NG_INSTALL_DIR_LIB} COMPONENT netgen_devel ARCHIVE DESTINATION ${NG_INSTALL_DIR_LIB} COMPONENT netgen_devel)
|
||||
install(EXPORT netgen-targets DESTINATION ${NG_INSTALL_DIR_CMAKE} )
|
||||
|
||||
set(CMAKE_MACOSX_RPATH TRUE)
|
||||
set(CMAKE_INSTALL_RPATH "${NG_RPATH_TOKEN};${NG_RPATH_TOKEN}/${NETGEN_RPATH}")
|
||||
|
||||
include (CheckIncludeFiles)
|
||||
check_include_files (dlfcn.h HAVE_DLFCN_H)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
add_definitions(-DHAVE_CONFIG_H)
|
||||
if(HAVE_DLFCN_H)
|
||||
add_definitions(-DHAVE_DLFCN_H)
|
||||
endif()
|
||||
add_definitions(-DPACKAGE_VERSION="${NETGEN_VERSION}")
|
||||
|
||||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
#######################################################################
|
||||
@ -133,8 +197,6 @@ if(WIN32)
|
||||
get_WIN32_WINNT(ver)
|
||||
add_definitions(-D_WIN32_WINNT=${ver} -DWNT -DWNT_WINDOW -DNOMINMAX)
|
||||
set(CMAKE_MFC_FLAG 0)
|
||||
# add_definitions(-DNGINTERFACE_EXPORTS)
|
||||
# add_definitions(-DNGLIB_EXPORTS)
|
||||
add_definitions(-DMSVC_EXPRESS -D_CRT_SECURE_NO_WARNINGS -DHAVE_STRUCT_TIMESPEC)
|
||||
# build convenience (aka object) libraries in windows)
|
||||
set(NG_LIB_TYPE OBJECT)
|
||||
@ -145,9 +207,7 @@ else(WIN32)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
|
||||
endif(WIN32)
|
||||
if(APPLE)
|
||||
# set(MACOSX_BUNDLE ON)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
|
||||
# set(CMAKE_SHARED_LIBRARY_SUFFIX ".so")
|
||||
endif(APPLE)
|
||||
|
||||
#######################################################################
|
||||
@ -190,8 +250,8 @@ if (USE_PYTHON)
|
||||
include_directories(${PYBIND_INCLUDE_DIR})
|
||||
include_directories(${PYTHON_INCLUDE_DIRS})
|
||||
|
||||
install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${INCDIR} COMPONENT netgen_devel)
|
||||
install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${INCDIR}/pybind11 COMPONENT netgen_devel)
|
||||
install(DIRECTORY ${PYBIND_INCLUDE_DIR}/pybind11 DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)
|
||||
install(FILES ${PYBIND_INCLUDE_DIR}/../LICENSE DESTINATION ${NG_INSTALL_DIR_INCLUDE}/pybind11 COMPONENT netgen_devel)
|
||||
endif (USE_PYTHON)
|
||||
|
||||
#######################################################################
|
||||
@ -227,10 +287,10 @@ endif (USE_MPEG)
|
||||
#######################################################################
|
||||
if(INSTALL_PROFILES)
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "#!/bin/sh\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PATH=${INSTALL_DIR}/bin:$PATH\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export NETGENDIR=${INSTALL_DIR}/bin\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PYTHONPATH=${INSTALL_DIR}/${PYTHON_PACKAGES_INSTALL_DIR}:.\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export LD_LIBRARY_PATH=${INSTALL_DIR}/lib:.\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PATH=${CMAKE_INSTALL_PREFIX}/bin:$PATH\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export NETGENDIR=${CMAKE_INSTALL_PREFIX}/bin\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export PYTHONPATH=${CMAKE_INSTALL_PREFIX}/${PYTHON_PACKAGES_INSTALL_DIR}:.\n")
|
||||
file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh "export LD_LIBRARY_PATH=${CMAKE_INSTALL_PREFIX}/lib:.\n")
|
||||
install(PROGRAMS ${CMAKE_CURRENT_BINARY_DIR}/netgen.sh DESTINATION /etc/profile.d COMPONENT netgen)
|
||||
|
||||
string(ASCII 27 Esc)
|
||||
@ -242,19 +302,19 @@ endif(INSTALL_PROFILES)
|
||||
#######################################################################
|
||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake "\
|
||||
include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/netgen_fixup.cmake)
|
||||
set(APP ${INSTALL_DIR})
|
||||
set(APP ${CMAKE_INSTALL_PREFIX})
|
||||
message(\${APP})
|
||||
set(BU_CHMOD_BUNDLE_ITEMS ON)
|
||||
|
||||
file(GLOB libs ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.dylib ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib}/*.so)
|
||||
file(GLOB libs ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_LIB}/*.dylib ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_LIB}/*.so)
|
||||
message(\"\${libs}\")
|
||||
netgen_fixup_bundle( \${APP}/Contents/MacOS/netgen \"\${libs}\" ${CMAKE_INSTALL_PREFIX}/${ng_install_dir_lib} )
|
||||
execute_process(COMMAND ln -s /Applications ${INSTALL_DIR}/../Applications)
|
||||
netgen_fixup_bundle( \${APP}/Contents/MacOS/netgen \"\${libs}\" ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_LIB} )
|
||||
execute_process(COMMAND ln -s /Applications ${CMAKE_INSTALL_PREFIX}/../Applications)
|
||||
set (bundle_filename \$ENV{NETGEN_BUNDLE_NAME})
|
||||
if(NOT bundle_filename)
|
||||
set(bundle_filename netgen)
|
||||
endif(NOT bundle_filename)
|
||||
execute_process(COMMAND hdiutil create -volname Netgen -srcfolder ${INSTALL_DIR} -ov -format UDZO \${bundle_filename}-${PACKAGE_VERSION}.dmg)
|
||||
execute_process(COMMAND hdiutil create -volname Netgen -srcfolder ${CMAKE_INSTALL_PREFIX} -ov -format UDZO \${bundle_filename}-${PACKAGE_VERSION}.dmg)
|
||||
")
|
||||
add_custom_target(bundle COMMAND ${CMAKE_COMMAND} "-P" "${CMAKE_CURRENT_BINARY_DIR}/fixup.cmake")
|
||||
#######################################################################
|
||||
@ -328,7 +388,7 @@ export PYTHONPATH=$Netgen_BUNDLE/Contents/Resources/${PYTHON_PACKAGES_INSTALL_DI
|
||||
cd $Netgen_MACOS
|
||||
$Netgen_MACOS/netgen
|
||||
")
|
||||
install(PROGRAMS ${mac_startup} DESTINATION ${ng_install_dir_bin})
|
||||
install(PROGRAMS ${mac_startup} DESTINATION ${NG_INSTALL_DIR_BIN})
|
||||
|
||||
set(mac_ngsuite ${CMAKE_CURRENT_BINARY_DIR}/ngsuite.sh)
|
||||
file(WRITE ${mac_ngsuite} "\
|
||||
@ -337,7 +397,7 @@ Netgen_BUNDLE=\"`echo \"$0\" | sed -e 's/\\/Contents\\/MacOS\\/Netgen1//'`\"
|
||||
Netgen_MACOS=\"$Netgen_BUNDLE/Contents/MacOS\"
|
||||
open -a /Applications/Utilities/Terminal.app $Netgen_MACOS/startup.sh
|
||||
")
|
||||
install(PROGRAMS ${mac_ngsuite} DESTINATION ../MacOS RENAME Netgen1)
|
||||
install(PROGRAMS ${mac_ngsuite} DESTINATION ${NG_INSTALL_DIR_BIN} RENAME Netgen1)
|
||||
|
||||
set(mac_plist ${CMAKE_CURRENT_BINARY_DIR}/Info.plist)
|
||||
file(WRITE ${mac_plist} "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
|
||||
@ -355,8 +415,8 @@ open -a /Applications/Utilities/Terminal.app $Netgen_MACOS/startup.sh
|
||||
</dict>
|
||||
</plist>
|
||||
")
|
||||
install(FILES ${mac_plist} DESTINATION ../)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns DESTINATION . RENAME Netgen.icns)
|
||||
install(FILES ${mac_plist} DESTINATION ${NG_INSTALL_DIR_BIN}/../)
|
||||
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/netgen.icns DESTINATION ${NG_INSTALL_DIR_RES}/../ RENAME Netgen.icns)
|
||||
|
||||
endif(APPLE)
|
||||
|
||||
@ -373,10 +433,14 @@ configure_file(
|
||||
add_custom_target(uninstall
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
|
||||
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY)
|
||||
#######################################################################
|
||||
# Generate package config file
|
||||
get_directory_property(NETGEN_COMPILE_DEFINITIONS COMPILE_DEFINITIONS)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION share/cmake)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/NetgenConfig.cmake.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake @ONLY ESCAPE_QUOTES)
|
||||
|
||||
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/NetgenConfig.cmake DESTINATION ${NG_INSTALL_DIR_CMAKE})
|
||||
|
||||
#######################################################################
|
||||
# Configure message
|
||||
|
@ -1,9 +1,20 @@
|
||||
set(PACKAGE_VERSION "@NETGEN_VERSION@")
|
||||
set(NETGEN_DIR "@CMAKE_INSTALL_PREFIX@")
|
||||
|
||||
set(NETGEN_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/@INCDIR@")
|
||||
get_filename_component(NETGEN_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
|
||||
|
||||
get_filename_component(NETGEN_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_DIR@" ABSOLUTE)
|
||||
|
||||
set(NETGEN_COMPILE_DEFINITIONS "@NETGEN_COMPILE_DEFINITIONS@")
|
||||
|
||||
get_filename_component(NETGEN_INCLUDE_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_INCLUDE_DIR@" ABSOLUTE)
|
||||
get_filename_component(NETGEN_BINARY_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_BINARY_DIR@" ABSOLUTE)
|
||||
get_filename_component(NETGEN_LIBRARY_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_LIBRARY_DIR@" ABSOLUTE)
|
||||
get_filename_component(NETGEN_PYTHON_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_PYTHON_DIR@" ABSOLUTE)
|
||||
get_filename_component(NETGEN_RESOURCE_DIR "${NETGEN_CMAKE_DIR}/@NETGEN_RESOURCE_DIR@" ABSOLUTE)
|
||||
|
||||
set(NETGEN_SOURCE_DIR "@PROJECT_SOURCE_DIR@")
|
||||
|
||||
set(NETGEN_INCLUDE_DIRS "${NETGEN_INCLUDE_DIR}/include;${NETGEN_INCLUDE_DIR}")
|
||||
set(NETGEN_CMAKE_THREAD_LIBS_INIT "@CMAKE_THREAD_LIBS_INIT@")
|
||||
set(NETGEN_FFMPEG_LIBRARIES "@FFMPEG_LIBRARIES@")
|
||||
set(NETGEN_JPEG_INCLUDE_DIR "@JPEG_INCLUDE_DIR@")
|
||||
@ -14,17 +25,14 @@ set(NETGEN_METIS_LIBRARY "@METIS_LIBRARY@")
|
||||
set(NETGEN_MKL_LIBRARIES "@MKL_LIBRARIES@")
|
||||
set(NETGEN_MPI_CXX_INCLUDE_PATH "@MPI_CXX_INCLUDE_PATH@")
|
||||
set(NETGEN_MPI_CXX_LIBRARIES "@MPI_CXX_LIBRARIES@")
|
||||
set(NETGEN_INCLUDE_DIRS "@CMAKE_INSTALL_PREFIX@/@INCDIR@;@CMAKE_INSTALL_PREFIX@/@INCDIR@/include")
|
||||
set(NETGEN_OCC_INCLUDE_DIR "@OCC_INCLUDE_DIR@")
|
||||
set(NETGEN_OCC_LIBRARIES_BIN "@OCC_LIBRARIES_BIN@")
|
||||
set(NETGEN_OCC_LIBRARIES "@OCC_LIBRARIES@")
|
||||
set(NETGEN_OCC_LIBRARY_DIR "@OCC_LIBRARY_DIR@")
|
||||
set(NETGEN_OPENGL_LIBRARIES "@OPENGL_LIBRARIES@")
|
||||
set(NETGEN_PYBIND_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include")
|
||||
set(NETGEN_PYTHON_EXECUTABLE "@PYTHON_EXECUTABLE@")
|
||||
set(NETGEN_PYTHON_INCLUDE_DIRS "@PYTHON_INCLUDE_DIRS@")
|
||||
set(NETGEN_PYTHON_LIBRARIES "@PYTHON_LIBRARIES@")
|
||||
set(NETGEN_PYTHON_PACKAGES_INSTALL_DIR "@PYTHON_PACKAGES_INSTALL_DIR@")
|
||||
set(NETGEN_TCL_INCLUDE_PATH "@TCL_INCLUDE_PATH@")
|
||||
set(NETGEN_TCL_LIBRARY "@TCL_LIBRARY@")
|
||||
set(NETGEN_TK_DND_LIBRARY "@TK_DND_LIBRARY@")
|
||||
@ -45,5 +53,15 @@ set(NETGEN_INTEL_MIC @INTEL_MIC@)
|
||||
set(NETGEN_INSTALL_PROFILES @INSTALL_PROFILES@)
|
||||
set(NETGEN_USE_CCACHE @USE_CCACHE@)
|
||||
|
||||
set(NETGEN_PYTHON_RPATH "@NETGEN_PYTHON_RPATH@")
|
||||
set(NETGEN_RPATH_TOKEN "@NG_RPATH_TOKEN@")
|
||||
|
||||
set(NETGEN_INSTALL_DIR_PYTHON @NG_INSTALL_DIR_PYTHON@)
|
||||
set(NETGEN_INSTALL_DIR_BIN @NG_INSTALL_DIR_BIN@)
|
||||
set(NETGEN_INSTALL_DIR_LIB @NG_INSTALL_DIR_LIB@)
|
||||
set(NETGEN_INSTALL_DIR_INCLUDE @NG_INSTALL_DIR_INCLUDE@)
|
||||
set(NETGEN_INSTALL_DIR_CMAKE @NG_INSTALL_DIR_CMAKE@)
|
||||
set(NETGEN_INSTALL_DIR_RES @NG_INSTALL_DIR_RES@)
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/netgen-targets.cmake)
|
||||
message(STATUS "Found Netgen: ${NETGEN_DIR}")
|
||||
message(STATUS "Found Netgen: ${CMAKE_CURRENT_LIST_DIR}")
|
||||
|
@ -40,19 +40,10 @@ if(WIN32)
|
||||
endif(${CMAKE_SIZEOF_VOID_P} MATCHES 4)
|
||||
endif(WIN32)
|
||||
|
||||
#######################################################################
|
||||
# find netgen
|
||||
if(APPLE)
|
||||
set(INSTALL_DIR /Applications/Netgen.app CACHE PATH "Install path")
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}/Contents/Resources" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
||||
else(APPLE)
|
||||
set(INSTALL_DIR /opt/netgen CACHE PATH "Install path")
|
||||
set(CMAKE_INSTALL_PREFIX "${INSTALL_DIR}" CACHE INTERNAL "Prefix prepended to install directories" FORCE)
|
||||
endif(APPLE)
|
||||
if(UNIX)
|
||||
message("Checking for write permissions in install directory...")
|
||||
execute_process(COMMAND mkdir -p ${INSTALL_DIR})
|
||||
execute_process(COMMAND test -w ${INSTALL_DIR} RESULT_VARIABLE res)
|
||||
execute_process(COMMAND mkdir -p ${CMAKE_INSTALL_PREFIX})
|
||||
execute_process(COMMAND test -w ${CMAKE_INSTALL_PREFIX} RESULT_VARIABLE res)
|
||||
if(res)
|
||||
message(WARNING "No write access at install directory, please set correct permissions")
|
||||
endif()
|
||||
@ -94,7 +85,7 @@ if(USE_OCC AND WIN32 AND NOT OCC_INCLUDE_DIR)
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${INSTALL_DIR}
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
|
||||
LOG_DOWNLOAD 1
|
||||
)
|
||||
list(APPEND NETGEN_DEPENDENCIES win_download_occ)
|
||||
@ -140,10 +131,11 @@ set_vars( NETGEN_CMAKE_ARGS
|
||||
USE_NATIVE_ARCH
|
||||
USE_OCC
|
||||
USE_MPEG
|
||||
INSTALL_DIR
|
||||
USE_INTERNAL_TCL
|
||||
INSTALL_PROFILES
|
||||
INTEL_MIC
|
||||
CMAKE_PREFIX_PATH
|
||||
CMAKE_INSTALL_PREFIX
|
||||
)
|
||||
|
||||
# propagate all variables set on the command line using cmake -DFOO=BAR
|
||||
@ -166,7 +158,7 @@ endif()
|
||||
ExternalProject_Add (netgen
|
||||
DEPENDS ${NETGEN_DEPENDENCIES}
|
||||
SOURCE_DIR ${PROJECT_SOURCE_DIR}
|
||||
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${NETGEN_CMAKE_ARGS} -DCMAKE_PREFIX_PATH=${INSTALL_DIR}
|
||||
CMAKE_ARGS -DUSE_SUPERBUILD=OFF ${NETGEN_CMAKE_ARGS}
|
||||
INSTALL_COMMAND ""
|
||||
BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/netgen
|
||||
BUILD_COMMAND ${NETGEN_BUILD_COMMAND}
|
||||
@ -176,21 +168,21 @@ ExternalProject_Add (netgen
|
||||
# Check if the git submodules (i.e. pybind11) are up to date
|
||||
# in case, something is wrong, emit a warning but continue
|
||||
ExternalProject_Add_Step(netgen check_submodules
|
||||
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
|
||||
DEPENDERS install # Steps on which this step depends
|
||||
)
|
||||
|
||||
# Due to 'ALWAYS 1', this step is always run which also forces a build of
|
||||
# the Netgen subproject
|
||||
ExternalProject_Add_Step(netgen check_submodules1
|
||||
COMMAND cmake -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
|
||||
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_submodules.cmake
|
||||
DEPENDEES configure # Steps on which this step depends
|
||||
DEPENDERS build # Steps that depend on this step
|
||||
ALWAYS 1 # No stamp file, step always runs
|
||||
)
|
||||
|
||||
|
||||
install(CODE "execute_process(COMMAND cmake --build . --target install --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/netgen)")
|
||||
install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} --build . --target install --config ${CMAKE_BUILD_TYPE} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/netgen)")
|
||||
|
||||
add_custom_target(test_netgen
|
||||
${CMAKE_COMMAND} --build ${CMAKE_CURRENT_BINARY_DIR}/netgen
|
||||
|
@ -1,59 +1,58 @@
|
||||
if(APPLE)
|
||||
set(HOME $ENV{HOME})
|
||||
set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../)
|
||||
ExternalProject_Add(project_tcl
|
||||
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tcl8.6.4-src.tar.gz"
|
||||
URL_MD5 d7cbb91f1ded1919370a30edd1534304
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
UPDATE_COMMAND "" # Disable update
|
||||
CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
|
||||
BUILD_COMMAND make -j4 binaries libraries
|
||||
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_BUILD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_INSTALL 1
|
||||
)
|
||||
|
||||
ExternalProject_Add(project_tk
|
||||
DEPENDS project_tcl
|
||||
URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tk8.6.4-src.tar.gz"
|
||||
URL_MD5 261754d7dc2a582f00e35547777e1fea
|
||||
DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
UPDATE_COMMAND "" # Disable update
|
||||
CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
|
||||
BUILD_COMMAND make -j4 binaries libraries
|
||||
INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||
LOG_DOWNLOAD 1
|
||||
LOG_BUILD 1
|
||||
LOG_CONFIGURE 1
|
||||
LOG_INSTALL 1
|
||||
)
|
||||
|
||||
#ExternalProject_Add(tkdnd
|
||||
#DEPENDS tcl tk
|
||||
#URL "http://sourceforge.net/projects/tkdnd/files/TkDND/TkDND%202.8/tkdnd2.8-src.tar.gz"
|
||||
#URL_MD5 a6d47a996ea957416469b12965d4db91
|
||||
#DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
#PATCH_COMMAND patch -p1 < ${CMAKE_CURRENT_LIST_DIR}/tkdnd_macosx.patch
|
||||
#UPDATE_COMMAND "" # Disable update
|
||||
#BUILD_IN_SOURCE 1
|
||||
#CONFIGURE_COMMAND ./configure --with-tcl=${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework --with-tk=${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework --prefix=${CMAKE_INSTALL_PREFIX}/../MacOS --libdir=${CMAKE_INSTALL_PREFIX}/../MacOS
|
||||
#BUILD_COMMAND make
|
||||
#INSTALL_COMMAND make install
|
||||
#LOG_DOWNLOAD 1
|
||||
#LOG_CONFIGURE 1
|
||||
#LOG_BUILD 1
|
||||
#LOG_INSTALL 1
|
||||
#)
|
||||
|
||||
list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk)
|
||||
list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}../Frameworks)
|
||||
set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework/Headers)
|
||||
set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework)
|
||||
set(TK_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework)
|
||||
set(TK_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework/Headers)
|
||||
|
||||
# use system tcl/tk
|
||||
find_package(TCL 8.5 REQUIRED)
|
||||
# set(HOME $ENV{HOME})
|
||||
# set(tcl_prefix ${CMAKE_INSTALL_PREFIX}/../../)
|
||||
# ExternalProject_Add(project_tcl
|
||||
# URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tcl8.6.4-src.tar.gz"
|
||||
# URL_MD5 d7cbb91f1ded1919370a30edd1534304
|
||||
# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
# UPDATE_COMMAND "" # Disable update
|
||||
# CONFIGURE_COMMAND ../project_tcl/macosx/configure --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin
|
||||
# BUILD_COMMAND make -j4 binaries libraries
|
||||
# INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||
# LOG_DOWNLOAD 1
|
||||
# LOG_BUILD 1
|
||||
# LOG_CONFIGURE 1
|
||||
# LOG_INSTALL 1
|
||||
# )
|
||||
#
|
||||
# ExternalProject_Add(project_tk
|
||||
# DEPENDS project_tcl
|
||||
# URL "http://sourceforge.net/projects/tcl/files/Tcl/8.6.4/tk8.6.4-src.tar.gz"
|
||||
# URL_MD5 261754d7dc2a582f00e35547777e1fea
|
||||
# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
# UPDATE_COMMAND "" # Disable update
|
||||
# CONFIGURE_COMMAND ../project_tk/macosx/configure --enable-aqua=yes --enable-threads --enable-framework --prefix=${tcl_prefix} --libdir=${tcl_prefix}/Contents/Frameworks --bindir=${tcl_prefix}/Contents/Frameworks/Tcl.framework/bin --with-tcl=${tcl_prefix}/Contents/Frameworks/Tcl.framework
|
||||
# BUILD_COMMAND make -j4 binaries libraries
|
||||
# INSTALL_COMMAND make install-binaries install-headers install-libraries install-private-headers
|
||||
# LOG_DOWNLOAD 1
|
||||
# LOG_BUILD 1
|
||||
# LOG_CONFIGURE 1
|
||||
# LOG_INSTALL 1
|
||||
# )
|
||||
#
|
||||
# ExternalProject_Add(project_tkdnd
|
||||
# URL "https://sourceforge.net/projects/tkdnd/files/OS%20X%20Binaries/TkDND%202.8/tkdnd2.8-OSX-MountainLion.tar.gz"
|
||||
# URL_MD5 2dbb471b1d66c5f391f3c3c5b71548fb
|
||||
# DOWNLOAD_DIR ${CMAKE_CURRENT_SOURCE_DIR}/external_dependencies
|
||||
# BUILD_IN_SOURCE 1
|
||||
# CONFIGURE_COMMAND ""
|
||||
# BUILD_COMMAND ""
|
||||
# INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}/../MacOS
|
||||
# LOG_DOWNLOAD 1
|
||||
# LOG_CONFIGURE 1
|
||||
# LOG_BUILD 1
|
||||
# LOG_INSTALL 1
|
||||
# )
|
||||
#
|
||||
# list(APPEND NETGEN_DEPENDENCIES project_tcl project_tk project_tkdnd)
|
||||
# list(APPEND CMAKE_PREFIX_PATH ${CMAKE_INSTALL_PREFIX}../Frameworks)
|
||||
# set(TCL_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework/Headers)
|
||||
# set(TCL_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tcl.framework)
|
||||
# set(TK_LIBRARY ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework)
|
||||
# set(TK_INCLUDE_PATH ${CMAKE_INSTALL_PREFIX}/../Frameworks/Tk.framework/Headers)
|
||||
#
|
||||
elseif(WIN32)
|
||||
|
||||
ExternalProject_Add(project_win_extlibs
|
||||
@ -62,7 +61,7 @@ elseif(WIN32)
|
||||
BUILD_IN_SOURCE 1
|
||||
CONFIGURE_COMMAND ""
|
||||
BUILD_COMMAND ""
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${INSTALL_DIR}
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} -E copy_directory . ${CMAKE_INSTALL_PREFIX}
|
||||
LOG_DOWNLOAD 1
|
||||
)
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
#cmakedefine HAVE_DLFCN_H 1
|
||||
#define PACKAGE_VERSION "${NETGEN_VERSION}"
|
@ -1 +1 @@
|
||||
INSTALL(FILES ng4.pdf DESTINATION doc COMPONENT netgen_doc)
|
||||
INSTALL(FILES ng4.pdf DESTINATION ${NG_INSTALL_DIR_RES}/${NG_INSTALL_SUFFIX}/doc COMPONENT netgen_doc)
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit 07de0d8627101be53986e841cd4e21ee38c2498a
|
||||
Subproject commit fe0cf8b73b8e068c205e062c779eb694b194d6b4
|
@ -14,7 +14,7 @@ endif(APPLE)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(csg mesh ${PYTHON_LIBRARIES})
|
||||
target_link_libraries(csg ${PYTHON_LIBRARIES})
|
||||
install( TARGETS csg ${ng_install_dir})
|
||||
install( TARGETS csg ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ if(USE_GUI)
|
||||
if(APPLE)
|
||||
set_target_properties( csgvis PROPERTIES SUFFIX ".so")
|
||||
endif(APPLE)
|
||||
install( TARGETS csgvis ${ng_install_dir})
|
||||
install( TARGETS csgvis ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
endif(USE_GUI)
|
||||
|
||||
@ -36,5 +36,5 @@ install(FILES
|
||||
polyhedra.hpp revolution.hpp singularref.hpp solid.hpp
|
||||
specpoin.hpp spline3d.hpp splinesurface.hpp surface.hpp
|
||||
triapprox.hpp vscsg.hpp
|
||||
DESTINATION ${INCDIR}/csg COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/csg COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -441,6 +441,9 @@ DLL_HEADER void ExportCSG(py::module &m)
|
||||
}
|
||||
spsol->AddSurfaces(self);
|
||||
int tlonr = self.SetTopLevelObject(spsol->GetSolid(), surf.get());
|
||||
self.GetTopLevelObject(tlonr) -> SetBCProp(surf->GetBase()->GetBCProperty());
|
||||
self.GetTopLevelObject(tlonr) -> SetBCName(surf->GetBase()->GetBCName());
|
||||
self.GetTopLevelObject(tlonr) -> SetMaxH(surf->GetBase()->GetMaxH());
|
||||
for(auto p : surf->GetPoints())
|
||||
self.AddUserPoint(p);
|
||||
self.AddSplineSurface(surf);
|
||||
|
@ -259,11 +259,11 @@ namespace netgen
|
||||
first_id.Set();
|
||||
|
||||
|
||||
INDEX_2_HASHTABLE<int> & identpts =
|
||||
mesh.GetIdentifications().GetIdentifiedPoints ();
|
||||
|
||||
if (&identpts)
|
||||
if (mesh.GetIdentifications().HasIdentifiedPoints())
|
||||
{
|
||||
INDEX_2_HASHTABLE<int> & identpts =
|
||||
mesh.GetIdentifications().GetIdentifiedPoints ();
|
||||
|
||||
for (i = 1; i <= identpts.GetNBags(); i++)
|
||||
for (j = 1; j <= identpts.GetBagSize(i); j++)
|
||||
{
|
||||
|
@ -8,14 +8,14 @@ add_library(gen OBJECT
|
||||
|
||||
set_target_properties( gen PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
||||
|
||||
install( FILES ngexception.hpp DESTINATION ${INCDIR} COMPONENT netgen_devel )
|
||||
install( FILES ngexception.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel )
|
||||
|
||||
install(FILES
|
||||
archive_base.hpp array.hpp autodiff.hpp autoptr.hpp bitarray.hpp
|
||||
dynamicmem.hpp flags.hpp hashtabl.hpp mpi_interface.hpp myadt.hpp
|
||||
mysimd.hpp mystring.hpp netgenout.hpp ngexception.hpp ngpython.hpp
|
||||
ngsimd.hpp mystring.hpp netgenout.hpp ngexception.hpp ngpython.hpp
|
||||
optmem.hpp parthreads.hpp profiler.hpp seti.hpp sort.hpp
|
||||
spbita2d.hpp stack.hpp symbolta.hpp table.hpp template.hpp
|
||||
gzstream.h
|
||||
DESTINATION ${INCDIR}/general COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/general COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -329,7 +329,7 @@ namespace netgen
|
||||
RangeCheck (i+1);
|
||||
#endif
|
||||
|
||||
data[i] = data[size-1];
|
||||
data[i] = std::move(data[size-1]);
|
||||
size--;
|
||||
// DeleteElement (i+1);
|
||||
}
|
||||
@ -342,7 +342,7 @@ namespace netgen
|
||||
RangeCheck (i);
|
||||
#endif
|
||||
|
||||
data[i-1] = data[size-1];
|
||||
data[i-1] = std::move(data[size-1]);
|
||||
size--;
|
||||
}
|
||||
|
||||
|
@ -213,22 +213,27 @@ namespace netgen
|
||||
|
||||
|
||||
BASE_INDEX_2_CLOSED_HASHTABLE ::
|
||||
BASE_INDEX_2_CLOSED_HASHTABLE (int size)
|
||||
: hash(size)
|
||||
BASE_INDEX_2_CLOSED_HASHTABLE (size_t size)
|
||||
: hash(RoundUp2(size))
|
||||
{
|
||||
size = hash.Size();
|
||||
mask = size-1;
|
||||
// hash.SetName ("i2-hashtable, hash");
|
||||
|
||||
invalid = -1;
|
||||
for (int i = 1; i <= size; i++)
|
||||
hash.Elem(i).I1() = invalid;
|
||||
for (size_t i = 0; i < size; i++)
|
||||
hash[i].I1() = invalid;
|
||||
}
|
||||
|
||||
void BASE_INDEX_2_CLOSED_HASHTABLE ::
|
||||
BaseSetSize (int size)
|
||||
{
|
||||
size = RoundUp2 (size);
|
||||
mask = size-1;
|
||||
|
||||
hash.SetSize(size);
|
||||
for (int i = 1; i <= size; i++)
|
||||
hash.Elem(i).I1() = invalid;
|
||||
for (size_t i = 0; i < size; i++)
|
||||
hash[i].I1() = invalid;
|
||||
}
|
||||
|
||||
|
||||
@ -245,25 +250,28 @@ namespace netgen
|
||||
}
|
||||
}
|
||||
|
||||
int BASE_INDEX_2_CLOSED_HASHTABLE ::
|
||||
bool BASE_INDEX_2_CLOSED_HASHTABLE ::
|
||||
PositionCreate2 (const INDEX_2 & ind, int & apos)
|
||||
{
|
||||
int i = HashValue(ind);
|
||||
int startpos = i;
|
||||
while (1)
|
||||
{
|
||||
/*
|
||||
i++;
|
||||
if (i > hash.Size()) i = 1;
|
||||
if (hash.Get(i) == ind)
|
||||
*/
|
||||
i = (i+1) % hash.Size();
|
||||
if (hash[i] == ind)
|
||||
{
|
||||
apos = i;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
if (hash.Get(i).I1() == invalid)
|
||||
if (hash[i].I1() == invalid)
|
||||
{
|
||||
hash.Elem(i) = ind;
|
||||
hash[i] = ind;
|
||||
apos = i;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
if (i == startpos)
|
||||
throw NgException ("Try to set new element in full closed hashtable");
|
||||
|
@ -628,7 +628,12 @@ public:
|
||||
|
||||
|
||||
|
||||
|
||||
inline size_t RoundUp2 (size_t i)
|
||||
{
|
||||
size_t res = 1;
|
||||
while (res < i) res *= 2; // hope it will never be too large
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Closed Hashing HT
|
||||
|
||||
@ -640,47 +645,52 @@ protected:
|
||||
Array<INDEX_2> hash;
|
||||
///
|
||||
int invalid;
|
||||
size_t mask;
|
||||
public:
|
||||
///
|
||||
BASE_INDEX_2_CLOSED_HASHTABLE (int size);
|
||||
BASE_INDEX_2_CLOSED_HASHTABLE (size_t size);
|
||||
|
||||
int Size() const { return hash.Size(); }
|
||||
int UsedPos (int pos) const { return ! (hash.Get(pos).I1() == invalid); }
|
||||
bool UsedPos0 (int pos) const { return ! (hash[pos].I1() == invalid); }
|
||||
int UsedElements () const;
|
||||
|
||||
///
|
||||
int HashValue (const INDEX_2 & ind) const
|
||||
{
|
||||
return (ind.I1() + 71 * ind.I2()) % hash.Size() + 1;
|
||||
// return (ind.I1() + 71 * ind.I2()) % hash.Size() + 1;
|
||||
return (ind.I1() + 71 * ind.I2()) & mask;
|
||||
}
|
||||
|
||||
|
||||
int Position (const INDEX_2 & ind) const
|
||||
int Position0 (const INDEX_2 & ind) const
|
||||
{
|
||||
int i = HashValue(ind);
|
||||
while (1)
|
||||
{
|
||||
if (hash.Get(i) == ind) return i;
|
||||
if (hash.Get(i).I1() == invalid) return 0;
|
||||
if (hash[i] == ind) return i;
|
||||
if (hash[i].I1() == invalid) return -1;
|
||||
i = (i+1) & mask;
|
||||
/*
|
||||
i++;
|
||||
if (i > hash.Size()) i = 1;
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
// returns 1, if new postion is created
|
||||
int PositionCreate (const INDEX_2 & ind, int & apos)
|
||||
bool PositionCreate0 (const INDEX_2 & ind, int & apos)
|
||||
{
|
||||
int i = HashValue (ind);
|
||||
if (hash.Get(i) == ind)
|
||||
if (hash[i] == ind)
|
||||
{
|
||||
apos = i;
|
||||
return 0;
|
||||
return false;
|
||||
}
|
||||
if (hash.Get(i).I1() == invalid)
|
||||
if (hash[i].I1() == invalid)
|
||||
{
|
||||
hash.Elem(i) = ind;
|
||||
hash[i] = ind;
|
||||
apos = i;
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
return PositionCreate2 (ind, apos);
|
||||
}
|
||||
@ -689,7 +699,7 @@ protected:
|
||||
///
|
||||
|
||||
int Position2 (const INDEX_2 & ind) const;
|
||||
int PositionCreate2 (const INDEX_2 & ind, int & apos);
|
||||
bool PositionCreate2 (const INDEX_2 & ind, int & apos);
|
||||
void BaseSetSize (int asize);
|
||||
};
|
||||
|
||||
@ -697,31 +707,65 @@ protected:
|
||||
template <class T>
|
||||
class INDEX_2_CLOSED_HASHTABLE : public BASE_INDEX_2_CLOSED_HASHTABLE
|
||||
{
|
||||
///
|
||||
// MoveableArray<T> cont;
|
||||
Array<T> cont;
|
||||
|
||||
public:
|
||||
INDEX_2_CLOSED_HASHTABLE (size_t size)
|
||||
: BASE_INDEX_2_CLOSED_HASHTABLE(size), cont(RoundUp2(size))
|
||||
{ ; }
|
||||
|
||||
void Set (const INDEX_2 & ahash, const T & acont)
|
||||
{
|
||||
int pos;
|
||||
PositionCreate0 (ahash, pos);
|
||||
hash[pos] = ahash;
|
||||
cont[pos] = acont;
|
||||
}
|
||||
|
||||
const T & Get (const INDEX_2 & ahash) const
|
||||
{
|
||||
int pos = Position0 (ahash);
|
||||
return cont[pos];
|
||||
}
|
||||
|
||||
inline bool Used (const INDEX_2 & ahash) const
|
||||
{
|
||||
int pos = Position0 (ahash);
|
||||
return (pos != -1);
|
||||
}
|
||||
|
||||
inline void SetData0 (int pos, const INDEX_2 & ahash, const T & acont)
|
||||
{
|
||||
hash[pos] = ahash;
|
||||
cont[pos] = acont;
|
||||
}
|
||||
|
||||
///
|
||||
inline INDEX_2_CLOSED_HASHTABLE (int size);
|
||||
inline void GetData0 (int pos, INDEX_2 & ahash, T & acont) const
|
||||
{
|
||||
ahash = hash[pos];
|
||||
acont = cont[pos];
|
||||
}
|
||||
|
||||
inline void SetData0 (int pos, const T & acont)
|
||||
{
|
||||
cont[pos] = acont;
|
||||
}
|
||||
|
||||
inline void GetData0 (int pos, T & acont) const
|
||||
{
|
||||
acont = cont[pos];
|
||||
}
|
||||
|
||||
///
|
||||
inline void Set (const INDEX_2 & ahash, const T & acont);
|
||||
const T & GetData0 (int pos) { return cont[pos]; }
|
||||
///
|
||||
inline const T & Get (const INDEX_2 & ahash) const;
|
||||
///
|
||||
inline bool Used (const INDEX_2 & ahash) const;
|
||||
///
|
||||
inline void SetData (int pos, const INDEX_2 & ahash, const T & acont);
|
||||
///
|
||||
inline void GetData (int pos, INDEX_2 & ahash, T & acont) const;
|
||||
///
|
||||
inline void SetData (int pos, const T & acont);
|
||||
///
|
||||
inline void GetData (int pos, T & acont) const;
|
||||
///
|
||||
const T & GetData (int pos) { return cont.Get(pos); }
|
||||
///
|
||||
inline void SetSize (int size);
|
||||
inline void SetSize (size_t size)
|
||||
{
|
||||
BaseSetSize(size);
|
||||
cont.SetSize(RoundUp2(size));
|
||||
}
|
||||
|
||||
|
||||
///
|
||||
inline void PrintMemInfo (ostream & ost) const;
|
||||
///
|
||||
@ -746,7 +790,7 @@ inline ostream & operator<< (ostream & ost, const INDEX_2_CLOSED_HASHTABLE<T> &
|
||||
{
|
||||
INDEX_2 hash;
|
||||
T data;
|
||||
ht.GetData (i, hash, data);
|
||||
ht.GetData0 (i, hash, data);
|
||||
ost << "hash = " << hash << ", data = " << data << endl;
|
||||
}
|
||||
return ost;
|
||||
@ -755,13 +799,6 @@ inline ostream & operator<< (ostream & ost, const INDEX_2_CLOSED_HASHTABLE<T> &
|
||||
|
||||
|
||||
|
||||
inline size_t RoundUp2 (size_t i)
|
||||
{
|
||||
size_t res = 1;
|
||||
while (res < i) res *= 2; // hope it will never be too large
|
||||
return res;
|
||||
}
|
||||
|
||||
class BASE_INDEX_3_CLOSED_HASHTABLE
|
||||
{
|
||||
protected:
|
||||
@ -1186,83 +1223,6 @@ inline void INDEX_HASHTABLE<T> :: PrintMemInfo (ostream & ost) const
|
||||
|
||||
|
||||
/* *********** Closed Hashing ************************* */
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
inline INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
INDEX_2_CLOSED_HASHTABLE (int size)
|
||||
: BASE_INDEX_2_CLOSED_HASHTABLE(size), cont(size)
|
||||
{
|
||||
// cont.SetName ("i2-hashtable, contents");
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
Set (const INDEX_2 & ahash, const T & acont)
|
||||
{
|
||||
int pos;
|
||||
PositionCreate (ahash, pos);
|
||||
hash.Elem(pos) = ahash;
|
||||
cont.Elem(pos) = acont;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T & INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
Get (const INDEX_2 & ahash) const
|
||||
{
|
||||
int pos = Position (ahash);
|
||||
return cont.Get(pos);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
Used (const INDEX_2 & ahash) const
|
||||
{
|
||||
int pos = Position (ahash);
|
||||
return (pos != 0);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
SetData (int pos, const INDEX_2 & ahash, const T & acont)
|
||||
{
|
||||
hash.Elem(pos) = ahash;
|
||||
cont.Elem(pos) = acont;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
GetData (int pos, INDEX_2 & ahash, T & acont) const
|
||||
{
|
||||
ahash = hash.Get(pos);
|
||||
acont = cont.Get(pos);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
SetData (int pos, const T & acont)
|
||||
{
|
||||
cont.Elem(pos) = acont;
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
GetData (int pos, T & acont) const
|
||||
{
|
||||
acont = cont.Get(pos);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
SetSize (int size)
|
||||
{
|
||||
BaseSetSize(size);
|
||||
cont.SetSize(size);
|
||||
}
|
||||
|
||||
|
||||
|
||||
template<class T>
|
||||
inline void INDEX_2_CLOSED_HASHTABLE<T> ::
|
||||
|
@ -46,7 +46,7 @@
|
||||
#include "gzstream.h"
|
||||
#include "archive_base.hpp"
|
||||
|
||||
#include "mysimd.hpp"
|
||||
#include "ngsimd.hpp"
|
||||
|
||||
|
||||
#endif
|
||||
|
@ -1,403 +0,0 @@
|
||||
#ifndef FILE_MYSIMD
|
||||
#define FILE_MYSIMD
|
||||
|
||||
/**************************************************************************/
|
||||
/* File: mysimd.hpp */
|
||||
/* Author: Joachim Schoeberl */
|
||||
/* Date: 25. Mar. 16 */
|
||||
/**************************************************************************/
|
||||
|
||||
#include <immintrin.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef AVX_OPERATORS_DEFINED
|
||||
#define AVX_OPERATORS_DEFINED
|
||||
inline __m128d operator- (__m128d a) { return _mm_xor_pd(a, _mm_set1_pd(-0.0)); }
|
||||
inline __m128d operator+ (__m128d a, __m128d b) { return _mm_add_pd(a,b); }
|
||||
inline __m128d operator- (__m128d a, __m128d b) { return _mm_sub_pd(a,b); }
|
||||
inline __m128d operator* (__m128d a, __m128d b) { return _mm_mul_pd(a,b); }
|
||||
inline __m128d operator/ (__m128d a, __m128d b) { return _mm_div_pd(a,b); }
|
||||
inline __m128d operator* (double a, __m128d b) { return _mm_set1_pd(a)*b; }
|
||||
inline __m128d operator* (__m128d b, double a) { return _mm_set1_pd(a)*b; }
|
||||
|
||||
inline __m128d operator+= (__m128d &a, __m128d b) { return a = a+b; }
|
||||
inline __m128d operator-= (__m128d &a, __m128d b) { return a = a-b; }
|
||||
inline __m128d operator*= (__m128d &a, __m128d b) { return a = a*b; }
|
||||
inline __m128d operator/= (__m128d &a, __m128d b) { return a = a/b; }
|
||||
|
||||
inline __m256d operator- (__m256d a) { return _mm256_xor_pd(a, _mm256_set1_pd(-0.0)); }
|
||||
inline __m256d operator+ (__m256d a, __m256d b) { return _mm256_add_pd(a,b); }
|
||||
inline __m256d operator- (__m256d a, __m256d b) { return _mm256_sub_pd(a,b); }
|
||||
inline __m256d operator* (__m256d a, __m256d b) { return _mm256_mul_pd(a,b); }
|
||||
inline __m256d operator/ (__m256d a, __m256d b) { return _mm256_div_pd(a,b); }
|
||||
inline __m256d operator* (double a, __m256d b) { return _mm256_set1_pd(a)*b; }
|
||||
inline __m256d operator* (__m256d b, double a) { return _mm256_set1_pd(a)*b; }
|
||||
|
||||
inline __m256d operator+= (__m256d &a, __m256d b) { return a = a+b; }
|
||||
inline __m256d operator-= (__m256d &a, __m256d b) { return a = a-b; }
|
||||
inline __m256d operator*= (__m256d &a, __m256d b) { return a = a*b; }
|
||||
inline __m256d operator/= (__m256d &a, __m256d b) { return a = a/b; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
template <typename T> class SIMD;
|
||||
|
||||
template <typename T>
|
||||
struct has_call_operator
|
||||
{
|
||||
template <typename C> static std::true_type check( decltype( sizeof(&C::operator() )) ) { return std::true_type(); }
|
||||
template <typename> static std::false_type check(...) { return std::false_type(); }
|
||||
typedef decltype( check<T>(sizeof(char)) ) type;
|
||||
static constexpr type value = type();
|
||||
};
|
||||
|
||||
#ifdef __AVX__
|
||||
|
||||
template <typename T>
|
||||
class AlignedAlloc
|
||||
{
|
||||
protected:
|
||||
static void * aligned_malloc(size_t s)
|
||||
{
|
||||
// Assume 16 byte alignment of standard library
|
||||
if(alignof(T)<=16)
|
||||
return malloc(s);
|
||||
else
|
||||
return _mm_malloc(s, alignof(T));
|
||||
}
|
||||
|
||||
static void aligned_free(void *p)
|
||||
{
|
||||
if(alignof(T)<=16)
|
||||
free(p);
|
||||
else
|
||||
_mm_free(p);
|
||||
}
|
||||
|
||||
public:
|
||||
void * operator new (size_t s, void *p) { return p; }
|
||||
void * operator new (size_t s) { return aligned_malloc(s); }
|
||||
void * operator new[] (size_t s) { return aligned_malloc(s); }
|
||||
void operator delete (void * p) { aligned_free(p); }
|
||||
void operator delete[] (void * p) { aligned_free(p); }
|
||||
};
|
||||
|
||||
template<>
|
||||
class alignas(32) SIMD<double> : public AlignedAlloc<SIMD<double>>
|
||||
{
|
||||
__m256d data;
|
||||
|
||||
public:
|
||||
static constexpr int Size() { return 4; }
|
||||
SIMD () = default;
|
||||
SIMD (const SIMD &) = default;
|
||||
SIMD & operator= (const SIMD &) = default;
|
||||
|
||||
SIMD (double val)
|
||||
{
|
||||
data = _mm256_set1_pd(val);
|
||||
}
|
||||
|
||||
SIMD (__m256d adata)
|
||||
: data(adata)
|
||||
{ ; }
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
SIMD (const T & val)
|
||||
{
|
||||
// SIMD_function(val, std::is_convertible<T, std::function<double(int)>>());
|
||||
SIMD_function(val, has_call_operator<T>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
SIMD & operator= (const T & val)
|
||||
{
|
||||
// SIMD_function(val, std::is_convertible<T, std::function<double(int)>>());
|
||||
SIMD_function(val, has_call_operator<T>::value);
|
||||
return *this;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
template <typename Function>
|
||||
void SIMD_function (const Function & func, std::true_type)
|
||||
{
|
||||
data = _mm256_set_pd(func(3), func(2), func(1), func(0));
|
||||
}
|
||||
|
||||
// not a function
|
||||
void SIMD_function (double const * p, std::false_type)
|
||||
{
|
||||
data = _mm256_loadu_pd(p);
|
||||
}
|
||||
|
||||
void SIMD_function (double val, std::false_type)
|
||||
{
|
||||
data = _mm256_set1_pd(val);
|
||||
}
|
||||
|
||||
void SIMD_function (__m256d _data, std::false_type)
|
||||
{
|
||||
data = _data;
|
||||
}
|
||||
|
||||
inline double operator[] (int i) const { return ((double*)(&data))[i]; }
|
||||
inline __m256d Data() const { return data; }
|
||||
inline __m256d & Data() { return data; }
|
||||
};
|
||||
|
||||
|
||||
inline SIMD<double> operator+ (SIMD<double> a, SIMD<double> b) { return a.Data()+b.Data(); }
|
||||
inline SIMD<double> operator- (SIMD<double> a, SIMD<double> b) { return a.Data()-b.Data(); }
|
||||
inline SIMD<double> operator- (SIMD<double> a) { return -a.Data(); }
|
||||
inline SIMD<double> operator* (SIMD<double> a, SIMD<double> b) { return a.Data()*b.Data(); }
|
||||
inline SIMD<double> operator/ (SIMD<double> a, SIMD<double> b) { return a.Data()/b.Data(); }
|
||||
inline SIMD<double> operator* (double a, SIMD<double> b) { return SIMD<double>(a)*b; }
|
||||
inline SIMD<double> operator* (SIMD<double> b, double a) { return SIMD<double>(a)*b; }
|
||||
inline SIMD<double> operator+= (SIMD<double> & a, SIMD<double> b) { return a.Data()+=b.Data(); }
|
||||
inline SIMD<double> operator-= (SIMD<double> & a, SIMD<double> b) { return a.Data()-=b.Data(); }
|
||||
inline SIMD<double> operator*= (SIMD<double> & a, SIMD<double> b) { return a.Data()*=b.Data(); }
|
||||
inline SIMD<double> operator/= (SIMD<double> & a, SIMD<double> b) { return a.Data()/=b.Data(); }
|
||||
|
||||
using std::sqrt;
|
||||
using std::fabs;
|
||||
|
||||
inline SIMD<double> sqrt (SIMD<double> a) { return _mm256_sqrt_pd(a.Data()); }
|
||||
inline SIMD<double> fabs (SIMD<double> a) { return _mm256_max_pd(a.Data(), -a.Data()); }
|
||||
inline SIMD<double> L2Norm2 (SIMD<double> a) { return a.Data()*a.Data(); }
|
||||
inline SIMD<double> Trans (SIMD<double> a) { return a; }
|
||||
inline SIMD<double> IfPos (SIMD<double> a, SIMD<double> b, SIMD<double> c)
|
||||
{
|
||||
auto cp = _mm256_cmp_pd (a.Data(), _mm256_setzero_pd(), _CMP_GT_OS);
|
||||
return _mm256_blendv_pd(c.Data(), b.Data(), cp);
|
||||
}
|
||||
|
||||
inline double HSum (SIMD<double> sd)
|
||||
{
|
||||
__m128d hv = _mm_add_pd (_mm256_extractf128_pd(sd.Data(),0), _mm256_extractf128_pd(sd.Data(),1));
|
||||
return _mm_cvtsd_f64 (_mm_hadd_pd (hv, hv));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// it's only a dummy without AVX
|
||||
template <typename T>
|
||||
class AlignedAlloc { ; };
|
||||
|
||||
template<>
|
||||
class SIMD<double>
|
||||
{
|
||||
double data;
|
||||
|
||||
public:
|
||||
static constexpr int Size() { return 1; }
|
||||
SIMD () = default;
|
||||
SIMD (const SIMD &) = default;
|
||||
SIMD & operator= (const SIMD &) = default;
|
||||
|
||||
SIMD (double val)
|
||||
: data(val) { ; }
|
||||
|
||||
/*
|
||||
template <typename T>
|
||||
SIMD (const T & val)
|
||||
{
|
||||
// SIMD_function(val, std::is_convertible<T, std::function<double(int)>>());
|
||||
SIMD_function(val, has_call_operator<T>::value);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
template <typename T>
|
||||
SIMD & operator= (const T & val)
|
||||
{
|
||||
// SIMD_function(val, std::is_convertible<T, std::function<double(int)>>());
|
||||
SIMD_function(val, has_call_operator<T>::value);
|
||||
return *this;
|
||||
}
|
||||
|
||||
template <typename Function>
|
||||
void SIMD_function (const Function & func, std::true_type)
|
||||
{
|
||||
data = func(0);
|
||||
}
|
||||
|
||||
// not a function
|
||||
void SIMD_function (double const * p, std::false_type)
|
||||
{
|
||||
data = *p;
|
||||
}
|
||||
|
||||
void SIMD_function (double val, std::false_type)
|
||||
{
|
||||
data = val;
|
||||
}
|
||||
|
||||
double operator[] (int i) const { return ((double*)(&data))[i]; }
|
||||
double Data() const { return data; }
|
||||
double & Data() { return data; }
|
||||
};
|
||||
|
||||
|
||||
inline SIMD<double> operator+ (SIMD<double> a, SIMD<double> b) { return a.Data()+b.Data(); }
|
||||
inline SIMD<double> operator- (SIMD<double> a, SIMD<double> b) { return a.Data()-b.Data(); }
|
||||
inline SIMD<double> operator- (SIMD<double> a) { return -a.Data(); }
|
||||
inline SIMD<double> operator* (SIMD<double> a, SIMD<double> b) { return a.Data()*b.Data(); }
|
||||
inline SIMD<double> operator/ (SIMD<double> a, SIMD<double> b) { return a.Data()/b.Data(); }
|
||||
inline SIMD<double> operator* (double a, SIMD<double> b) { return SIMD<double>(a)*b; }
|
||||
inline SIMD<double> operator* (SIMD<double> b, double a) { return SIMD<double>(a)*b; }
|
||||
inline SIMD<double> operator+= (SIMD<double> & a, SIMD<double> b) { return a.Data()+=b.Data(); }
|
||||
inline SIMD<double> operator-= (SIMD<double> & a, SIMD<double> b) { return a.Data()-=b.Data(); }
|
||||
inline SIMD<double> operator*= (SIMD<double> & a, SIMD<double> b) { return a.Data()*=b.Data(); }
|
||||
inline SIMD<double> operator/= (SIMD<double> & a, SIMD<double> b) { return a.Data()/=b.Data(); }
|
||||
|
||||
using std::sqrt;
|
||||
using std::fabs;
|
||||
|
||||
inline SIMD<double> sqrt (SIMD<double> a) { return std::sqrt(a.Data()); }
|
||||
inline SIMD<double> fabs (SIMD<double> a) { return std::fabs(a.Data()); }
|
||||
inline SIMD<double> L2Norm2 (SIMD<double> a) { return a.Data()*a.Data(); }
|
||||
inline SIMD<double> Trans (SIMD<double> a) { return a; }
|
||||
inline SIMD<double> IfPos (SIMD<double> a, SIMD<double> b, SIMD<double> c)
|
||||
{
|
||||
return (a.Data() > 0) ? b : c;
|
||||
}
|
||||
|
||||
inline double HSum (SIMD<double> sd)
|
||||
{ return sd.Data(); }
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename T>
|
||||
ostream & operator<< (ostream & ost, SIMD<T> simd)
|
||||
{
|
||||
ost << simd[0];
|
||||
for (int i = 1; i < simd.Size(); i++)
|
||||
ost << " " << simd[i];
|
||||
return ost;
|
||||
}
|
||||
|
||||
/*
|
||||
using std::exp;
|
||||
inline netgen::SIMD<double> exp (netgen::SIMD<double> a) {
|
||||
return netgen::SIMD<double>([&](int i)->double { return exp(a[i]); } );
|
||||
}
|
||||
|
||||
using std::log;
|
||||
inline netgen::SIMD<double> log (netgen::SIMD<double> a) {
|
||||
return netgen::SIMD<double>([&](int i)->double { return log(a[i]); } );
|
||||
}
|
||||
|
||||
using std::pow;
|
||||
inline netgen::SIMD<double> pow (netgen::SIMD<double> a, double x) {
|
||||
return netgen::SIMD<double>([&](int i)->double { return pow(a[i],x); } );
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
template <int D, typename T>
|
||||
class MultiSIMD
|
||||
{
|
||||
SIMD<T> head;
|
||||
MultiSIMD<D-1,T> tail;
|
||||
public:
|
||||
MultiSIMD () = default;
|
||||
MultiSIMD (const MultiSIMD & ) = default;
|
||||
MultiSIMD (T v) : head(v), tail(v) { ; }
|
||||
MultiSIMD (SIMD<T> _head, MultiSIMD<D-1,T> _tail)
|
||||
: head(_head), tail(_tail) { ; }
|
||||
SIMD<T> Head() const { return head; }
|
||||
MultiSIMD<D-1,T> Tail() const { return tail; }
|
||||
SIMD<T> & Head() { return head; }
|
||||
MultiSIMD<D-1,T> & Tail() { return tail; }
|
||||
|
||||
template <int NR>
|
||||
SIMD<T> Get() const { return NR==0 ? head : tail.template Get<NR-1>(); }
|
||||
template <int NR>
|
||||
SIMD<T> & Get() { return NR==0 ? head : tail.template Get<NR-1>(); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class MultiSIMD<2,T>
|
||||
{
|
||||
SIMD<T> v0, v1;
|
||||
public:
|
||||
MultiSIMD () = default;
|
||||
MultiSIMD (const MultiSIMD & ) = default;
|
||||
MultiSIMD (T v) : v0(v), v1(v) { ; }
|
||||
MultiSIMD (SIMD<T> _v0, SIMD<T> _v1) : v0(_v0), v1(_v1) { ; }
|
||||
|
||||
SIMD<T> Head() const { return v0; }
|
||||
SIMD<T> Tail() const { return v1; }
|
||||
SIMD<T> & Head() { return v0; }
|
||||
SIMD<T> & Tail() { return v1; }
|
||||
|
||||
template <int NR>
|
||||
SIMD<T> Get() const { return NR==0 ? v0 : v1; }
|
||||
template <int NR>
|
||||
SIMD<T> & Get() { return NR==0 ? v0 : v1; }
|
||||
};
|
||||
|
||||
template <int D> inline MultiSIMD<D,double> operator+ (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()+b.Head(), a.Tail()+b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator+ (double a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a+b.Head(), a+b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator+ (MultiSIMD<D,double> b, double a)
|
||||
{ return MultiSIMD<D,double> (a+b.Head(), a+b.Tail()); }
|
||||
|
||||
template <int D> inline MultiSIMD<D,double> operator- (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()-b.Head(), a.Tail()-b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator- (double a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a-b.Head(), a-b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator- (MultiSIMD<D,double> b, double a)
|
||||
{ return MultiSIMD<D,double> (b.Head()-a, b.Tail()-a); }
|
||||
template <int D> inline MultiSIMD<D,double> operator- (MultiSIMD<D,double> a)
|
||||
{ return MultiSIMD<D,double> (-a.Head(), -a.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator* (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()*b.Head(), a.Tail()*b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator/ (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()/b.Head(), a.Tail()/b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator* (double a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> ( a*b.Head(), a*b.Tail()); }
|
||||
template <int D> inline MultiSIMD<D,double> operator* (MultiSIMD<D,double> b, double a)
|
||||
{ return MultiSIMD<D,double> ( a*b.Head(), a*b.Tail()); }
|
||||
|
||||
template <int D> inline MultiSIMD<D,double> & operator+= (MultiSIMD<D,double> & a, MultiSIMD<D,double> b)
|
||||
{ a.Head()+=b.Head(); a.Tail()+=b.Tail(); return a; }
|
||||
template <int D> inline MultiSIMD<D,double> operator-= (MultiSIMD<D,double> & a, double b)
|
||||
{ a.Head()-=b; a.Tail()-=b; return a; }
|
||||
template <int D> inline MultiSIMD<D,double> operator-= (MultiSIMD<D,double> & a, MultiSIMD<D,double> b)
|
||||
{ a.Head()-=b.Head(); a.Tail()-=b.Tail(); return a; }
|
||||
template <int D> inline MultiSIMD<D,double> & operator*= (MultiSIMD<D,double> & a, MultiSIMD<D,double> b)
|
||||
{ a.Head()*=b.Head(); a.Tail()*=b.Tail(); return a; }
|
||||
template <int D> inline MultiSIMD<D,double> & operator*= (MultiSIMD<D,double> & a, double b)
|
||||
{ a.Head()*=b; a.Tail()*=b; return a; }
|
||||
// inline MultiSIMD<double> operator/= (MultiSIMD<double> & a, MultiSIMD<double> b) { return a.Data()/=b.Data(); }
|
||||
|
||||
|
||||
template <int D, typename T>
|
||||
ostream & operator<< (ostream & ost, MultiSIMD<D,T> multi)
|
||||
{
|
||||
ost << multi.Head() << " " << multi.Tail();
|
||||
return ost;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
558
libsrc/general/ngsimd.hpp
Normal file
558
libsrc/general/ngsimd.hpp
Normal file
@ -0,0 +1,558 @@
|
||||
#ifndef FILE_NGSIMD
|
||||
#define FILE_NGSIMD
|
||||
/**************************************************************************/
|
||||
/* File: ngsimd.hpp */
|
||||
/* Author: Joachim Schoeberl */
|
||||
/* Date: 25. Mar. 16 */
|
||||
/**************************************************************************/
|
||||
|
||||
#include <immintrin.h>
|
||||
#include <tuple>
|
||||
#include <ostream>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
#include <type_traits>
|
||||
|
||||
#ifdef WIN32
|
||||
#ifndef AVX_OPERATORS_DEFINED
|
||||
#define AVX_OPERATORS_DEFINED
|
||||
NG_INLINE __m128d operator- (__m128d a) { return _mm_xor_pd(a, _mm_set1_pd(-0.0)); }
|
||||
NG_INLINE __m128d operator+ (__m128d a, __m128d b) { return _mm_add_pd(a,b); }
|
||||
NG_INLINE __m128d operator- (__m128d a, __m128d b) { return _mm_sub_pd(a,b); }
|
||||
NG_INLINE __m128d operator* (__m128d a, __m128d b) { return _mm_mul_pd(a,b); }
|
||||
NG_INLINE __m128d operator/ (__m128d a, __m128d b) { return _mm_div_pd(a,b); }
|
||||
NG_INLINE __m128d operator* (double a, __m128d b) { return _mm_set1_pd(a)*b; }
|
||||
NG_INLINE __m128d operator* (__m128d b, double a) { return _mm_set1_pd(a)*b; }
|
||||
|
||||
NG_INLINE __m128d operator+= (__m128d &a, __m128d b) { return a = a+b; }
|
||||
NG_INLINE __m128d operator-= (__m128d &a, __m128d b) { return a = a-b; }
|
||||
NG_INLINE __m128d operator*= (__m128d &a, __m128d b) { return a = a*b; }
|
||||
NG_INLINE __m128d operator/= (__m128d &a, __m128d b) { return a = a/b; }
|
||||
|
||||
NG_INLINE __m256d operator- (__m256d a) { return _mm256_xor_pd(a, _mm256_set1_pd(-0.0)); }
|
||||
NG_INLINE __m256d operator+ (__m256d a, __m256d b) { return _mm256_add_pd(a,b); }
|
||||
NG_INLINE __m256d operator- (__m256d a, __m256d b) { return _mm256_sub_pd(a,b); }
|
||||
NG_INLINE __m256d operator* (__m256d a, __m256d b) { return _mm256_mul_pd(a,b); }
|
||||
NG_INLINE __m256d operator/ (__m256d a, __m256d b) { return _mm256_div_pd(a,b); }
|
||||
NG_INLINE __m256d operator* (double a, __m256d b) { return _mm256_set1_pd(a)*b; }
|
||||
NG_INLINE __m256d operator* (__m256d b, double a) { return _mm256_set1_pd(a)*b; }
|
||||
|
||||
NG_INLINE __m256d operator+= (__m256d &a, __m256d b) { return a = a+b; }
|
||||
NG_INLINE __m256d operator-= (__m256d &a, __m256d b) { return a = a-b; }
|
||||
NG_INLINE __m256d operator*= (__m256d &a, __m256d b) { return a = a*b; }
|
||||
NG_INLINE __m256d operator/= (__m256d &a, __m256d b) { return a = a/b; }
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
namespace ngsimd
|
||||
{
|
||||
constexpr int GetDefaultSIMDSize() {
|
||||
#if defined __AVX512F__
|
||||
return 8;
|
||||
#elif defined __AVX__
|
||||
return 4;
|
||||
#else
|
||||
return 1;
|
||||
#endif
|
||||
}
|
||||
|
||||
template <typename T, int N=GetDefaultSIMDSize()> class SIMD;
|
||||
|
||||
template <typename T>
|
||||
struct has_call_operator
|
||||
{
|
||||
template <typename C> static std::true_type check( decltype( sizeof(&C::operator() )) ) { return std::true_type(); }
|
||||
template <typename> static std::false_type check(...) { return std::false_type(); }
|
||||
typedef decltype( check<T>(sizeof(char)) ) type;
|
||||
static constexpr type value = type();
|
||||
};
|
||||
|
||||
template <typename T1, typename T2, typename T3>
|
||||
// a*b+c
|
||||
NG_INLINE auto FMA(T1 a, T2 b, T3 c)
|
||||
{
|
||||
return a*b+c;
|
||||
}
|
||||
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator+ (T a, SIMD<double,N> b) { return SIMD<double,N>(a) + b; }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator- (T a, SIMD<double,N> b) { return SIMD<double,N>(a) - b; }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator* (T a, SIMD<double,N> b) { return SIMD<double,N>(a) * b; }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator/ (T a, SIMD<double,N> b) { return SIMD<double,N>(a) / b; }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator+ (SIMD<double,N> a, T b) { return a + SIMD<double,N>(b); }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator- (SIMD<double,N> a, T b) { return a - SIMD<double,N>(b); }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator* (SIMD<double,N> a, T b) { return a * SIMD<double,N>(b); }
|
||||
template<int N, typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
NG_INLINE SIMD<double,N> operator/ (SIMD<double,N> a, T b) { return a / SIMD<double,N>(b); }
|
||||
|
||||
|
||||
#ifdef __AVX__
|
||||
template <typename T>
|
||||
class AlignedAlloc
|
||||
{
|
||||
protected:
|
||||
static void * aligned_malloc(size_t s)
|
||||
{
|
||||
// Assume 16 byte alignment of standard library
|
||||
if(alignof(T)<=16)
|
||||
return malloc(s);
|
||||
else
|
||||
return _mm_malloc(s, alignof(T));
|
||||
}
|
||||
|
||||
static void aligned_free(void *p)
|
||||
{
|
||||
if(alignof(T)<=16)
|
||||
free(p);
|
||||
else
|
||||
_mm_free(p);
|
||||
}
|
||||
|
||||
public:
|
||||
void * operator new (size_t s, void *p) { return p; }
|
||||
void * operator new (size_t s) { return aligned_malloc(s); }
|
||||
void * operator new[] (size_t s) { return aligned_malloc(s); }
|
||||
void operator delete (void * p) { aligned_free(p); }
|
||||
void operator delete[] (void * p) { aligned_free(p); }
|
||||
};
|
||||
#else
|
||||
// it's only a dummy without AVX
|
||||
template <typename T>
|
||||
class AlignedAlloc { ; };
|
||||
|
||||
#endif
|
||||
|
||||
using std::sqrt;
|
||||
using std::fabs;
|
||||
|
||||
class ExceptionNOSIMD : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
using std::runtime_error::runtime_error;
|
||||
std::string What() { return what(); }
|
||||
};
|
||||
|
||||
using std::exp;
|
||||
template<int N> NG_INLINE SIMD<double,N> exp (SIMD<double,N> a)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return exp(a[i]); } );
|
||||
}
|
||||
|
||||
using std::log;
|
||||
template<int N> NG_INLINE SIMD<double,N> log (SIMD<double,N> a)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return log(a[i]); } );
|
||||
}
|
||||
|
||||
using std::pow;
|
||||
template<int N> NG_INLINE SIMD<double,N> pow (SIMD<double,N> a, double x)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return pow(a[i],x); } );
|
||||
}
|
||||
|
||||
using std::sin;
|
||||
template<int N> NG_INLINE SIMD<double,N> sin (SIMD<double,N> a)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return sin(a[i]); } );
|
||||
}
|
||||
|
||||
using std::cos;
|
||||
template<int N> NG_INLINE SIMD<double,N> cos (SIMD<double,N> a)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return cos(a[i]); } );
|
||||
}
|
||||
|
||||
using std::tan;
|
||||
template<int N> NG_INLINE SIMD<double,N> tan (SIMD<double,N> a)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return tan(a[i]); } );
|
||||
}
|
||||
|
||||
using std::atan;
|
||||
template<int N> NG_INLINE SIMD<double,N> atan (SIMD<double,N> a)
|
||||
{
|
||||
return SIMD<double,N>([&](int i)->double { return atan(a[i]); } );
|
||||
}
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// SIMD width 1 (in case no AVX support is available)
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
template<>
|
||||
class SIMD<double,1>
|
||||
{
|
||||
double data;
|
||||
|
||||
public:
|
||||
static constexpr int Size() { return 1; }
|
||||
SIMD () = default;
|
||||
SIMD (const SIMD &) = default;
|
||||
SIMD & operator= (const SIMD &) = default;
|
||||
|
||||
// only called if T has a call operator of appropriate type
|
||||
template<typename T, typename std::enable_if<std::is_convertible<T, std::function<double(int)>>::value, int>::type = 0>
|
||||
SIMD (const T & func)
|
||||
{
|
||||
data = func(0);
|
||||
}
|
||||
|
||||
// only called if T is arithmetic (integral or floating point types)
|
||||
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
SIMD (const T & val)
|
||||
{
|
||||
data = val;
|
||||
}
|
||||
|
||||
SIMD (double const * p)
|
||||
{
|
||||
data = *p;
|
||||
}
|
||||
|
||||
NG_INLINE operator double() const { return data; }
|
||||
NG_INLINE double operator[] (int i) const { return ((double*)(&data))[i]; }
|
||||
NG_INLINE double Data() const { return data; }
|
||||
NG_INLINE double & Data() { return data; }
|
||||
|
||||
NG_INLINE SIMD<double,1> &operator+= (SIMD<double,1> b) { data+=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,1> &operator-= (SIMD<double,1> b) { data-=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,1> &operator*= (SIMD<double,1> b) { data*=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,1> &operator/= (SIMD<double,1> b) { data/=b.Data(); return *this; }
|
||||
|
||||
};
|
||||
|
||||
NG_INLINE SIMD<double,1> operator+ (SIMD<double,1> a, SIMD<double,1> b) { return a.Data()+b.Data(); }
|
||||
NG_INLINE SIMD<double,1> operator- (SIMD<double,1> a, SIMD<double,1> b) { return a.Data()-b.Data(); }
|
||||
NG_INLINE SIMD<double,1> operator- (SIMD<double,1> a) { return -a.Data(); }
|
||||
NG_INLINE SIMD<double,1> operator* (SIMD<double,1> a, SIMD<double,1> b) { return a.Data()*b.Data(); }
|
||||
NG_INLINE SIMD<double,1> operator/ (SIMD<double,1> a, SIMD<double,1> b) { return a.Data()/b.Data(); }
|
||||
|
||||
NG_INLINE SIMD<double,1> sqrt (SIMD<double,1> a) { return std::sqrt(a.Data()); }
|
||||
NG_INLINE SIMD<double,1> fabs (SIMD<double,1> a) { return std::fabs(a.Data()); }
|
||||
NG_INLINE SIMD<double,1> L2Norm2 (SIMD<double,1> a) { return a.Data()*a.Data(); }
|
||||
NG_INLINE SIMD<double,1> Trans (SIMD<double,1> a) { return a; }
|
||||
NG_INLINE SIMD<double,1> IfPos (SIMD<double,1> a, SIMD<double,1> b, SIMD<double,1> c)
|
||||
{
|
||||
return (a.Data() > 0) ? b : c;
|
||||
}
|
||||
|
||||
NG_INLINE double HSum (SIMD<double,1> sd)
|
||||
{
|
||||
return sd.Data();
|
||||
}
|
||||
|
||||
NG_INLINE auto HSum (SIMD<double,1> sd1, SIMD<double,1> sd2)
|
||||
{
|
||||
return std::make_tuple(sd1.Data(), sd2.Data());
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AVX - Simd width 4
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __AVX__
|
||||
template<>
|
||||
class alignas(32) SIMD<double,4> : public AlignedAlloc<SIMD<double,4>>
|
||||
{
|
||||
__m256d data;
|
||||
|
||||
public:
|
||||
static constexpr int Size() { return 4; }
|
||||
SIMD () = default;
|
||||
SIMD (const SIMD &) = default;
|
||||
SIMD & operator= (const SIMD &) = default;
|
||||
|
||||
SIMD (__m256d adata)
|
||||
: data(adata)
|
||||
{ ; }
|
||||
|
||||
// only called if T has a call operator of appropriate type
|
||||
template<typename T, typename std::enable_if<std::is_convertible<T, std::function<double(int)>>::value, int>::type = 0>
|
||||
SIMD (const T & func)
|
||||
{
|
||||
data = _mm256_set_pd(func(3), func(2), func(1), func(0));
|
||||
}
|
||||
|
||||
// only called if T is arithmetic (integral or floating point types)
|
||||
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
SIMD (const T & val)
|
||||
{
|
||||
data = _mm256_set1_pd(val);
|
||||
}
|
||||
|
||||
SIMD (double const * p)
|
||||
{
|
||||
data = _mm256_loadu_pd(p);
|
||||
}
|
||||
|
||||
NG_INLINE operator __m256d() const { return data; }
|
||||
NG_INLINE double operator[] (int i) const { return ((double*)(&data))[i]; }
|
||||
NG_INLINE __m256d Data() const { return data; }
|
||||
NG_INLINE __m256d & Data() { return data; }
|
||||
|
||||
NG_INLINE SIMD<double,4> &operator+= (SIMD<double,4> b) { data+=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,4> &operator-= (SIMD<double,4> b) { data-=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,4> &operator*= (SIMD<double,4> b) { data*=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,4> &operator/= (SIMD<double,4> b) { data/=b.Data(); return *this; }
|
||||
|
||||
};
|
||||
|
||||
NG_INLINE SIMD<double,4> operator+ (SIMD<double,4> a, SIMD<double,4> b) { return a.Data()+b.Data(); }
|
||||
NG_INLINE SIMD<double,4> operator- (SIMD<double,4> a, SIMD<double,4> b) { return a.Data()-b.Data(); }
|
||||
NG_INLINE SIMD<double,4> operator- (SIMD<double,4> a) { return -a.Data(); }
|
||||
NG_INLINE SIMD<double,4> operator* (SIMD<double,4> a, SIMD<double,4> b) { return a.Data()*b.Data(); }
|
||||
NG_INLINE SIMD<double,4> operator/ (SIMD<double,4> a, SIMD<double,4> b) { return a.Data()/b.Data(); }
|
||||
|
||||
NG_INLINE SIMD<double,4> sqrt (SIMD<double,4> a) { return _mm256_sqrt_pd(a.Data()); }
|
||||
NG_INLINE SIMD<double,4> fabs (SIMD<double,4> a) { return _mm256_max_pd(a.Data(), -a.Data()); }
|
||||
NG_INLINE SIMD<double,4> L2Norm2 (SIMD<double,4> a) { return a.Data()*a.Data(); }
|
||||
NG_INLINE SIMD<double,4> Trans (SIMD<double,4> a) { return a; }
|
||||
NG_INLINE SIMD<double,4> IfPos (SIMD<double,4> a, SIMD<double,4> b, SIMD<double,4> c)
|
||||
{
|
||||
auto cp = _mm256_cmp_pd (a.Data(), _mm256_setzero_pd(), _CMP_GT_OS);
|
||||
return _mm256_blendv_pd(c.Data(), b.Data(), cp);
|
||||
}
|
||||
|
||||
NG_INLINE double HSum (SIMD<double,4> sd)
|
||||
{
|
||||
__m128d hv = _mm_add_pd (_mm256_extractf128_pd(sd.Data(),0), _mm256_extractf128_pd(sd.Data(),1));
|
||||
return _mm_cvtsd_f64 (_mm_hadd_pd (hv, hv));
|
||||
}
|
||||
|
||||
NG_INLINE auto HSum (SIMD<double,4> sd1, SIMD<double,4> sd2)
|
||||
{
|
||||
__m256d hv = _mm256_hadd_pd(sd1.Data(), sd2.Data());
|
||||
__m128d hv2 = _mm_add_pd (_mm256_extractf128_pd(hv,0), _mm256_extractf128_pd(hv,1));
|
||||
return std::make_tuple(_mm_cvtsd_f64 (hv2), _mm_cvtsd_f64(_mm_shuffle_pd (hv2, hv2, 3)));
|
||||
}
|
||||
|
||||
NG_INLINE SIMD<double,4> HSum (SIMD<double,4> v1, SIMD<double,4> v2, SIMD<double,4> v3, SIMD<double,4> v4)
|
||||
{
|
||||
__m256d hsum1 = _mm256_hadd_pd (v1.Data(), v2.Data());
|
||||
__m256d hsum2 = _mm256_hadd_pd (v3.Data(), v4.Data());
|
||||
__m256d hsum = _mm256_add_pd (_mm256_permute2f128_pd (hsum1, hsum2, 1+2*16),
|
||||
_mm256_blend_pd (hsum1, hsum2, 12));
|
||||
return hsum;
|
||||
}
|
||||
|
||||
#endif // __AVX__
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// AVX512 - Simd width 8
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#ifdef __AVX512F__
|
||||
template<>
|
||||
class alignas(64) SIMD<double,8> : public AlignedAlloc<SIMD<double,8>>
|
||||
{
|
||||
__m512d data;
|
||||
|
||||
public:
|
||||
static constexpr int Size() { return 8; }
|
||||
SIMD () = default;
|
||||
SIMD (const SIMD &) = default;
|
||||
SIMD & operator= (const SIMD &) = default;
|
||||
|
||||
SIMD (__m512d adata)
|
||||
: data(adata)
|
||||
{ ; }
|
||||
|
||||
// only called if T has a call operator of appropriate type
|
||||
template<typename T, typename std::enable_if<std::is_convertible<T, std::function<double(int)>>::value, int>::type = 0>
|
||||
SIMD (const T & func)
|
||||
{
|
||||
data = _mm512_set_pd(func(7), func(6), func(5), func(4),
|
||||
func(3), func(2), func(1), func(0));
|
||||
}
|
||||
|
||||
// only called if T is arithmetic (integral or floating point types)
|
||||
template<typename T, typename std::enable_if<std::is_arithmetic<T>::value, int>::type = 0>
|
||||
SIMD (const T & val)
|
||||
{
|
||||
data = _mm512_set1_pd(val);
|
||||
}
|
||||
|
||||
SIMD (double const * p)
|
||||
{
|
||||
data = _mm512_loadu_pd(p);
|
||||
}
|
||||
|
||||
NG_INLINE operator __m512d() const { return data; }
|
||||
NG_INLINE double operator[] (int i) const { return ((double*)(&data))[i]; }
|
||||
NG_INLINE __m512d Data() const { return data; }
|
||||
NG_INLINE __m512d & Data() { return data; }
|
||||
|
||||
NG_INLINE SIMD<double,8> &operator+= (SIMD<double,8> b) { data+=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,8> &operator-= (SIMD<double,8> b) { data-=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,8> &operator*= (SIMD<double,8> b) { data*=b.Data(); return *this; }
|
||||
NG_INLINE SIMD<double,8> &operator/= (SIMD<double,8> b) { data/=b.Data(); return *this; }
|
||||
|
||||
};
|
||||
|
||||
NG_INLINE SIMD<double,8> operator- (SIMD<double,8> a) { return _mm512_sub_pd(_mm512_setzero_pd(), a.Data()); }
|
||||
|
||||
NG_INLINE SIMD<double,8> operator+ (SIMD<double,8> a, SIMD<double,8> b) { return _mm512_add_pd(a.Data(),b.Data()); }
|
||||
NG_INLINE SIMD<double,8> operator- (SIMD<double,8> a, SIMD<double,8> b) { return _mm512_sub_pd(a.Data(),b.Data()); }
|
||||
NG_INLINE SIMD<double,8> operator* (SIMD<double,8> a, SIMD<double,8> b) { return _mm512_mul_pd(a.Data(),b.Data()); }
|
||||
NG_INLINE SIMD<double,8> operator/ (SIMD<double,8> a, SIMD<double,8> b) { return _mm512_div_pd(a.Data(),b.Data()); }
|
||||
|
||||
NG_INLINE SIMD<double,8> sqrt (SIMD<double,8> a) { return _mm512_sqrt_pd(a.Data()); }
|
||||
NG_INLINE SIMD<double,8> fabs (SIMD<double,8> a) { return _mm512_max_pd(a.Data(), -a.Data()); }
|
||||
NG_INLINE SIMD<double,8> L2Norm2 (SIMD<double,8> a) { return a.Data()*a.Data(); }
|
||||
NG_INLINE SIMD<double,8> Trans (SIMD<double,8> a) { return a; }
|
||||
NG_INLINE SIMD<double,8> IfPos (SIMD<double,8> a, SIMD<double,8> b, SIMD<double,8> c)
|
||||
{
|
||||
auto cp = _mm512_cmp_pd_mask (a.Data(), _mm512_setzero_pd(), _MM_CMPINT_GT);
|
||||
return _mm512_mask_blend_pd(cp, c.Data(), b.Data());
|
||||
}
|
||||
|
||||
|
||||
template<> NG_INLINE auto FMA (SIMD<double,8> a, SIMD<double,8> b, SIMD<double,8> c)
|
||||
{
|
||||
return _mm512_fmadd_pd (a.Data(), b.Data(), c.Data());
|
||||
}
|
||||
|
||||
NG_INLINE double HSum (SIMD<double,8> sd)
|
||||
{
|
||||
SIMD<double,4> low = _mm512_extractf64x4_pd(sd.Data(),0);
|
||||
SIMD<double,4> high = _mm512_extractf64x4_pd(sd.Data(),1);
|
||||
return HSum(low)+HSum(high);
|
||||
}
|
||||
|
||||
NG_INLINE auto HSum (SIMD<double,8> sd1, SIMD<double,8> sd2)
|
||||
{
|
||||
return std::make_tuple(HSum(sd1), HSum(sd2));
|
||||
}
|
||||
|
||||
NG_INLINE SIMD<double,4> HSum (SIMD<double,8> v1, SIMD<double,8> v2, SIMD<double,8> v3, SIMD<double,8> v4)
|
||||
{
|
||||
SIMD<double,4> high1 = _mm512_extractf64x4_pd(v1.Data(),1);
|
||||
SIMD<double,4> high2 = _mm512_extractf64x4_pd(v2.Data(),1);
|
||||
SIMD<double,4> high3 = _mm512_extractf64x4_pd(v3.Data(),1);
|
||||
SIMD<double,4> high4 = _mm512_extractf64x4_pd(v4.Data(),1);
|
||||
SIMD<double,4> low1 = _mm512_extractf64x4_pd(v1.Data(),0);
|
||||
SIMD<double,4> low2 = _mm512_extractf64x4_pd(v2.Data(),0);
|
||||
SIMD<double,4> low3 = _mm512_extractf64x4_pd(v3.Data(),0);
|
||||
SIMD<double,4> low4 = _mm512_extractf64x4_pd(v4.Data(),0);
|
||||
return HSum(low1,low2,low3,low4) + HSum(high1,high2,high3,high4);
|
||||
}
|
||||
#endif // __AVX512F__
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
// MultiSIMD - Multiple SIMD values in one struct using head-tail implementation
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
template <int D, typename T>
|
||||
class MultiSIMD : public AlignedAlloc<MultiSIMD<D,T>>
|
||||
{
|
||||
SIMD<T> head;
|
||||
MultiSIMD<D-1,T> tail;
|
||||
public:
|
||||
MultiSIMD () = default;
|
||||
MultiSIMD (const MultiSIMD & ) = default;
|
||||
MultiSIMD (T v) : head(v), tail(v) { ; }
|
||||
MultiSIMD (SIMD<T> _head, MultiSIMD<D-1,T> _tail)
|
||||
: head(_head), tail(_tail) { ; }
|
||||
SIMD<T> Head() const { return head; }
|
||||
MultiSIMD<D-1,T> Tail() const { return tail; }
|
||||
SIMD<T> & Head() { return head; }
|
||||
MultiSIMD<D-1,T> & Tail() { return tail; }
|
||||
|
||||
template <int NR>
|
||||
SIMD<T> Get() const { return NR==0 ? head : tail.template Get<NR-1>(); }
|
||||
template <int NR>
|
||||
SIMD<T> & Get() { return NR==0 ? head : tail.template Get<NR-1>(); }
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
class MultiSIMD<2,T> : public AlignedAlloc<MultiSIMD<2,T>>
|
||||
{
|
||||
SIMD<T> v0, v1;
|
||||
public:
|
||||
MultiSIMD () = default;
|
||||
MultiSIMD (const MultiSIMD & ) = default;
|
||||
MultiSIMD (T v) : v0(v), v1(v) { ; }
|
||||
MultiSIMD (SIMD<T> _v0, SIMD<T> _v1) : v0(_v0), v1(_v1) { ; }
|
||||
|
||||
SIMD<T> Head() const { return v0; }
|
||||
SIMD<T> Tail() const { return v1; }
|
||||
SIMD<T> & Head() { return v0; }
|
||||
SIMD<T> & Tail() { return v1; }
|
||||
|
||||
template <int NR>
|
||||
SIMD<T> Get() const { return NR==0 ? v0 : v1; }
|
||||
template <int NR>
|
||||
SIMD<T> & Get() { return NR==0 ? v0 : v1; }
|
||||
};
|
||||
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator+ (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()+b.Head(), a.Tail()+b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator+ (double a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a+b.Head(), a+b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator+ (MultiSIMD<D,double> b, double a)
|
||||
{ return MultiSIMD<D,double> (a+b.Head(), a+b.Tail()); }
|
||||
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator- (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()-b.Head(), a.Tail()-b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator- (double a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a-b.Head(), a-b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator- (MultiSIMD<D,double> b, double a)
|
||||
{ return MultiSIMD<D,double> (b.Head()-a, b.Tail()-a); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator- (MultiSIMD<D,double> a)
|
||||
{ return MultiSIMD<D,double> (-a.Head(), -a.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator* (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()*b.Head(), a.Tail()*b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator/ (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> (a.Head()/b.Head(), a.Tail()/b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator* (double a, MultiSIMD<D,double> b)
|
||||
{ return MultiSIMD<D,double> ( a*b.Head(), a*b.Tail()); }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator* (MultiSIMD<D,double> b, double a)
|
||||
{ return MultiSIMD<D,double> ( a*b.Head(), a*b.Tail()); }
|
||||
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> & operator+= (MultiSIMD<D,double> & a, MultiSIMD<D,double> b)
|
||||
{ a.Head()+=b.Head(); a.Tail()+=b.Tail(); return a; }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator-= (MultiSIMD<D,double> & a, double b)
|
||||
{ a.Head()-=b; a.Tail()-=b; return a; }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> operator-= (MultiSIMD<D,double> & a, MultiSIMD<D,double> b)
|
||||
{ a.Head()-=b.Head(); a.Tail()-=b.Tail(); return a; }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> & operator*= (MultiSIMD<D,double> & a, MultiSIMD<D,double> b)
|
||||
{ a.Head()*=b.Head(); a.Tail()*=b.Tail(); return a; }
|
||||
template <int D> NG_INLINE MultiSIMD<D,double> & operator*= (MultiSIMD<D,double> & a, double b)
|
||||
{ a.Head()*=b; a.Tail()*=b; return a; }
|
||||
// NG_INLINE MultiSIMD<double> operator/= (MultiSIMD<double> & a, MultiSIMD<double> b) { return a.Data()/=b.Data(); }
|
||||
|
||||
NG_INLINE SIMD<double> HVSum (SIMD<double> a) { return a; }
|
||||
template <int D>
|
||||
NG_INLINE SIMD<double> HVSum (MultiSIMD<D,double> a) { return a.Head() + HVSum(a.Tail()); }
|
||||
|
||||
template <int D> NG_INLINE double HSum (MultiSIMD<D,double> a) { return HSum(HVSum(a)); }
|
||||
template <int D> NG_INLINE auto HSum (MultiSIMD<D,double> a, MultiSIMD<D,double> b)
|
||||
{ return HSum(HVSum(a), HVSum(b)); }
|
||||
|
||||
template <int D, typename T>
|
||||
std::ostream & operator<< (std::ostream & ost, MultiSIMD<D,T> multi)
|
||||
{
|
||||
ost << multi.Head() << " " << multi.Tail();
|
||||
return ost;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
std::ostream & operator<< (std::ostream & ost, SIMD<T> simd)
|
||||
{
|
||||
ost << simd[0];
|
||||
for (int i = 1; i < simd.Size(); i++)
|
||||
ost << " " << simd[i];
|
||||
return ost;
|
||||
}
|
||||
}
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
using namespace ngsimd;
|
||||
}
|
||||
#endif
|
@ -6,19 +6,19 @@ endif(APPLE)
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(geom2d mesh ${PYTHON_LIBRARIES})
|
||||
install( TARGETS geom2d ${ng_install_dir})
|
||||
install( TARGETS geom2d ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
if(USE_GUI)
|
||||
add_library(geom2dvis ${NG_LIB_TYPE} vsgeom2d.cpp)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(geom2dvis geom2d)
|
||||
install( TARGETS geom2dvis ${ng_install_dir})
|
||||
install( TARGETS geom2dvis ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
endif(USE_GUI)
|
||||
|
||||
install(FILES
|
||||
geom2dmesh.hpp geometry2d.hpp spline2d.hpp
|
||||
splinegeometry2.hpp vsgeom2d.hpp
|
||||
DESTINATION ${INCDIR}/geom2d COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/geom2d COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -10,5 +10,5 @@ install(FILES
|
||||
adtree.hpp geom2d.hpp geom3d.hpp geomfuncs.hpp geomobjects2.hpp
|
||||
geomobjects.hpp geomops2.hpp geomops.hpp geomtest3d.hpp gprim.hpp
|
||||
splinegeometry.hpp spline.hpp transform3d.hpp
|
||||
DESTINATION ${INCDIR}/gprim COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/gprim COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -17,7 +17,7 @@ namespace netgen
|
||||
|
||||
|
||||
template <int D, typename T>
|
||||
class Point : public AlignedAlloc<Point<D,T>>
|
||||
class Point : public ngsimd::AlignedAlloc<Point<D,T>>
|
||||
{
|
||||
|
||||
protected:
|
||||
@ -67,7 +67,7 @@ namespace netgen
|
||||
};
|
||||
|
||||
template <int D, typename T>
|
||||
class Vec : public AlignedAlloc<Vec<D,T>>
|
||||
class Vec : public ngsimd::AlignedAlloc<Vec<D,T>>
|
||||
{
|
||||
|
||||
protected:
|
||||
@ -150,7 +150,7 @@ namespace netgen
|
||||
|
||||
|
||||
template <int H, int W=H, typename T = double>
|
||||
class Mat : public AlignedAlloc<Mat<H,W,T>>
|
||||
class Mat : public ngsimd::AlignedAlloc<Mat<H,W,T>>
|
||||
{
|
||||
|
||||
protected:
|
||||
|
@ -1,10 +1,10 @@
|
||||
install(FILES nginterface.h nginterface_v2.hpp DESTINATION ${INCDIR} COMPONENT netgen_devel)
|
||||
install(FILES nginterface.h nginterface_v2.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)
|
||||
|
||||
install(FILES
|
||||
acisgeom.hpp csg.hpp geometry2d.hpp gprim.hpp incopengl.hpp
|
||||
inctcl.hpp incvis.hpp linalg.hpp meshing.hpp myadt.hpp mydefs.hpp
|
||||
mystdlib.h nginterface_v2_impl.hpp occgeom.hpp
|
||||
mystdlib.h nginterface_v2_impl.hpp occgeom.hpp ngsimd.hpp
|
||||
opti.hpp parallel.hpp parallelinterface.hpp stlgeom.hpp visual.hpp
|
||||
DESTINATION ${INCDIR}/include COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel
|
||||
)
|
||||
|
||||
|
@ -36,6 +36,22 @@
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef NG_INLINE
|
||||
#ifdef __INTEL_COMPILER
|
||||
#ifdef WIN32
|
||||
#define NG_INLINE __forceinline inline
|
||||
#else
|
||||
#define NG_INLINE __forceinline inline
|
||||
#endif
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
#define NG_INLINE __attribute__ ((__always_inline__)) inline
|
||||
#define VLA
|
||||
#else
|
||||
#define NG_INLINE inline
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
// #define BASE0
|
||||
|
@ -1,11 +1,6 @@
|
||||
#ifndef FILE_MYSTDLIB
|
||||
#define FILE_MYSTDLIB
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include <config.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <fstream>
|
||||
|
@ -78,10 +78,11 @@ namespace netgen
|
||||
{
|
||||
public:
|
||||
size_t num;
|
||||
int base;
|
||||
const int * ptr;
|
||||
|
||||
|
||||
size_t Size() const { return num; }
|
||||
int operator[] (size_t i) const { return ptr[i]; }
|
||||
int operator[] (size_t i) const { return ptr[i]-base; }
|
||||
};
|
||||
|
||||
|
||||
@ -105,7 +106,7 @@ namespace netgen
|
||||
double * pt;
|
||||
public:
|
||||
Ng_Point (double * apt) : pt(apt) { ; }
|
||||
double operator[] (int i)
|
||||
double operator[] (size_t i)
|
||||
{ return pt[i]; }
|
||||
operator const double * () { return pt; }
|
||||
};
|
||||
@ -121,11 +122,11 @@ namespace netgen
|
||||
class Ng_Elements
|
||||
{
|
||||
public:
|
||||
int ne;
|
||||
size_t ne;
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return ne; }
|
||||
int operator[] (int i) const { return ptr[i]; }
|
||||
size_t Size() const { return ne; }
|
||||
int operator[] (size_t i) const { return ptr[i]; }
|
||||
};
|
||||
|
||||
|
||||
@ -145,8 +146,8 @@ namespace netgen
|
||||
public:
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return 2; }
|
||||
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
size_t Size() const { return 2; }
|
||||
int operator[] (size_t i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
};
|
||||
|
||||
|
||||
@ -162,27 +163,28 @@ namespace netgen
|
||||
class Ng_Vertices
|
||||
{
|
||||
public:
|
||||
int nv;
|
||||
size_t nv;
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return nv; }
|
||||
int operator[] (int i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
size_t Size() const { return nv; }
|
||||
int operator[] (size_t i) const { return ptr[i]-POINTINDEX_BASE; }
|
||||
};
|
||||
|
||||
class Ng_Edges
|
||||
{
|
||||
public:
|
||||
int ned;
|
||||
size_t ned;
|
||||
const int * ptr;
|
||||
|
||||
int Size() const { return ned; }
|
||||
int operator[] (int i) const { return ptr[i]-1; }
|
||||
size_t Size() const { return ned; }
|
||||
int operator[] (size_t i) const { return ptr[i]-1; }
|
||||
};
|
||||
|
||||
|
||||
public:
|
||||
Ng_Vertices vertices;
|
||||
Ng_Edges edges;
|
||||
int surface_el; // -1 if face not on surface
|
||||
};
|
||||
|
||||
|
||||
@ -269,6 +271,9 @@ namespace netgen
|
||||
template <int DIM>
|
||||
int GetNNodes ();
|
||||
|
||||
// returns domain numbers of domains next to boundary bnr -> (domin, domout)
|
||||
// 3D only
|
||||
// std::pair<int,int> GetBoundaryNeighbouringDomains (int bnr);
|
||||
|
||||
void Refine (NG_REFINEMENT_TYPE reftype,
|
||||
void (*taskmanager)(function<void(int,int)>) = &DummyTaskManager2);
|
||||
|
@ -73,7 +73,13 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
|
||||
if (mesh->GetDimension() == 2)
|
||||
ret.mat = mesh->GetBCNamePtr(el.si-1);
|
||||
else
|
||||
ret.mat = nullptr;
|
||||
{
|
||||
if (mesh->GetDimension() == 3)
|
||||
ret.mat = mesh->GetCD2NamePtr(el.edgenr-1);
|
||||
else
|
||||
ret.mat = nullptr;
|
||||
}
|
||||
|
||||
ret.points.num = el.GetNP();
|
||||
ret.points.ptr = (int*)&(el[0]);
|
||||
|
||||
@ -89,15 +95,14 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
|
||||
if (mesh->GetDimension() == 2)
|
||||
{
|
||||
ret.facets.num = 1;
|
||||
ret.facets.base = 0;
|
||||
ret.facets.ptr = (int*)ret.edges.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.facets.num = 0;
|
||||
ret.facets.ptr = nullptr;
|
||||
// not working as long as vertices are 1-based
|
||||
// ret.facets.num = 2;
|
||||
// ret.facets.ptr = (int*)&(el[0]);
|
||||
ret.facets.num = 2;
|
||||
ret.facets.base = 1;
|
||||
ret.facets.ptr = (int*)&(el[0]);
|
||||
}
|
||||
|
||||
// ret.is_curved = mesh->GetCurvedElements().IsSegmentCurved(nr);
|
||||
@ -109,7 +114,8 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (size_t nr) const
|
||||
{
|
||||
const Element2d & el = mesh->SurfaceElement (SurfaceElementIndex (nr));
|
||||
// const Element2d & el = mesh->SurfaceElement (SurfaceElementIndex (nr));
|
||||
const Element2d & el = mesh->SurfaceElements()[nr];
|
||||
|
||||
Ng_Element ret;
|
||||
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
||||
@ -134,11 +140,13 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (size_t nr) const
|
||||
if (mesh->GetDimension() == 3)
|
||||
{
|
||||
ret.facets.num = ret.faces.num;
|
||||
ret.facets.base = 0;
|
||||
ret.facets.ptr = (int*)ret.faces.ptr;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret.facets.num = ret.edges.num;
|
||||
ret.facets.base = 0;
|
||||
ret.facets.ptr = (int*)ret.edges.ptr;
|
||||
}
|
||||
ret.is_curved = el.IsCurved();
|
||||
@ -148,7 +156,8 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (size_t nr) const
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (size_t nr) const
|
||||
{
|
||||
const Element & el = mesh->VolumeElement (ElementIndex (nr));
|
||||
// const Element & el = mesh->VolumeElement (ElementIndex (nr));
|
||||
const Element & el = mesh->VolumeElements()[nr];
|
||||
|
||||
Ng_Element ret;
|
||||
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
||||
@ -167,6 +176,7 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (size_t nr) const
|
||||
ret.faces.ptr = (T_FACE2*)mesh->GetTopology().GetElementFacesPtr (nr);
|
||||
|
||||
ret.facets.num = ret.faces.num;
|
||||
ret.facets.base = 0;
|
||||
ret.facets.ptr = (int*)ret.faces.ptr;
|
||||
|
||||
ret.is_curved = el.IsCurved();
|
||||
@ -264,6 +274,7 @@ template <> NGX_INLINE DLL_HEADER const Ng_Node<2> Ngx_Mesh :: GetNode<2> (int n
|
||||
Ng_Node<2> node;
|
||||
node.vertices.ptr = mesh->GetTopology().GetFaceVerticesPtr(nr);
|
||||
node.vertices.nv = (node.vertices.ptr[3] == 0) ? 3 : 4;
|
||||
node.surface_el = mesh->GetTopology().GetFace2SurfaceElement (nr+1)-1;
|
||||
return node;
|
||||
}
|
||||
|
||||
|
1
libsrc/include/ngsimd.hpp
Normal file
1
libsrc/include/ngsimd.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include <../general/ngsimd.hpp>
|
@ -1,11 +1,5 @@
|
||||
add_definitions(-DNGINTERFACE_EXPORTS)
|
||||
add_library(interface ${NG_LIB_TYPE}
|
||||
# $<TARGET_OBJECTS:mesh>
|
||||
# $<TARGET_OBJECTS:csg>
|
||||
# $<TARGET_OBJECTS:visual>
|
||||
# $<TARGET_OBJECTS:la>
|
||||
# $<TARGET_OBJECTS:gprim>
|
||||
# $<TARGET_OBJECTS:gen>
|
||||
nginterface.cpp nginterface_v2.cpp
|
||||
read_fnf_mesh.cpp readtetmesh.cpp readuser.cpp writeabaqus.cpp writediffpack.cpp
|
||||
writedolfin.cpp writeelmer.cpp writefeap.cpp writefluent.cpp writegmsh.cpp writejcm.cpp
|
||||
@ -13,17 +7,15 @@ add_library(interface ${NG_LIB_TYPE}
|
||||
wuchemnitz.cpp writegmsh2.cpp writeOpenFOAM15x.cpp
|
||||
)
|
||||
|
||||
# TARGET_LINK_LIBRARIES(interface ${MPI_CXX_LIBRARIES} ${PYTHON_LIBS})
|
||||
# TARGET_LINK_LIBRARIES( interface ${LIBPTHREAD} ${OCC_LIBRARIES} ${LIBTOGL} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} )
|
||||
if(NOT WIN32)
|
||||
target_link_libraries(interface mesh csg geom2d)
|
||||
if(USE_GUI)
|
||||
target_link_libraries(interface visual)
|
||||
endif(USE_GUI)
|
||||
install( TARGETS interface ${ng_install_dir})
|
||||
install( TARGETS interface ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
install(FILES
|
||||
writeuser.hpp
|
||||
DESTINATION ${INCDIR}/interface COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/interface COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -108,7 +108,8 @@ void Ng_LoadMeshFromStream ( istream & input )
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!ng_geometry)
|
||||
ng_geometry = make_shared<NetgenGeometry>();
|
||||
mesh->SetGeometry (ng_geometry);
|
||||
}
|
||||
|
||||
|
@ -757,7 +757,7 @@ namespace netgen
|
||||
double hdxdxi[4][3];
|
||||
for (int j = 0; j<4;j++)
|
||||
hxi[j][0] = ((double*)&(xi[0]))[j];
|
||||
MultiElementTransformation<1,3> (elnr, 4, &hxi[0][0], 1, &hx[0][0], 2, &hdxdxi[0][0],4);
|
||||
MultiElementTransformation<1,3> (elnr, 4, &hxi[0][0], 1, &hx[0][0], 3, &hdxdxi[0][0],3);
|
||||
for(int j=0; j<4; j++)
|
||||
for(int k=0; k<3; k++)
|
||||
((double*)&(x[k]))[j] = hx[j][k];
|
||||
@ -780,16 +780,16 @@ namespace netgen
|
||||
{
|
||||
double hxi[4][1];
|
||||
double hx[4][2];
|
||||
double hdxdxi[4][4];
|
||||
double hdxdxi[4][2];
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int k = 0; k < 1; k++)
|
||||
hxi[j][k] = ((double*)&(xi[k]))[j];
|
||||
MultiElementTransformation<1,2> (elnr, 4, &hxi[0][0], 1, &hx[0][0], 2, &hdxdxi[0][0], 4);
|
||||
MultiElementTransformation<1,2> (elnr, 4, &hxi[0][0], 1, &hx[0][0], 2, &hdxdxi[0][0], 2);
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int k = 0; k < 2; k++)
|
||||
((double*)&(x[k]))[j] = hx[j][k];
|
||||
for (int j = 0; j < 4; j++)
|
||||
for (int k = 0; k < 4; k++)
|
||||
for (int k = 0; k < 2; k++)
|
||||
((double*)&(dxdxi[k]))[j] = hdxdxi[j][k];
|
||||
|
||||
xi += sxi;
|
||||
|
@ -7,5 +7,5 @@ set_target_properties(la PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
||||
install(FILES
|
||||
densemat.hpp linalg.hpp opti.hpp
|
||||
polynomial.hpp vector.hpp
|
||||
DESTINATION ${INCDIR}/linalg COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/linalg COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -21,6 +21,7 @@ add_library(mesh ${NG_LIB_TYPE}
|
||||
topology.cpp triarls.cpp validate.cpp bcfunctions.cpp
|
||||
parallelmesh.cpp paralleltop.cpp paralleltop.hpp basegeom.cpp
|
||||
python_mesh.cpp hexarls.cpp
|
||||
../../ng/onetcl.cpp
|
||||
${mesh_object_libs}
|
||||
)
|
||||
|
||||
@ -30,7 +31,7 @@ endif(APPLE)
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( mesh ${ZLIB_LIBRARIES} ${MPI_CXX_LIBRARIES} ${PYTHON_LIBRARIES} ${METIS_LIBRARY})
|
||||
install( TARGETS mesh ${ng_install_dir})
|
||||
install( TARGETS mesh ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
install(FILES
|
||||
@ -42,5 +43,5 @@ install(FILES
|
||||
localh.hpp meshclass.hpp meshfunc.hpp meshing2.hpp meshing3.hpp
|
||||
meshing.hpp meshtool.hpp meshtype.hpp msghandler.hpp paralleltop.hpp
|
||||
ruler2.hpp ruler3.hpp specials.hpp topology.hpp validate.hpp
|
||||
DESTINATION ${INCDIR}/meshing COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/meshing COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -44,10 +44,17 @@ namespace netgen
|
||||
bool incorder;
|
||||
unsigned int order:6;
|
||||
|
||||
MarkedTet()
|
||||
MarkedTet() = default;
|
||||
/*
|
||||
{
|
||||
for (int i = 0; i < 4; i++) { faceedges[i] = 255; }
|
||||
for (int i = 0; i < 4; i++) { faceedges[i] = 127; }
|
||||
}
|
||||
*/
|
||||
MarkedTet (const MarkedTet&) = default;
|
||||
MarkedTet (MarkedTet &&) = default;
|
||||
MarkedTet & operator= (const MarkedTet&) = default;
|
||||
MarkedTet & operator= (MarkedTet&&) = default;
|
||||
|
||||
};
|
||||
|
||||
ostream & operator<< (ostream & ost, const MarkedTet & mt)
|
||||
@ -178,6 +185,12 @@ namespace netgen
|
||||
class MarkedTri
|
||||
{
|
||||
public:
|
||||
MarkedTri () = default;
|
||||
MarkedTri (const MarkedTri&) = default;
|
||||
MarkedTri (MarkedTri &&) = default;
|
||||
MarkedTri & operator= (const MarkedTri&) = default;
|
||||
MarkedTri & operator= (MarkedTri&&) = default;
|
||||
|
||||
/// three point numbers
|
||||
PointIndex pnums[3];
|
||||
/// three geominfos
|
||||
@ -1657,32 +1670,43 @@ namespace netgen
|
||||
|
||||
|
||||
int MarkHangingTets (T_MTETS & mtets,
|
||||
const INDEX_2_CLOSED_HASHTABLE<PointIndex> & cutedges)
|
||||
const INDEX_2_CLOSED_HASHTABLE<PointIndex> & cutedges,
|
||||
TaskManager tm)
|
||||
{
|
||||
static int timer = NgProfiler::CreateTimer ("MarkHangingTets");
|
||||
NgProfiler::RegionTimer reg (timer);
|
||||
|
||||
int hanging = 0;
|
||||
for (int i = 1; i <= mtets.Size(); i++)
|
||||
{
|
||||
MarkedTet & teti = mtets.Elem(i);
|
||||
|
||||
if (teti.marked)
|
||||
{
|
||||
hanging = 1;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
for (int k = j+1; k < 4; k++)
|
||||
{
|
||||
INDEX_2 edge(teti.pnums[j],
|
||||
teti.pnums[k]);
|
||||
edge.Sort();
|
||||
if (cutedges.Used (edge))
|
||||
{
|
||||
teti.marked = 1;
|
||||
hanging = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
// for (int i = 1; i <= mtets.Size(); i++)
|
||||
ParallelForRange
|
||||
(tm, mtets.Size(), [&] (size_t begin, size_t end)
|
||||
{
|
||||
bool my_hanging = false;
|
||||
for (size_t i = begin; i < end; i++)
|
||||
{
|
||||
MarkedTet & teti = mtets[i];
|
||||
|
||||
if (teti.marked)
|
||||
{
|
||||
my_hanging = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int j = 0; j < 3; j++)
|
||||
for (int k = j+1; k < 4; k++)
|
||||
{
|
||||
INDEX_2 edge(teti.pnums[j],
|
||||
teti.pnums[k]);
|
||||
edge.Sort();
|
||||
if (cutedges.Used (edge))
|
||||
{
|
||||
teti.marked = 1;
|
||||
my_hanging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (my_hanging) hanging = true;
|
||||
});
|
||||
|
||||
return hanging;
|
||||
}
|
||||
@ -1723,30 +1747,40 @@ namespace netgen
|
||||
|
||||
|
||||
|
||||
int MarkHangingTris (T_MTRIS & mtris,
|
||||
const INDEX_2_CLOSED_HASHTABLE<PointIndex> & cutedges)
|
||||
bool MarkHangingTris (T_MTRIS & mtris,
|
||||
const INDEX_2_CLOSED_HASHTABLE<PointIndex> & cutedges,
|
||||
TaskManager tm)
|
||||
{
|
||||
int hanging = 0;
|
||||
for (int i = 1; i <= mtris.Size(); i++)
|
||||
{
|
||||
if (mtris.Get(i).marked)
|
||||
{
|
||||
hanging = 1;
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < 2; j++)
|
||||
for (int k = j+1; k < 3; k++)
|
||||
{
|
||||
INDEX_2 edge(mtris.Get(i).pnums[j],
|
||||
mtris.Get(i).pnums[k]);
|
||||
edge.Sort();
|
||||
if (cutedges.Used (edge))
|
||||
{
|
||||
mtris.Elem(i).marked = 1;
|
||||
hanging = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
bool hanging = false;
|
||||
// for (int i = 1; i <= mtris.Size(); i++)
|
||||
// for (auto & tri : mtris)
|
||||
ParallelForRange
|
||||
(tm, mtris.Size(), [&] (size_t begin, size_t end)
|
||||
{
|
||||
bool my_hanging = false;
|
||||
for (size_t i = begin; i < end; i++)
|
||||
{
|
||||
auto & tri = mtris[i];
|
||||
if (tri.marked)
|
||||
{
|
||||
my_hanging = true;
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < 2; j++)
|
||||
for (int k = j+1; k < 3; k++)
|
||||
{
|
||||
INDEX_2 edge(tri.pnums[j],
|
||||
tri.pnums[k]);
|
||||
edge.Sort();
|
||||
if (cutedges.Used (edge))
|
||||
{
|
||||
tri.marked = 1;
|
||||
my_hanging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (my_hanging) hanging = true;
|
||||
});
|
||||
return hanging;
|
||||
}
|
||||
|
||||
@ -2620,14 +2654,22 @@ namespace netgen
|
||||
|
||||
static int timer = NgProfiler::CreateTimer ("Bisect");
|
||||
static int timer1 = NgProfiler::CreateTimer ("Bisect 1");
|
||||
static int timer1a = NgProfiler::CreateTimer ("Bisect 1a");
|
||||
static int timer1b = NgProfiler::CreateTimer ("Bisect 1b");
|
||||
static int timer2 = NgProfiler::CreateTimer ("Bisect 2");
|
||||
static int timer2a = NgProfiler::CreateTimer ("Bisect 2a");
|
||||
static int timer2b = NgProfiler::CreateTimer ("Bisect 2b");
|
||||
static int timer2c = NgProfiler::CreateTimer ("Bisect 2c");
|
||||
static int timer3 = NgProfiler::CreateTimer ("Bisect 3");
|
||||
static int timer3a = NgProfiler::CreateTimer ("Bisect 3a");
|
||||
static int timer3b = NgProfiler::CreateTimer ("Bisect 3b");
|
||||
static int timer_bisecttet = NgProfiler::CreateTimer ("Bisect tets");
|
||||
static int timer_bisecttrig = NgProfiler::CreateTimer ("Bisect trigs");
|
||||
static int timer_bisectsegms = NgProfiler::CreateTimer ("Bisect segms");
|
||||
NgProfiler::RegionTimer reg1 (timer);
|
||||
|
||||
NgProfiler::StartTimer (timer1);
|
||||
|
||||
NgProfiler::StartTimer (timer1a);
|
||||
static int localizetimer = NgProfiler::CreateTimer("localize edgepoints");
|
||||
NgProfiler::RegionTimer * loct = new NgProfiler::RegionTimer(localizetimer);
|
||||
LocalizeEdgePoints(mesh);
|
||||
@ -2756,7 +2798,8 @@ namespace netgen
|
||||
INDEX_2_CLOSED_HASHTABLE<PointIndex> cutedges(10 + 9 * (mtets.Size()+mprisms.Size()+mtris.Size()+mquads.Size()));
|
||||
|
||||
bool noprojection = false;
|
||||
|
||||
NgProfiler::StopTimer (timer1a);
|
||||
|
||||
for (int l = 1; l <= 1; l++)
|
||||
{
|
||||
int marked = 0;
|
||||
@ -3169,7 +3212,6 @@ namespace netgen
|
||||
//string yn;
|
||||
//cin >> yn;
|
||||
|
||||
NgProfiler::StopTimer (timer1);
|
||||
|
||||
(*testout) << "refine volume elements" << endl;
|
||||
do
|
||||
@ -3312,7 +3354,7 @@ namespace netgen
|
||||
|
||||
|
||||
hangingvol =
|
||||
MarkHangingTets (mtets, cutedges) +
|
||||
MarkHangingTets (mtets, cutedges, opt.task_manager) +
|
||||
MarkHangingPrisms (mprisms, cutedges) +
|
||||
MarkHangingIdentifications (mids, cutedges);
|
||||
|
||||
@ -3369,7 +3411,10 @@ namespace netgen
|
||||
mtris.Append (newtri2);
|
||||
mesh.mlparentsurfaceelement.Append (i);
|
||||
}
|
||||
|
||||
|
||||
NgProfiler::StopTimer (timer_bisecttrig);
|
||||
|
||||
|
||||
int nquad = mquads.Size();
|
||||
for (int i = 1; i <= nquad; i++)
|
||||
if (mquads.Elem(i).marked)
|
||||
@ -3461,15 +3506,15 @@ namespace netgen
|
||||
mquads.Elem(i) = newquad1;
|
||||
mquads.Append (newquad2);
|
||||
}
|
||||
|
||||
NgProfiler::StopTimer (timer_bisecttrig);
|
||||
|
||||
|
||||
NgProfiler::StartTimer (timer1b);
|
||||
hangingsurf =
|
||||
MarkHangingTris (mtris, cutedges) +
|
||||
MarkHangingTris (mtris, cutedges, opt.task_manager) +
|
||||
MarkHangingQuads (mquads, cutedges);
|
||||
|
||||
hangingedge = 0;
|
||||
|
||||
NgProfiler::StopTimer (timer1b);
|
||||
NgProfiler::StartTimer (timer_bisectsegms);
|
||||
int nseg = mesh.GetNSeg ();
|
||||
for (int i = 1; i <= nseg; i++)
|
||||
{
|
||||
@ -3506,6 +3551,8 @@ namespace netgen
|
||||
mesh.AddSegment (nseg2);
|
||||
}
|
||||
}
|
||||
|
||||
NgProfiler::StopTimer (timer_bisectsegms);
|
||||
}
|
||||
while (hangingvol || hangingsurf || hangingedge);
|
||||
|
||||
@ -3534,6 +3581,8 @@ namespace netgen
|
||||
PrintMessage (4, mesh.GetNP(), " points");
|
||||
}
|
||||
|
||||
NgProfiler::StopTimer (timer1);
|
||||
|
||||
|
||||
// (*testout) << "mtets = " << mtets << endl;
|
||||
|
||||
@ -3579,6 +3628,8 @@ namespace netgen
|
||||
}
|
||||
|
||||
NgProfiler::StartTimer (timer2);
|
||||
|
||||
NgProfiler::StartTimer (timer2a);
|
||||
|
||||
mtets.SetAllocSize (mtets.Size());
|
||||
mprisms.SetAllocSize (mprisms.Size());
|
||||
@ -3654,15 +3705,18 @@ namespace netgen
|
||||
}
|
||||
|
||||
mesh.ClearSurfaceElements();
|
||||
for (int i = 1; i <= mtris.Size(); i++)
|
||||
mesh.SurfaceElements().SetAllocSize (mtris.Size()+mquads.Size());
|
||||
NgProfiler::StopTimer (timer2a);
|
||||
NgProfiler::StartTimer (timer2b);
|
||||
for (auto & trig : mtris)
|
||||
{
|
||||
Element2d el(TRIG);
|
||||
el.SetIndex (mtris.Get(i).surfid);
|
||||
el.SetOrder (mtris.Get(i).order);
|
||||
for (int j = 1; j <= 3; j++)
|
||||
el.SetIndex (trig.surfid);
|
||||
el.SetOrder (trig.order);
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
el.PNum(j) = mtris.Get(i).pnums[j-1];
|
||||
el.GeomInfoPi(j) = mtris.Get(i).pgeominfo[j-1];
|
||||
el[j] = trig.pnums[j];
|
||||
el.GeomInfoPi(j+1) = trig.pgeominfo[j];
|
||||
}
|
||||
mesh.AddSurfaceElement (el);
|
||||
}
|
||||
@ -3675,7 +3729,7 @@ namespace netgen
|
||||
Swap (el.PNum(3), el.PNum(4));
|
||||
mesh.AddSurfaceElement (el);
|
||||
}
|
||||
|
||||
NgProfiler::StopTimer (timer2b);
|
||||
|
||||
|
||||
// write multilevel hierarchy to mesh:
|
||||
@ -3705,12 +3759,12 @@ namespace netgen
|
||||
BitArray isnewpoint(np);
|
||||
isnewpoint.Clear();
|
||||
|
||||
for (int i = 1; i <= cutedges.Size(); i++)
|
||||
if (cutedges.UsedPos(i))
|
||||
for (int i = 0; i < cutedges.Size(); i++)
|
||||
if (cutedges.UsedPos0(i))
|
||||
{
|
||||
INDEX_2 edge;
|
||||
PointIndex newpi;
|
||||
cutedges.GetData (i, edge, newpi);
|
||||
cutedges.GetData0 (i, edge, newpi);
|
||||
isnewpoint.Set(newpi);
|
||||
mesh.mlbetweennodes.Elem(newpi) = edge;
|
||||
}
|
||||
@ -3811,12 +3865,12 @@ namespace netgen
|
||||
}
|
||||
*/
|
||||
|
||||
for (int j = 1; j <= cutedges.Size(); j++)
|
||||
if (cutedges.UsedPos(j))
|
||||
for (int j = 0; j < cutedges.Size(); j++)
|
||||
if (cutedges.UsedPos0(j))
|
||||
{
|
||||
INDEX_2 i2;
|
||||
PointIndex newpi;
|
||||
cutedges.GetData (j, i2, newpi);
|
||||
cutedges.GetData0 (j, i2, newpi);
|
||||
INDEX_2 oi2(identmap.Get(i2.I1()),
|
||||
identmap.Get(i2.I2()));
|
||||
oi2.Sort();
|
||||
@ -3960,9 +4014,10 @@ namespace netgen
|
||||
|
||||
NgProfiler::StopTimer (timer2);
|
||||
NgProfiler::StartTimer (timer3);
|
||||
|
||||
mesh.UpdateTopology(opt.task_manager);
|
||||
|
||||
NgProfiler::StartTimer (timer3a);
|
||||
mesh.UpdateTopology(opt.task_manager);
|
||||
NgProfiler::StopTimer (timer3a);
|
||||
|
||||
|
||||
|
||||
@ -3976,8 +4031,9 @@ namespace netgen
|
||||
ofst.close();
|
||||
}
|
||||
|
||||
|
||||
NgProfiler::StartTimer (timer3b);
|
||||
mesh.CalcSurfacesOfNode();
|
||||
NgProfiler::StopTimer (timer3b);
|
||||
|
||||
PrintMessage (1, "Bisection done");
|
||||
|
||||
|
@ -21,6 +21,7 @@ namespace netgen
|
||||
static int timer = NgProfiler::CreateTimer ("clusters");
|
||||
static int timer1 = NgProfiler::CreateTimer ("clusters1");
|
||||
static int timer2 = NgProfiler::CreateTimer ("clusters2");
|
||||
static int timer3 = NgProfiler::CreateTimer ("clusters3");
|
||||
NgProfiler::RegionTimer reg (timer);
|
||||
|
||||
const MeshTopology & top = mesh.GetTopology();
|
||||
@ -110,7 +111,7 @@ namespace netgen
|
||||
|
||||
NgProfiler::StopTimer(timer1);
|
||||
NgProfiler::StartTimer(timer2);
|
||||
|
||||
/*
|
||||
for (int i = 1; i <= nse; i++)
|
||||
{
|
||||
const Element2d & el = mesh.SurfaceElement(i);
|
||||
@ -132,7 +133,40 @@ namespace netgen
|
||||
for (int j = 0; j < nnums.Size(); j++)
|
||||
cluster_reps.Elem(nnums[j]) = nnums[j];
|
||||
}
|
||||
*/
|
||||
ParallelForRange
|
||||
(tm, nse,
|
||||
[&] (size_t begin, size_t end)
|
||||
{
|
||||
ArrayMem<int,9> nnums, ednums;
|
||||
for (int i = begin+1; i <= end; i++)
|
||||
{
|
||||
const Element2d & el = mesh.SurfaceElement(i);
|
||||
ELEMENT_TYPE typ = el.GetType();
|
||||
|
||||
top.GetSurfaceElementEdges (i, ednums);
|
||||
int fanum = top.GetSurfaceElementFace (i);
|
||||
|
||||
int elnv = top.GetNVertices (typ);
|
||||
int elned = ednums.Size();
|
||||
|
||||
nnums.SetSize(elnv+elned+1);
|
||||
for (int j = 1; j <= elnv; j++)
|
||||
nnums.Elem(j) = el.PNum(j)+1-PointIndex::BASE;
|
||||
for (int j = 1; j <= elned; j++)
|
||||
nnums.Elem(elnv+j) = nv+ednums.Elem(j);
|
||||
nnums.Elem(elnv+elned+1) = fanum;
|
||||
|
||||
for (int j = 0; j < nnums.Size(); j++)
|
||||
cluster_reps.Elem(nnums[j]) = nnums[j];
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
NgProfiler::StopTimer(timer2);
|
||||
NgProfiler::StartTimer(timer3);
|
||||
|
||||
|
||||
static const int hex_cluster[] =
|
||||
{
|
||||
1, 2, 3, 4, 1, 2, 3, 4,
|
||||
@ -300,7 +334,7 @@ namespace netgen
|
||||
}
|
||||
}
|
||||
while (changed);
|
||||
NgProfiler::StopTimer(timer2);
|
||||
NgProfiler::StopTimer(timer3);
|
||||
/*
|
||||
(*testout) << "cluster reps:" << endl;
|
||||
for (i = 1; i <= cluster_reps.Size(); i++)
|
||||
|
@ -27,7 +27,9 @@ namespace netgen
|
||||
global_mesh = m;
|
||||
}
|
||||
|
||||
|
||||
// true if netgen was started using the netgen executable
|
||||
// false if netgen.gui was imported from python
|
||||
DLL_HEADER bool netgen_executable_started = false;
|
||||
|
||||
// Flags parameters;
|
||||
int silentflag = 0;
|
||||
@ -88,7 +90,8 @@ namespace netgen
|
||||
DebugParameters debugparam;
|
||||
bool verbose = 0;
|
||||
|
||||
int timestamp = 0;
|
||||
size_t timestamp = 0;
|
||||
/*
|
||||
int GetTimeStamp()
|
||||
{
|
||||
return timestamp;
|
||||
@ -99,4 +102,5 @@ namespace netgen
|
||||
timestamp++;
|
||||
return timestamp;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
@ -455,7 +455,7 @@ void MeshOptimize3d :: SplitImprove (Mesh & mesh,
|
||||
if (el[l] == pi1 || el[l] == pi2)
|
||||
{
|
||||
INDEX_3 i3;
|
||||
Element2d face;
|
||||
Element2d face(TRIG);
|
||||
el.GetFace (l+1, face);
|
||||
for (int kk = 1; kk <= 3; kk++)
|
||||
i3.I(kk) = face.PNum(kk);
|
||||
|
@ -116,7 +116,7 @@ namespace netgen
|
||||
surfelements.SetSize(0);
|
||||
volelements.SetSize(0);
|
||||
lockedpoints.SetSize(0);
|
||||
surfacesonnode.SetSize(0);
|
||||
// surfacesonnode.SetSize(0);
|
||||
|
||||
delete boundaryedges;
|
||||
boundaryedges = NULL;
|
||||
@ -926,7 +926,7 @@ namespace netgen
|
||||
PrintMessage (3, n, " volume elements");
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
Element el;
|
||||
Element el(TET);
|
||||
int hi, nep;
|
||||
infile >> hi;
|
||||
if (hi == 0) hi = 1;
|
||||
@ -1423,7 +1423,7 @@ namespace netgen
|
||||
PrintMessage (3, n, " volume elements");
|
||||
for (i = 1; i <= n; i++)
|
||||
{
|
||||
Element el;
|
||||
Element el(TET);
|
||||
int hi, nep;
|
||||
infile >> hi;
|
||||
if (hi == 0) hi = 1;
|
||||
@ -1593,12 +1593,14 @@ namespace netgen
|
||||
|
||||
void Mesh :: CalcSurfacesOfNode ()
|
||||
{
|
||||
surfacesonnode.SetSize (GetNP());
|
||||
// surfacesonnode.SetSize (GetNP());
|
||||
TABLE<int,PointIndex::BASE> surfacesonnode(GetNP());
|
||||
|
||||
delete boundaryedges;
|
||||
boundaryedges = NULL;
|
||||
|
||||
delete surfelementht;
|
||||
surfelementht = nullptr;
|
||||
delete segmentht;
|
||||
|
||||
/*
|
||||
@ -1606,9 +1608,11 @@ namespace netgen
|
||||
segmentht = new INDEX_2_HASHTABLE<int> (GetNSeg() + 1);
|
||||
*/
|
||||
|
||||
surfelementht = new INDEX_3_CLOSED_HASHTABLE<int> (3*GetNSE() + 1);
|
||||
if (dimension == 3)
|
||||
surfelementht = new INDEX_3_CLOSED_HASHTABLE<int> (3*GetNSE() + 1);
|
||||
segmentht = new INDEX_2_CLOSED_HASHTABLE<int> (3*GetNSeg() + 1);
|
||||
|
||||
if (dimension == 3)
|
||||
for (SurfaceElementIndex sei = 0; sei < GetNSE(); sei++)
|
||||
{
|
||||
const Element2d & sel = surfelements[sei];
|
||||
@ -1619,6 +1623,9 @@ namespace netgen
|
||||
for (int j = 0; j < sel.GetNP(); j++)
|
||||
{
|
||||
PointIndex pi = sel[j];
|
||||
if (!surfacesonnode[pi].Contains(si))
|
||||
surfacesonnode.Add (pi, si);
|
||||
/*
|
||||
bool found = 0;
|
||||
for (int k = 0; k < surfacesonnode[pi].Size(); k++)
|
||||
if (surfacesonnode[pi][k] == si)
|
||||
@ -1629,6 +1636,7 @@ namespace netgen
|
||||
|
||||
if (!found)
|
||||
surfacesonnode.Add (pi, si);
|
||||
*/
|
||||
}
|
||||
}
|
||||
/*
|
||||
@ -1647,6 +1655,8 @@ namespace netgen
|
||||
|
||||
surfelementht -> AllocateElements();
|
||||
*/
|
||||
|
||||
if (dimension==3)
|
||||
for (SurfaceElementIndex sei = 0; sei < GetNSE(); sei++)
|
||||
{
|
||||
const Element2d & sel = surfelements[sei];
|
||||
@ -1891,7 +1901,7 @@ namespace netgen
|
||||
int ii;
|
||||
PointIndex pi;
|
||||
SurfaceElementIndex sei;
|
||||
Element2d hel;
|
||||
// Element2d hel;
|
||||
|
||||
|
||||
INDEX_3_CLOSED_HASHTABLE<INDEX_2> faceht(100);
|
||||
@ -1905,7 +1915,7 @@ namespace netgen
|
||||
FlatArray<SurfaceElementIndex> row = selsonpoint[pi];
|
||||
for (ii = 0; ii < row.Size(); ii++)
|
||||
{
|
||||
hel = SurfaceElement(row[ii]);
|
||||
Element2d hel = SurfaceElement(row[ii]);
|
||||
if (hel.GetType() == TRIG6) hel.SetType(TRIG);
|
||||
int ind = hel.GetIndex();
|
||||
|
||||
@ -1950,6 +1960,7 @@ namespace netgen
|
||||
{
|
||||
for (int j = 1; j <= el.GetNFaces(); j++)
|
||||
{
|
||||
Element2d hel(TRIG);
|
||||
el.GetFace (j, hel);
|
||||
hel.Invert();
|
||||
hel.NormalizeNumbering();
|
||||
@ -2004,8 +2015,9 @@ namespace netgen
|
||||
faceht.GetData (i, i3, i2);
|
||||
if (i2.I1() != PointIndex::BASE-1)
|
||||
{
|
||||
Element2d tri;
|
||||
tri.SetType ( (i2.I2() == PointIndex::BASE-1) ? TRIG : QUAD);
|
||||
// Element2d tri;
|
||||
// tri.SetType ( (i2.I2() == PointIndex::BASE-1) ? TRIG : QUAD);
|
||||
Element2d tri ( (i2.I2() == PointIndex::BASE-1) ? TRIG : QUAD);
|
||||
for (int l = 0; l < 3; l++)
|
||||
tri[l] = i3.I(l+1);
|
||||
tri.PNum(4) = i2.I2();
|
||||
@ -3665,11 +3677,11 @@ namespace netgen
|
||||
{
|
||||
bool sege = false, be = false;
|
||||
|
||||
int pos = boundaryedges -> Position(INDEX_2::Sort(el[i], el[j]));
|
||||
if (pos)
|
||||
int pos = boundaryedges -> Position0(INDEX_2::Sort(el[i], el[j]));
|
||||
if (pos != -1)
|
||||
{
|
||||
be = true;
|
||||
if (boundaryedges -> GetData(pos) == 2)
|
||||
if (boundaryedges -> GetData0(pos) == 2)
|
||||
sege = true;
|
||||
}
|
||||
|
||||
@ -5351,7 +5363,7 @@ namespace netgen
|
||||
// angles in faces
|
||||
for (j = 1; j <= 4; j++)
|
||||
{
|
||||
Element2d face;
|
||||
Element2d face(TRIG);
|
||||
el.GetFace (j, face);
|
||||
for (lpi1 = 1; lpi1 <= 3; lpi1++)
|
||||
{
|
||||
@ -5545,6 +5557,7 @@ namespace netgen
|
||||
if (el[j] > numvertices)
|
||||
numvertices = el[j];
|
||||
}
|
||||
/*
|
||||
for (i = 1; i <= nse; i++)
|
||||
{
|
||||
const Element2d & el = SurfaceElement(i);
|
||||
@ -5553,6 +5566,10 @@ namespace netgen
|
||||
if (el.PNum(j) > numvertices)
|
||||
numvertices = el.PNum(j);
|
||||
}
|
||||
*/
|
||||
for (auto & el : SurfaceElements())
|
||||
for (PointIndex v : el.Vertices())
|
||||
if (v > numvertices) numvertices = v;
|
||||
|
||||
numvertices += 1- PointIndex::BASE;
|
||||
}
|
||||
@ -5741,8 +5758,8 @@ namespace netgen
|
||||
{
|
||||
int olds = materials.Size();
|
||||
materials.SetSize (domnr);
|
||||
for (int i = olds; i < domnr; i++)
|
||||
materials[i] = 0;
|
||||
for (int i = olds; i < domnr-1; i++)
|
||||
materials[i] = new string("default");
|
||||
}
|
||||
/*
|
||||
materials.Elem(domnr) = new char[strlen(mat)+1];
|
||||
@ -5751,11 +5768,12 @@ namespace netgen
|
||||
materials.Elem(domnr) = new string(mat);
|
||||
}
|
||||
|
||||
string Mesh :: defaultmat = "default";
|
||||
const string & Mesh :: GetMaterial (int domnr) const
|
||||
{
|
||||
if (domnr <= materials.Size())
|
||||
return *materials.Get(domnr);
|
||||
static string emptystring;
|
||||
static string emptystring("default");
|
||||
return emptystring;
|
||||
}
|
||||
|
||||
@ -5832,6 +5850,7 @@ namespace netgen
|
||||
cd2names[cd2nr] = nullptr;
|
||||
}
|
||||
|
||||
string Mesh :: cd2_default_name = "default";
|
||||
const string & Mesh :: GetCD2Name (int cd2nr) const
|
||||
{
|
||||
static string defaultstring = "default";
|
||||
@ -5916,8 +5935,8 @@ namespace netgen
|
||||
<< sizeof (Element) << " = "
|
||||
<< GetNE() * sizeof(Element) << endl;
|
||||
|
||||
ost << "surfs on node:";
|
||||
surfacesonnode.PrintMemInfo (cout);
|
||||
// ost << "surfs on node:";
|
||||
// surfacesonnode.PrintMemInfo (cout);
|
||||
|
||||
ost << "boundaryedges: ";
|
||||
if (boundaryedges)
|
||||
|
@ -24,8 +24,9 @@ namespace netgen
|
||||
{
|
||||
public:
|
||||
typedef ::netgen::T_POINTS T_POINTS;
|
||||
typedef Array<Element, 0, ElementIndex> T_VOLELEMENTS;
|
||||
typedef Array<Element2d, 0, SurfaceElementIndex> T_SURFELEMENTS;
|
||||
typedef Array<Element, 0, size_t> T_VOLELEMENTS;
|
||||
// typedef Array<Element2d, 0, SurfaceElementIndex> T_SURFELEMENTS;
|
||||
typedef Array<Element2d, 0, size_t> T_SURFELEMENTS;
|
||||
|
||||
private:
|
||||
/// point coordinates
|
||||
@ -42,7 +43,7 @@ namespace netgen
|
||||
|
||||
|
||||
/// surface indices at boundary nodes
|
||||
TABLE<int,PointIndex::BASE> surfacesonnode;
|
||||
// TABLE<int,PointIndex::BASE> surfacesonnode;
|
||||
/// boundary edges (1..normal bedge, 2..segment)
|
||||
INDEX_2_CLOSED_HASHTABLE<int> * boundaryedges;
|
||||
///
|
||||
@ -592,8 +593,11 @@ namespace netgen
|
||||
DLL_HEADER void SetMaterial (int domnr, const string & mat);
|
||||
///
|
||||
const string & GetMaterial (int domnr) const;
|
||||
static string defaultmat;
|
||||
const string * GetMaterialPtr (int domnr) const // 1-based
|
||||
{ return domnr <= materials.Size() ? materials.Get(domnr) : nullptr; }
|
||||
{
|
||||
return domnr <= materials.Size() ? materials.Get(domnr) : &defaultmat;
|
||||
}
|
||||
|
||||
DLL_HEADER void SetNBCNames ( int nbcn );
|
||||
|
||||
@ -605,6 +609,12 @@ namespace netgen
|
||||
DLL_HEADER void SetCD2Name (int cd2nr, const string & abcname);
|
||||
|
||||
const string & GetCD2Name (int cd2nr ) const;
|
||||
static string cd2_default_name;
|
||||
string * GetCD2NamePtr (int cd2nr ) const
|
||||
{
|
||||
if (cd2nr < cd2names.Size() && cd2names[cd2nr]) return cd2names[cd2nr];
|
||||
return &cd2_default_name;
|
||||
}
|
||||
size_t GetNCD2Names() const { return cd2names.Size(); }
|
||||
|
||||
string * GetBCNamePtr (int bcnr) const
|
||||
|
@ -109,7 +109,7 @@ static double CalcLocH (const Array<Point3d> & locpoints,
|
||||
sum = 0;
|
||||
weight = 0;
|
||||
|
||||
for (i = 1; i <= locfaces.Size(); i++)
|
||||
for(int i = 1; i <= locfaces.Size(); i++)
|
||||
{
|
||||
pc.X() = pc.Y() = pc.Z() = 0;
|
||||
for (j = 1; j <= 3; j++)
|
||||
@ -187,7 +187,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
Array<int> delpoints, delfaces; // points and lines to be deleted
|
||||
Array<Element> locelements; // new generated elements
|
||||
|
||||
int i, j, oldnp, oldnf;
|
||||
int j, oldnp, oldnf;
|
||||
int found;
|
||||
referencetransform trans;
|
||||
int rotind;
|
||||
@ -344,7 +344,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
|
||||
allowpoint.SetSize(locpoints.Size());
|
||||
if (uselocalh && stat.qualclass <= 3)
|
||||
for (i = 1; i <= allowpoint.Size(); i++)
|
||||
for(int i = 1; i <= allowpoint.Size(); i++)
|
||||
{
|
||||
allowpoint.Elem(i) =
|
||||
(mesh.GetH (locpoints.Get(i)) > 0.4 * hshould / mp.sloppy) ? 2 : 1;
|
||||
@ -378,10 +378,10 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
{
|
||||
(*testout) << "inner point found" << endl;
|
||||
|
||||
for (i = 1; i <= groupfaces.Size(); i++)
|
||||
for(int i = 1; i <= groupfaces.Size(); i++)
|
||||
adfront -> DeleteFace (groupfindex.Get(i));
|
||||
|
||||
for (i = 1; i <= groupfaces.Size(); i++)
|
||||
for(int i = 1; i <= groupfaces.Size(); i++)
|
||||
for (j = 1; j <= locfaces.Size(); j++)
|
||||
if (findex.Get(j) == groupfindex.Get(i))
|
||||
delfaces.Append (j);
|
||||
@ -390,13 +390,13 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
delfaces.SetSize (0);
|
||||
|
||||
INDEX npi;
|
||||
Element newel;
|
||||
Element newel(TET);
|
||||
|
||||
npi = mesh.AddPoint (inp);
|
||||
newel.SetNP(4);
|
||||
newel.PNum(4) = npi;
|
||||
|
||||
for (i = 1; i <= groupfaces.Size(); i++)
|
||||
for(int i = 1; i <= groupfaces.Size(); i++)
|
||||
{
|
||||
for (j = 1; j <= 3; j++)
|
||||
{
|
||||
@ -417,14 +417,14 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
// int optother = 0;
|
||||
|
||||
/*
|
||||
for (i = 1; i <= locfaces.Size(); i++)
|
||||
for(int i = 1; i <= locfaces.Size(); i++)
|
||||
{
|
||||
(*testout) << "Face " << i << ": ";
|
||||
for (j = 1; j <= locfaces.Get(i).GetNP(); j++)
|
||||
(*testout) << pindex.Get(locfaces.Get(i).PNum(j)) << " ";
|
||||
(*testout) << endl;
|
||||
}
|
||||
for (i = 1; i <= locpoints.Size(); i++)
|
||||
for(int i = 1; i <= locpoints.Size(); i++)
|
||||
{
|
||||
(*testout) << "p" << i
|
||||
<< ", gi = " << pindex.Get(i)
|
||||
@ -470,7 +470,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
if (stat.cnttrials % 100 == 0)
|
||||
{
|
||||
(*testout) << "\n";
|
||||
for (i = 1; i <= canuse.Size(); i++)
|
||||
for(int i = 1; i <= canuse.Size(); i++)
|
||||
{
|
||||
(*testout) << foundmap.Get(i) << "/"
|
||||
<< canuse.Get(i) << "/"
|
||||
@ -565,7 +565,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
if (testmode)
|
||||
{
|
||||
(*testout) << "found is active, 3" << endl;
|
||||
for (i = 1; i <= plainpoints.Size(); i++)
|
||||
for(int i = 1; i <= plainpoints.Size(); i++)
|
||||
{
|
||||
(*testout) << "p";
|
||||
if (i <= pindex.Size())
|
||||
@ -582,19 +582,19 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
minerr = err;
|
||||
|
||||
tempnewpoints.SetSize (0);
|
||||
for (i = oldnp+1; i <= locpoints.Size(); i++)
|
||||
for(int i = oldnp+1; i <= locpoints.Size(); i++)
|
||||
tempnewpoints.Append (locpoints.Get(i));
|
||||
|
||||
tempnewfaces.SetSize (0);
|
||||
for (i = oldnf+1; i <= locfaces.Size(); i++)
|
||||
for(int i = oldnf+1; i <= locfaces.Size(); i++)
|
||||
tempnewfaces.Append (locfaces.Get(i));
|
||||
|
||||
tempdelfaces.SetSize (0);
|
||||
for (i = 1; i <= delfaces.Size(); i++)
|
||||
for(int i = 1; i <= delfaces.Size(); i++)
|
||||
tempdelfaces.Append (delfaces.Get(i));
|
||||
|
||||
templocelements.SetSize (0);
|
||||
for (i = 1; i <= locelements.Size(); i++)
|
||||
for(int i = 1; i <= locelements.Size(); i++)
|
||||
templocelements.Append (locelements.Get(i));
|
||||
|
||||
/*
|
||||
@ -624,20 +624,20 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
}
|
||||
*/
|
||||
|
||||
for (i = 1; i <= tempnewpoints.Size(); i++)
|
||||
for(int i = 1; i <= tempnewpoints.Size(); i++)
|
||||
locpoints.Append (tempnewpoints.Get(i));
|
||||
for (i = 1; i <= tempnewfaces.Size(); i++)
|
||||
for(int i = 1; i <= tempnewfaces.Size(); i++)
|
||||
locfaces.Append (tempnewfaces.Get(i));
|
||||
for (i = 1; i <= tempdelfaces.Size(); i++)
|
||||
for(int i = 1; i <= tempdelfaces.Size(); i++)
|
||||
delfaces.Append (tempdelfaces.Get(i));
|
||||
for (i = 1; i <= templocelements.Size(); i++)
|
||||
for(int i = 1; i <= templocelements.Size(); i++)
|
||||
locelements.Append (templocelements.Get(i));
|
||||
|
||||
|
||||
if (loktestmode)
|
||||
{
|
||||
(*testout) << "apply rule" << endl;
|
||||
for (i = 1; i <= locpoints.Size(); i++)
|
||||
for(int i = 1; i <= locpoints.Size(); i++)
|
||||
{
|
||||
(*testout) << "p";
|
||||
if (i <= pindex.Size())
|
||||
@ -676,7 +676,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
stat.cntelem++;
|
||||
}
|
||||
|
||||
for (i = oldnf+1; i <= locfaces.Size(); i++)
|
||||
for(int i = oldnf+1; i <= locfaces.Size(); i++)
|
||||
{
|
||||
for (j = 1; j <= locfaces.Get(i).GetNP(); j++)
|
||||
locfaces.Elem(i).PNum(j) =
|
||||
@ -685,7 +685,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
adfront->AddFace (locfaces.Get(i));
|
||||
}
|
||||
|
||||
for (i = 1; i <= delfaces.Size(); i++)
|
||||
for(int i = 1; i <= delfaces.Size(); i++)
|
||||
adfront->DeleteFace (findex.Get(delfaces.Get(i)));
|
||||
}
|
||||
else
|
||||
@ -709,7 +709,7 @@ GenerateMesh (Mesh & mesh, const MeshingParameters & mp)
|
||||
|
||||
PrintMessage (5, ""); // line feed after statistics
|
||||
|
||||
for (i = 1; i <= ruleused.Size(); i++)
|
||||
for(int i = 1; i <= ruleused.Size(); i++)
|
||||
(*testout) << setw(4) << ruleused.Get(i)
|
||||
<< " times used rule " << rules.Get(i) -> Name() << endl;
|
||||
|
||||
@ -742,7 +742,7 @@ void Meshing3 :: BlockFill (Mesh & mesh, double gh)
|
||||
double xminb, xmaxb, yminb, ymaxb, zminb, zmaxb;
|
||||
//double rad = 0.7 * gh;
|
||||
|
||||
for (i = 1; i <= adfront->GetNP(); i++)
|
||||
for(int i = 1; i <= adfront->GetNP(); i++)
|
||||
{
|
||||
const Point3d & p = adfront->GetPoint(PointIndex(i));
|
||||
if (i == 1)
|
||||
@ -780,13 +780,13 @@ void Meshing3 :: BlockFill (Mesh & mesh, double gh)
|
||||
|
||||
// initialize inner to 1
|
||||
|
||||
for (i = 1; i <= n; i++)
|
||||
for(int i = 1; i <= n; i++)
|
||||
inner.Elem(i) = BLOCKUNDEF;
|
||||
|
||||
|
||||
// set blocks cutting surfaces to 0
|
||||
|
||||
for (i = 1; i <= adfront->GetNF(); i++)
|
||||
for(int i = 1; i <= adfront->GetNF(); i++)
|
||||
{
|
||||
const MiniElement2d & el = adfront->GetFace(i);
|
||||
xminb = xmax; xmaxb = xmin;
|
||||
@ -916,14 +916,14 @@ void Meshing3 :: BlockFill (Mesh & mesh, double gh)
|
||||
|
||||
|
||||
filled = 0;
|
||||
for (i = 1; i <= n; i++)
|
||||
for(int i = 1; i <= n; i++)
|
||||
if (inner.Elem(i) == BLOCKINNER)
|
||||
{
|
||||
filled++;
|
||||
}
|
||||
PrintMessage (5, "Filled blocks: ", filled);
|
||||
|
||||
for (i = 1; i <= n; i++)
|
||||
for(int i = 1; i <= n; i++)
|
||||
{
|
||||
pointnr.Elem(i) = 0;
|
||||
frontpointnr.Elem(i) = 0;
|
||||
|
@ -157,10 +157,9 @@ namespace netgen
|
||||
<< " si = " << seg.si << ", edgenr = " << seg.edgenr;
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Element2d :: Element2d ()
|
||||
{
|
||||
{
|
||||
for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++)
|
||||
{
|
||||
pnum[i] = 0;
|
||||
@ -177,8 +176,7 @@ namespace netgen
|
||||
strongrefflag = false;
|
||||
is_curved = false;
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
Element2d :: Element2d (int anp)
|
||||
{
|
||||
for (int i = 0; i < ELEMENT2D_MAXPOINTS; i++)
|
||||
@ -969,7 +967,7 @@ namespace netgen
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Element :: Element ()
|
||||
{
|
||||
typ = TET;
|
||||
@ -992,9 +990,8 @@ namespace netgen
|
||||
#ifdef PARALLEL
|
||||
partitionNumber = -1;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
Element :: Element (int anp)
|
||||
{
|
||||
@ -1063,12 +1060,15 @@ namespace netgen
|
||||
flags.fixed = 0;
|
||||
orderx = ordery = orderz = 1;
|
||||
is_curved = typ != TET; // false;
|
||||
#ifdef PARALLEL
|
||||
partitionNumber = -1;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/*
|
||||
Element & Element :: operator= (const Element & el2)
|
||||
{
|
||||
typ = el2.typ;
|
||||
@ -1085,7 +1085,7 @@ namespace netgen
|
||||
is_curved = el2.is_curved;
|
||||
return *this;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
|
||||
void Element :: SetNP (int anp)
|
||||
|
@ -54,18 +54,35 @@ namespace netgen
|
||||
enum OPTIMIZEGOAL { OPT_QUALITY, OPT_CONFORM, OPT_REST, OPT_WORSTCASE, OPT_LEGAL };
|
||||
|
||||
|
||||
extern DLL_HEADER size_t timestamp;
|
||||
inline size_t GetTimeStamp()
|
||||
{
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
inline size_t NextTimeStamp()
|
||||
{
|
||||
timestamp++;
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/*
|
||||
extern DLL_HEADER int GetTimeStamp();
|
||||
extern DLL_HEADER int NextTimeStamp();
|
||||
|
||||
*/
|
||||
class PointGeomInfo
|
||||
{
|
||||
public:
|
||||
int trignum; // for STL Meshing
|
||||
double u, v; // for OCC Meshing
|
||||
|
||||
PointGeomInfo ()
|
||||
: trignum(-1), u(0), v(0) { ; }
|
||||
PointGeomInfo () = default;
|
||||
// : trignum(-1), u(0), v(0) { ; }
|
||||
PointGeomInfo (const PointGeomInfo&) = default;
|
||||
PointGeomInfo (PointGeomInfo &&) = default;
|
||||
PointGeomInfo & operator= (const PointGeomInfo&) = default;
|
||||
PointGeomInfo & operator= (PointGeomInfo&&) = default;
|
||||
|
||||
};
|
||||
|
||||
inline ostream & operator<< (ostream & ost, const PointGeomInfo & gi)
|
||||
@ -133,9 +150,14 @@ namespace netgen
|
||||
{
|
||||
int i;
|
||||
public:
|
||||
PointIndex () { ; }
|
||||
PointIndex () = default;
|
||||
PointIndex (const PointIndex&) = default;
|
||||
PointIndex (PointIndex &&) = default;
|
||||
PointIndex & operator= (const PointIndex&) = default;
|
||||
PointIndex & operator= (PointIndex&&) = default;
|
||||
|
||||
PointIndex (int ai) : i(ai) { ; }
|
||||
PointIndex & operator= (const PointIndex &ai) { i = ai.i; return *this; }
|
||||
// PointIndex & operator= (const PointIndex &ai) { i = ai.i; return *this; }
|
||||
operator int () const { return i; }
|
||||
PointIndex operator++ (int) { PointIndex hi(*this); i++; return hi; }
|
||||
PointIndex operator-- (int) { PointIndex hi(*this); i--; return hi; }
|
||||
@ -352,7 +374,11 @@ namespace netgen
|
||||
|
||||
public:
|
||||
///
|
||||
Element2d ();
|
||||
Element2d () = default;
|
||||
Element2d (const Element2d &) = default;
|
||||
Element2d (Element2d &&) = default;
|
||||
Element2d & operator= (const Element2d &) = default;
|
||||
Element2d & operator= (Element2d &&) = default;
|
||||
///
|
||||
Element2d (int anp);
|
||||
///
|
||||
@ -422,6 +448,8 @@ namespace netgen
|
||||
{ return FlatArray<const PointIndex> (np, &pnum[0]); }
|
||||
FlatArray<PointIndex> PNums ()
|
||||
{ return FlatArray<PointIndex> (np, &pnum[0]); }
|
||||
auto Vertices() const
|
||||
{ return FlatArray<const PointIndex> (GetNV(), &pnum[0]); }
|
||||
|
||||
///
|
||||
PointIndex & PNum (int i) { return pnum[i-1]; }
|
||||
@ -632,13 +660,18 @@ namespace netgen
|
||||
flagstruct flags;
|
||||
|
||||
///
|
||||
DLL_HEADER Element ();
|
||||
DLL_HEADER Element () = default;
|
||||
Element (const Element &) = default;
|
||||
Element (Element &&) = default;
|
||||
Element & operator= (const Element &) = default;
|
||||
Element & operator= (Element &&) = default;
|
||||
|
||||
///
|
||||
Element (int anp);
|
||||
///
|
||||
Element (ELEMENT_TYPE type);
|
||||
///
|
||||
Element & operator= (const Element & el2);
|
||||
// Element & operator= (const Element & el2);
|
||||
|
||||
///
|
||||
void SetNP (int anp);
|
||||
@ -647,7 +680,7 @@ namespace netgen
|
||||
///
|
||||
int GetNP () const { return np; }
|
||||
///
|
||||
short int GetNV() const
|
||||
uint8_t GetNV() const
|
||||
{
|
||||
__assume(typ >= TET && typ <= HEX);
|
||||
switch (typ)
|
||||
@ -666,7 +699,8 @@ namespace netgen
|
||||
#ifdef DEBUG
|
||||
PrintSysError ("Element3d::GetNV not implemented for typ ", typ);
|
||||
#endif
|
||||
return -1;
|
||||
__assume(false);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -329,7 +329,7 @@ void netrule :: LoadRule (istream & ist)
|
||||
|
||||
while (ch == '(')
|
||||
{
|
||||
elements.Append (Element2d());
|
||||
elements.Append (Element2d(TRIG));
|
||||
|
||||
ist >> elements.Last().PNum(1);
|
||||
ist >> ch; // ','
|
||||
|
@ -84,7 +84,7 @@ void vnetrule :: LoadRule (istream & ist)
|
||||
char buf[256];
|
||||
char ch, ok;
|
||||
Point3d p;
|
||||
Element2d face;
|
||||
Element2d face(TRIG);
|
||||
int i, j, i1, i2, i3, fs, ii, ii1, ii2, ii3;
|
||||
twoint edge;
|
||||
DenseMatrix tempoldutonewu(30, 20),
|
||||
|
@ -11,8 +11,11 @@
|
||||
|
||||
using namespace netgen;
|
||||
|
||||
extern const char *ngscript[];
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
extern bool netgen_executable_started;
|
||||
extern shared_ptr<NetgenGeometry> ng_geometry;
|
||||
}
|
||||
|
||||
@ -49,6 +52,14 @@ static Transformation<3> global_trafo(Vec<3> (0,0,0));
|
||||
|
||||
DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
{
|
||||
m.attr("_netgen_executable_started") = py::cast(netgen::netgen_executable_started);
|
||||
string script;
|
||||
const char ** hcp = ngscript;
|
||||
while (*hcp)
|
||||
script += *hcp++;
|
||||
|
||||
m.attr("_ngscript") = py::cast(script);
|
||||
|
||||
py::class_<NGDummyArgument>(m, "NGDummyArgument")
|
||||
.def("__bool__", []( NGDummyArgument &self ) { return false; } )
|
||||
;
|
||||
@ -226,6 +237,14 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
li.append (py::cast(self[i]));
|
||||
return li;
|
||||
}))
|
||||
.def_property_readonly("points",
|
||||
FunctionPointer ([](const Element & self) -> py::list
|
||||
{
|
||||
py::list li;
|
||||
for (int i = 0; i < self.GetNP(); i++)
|
||||
li.append (py::cast(self[i]));
|
||||
return li;
|
||||
}))
|
||||
;
|
||||
|
||||
py::class_<Element2d>(m, "Element2D")
|
||||
@ -375,8 +394,8 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
|
||||
|
||||
|
||||
ExportArray<Element,0,ElementIndex>(m);
|
||||
ExportArray<Element2d,0,SurfaceElementIndex>(m);
|
||||
ExportArray<Element,0,size_t>(m);
|
||||
ExportArray<Element2d,0,size_t>(m);
|
||||
ExportArray<Segment>(m);
|
||||
ExportArray<Element0d>(m);
|
||||
ExportArray<MeshPoint,PointIndex::BASE,PointIndex>(m);
|
||||
@ -458,11 +477,11 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
.def_property("dim", &Mesh::GetDimension, &Mesh::SetDimension)
|
||||
|
||||
.def("Elements3D",
|
||||
static_cast<Array<Element,0,ElementIndex>&(Mesh::*)()> (&Mesh::VolumeElements),
|
||||
static_cast<Array<Element,0,size_t>&(Mesh::*)()> (&Mesh::VolumeElements),
|
||||
py::return_value_policy::reference)
|
||||
|
||||
.def("Elements2D",
|
||||
static_cast<Array<Element2d,0,SurfaceElementIndex>&(Mesh::*)()> (&Mesh::SurfaceElements),
|
||||
static_cast<Array<Element2d,0,size_t>&(Mesh::*)()> (&Mesh::SurfaceElements),
|
||||
py::return_value_policy::reference)
|
||||
|
||||
.def("Elements1D",
|
||||
@ -590,6 +609,15 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
Refinement().Refine(self);
|
||||
}))
|
||||
|
||||
.def ("SecondOrder", FunctionPointer
|
||||
([](Mesh & self)
|
||||
{
|
||||
if (self.GetGeometry())
|
||||
self.GetGeometry()->GetRefinement().MakeSecondOrder(self);
|
||||
else
|
||||
Refinement().MakeSecondOrder(self);
|
||||
}))
|
||||
|
||||
.def ("SetGeometry", FunctionPointer
|
||||
([](Mesh & self, shared_ptr<NetgenGeometry> geo)
|
||||
{
|
||||
@ -684,7 +712,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
.def(py::init<>())
|
||||
.def("__init__",
|
||||
[](MP *instance, double maxh, bool quad_dominated, int optsteps2d, int optsteps3d,
|
||||
MESHING_STEP perfstepsend, int only3D_domain)
|
||||
MESHING_STEP perfstepsend, int only3D_domain, const string & meshsizefilename)
|
||||
{
|
||||
new (instance) MeshingParameters;
|
||||
instance->maxh = maxh;
|
||||
@ -693,6 +721,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
instance->optsteps3d = optsteps3d;
|
||||
instance->only3D_domain_nr = only3D_domain;
|
||||
instance->perfstepsend = perfstepsend;
|
||||
instance->meshsizefilename = meshsizefilename;
|
||||
},
|
||||
py::arg("maxh")=1000,
|
||||
py::arg("quad_dominated")=false,
|
||||
@ -700,6 +729,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
py::arg("optsteps3d") = 3,
|
||||
py::arg("perfstepsend") = MESHCONST_OPTVOLUME,
|
||||
py::arg("only3D_domain") = 0,
|
||||
py::arg("meshsizefilename") = "",
|
||||
"create meshing parameters"
|
||||
)
|
||||
.def("__str__", &ToString<MP>)
|
||||
|
@ -436,7 +436,7 @@ namespace netgen
|
||||
int ind = el.GetIndex();
|
||||
for (int j = 0; j < 8; j++)
|
||||
{
|
||||
Element nel;
|
||||
Element nel(TET);
|
||||
for (int k = 1; k <= 4; k++)
|
||||
nel.PNum(k) = pnums.Get(reftab[j][k-1]);
|
||||
nel.SetIndex(ind);
|
||||
|
@ -112,7 +112,7 @@ namespace netgen
|
||||
|
||||
int onp(0);
|
||||
|
||||
Element2d newel;
|
||||
Element2d newel(TRIG);
|
||||
newel.SetIndex (el.GetIndex());
|
||||
|
||||
static int betw_trig[3][3] =
|
||||
@ -204,7 +204,7 @@ namespace netgen
|
||||
const Element & el = mesh.VolumeElement(i);
|
||||
int onp = 0;
|
||||
|
||||
Element newel;
|
||||
Element newel(TET);
|
||||
newel.SetIndex (el.GetIndex());
|
||||
|
||||
static int betw_tet[6][3] =
|
||||
|
@ -432,7 +432,7 @@ namespace netgen
|
||||
for (int k = 1; k <= 4; k++)
|
||||
if (el.PNum(k) == actpind)
|
||||
{
|
||||
Element2d face;
|
||||
Element2d face(TRIG);
|
||||
el.GetFace (k, face);
|
||||
Swap (face.PNum(2), face.PNum(3));
|
||||
faces.Append (face);
|
||||
|
@ -1119,8 +1119,8 @@ namespace netgen
|
||||
(*testout) << "points = " << face2vert[i] << endl;
|
||||
(*testout) << "pos = ";
|
||||
for (int j = 0; j < 4; j++)
|
||||
if (face2vert[i].I(j+1) >= 1)
|
||||
(*testout) << mesh[(PointIndex)face2vert[i].I(j+1)] << " ";
|
||||
if (face2vert[i].I(j+1) >= 1)
|
||||
(*testout) << (*mesh)[(PointIndex)face2vert[i].I(j+1)] << " ";
|
||||
(*testout) << endl;
|
||||
|
||||
FlatArray<ElementIndex> vertels = GetVertexElements (face2vert[i].I(1));
|
||||
|
@ -2,7 +2,7 @@ add_definitions(-DNGINTERFACE_EXPORTS)
|
||||
add_library(occ ${NG_LIB_TYPE}
|
||||
Partition_Inter2d.cxx Partition_Inter3d.cxx
|
||||
Partition_Loop.cxx Partition_Loop2d.cxx Partition_Loop3d.cxx Partition_Spliter.cxx
|
||||
occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp
|
||||
occconstruction.cpp occgenmesh.cpp occgeom.cpp occmeshsurf.cpp python_occ.cpp
|
||||
)
|
||||
|
||||
add_library(occvis ${NG_LIB_TYPE} vsocc.cpp)
|
||||
@ -10,10 +10,10 @@ add_library(occvis ${NG_LIB_TYPE} vsocc.cpp)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( occ ${OCC_LIBRARIES} ${PYTHON_LIBRARIES})
|
||||
target_link_libraries( occvis occ )
|
||||
install( TARGETS occ occvis ${ng_install_dir})
|
||||
install( TARGETS occ occvis ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
install(FILES
|
||||
occgeom.hpp occmeshsurf.hpp vsocc.hpp
|
||||
DESTINATION ${INCDIR}/occ COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/occ COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -422,6 +422,10 @@ namespace netgen
|
||||
{
|
||||
mesh.GetFaceDescriptor(facenr).SetSurfColour(Vec3d(0.0,1.0,0.0));
|
||||
}
|
||||
|
||||
if(geom.fnames.Size()>=facenr)
|
||||
mesh.GetFaceDescriptor(facenr).SetBCName(&geom.fnames[facenr-1]);
|
||||
mesh.GetFaceDescriptor(facenr).SetBCProperty(facenr);
|
||||
// ACHTUNG! STIMMT NICHT ALLGEMEIN (RG)
|
||||
|
||||
|
||||
@ -974,6 +978,13 @@ namespace netgen
|
||||
NgProfiler::StopTimer (timer_opt2d);
|
||||
|
||||
multithread.task = savetask;
|
||||
|
||||
// Gerhard BEGIN
|
||||
for(int i = 0; i<mesh.GetNFD();i++)
|
||||
mesh.SetBCName(i,mesh.GetFaceDescriptor(i+1).GetBCName());
|
||||
// for(int i = 0; i<mesh.GetNDomains();i++)
|
||||
// mesh.SetMaterial(i,geom.snames[i]);
|
||||
// Gerhard END
|
||||
}
|
||||
|
||||
|
||||
@ -1459,6 +1470,9 @@ namespace netgen
|
||||
for (int i = 1; i <= mesh->GetNSeg(); i++)
|
||||
(*testout) << mesh->LineSegment(i) << endl;
|
||||
|
||||
for (int i = 0; i < mesh->GetNDomains(); i++)
|
||||
if(geom.snames.Size())
|
||||
mesh->SetMaterial( i+1, geom.snames[i] );
|
||||
return TCL_OK;
|
||||
}
|
||||
}
|
||||
|
@ -17,6 +17,10 @@
|
||||
#include "Partition_Spliter.hxx"
|
||||
#include "BRepAlgoAPI_Fuse.hxx"
|
||||
|
||||
#include "XSControl_WorkSession.hxx"
|
||||
#include "XSControl_TransferReader.hxx"
|
||||
#include "StepRepr_RepresentationItem.hxx"
|
||||
|
||||
#ifndef _Standard_Version_HeaderFile
|
||||
#include <Standard_Version.hxx>
|
||||
#endif
|
||||
@ -29,6 +33,44 @@
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
void STEP_GetEntityName(const TopoDS_Shape & theShape, STEPCAFControl_Reader * aReader, char * acName)
|
||||
{
|
||||
const Handle(XSControl_WorkSession)& theSession = aReader->Reader().WS();
|
||||
const Handle(XSControl_TransferReader)& aTransferReader =
|
||||
theSession->TransferReader();
|
||||
|
||||
Handle(Standard_Transient) anEntity =
|
||||
aTransferReader->EntityFromShapeResult(theShape, 1);
|
||||
|
||||
if (anEntity.IsNull()) {
|
||||
// as just mapped
|
||||
anEntity = aTransferReader->EntityFromShapeResult (theShape,-1);
|
||||
}
|
||||
|
||||
if (anEntity.IsNull()) {
|
||||
// as anything
|
||||
anEntity = aTransferReader->EntityFromShapeResult (theShape,4);
|
||||
}
|
||||
|
||||
if (anEntity.IsNull()) {
|
||||
cout<<"Warning: XSInterVertex_STEPReader::ReadAttributes()\nentity not found"<<endl;
|
||||
strcpy(acName, "none");
|
||||
}
|
||||
else
|
||||
{
|
||||
Handle(StepRepr_RepresentationItem) aReprItem;
|
||||
aReprItem =
|
||||
Handle(StepRepr_RepresentationItem)::DownCast(anEntity);
|
||||
|
||||
if (aReprItem.IsNull()) {
|
||||
cout<<"Error: STEPReader::ReadAttributes():\nStepRepr_RepresentationItem Is NULL"<<endl;
|
||||
}
|
||||
else
|
||||
strcpy(acName, aReprItem->Name()->ToCString());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void OCCGeometry :: PrintNrShapes ()
|
||||
{
|
||||
TopExp_Explorer e;
|
||||
@ -1169,7 +1211,7 @@ namespace netgen
|
||||
|
||||
// Enable transfer of colours
|
||||
reader.SetColorMode(Standard_True);
|
||||
|
||||
reader.SetNameMode(Standard_True);
|
||||
Standard_Integer stat = reader.ReadFile((char*)filename);
|
||||
|
||||
if(stat != IFSelect_RetDone)
|
||||
@ -1210,7 +1252,38 @@ namespace netgen
|
||||
|
||||
occgeo->CalcBoundingBox();
|
||||
PrintContents (occgeo);
|
||||
|
||||
char * name = new char(50);
|
||||
//string name;
|
||||
STEP_GetEntityName(occgeo->shape,&reader,name);
|
||||
occgeo->snames.Append(name);
|
||||
TopExp_Explorer exp0,exp1;
|
||||
|
||||
for (exp0.Init(occgeo->shape, TopAbs_FACE); exp0.More(); exp0.Next())
|
||||
{
|
||||
TopoDS_Face face = TopoDS::Face(exp0.Current());
|
||||
STEP_GetEntityName(face,&reader,name);
|
||||
occgeo->fnames.Append(name);
|
||||
for (exp1.Init(face, TopAbs_EDGE); exp1.More(); exp1.Next())
|
||||
{
|
||||
TopoDS_Edge edge = TopoDS::Edge(exp1.Current());
|
||||
STEP_GetEntityName(edge,&reader,name);
|
||||
occgeo->enames.Append(name);
|
||||
}
|
||||
}
|
||||
// Gerhard BEGIN
|
||||
// cout << "Solid Names: "<<endl;
|
||||
// for (int i=0;i<occgeo->snames.Size();i++)
|
||||
// cout << occgeo->snames[i] << endl;
|
||||
// cout << " " <<endl;
|
||||
// cout << "Face Names: "<<endl;
|
||||
// for (int i=0;i<occgeo->fnames.Size();i++)
|
||||
// cout << occgeo->fnames[i] << endl;
|
||||
// cout << " " <<endl;
|
||||
// cout << "Edge Names: "<<endl;
|
||||
// for (int i=0;i<occgeo->enames.Size();i++)
|
||||
// cout << occgeo->enames[i] << endl;
|
||||
// cout << " " <<endl;
|
||||
// Gerhard END
|
||||
return occgeo;
|
||||
}
|
||||
|
||||
|
@ -198,7 +198,7 @@ namespace netgen
|
||||
TopTools_IndexedMapOfShape fmap, emap, vmap, somap, shmap, wmap;
|
||||
Array<bool> fsingular, esingular, vsingular;
|
||||
Box<3> boundingbox;
|
||||
|
||||
Array<string> fnames, enames, snames;
|
||||
// Philippose - 29/01/2009
|
||||
// OpenCascade XDE Support
|
||||
// XCAF Handle to make the face colours available to the rest of
|
||||
|
56
libsrc/occ/python_occ.cpp
Normal file
56
libsrc/occ/python_occ.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
#ifdef NG_PYTHON
|
||||
#ifdef OCCGEOMETRY
|
||||
|
||||
#include <../general/ngpython.hpp>
|
||||
|
||||
#include <meshing.hpp>
|
||||
#include <occgeom.hpp>
|
||||
|
||||
using namespace netgen;
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
extern std::shared_ptr<NetgenGeometry> ng_geometry;
|
||||
}
|
||||
|
||||
|
||||
DLL_HEADER void ExportNgOCC(py::module &m)
|
||||
{
|
||||
py::class_<OCCGeometry, shared_ptr<OCCGeometry>> (m, "OCCGeometry")
|
||||
.def(py::init<>())
|
||||
;
|
||||
m.def("LoadOCCGeometry",FunctionPointer([] (const string & filename)
|
||||
{
|
||||
cout << "load OCC geometry";
|
||||
ifstream ist(filename);
|
||||
OCCGeometry * instance = new OCCGeometry();
|
||||
instance = LoadOCC_STEP(filename.c_str());
|
||||
return shared_ptr<OCCGeometry>(instance, NOOP_Deleter);
|
||||
}));
|
||||
m.def("GenerateMesh", FunctionPointer([] (shared_ptr<OCCGeometry> geo, MeshingParameters ¶m)
|
||||
{
|
||||
auto mesh = make_shared<Mesh>();
|
||||
SetGlobalMesh(mesh);
|
||||
mesh->SetGeometry(geo);
|
||||
ng_geometry = geo;
|
||||
try
|
||||
{
|
||||
geo->GenerateMesh(mesh,param);
|
||||
}
|
||||
catch (NgException ex)
|
||||
{
|
||||
cout << "Caught NgException: " << ex.What() << endl;
|
||||
}
|
||||
return mesh;
|
||||
}))
|
||||
;
|
||||
}
|
||||
|
||||
PYBIND11_PLUGIN(libNgOCC) {
|
||||
py::module m("NgOCC", "pybind NgOCC");
|
||||
ExportNgOCC(m);
|
||||
return m.ptr();
|
||||
}
|
||||
|
||||
#endif // OCCGEOMETRY
|
||||
#endif // NG_PYTHON
|
@ -6,7 +6,7 @@ add_library(stl ${NG_LIB_TYPE}
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( stl mesh ${PYTHON_LIBRARIES})
|
||||
target_link_libraries( stl ${PYTHON_LIBRARIES})
|
||||
install( TARGETS stl ${ng_install_dir})
|
||||
install( TARGETS stl ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
if(USE_GUI)
|
||||
@ -15,12 +15,12 @@ if(USE_GUI)
|
||||
)
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( stlvis stl )
|
||||
install( TARGETS stlvis ${ng_install_dir})
|
||||
install( TARGETS stlvis ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
endif(USE_GUI)
|
||||
|
||||
install(FILES
|
||||
meshstlsurface.hpp stlgeom.hpp stlline.hpp
|
||||
stltool.hpp stltopology.hpp vsstl.hpp
|
||||
DESTINATION ${INCDIR}/stlgeom COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/stlgeom COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -1,7 +1,5 @@
|
||||
add_definitions(-DNGINTERFACE_EXPORTS)
|
||||
install(FILES soldata.hpp DESTINATION ${INCDIR} COMPONENT netgen_devel )
|
||||
|
||||
# AM_CPPFLAGS = $(MPI_INCLUDES) -I$(top_srcdir)/libsrc/include -DOPENGL -D$(TOGL_WINDOWINGSYSTEM) $(OCCFLAGS) $(TCL_INCLUDES)
|
||||
install(FILES soldata.hpp DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel )
|
||||
|
||||
if(USE_GUI)
|
||||
set( LIB_VISUAL_SOURCES meshdoc.cpp mvdraw.cpp vsfieldlines.cpp vsmesh.cpp vssolution.cpp importsolution.cpp )
|
||||
@ -12,12 +10,12 @@ endif(USE_GUI)
|
||||
add_library(visual ${NG_LIB_TYPE} ${LIB_VISUAL_SOURCES})
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( visual ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TCL_LIBRARY} )
|
||||
install( TARGETS visual ${ng_install_dir})
|
||||
target_link_libraries( visual ${PYTHON_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} )
|
||||
install( TARGETS visual ${NG_INSTALL_DIR})
|
||||
endif(NOT WIN32)
|
||||
|
||||
install(FILES
|
||||
meshdoc.hpp mvdraw.hpp
|
||||
vispar.hpp visual.hpp vssolution.hpp
|
||||
DESTINATION ${INCDIR}/visualization COMPONENT netgen_devel
|
||||
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/visualization COMPONENT netgen_devel
|
||||
)
|
||||
|
@ -99,7 +99,7 @@ namespace netgen
|
||||
const __m256d * dxdxref,
|
||||
__m256d * values)
|
||||
{
|
||||
cerr << "GetMultiSurfVaue not overloaded" << endl;
|
||||
cerr << "GetMultiSurfVaue not overloaded for SIMD<double>" << endl;
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
@ -1279,7 +1279,6 @@ namespace netgen
|
||||
|
||||
Array<double> mvalues(npt);
|
||||
int sol_comp = (sol && sol->draw_surface) ? sol->components : 0;
|
||||
#ifdef __AVX__
|
||||
Array<Point<2,SIMD<double>> > simd_pref ( (npt+SIMD<double>::Size()-1)/SIMD<double>::Size() );
|
||||
Array<Point<3,SIMD<double>> > simd_points ( (npt+SIMD<double>::Size()-1)/SIMD<double>::Size() );
|
||||
Array<Mat<3,2,SIMD<double>> > simd_dxdxis ( (npt+SIMD<double>::Size()-1)/SIMD<double>::Size() );
|
||||
@ -1287,7 +1286,6 @@ namespace netgen
|
||||
Array<SIMD<double>> simd_values( (npt+SIMD<double>::Size()-1)/SIMD<double>::Size() * sol_comp);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
// Array<Point<3,float>> glob_pnts;
|
||||
// Array<Vec<3,float>> glob_nvs;
|
||||
@ -1486,7 +1484,6 @@ namespace netgen
|
||||
NgProfiler::StartTimer(timerloops);
|
||||
size_t base_pi = 0;
|
||||
|
||||
#ifdef __AVX__
|
||||
for (int iy = 0, ii = 0; iy <= n; iy++)
|
||||
for (int ix = 0; ix <= n-iy; ix++, ii++)
|
||||
pref[ii] = Point<2> (ix*invn, iy*invn);
|
||||
@ -1496,10 +1493,9 @@ namespace netgen
|
||||
|
||||
for (size_t i = 0; i < simd_npt; i++)
|
||||
{
|
||||
simd_pref[i](0).SIMD_function ([&] (size_t j) { size_t ii = i*simd_size+j; return (ii < npt) ? pref[ii](0) : 0; }, std::true_type());
|
||||
simd_pref[i](1).SIMD_function ([&] (size_t j) { size_t ii = i*simd_size+j; return (ii < npt) ? pref[ii](1) : 0; }, std::true_type());
|
||||
simd_pref[i](0) = [&] (size_t j) { size_t ii = i*simd_size+j; return (ii < npt) ? pref[ii](0) : 0; };
|
||||
simd_pref[i](1) = [&] (size_t j) { size_t ii = i*simd_size+j; return (ii < npt) ? pref[ii](1) : 0; };
|
||||
}
|
||||
#endif
|
||||
|
||||
Array<int> ind_reftrig;
|
||||
for (int iy = 0, ii = 0; iy < n; iy++,ii++)
|
||||
@ -1928,12 +1924,12 @@ namespace netgen
|
||||
Array<Point<3> > grid(n3);
|
||||
Array<Point<3> > locgrid(n3);
|
||||
Array<Mat<3,3> > trans(n3);
|
||||
Array<double> val(n3);
|
||||
Array<Vec<3> > grads(n3);
|
||||
Array<double> val1(n3*sol->components);
|
||||
Array<Vec<3> > grads1(n3);
|
||||
Array<int> compress(n3);
|
||||
|
||||
MatrixFixWidth<3> pointmat(8);
|
||||
grads = Vec<3> (0.0);
|
||||
grads1 = Vec<3> (0.0);
|
||||
|
||||
for (ElementIndex ei = 0; ei < ne; ei++)
|
||||
{
|
||||
@ -2023,26 +2019,47 @@ namespace netgen
|
||||
}
|
||||
|
||||
bool has_pos = 0, has_neg = 0;
|
||||
|
||||
GetMultiValues( sol, ei, -1, n3,
|
||||
&locgrid[0](0), &locgrid[1](0)-&locgrid[0](0),
|
||||
&grid[0](0), &grid[1](0)-&grid[0](0),
|
||||
&trans[0](0), &trans[1](0)-&trans[0](0),
|
||||
&val1[0], sol->components);
|
||||
for (int i = 0; i < cnt_valid; i++)
|
||||
{
|
||||
GetValue (sol, ei, &locgrid[i](0), &grid[i](0), &trans[i](0), comp, val[i]);
|
||||
|
||||
val[i] -= minval;
|
||||
// GetValue (sol, ei, &locgrid[i](0), &grid[i](0), &trans[i](0), comp, val[i]);
|
||||
|
||||
if (vsol)
|
||||
GetValues (vsol, ei, &locgrid[i](0), &grid[i](0), &trans[i](0), &grads[i](0));
|
||||
grads[i] *= -1;
|
||||
// val[i] -= minval;
|
||||
val1[sol->components*i+comp-1] -= minval;
|
||||
|
||||
|
||||
if (val[i] > 0)
|
||||
// if (vsol)
|
||||
// GetValues (vsol, ei, &locgrid[i](0), &grid[i](0), &trans[i](0), &grads[i](0));
|
||||
// grads[i] *= -1;
|
||||
|
||||
if (val1[i*sol->components+comp-1] > 0)
|
||||
has_pos = 1;
|
||||
else
|
||||
has_neg = 1;
|
||||
// if (val[i] > 0)
|
||||
// has_pos = 1;
|
||||
// else
|
||||
// has_neg = 1;
|
||||
}
|
||||
|
||||
if (!has_pos || !has_neg) continue;
|
||||
|
||||
if (vsol)
|
||||
{
|
||||
GetMultiValues(vsol, ei, -1, n3,
|
||||
&locgrid[0](0), &locgrid[1](0)-&locgrid[0](0),
|
||||
&grid[0](0), &grid[1](0)-&grid[0](0),
|
||||
&trans[0](0), &trans[1](0)-&trans[0](0),
|
||||
&grads1[0](0), vsol->components);
|
||||
// for (int i = 0; i < cnt_valid; i++)
|
||||
// grads1[i*sol->components+comp-1] *= -1;
|
||||
for (int i = 0; i < cnt_valid; i++)
|
||||
grads1[i] *= -1;
|
||||
|
||||
}
|
||||
for (int ix = 0; ix < n; ix++)
|
||||
for (int iy = 0; iy < n; iy++)
|
||||
for (int iz = 0; iz < n; iz++)
|
||||
@ -2075,8 +2092,10 @@ namespace netgen
|
||||
|
||||
if (!is_valid) continue;
|
||||
|
||||
// for (int j = 0; j < 4; j++)
|
||||
// nodevali[j] = val[teti[j]];
|
||||
for (int j = 0; j < 4; j++)
|
||||
nodevali[j] = val[teti[j]];
|
||||
nodevali[j] = val1[sol->components*teti[j]+comp-1];
|
||||
|
||||
cntce = 0;
|
||||
for (int j = 0; j < 6; j++)
|
||||
@ -2091,8 +2110,9 @@ namespace netgen
|
||||
|
||||
edgelam[j] = nodevali[lpi2] / (nodevali[lpi2] - nodevali[lpi1]);
|
||||
edgep[j] = grid[teti[lpi1]] + (1-edgelam[j]) * (grid[teti[lpi2]]-grid[teti[lpi1]]);
|
||||
normp[j] = grads[teti[lpi1]] + (1-edgelam[j]) * (grads[teti[lpi2]]-grads[teti[lpi1]]);
|
||||
|
||||
// normp[j] = grads[teti[lpi1]] + (1-edgelam[j]) * (grads[teti[lpi2]]-grads[teti[lpi1]]);
|
||||
normp[j] = grads1[teti[lpi1]] + (1-edgelam[j]) * (grads1[teti[lpi2]]-grads1[teti[lpi1]]);
|
||||
// normp[j] = grads1[sol->components*teti[lpi1]+comp-1] + (1-edgelam[j]) * (grads1[sol->components*teti[lpi2]+comp-1]-grads1[sol->components*teti[lpi1]+comp-1]);
|
||||
cntce++;
|
||||
cpe3 = cpe2;
|
||||
cpe2 = cpe1;
|
||||
@ -3350,8 +3370,6 @@ namespace netgen
|
||||
double lam1, double lam2,
|
||||
int comp, double & val) const
|
||||
{
|
||||
shared_ptr<Mesh> mesh = GetMesh();
|
||||
|
||||
bool ok;
|
||||
if (comp == 0)
|
||||
{
|
||||
@ -3399,6 +3417,7 @@ namespace netgen
|
||||
|
||||
case SOL_NODAL:
|
||||
{
|
||||
shared_ptr<Mesh> mesh = GetMesh();
|
||||
const Element2d & el = (*mesh)[selnr];
|
||||
|
||||
double lami[8];
|
||||
@ -3457,6 +3476,7 @@ namespace netgen
|
||||
|
||||
case SOL_ELEMENT:
|
||||
{
|
||||
shared_ptr<Mesh> mesh = GetMesh();
|
||||
int el1, el2;
|
||||
mesh->GetTopology().GetSurface2VolumeElement (selnr+1, el1, el2);
|
||||
el1--;
|
||||
@ -3480,6 +3500,7 @@ namespace netgen
|
||||
|
||||
case SOL_SURFACE_NONCONTINUOUS:
|
||||
{
|
||||
shared_ptr<Mesh> mesh = GetMesh();
|
||||
const Element2d & el = (*mesh)[selnr];
|
||||
|
||||
double lami[8];
|
||||
@ -3554,12 +3575,14 @@ namespace netgen
|
||||
|
||||
case SOL_MARKED_ELEMENTS:
|
||||
{
|
||||
shared_ptr<Mesh> mesh = GetMesh();
|
||||
val = (*mesh)[selnr].TestRefinementFlag();
|
||||
return 1;
|
||||
}
|
||||
|
||||
case SOL_ELEMENT_ORDER:
|
||||
{
|
||||
{
|
||||
shared_ptr<Mesh> mesh = GetMesh();
|
||||
val = (*mesh)[selnr].GetOrder();
|
||||
return 1;
|
||||
}
|
||||
@ -4813,12 +4836,14 @@ void (*glGenBuffers) (GLsizei a, GLuint *b);
|
||||
void (*glBufferData) (GLenum a, GLsizeiptr b, const GLvoid *c, GLenum d);
|
||||
void (*glBufferSubData) (GLenum a, GLintptr b, GLsizeiptr c, const GLvoid *d);
|
||||
DLL_HEADER void LoadOpenGLFunctionPointers() {
|
||||
#ifdef USE_BUFFERS
|
||||
glBindBuffer = (decltype(glBindBuffer)) wglGetProcAddress("glBindBuffer");
|
||||
glBufferSubData = (decltype(glBufferSubData)) wglGetProcAddress("glBufferSubData");
|
||||
glBufferData = (decltype(glBufferData)) wglGetProcAddress("glBufferData");
|
||||
glDeleteBuffers = (decltype(glDeleteBuffers)) wglGetProcAddress("glDeleteBuffers");
|
||||
glGenBuffers = (decltype(glGenBuffers)) wglGetProcAddress("glGenBuffers");
|
||||
if(!glBindBuffer) throw std::runtime_error("Could not load OpenGL functions!");
|
||||
#endif
|
||||
}
|
||||
#else // WIN32
|
||||
DLL_HEADER void LoadOpenGLFunctionPointers() { }
|
||||
|
@ -43,7 +43,13 @@ class DLL_HEADER VisualSceneSolution : public VisualScene
|
||||
Point<3> p;
|
||||
};
|
||||
|
||||
// #define USE_BUFFERS
|
||||
#ifndef WIN32
|
||||
// use OpenGL vertex buffers from OpenGL 2.x
|
||||
// not supported by some drivers on windows
|
||||
// try on your own responsibility
|
||||
#define USE_BUFFERS
|
||||
#endif
|
||||
|
||||
#ifdef USE_BUFFERS
|
||||
bool has_surfel_vbo = false;
|
||||
GLuint surfel_vbo[4]; //
|
||||
|
@ -1,24 +1,57 @@
|
||||
set(netgen_sources demoview.cpp ngappinit.cpp onetcl.cpp parallelfunc.cpp ngpkg.cpp ../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp ../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp ../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp)
|
||||
if(USE_INTERNAL_TCL)
|
||||
add_definitions(-DINTERNAL_TCL_DEFAULT=1)
|
||||
else()
|
||||
add_definitions(-DINTERNAL_TCL_DEFAULT=0)
|
||||
endif()
|
||||
|
||||
set(netgen_sources ngappinit.cpp onetcl.cpp)
|
||||
if(WIN32)
|
||||
# add icon to netgen executable
|
||||
enable_language(RC)
|
||||
set(netgen_sources ${netgen_sources} ../windows/netgen.rc)
|
||||
# Don't use ccache here due to incompatiblity with the resource compiler
|
||||
set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "")
|
||||
endif(WIN32)
|
||||
|
||||
if(USE_GUI)
|
||||
if(WIN32)
|
||||
# add icon to netgen executable
|
||||
enable_language(RC)
|
||||
set(netgen_sources ${netgen_sources} ../windows/netgen.rc)
|
||||
# Don't use ccache here due to incompatiblity with the resource compiler
|
||||
set_directory_properties(PROPERTIES RULE_LAUNCH_COMPILE "")
|
||||
endif(WIN32)
|
||||
|
||||
add_executable(netgen ${netgen_sources})
|
||||
target_link_libraries( netgen nglib ${ZLIB_LIBRARIES} ${LIBTOGL} ${TK_LIBRARY} ${TCL_LIBRARY} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES})
|
||||
add_library(gui SHARED
|
||||
gui.cpp ngpkg.cpp demoview.cpp parallelfunc.cpp
|
||||
../libsrc/stlgeom/stlpkg.cpp ../libsrc/visualization/visualpkg.cpp
|
||||
../libsrc/csg/csgpkg.cpp ../libsrc/geom2d/geom2dpkg.cpp
|
||||
../libsrc/occ/occpkg.cpp ../libsrc/occ/vsocc.cpp
|
||||
)
|
||||
|
||||
add_executable(netgen ngappinit.cpp onetcl.cpp)
|
||||
|
||||
target_link_libraries( gui PUBLIC nglib ${ZLIB_LIBRARIES} ${JPEG_LIBRARIES} ${FFMPEG_LIBRARIES} ${X11_X11_LIB} ${OCC_LIBRARIES} )
|
||||
target_link_libraries( gui PRIVATE ${LIBTOGL})
|
||||
|
||||
target_link_libraries( netgen nglib gui )
|
||||
|
||||
if(APPLE)
|
||||
# Leave decision about which tcl/tk version to use open to python (and it's tkinter package).
|
||||
# Thus, only link tcl/tk to the netgen executable and not to the gui library.
|
||||
target_link_libraries( netgen ${TK_LIBRARY} ${TCL_LIBRARY})
|
||||
else(APPLE)
|
||||
# On other systems assume that the found libraries are compatible with python/tkinter
|
||||
target_link_libraries( gui PUBLIC ${TK_LIBRARY} ${TCL_LIBRARY})
|
||||
endif(APPLE)
|
||||
|
||||
if(NOT WIN32)
|
||||
target_link_libraries( netgen mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||
target_link_libraries( gui PUBLIC mesh stlvis stl geom2dvis interface geom2d csg stl visual csgvis )
|
||||
endif(NOT WIN32)
|
||||
|
||||
install(TARGETS netgen ${ng_install_dir})
|
||||
install(TARGETS netgen ${NG_INSTALL_DIR})
|
||||
install(TARGETS gui ${NG_INSTALL_DIR})
|
||||
|
||||
if(APPLE)
|
||||
set_target_properties(netgen PROPERTIES OUTPUT_NAME netgen)
|
||||
endif(APPLE)
|
||||
if(WIN32)
|
||||
set_target_properties( gui PROPERTIES OUTPUT_NAME libgui )
|
||||
endif(WIN32)
|
||||
|
||||
endif(USE_GUI)
|
||||
|
||||
@ -31,18 +64,20 @@ if(USE_PYTHON)
|
||||
set_target_properties( ngpy PROPERTIES SUFFIX ".pyd")
|
||||
set_target_properties( ngpy PROPERTIES OUTPUT_NAME "libngpy")
|
||||
endif()
|
||||
install(TARGETS ngpy ${ng_install_dir})
|
||||
set_target_properties(ngpy PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}")
|
||||
install(TARGETS ngpy DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX})
|
||||
endif(USE_PYTHON)
|
||||
|
||||
if(USE_GUI)
|
||||
install(FILES
|
||||
dialog.tcl menustat.tcl ngicon.tcl ng.tcl
|
||||
ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl
|
||||
ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl
|
||||
occgeom.tcl acisgeom.tcl netgen.ocf
|
||||
DESTINATION ${ng_install_dir_bin} COMPONENT netgen)
|
||||
if(NOT USE_INTERNAL_TCL)
|
||||
install(FILES
|
||||
dialog.tcl menustat.tcl ngicon.tcl ng.tcl
|
||||
ngvisual.tcl sockets.tcl nghelp.tcl ngshell.tcl
|
||||
ngtesting.tcl parameters.tcl variables.tcl csgeom.tcl stlgeom.tcl
|
||||
occgeom.tcl acisgeom.tcl netgen.ocf drawing.tcl
|
||||
DESTINATION ${NG_INSTALL_DIR_BIN} COMPONENT netgen)
|
||||
endif()
|
||||
|
||||
add_subdirectory(Togl2.1)
|
||||
install(FILES drawing.tcl DESTINATION ${ng_install_dir_bin} COMPONENT netgen)
|
||||
endif(USE_GUI)
|
||||
|
||||
|
@ -7,13 +7,14 @@ endif(APPLE)
|
||||
if(WIN32)
|
||||
add_definitions("-DBUILD_togl -DUNICODE -D_UNICODE -DTOGL_USE_FONTS=0 -DSTDC_HEADERS -DSTDC_HEADER")
|
||||
add_library(togl SHARED togl.c toglProcAddr.c toglStubInit.c)
|
||||
install(TARGETS togl DESTINATION ${ng_install_dir} COMPONENT netgen)
|
||||
install(TARGETS togl DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
|
||||
target_link_libraries(togl ${TCL_LIBRARY} ${TK_LIBRARY})
|
||||
else(WIN32)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fomit-frame-pointer -Wno-implicit-int")
|
||||
add_definitions("-DPACKAGE_NAME=\"Togl\" -DPACKAGE_TARNAME=\"togl\" -DPACKAGE_VERSION=\"2.1\" -DPACKAGE_STRING=\"Togl\ 2.1\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=0 -DHAVE_LIMITS_H=1 -DHAVE_SYS_PARAM_H=1 -DUSE_THREAD_ALLOC=1 -D_REENTRANT=1 -D_THREAD_SAFE=1 -DTCL_THREADS=1 -DMODULE_SCOPE=extern\ __attribute__\(\(__visibility__\(\"hidden\"\)\)\) -D_LARGEFILE64_SOURCE=1 -DTCL_WIDE_INT_IS_LONG=1 -DUSE_TCL_STUBS=1 -DUSE_TK_STUBS=1 -DAUTOSTEREOD=\"\"")
|
||||
|
||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tcl-private/generic" "${TCL_INCLUDE_PATH}/tcl-private/unix")
|
||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tk-private/generic" "${TCL_INCLUDE_PATH}/tk-private/unix")
|
||||
include_directories(BEFORE "${TK_INCLUDE_PATH}/tk-private/generic" "${TK_INCLUDE_PATH}/tk-private/unix" "${TK_INCLUDE_PATH}/tk-private")
|
||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}/tk-private/generic/ttk")
|
||||
include_directories(BEFORE "${TK_INCLUDE_PATH}/../PrivateHeaders")
|
||||
include_directories(BEFORE "${TCL_INCLUDE_PATH}")
|
||||
@ -23,5 +24,5 @@ else(WIN32)
|
||||
target_link_libraries(togl -ldl)
|
||||
endif(WIN32)
|
||||
|
||||
target_link_libraries(togl ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} )
|
||||
target_link_libraries(togl ${OPENGL_LIBRARIES})
|
||||
set_target_properties(togl PROPERTIES POSITION_INDEPENDENT_CODE ON )
|
||||
|
@ -165,11 +165,12 @@
|
||||
# endif
|
||||
#endif /* TOGL_AGL */
|
||||
|
||||
#if defined(TOGL_NSOPENGL)
|
||||
# if TK_MAJOR_VERSION < 8 || (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 6)
|
||||
# error Sorry Mac Cocoa version requires Tcl/Tk ver 8.6.0 or higher.
|
||||
# endif
|
||||
#endif /* TOGL_NSOPENGL */
|
||||
// Seems to work with Apple Tcl 8.5 too....
|
||||
// #if defined(TOGL_NSOPENGL)
|
||||
// # if TK_MAJOR_VERSION < 8 || (TK_MAJOR_VERSION == 8 && TK_MINOR_VERSION < 6)
|
||||
// # error Sorry Mac Cocoa version requires Tcl/Tk ver 8.6.0 or higher.
|
||||
// # endif
|
||||
// #endif /* TOGL_NSOPENGL */
|
||||
|
||||
#if defined(TOGL_WGL) && defined(_MSC_VER)
|
||||
# define snprintf _snprintf
|
||||
|
41
ng/gui.cpp
Normal file
41
ng/gui.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
#include <mystdlib.h>
|
||||
#include <inctcl.hpp>
|
||||
#include <meshing.hpp>
|
||||
|
||||
#ifdef WIN32
|
||||
#define DLL_HEADER_IMPORT __declspec(dllimport)
|
||||
#define DLL_HEADER_EXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DLL_HEADER_IMPORT
|
||||
#define DLL_HEADER_EXPORT
|
||||
#endif
|
||||
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
DLL_HEADER_EXPORT Flags parameters;
|
||||
}
|
||||
|
||||
DLL_HEADER_EXPORT bool nodisplay = false;
|
||||
|
||||
extern "C" int Ng_Init (Tcl_Interp * interp);
|
||||
extern "C" int Ng_Vis_Init (Tcl_Interp * interp);
|
||||
extern "C" void Ng_TclCmd(string);
|
||||
|
||||
// tcl package dynamic load
|
||||
extern "C" int DLL_HEADER_EXPORT Gui_Init (Tcl_Interp * interp)
|
||||
{
|
||||
if (Ng_Init(interp) == TCL_ERROR) {
|
||||
cerr << "Problem in Ng_Init: " << endl;
|
||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (!nodisplay && Ng_Vis_Init(interp) == TCL_ERROR) {
|
||||
cerr << "Problem in Ng_Vis_Init: " << endl;
|
||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
@ -352,7 +352,7 @@ proc demoredraw { } {
|
||||
set file [tk_getSaveFile -filetypes $types]
|
||||
# -defaultextension ".ppm"]
|
||||
if {$file != ""} {
|
||||
.ndraw Ng_SnapShot $file }
|
||||
Ng_SnapShot .ndraw $file }
|
||||
}
|
||||
|
||||
|
||||
@ -421,6 +421,7 @@ set videoactive 0
|
||||
# puts "error: $result"
|
||||
}
|
||||
|
||||
after cancel { timer2 }
|
||||
Ng_Exit;
|
||||
destroy .
|
||||
}
|
||||
|
@ -17,6 +17,9 @@ void DLL_HEADER ExportCSGVis(py::module &m);
|
||||
void DLL_HEADER ExportGeom2d(py::module &m);
|
||||
void DLL_HEADER ExportSTL(py::module &m);
|
||||
void DLL_HEADER ExportSTLVis(py::module &m);
|
||||
#ifdef OCCGEOMETRY
|
||||
void DLL_HEADER ExportNgOCC(py::module &m);
|
||||
#endif // OCCGEOMETRY
|
||||
|
||||
PYBIND11_PLUGIN(libngpy)
|
||||
{
|
||||
@ -29,6 +32,10 @@ PYBIND11_PLUGIN(libngpy)
|
||||
ExportGeom2d(geom2d);
|
||||
py::module stl = ngpy.def_submodule("_stl", "pybind stl module");
|
||||
ExportSTL(stl);
|
||||
#ifdef OCCGEOMETRY
|
||||
py::module NgOCC = ngpy.def_submodule("_NgOCC", "pybind NgOCC module");
|
||||
ExportNgOCC(NgOCC);
|
||||
#endif // OCCGEOMETRY
|
||||
#ifdef OPENGL
|
||||
py::module meshvis = ngpy.def_submodule("meshvis", "pybind meshvis module");
|
||||
ExportMeshVis(meshvis);
|
||||
|
22
ng/ng.tcl
22
ng/ng.tcl
@ -1,4 +1,9 @@
|
||||
catch {lappend auto_path $env(NETGENDIR) }
|
||||
catch {lappend auto_path $env(NETGENDIR)/../lib }
|
||||
|
||||
if {[catch {Ng_GetCommandLineParameter batchmode} result ]} {
|
||||
load libgui[info sharedlibextension] gui
|
||||
}
|
||||
|
||||
set batchmode [Ng_GetCommandLineParameter batchmode]
|
||||
if {$batchmode=="undefined"} {
|
||||
@ -264,7 +269,22 @@ if { $stereo == "defined" } {
|
||||
}
|
||||
|
||||
|
||||
catch { source ${ngdir}/ngsolve.tcl }
|
||||
set ngsolve_loaded 0
|
||||
catch {
|
||||
source ${ngdir}/ngsolve.tcl;
|
||||
set ngsolve_loaded 1
|
||||
}
|
||||
|
||||
# try to find ngsolve.tcl in PATH
|
||||
set pathlist [split $::env(PATH) \ [expr {$::tcl_platform(platform) == "windows" ? ";" : ":"}]]
|
||||
foreach dir $pathlist {
|
||||
if { $ngsolve_loaded != 1 } {
|
||||
catch {
|
||||
source ${dir}/ngsolve.tcl
|
||||
set ngsolve_loaded 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
set scriptfilename [Ng_GetCommandLineParameter script]
|
||||
|
@ -7,17 +7,6 @@
|
||||
#include <inctcl.hpp>
|
||||
#include <meshing.hpp>
|
||||
|
||||
#ifdef NGPYTHON
|
||||
#include <boost/python.hpp>
|
||||
#endif
|
||||
|
||||
/*
|
||||
namespace netgen
|
||||
{
|
||||
int id = 0, ntasks = 1;
|
||||
}
|
||||
*/
|
||||
|
||||
#ifdef PARALLEL
|
||||
#include <mpi.h>
|
||||
|
||||
@ -33,9 +22,11 @@ namespace netgen
|
||||
|
||||
namespace netgen
|
||||
{
|
||||
Flags parameters;
|
||||
DLL_HEADER extern Flags parameters;
|
||||
DLL_HEADER extern bool netgen_executable_started;
|
||||
}
|
||||
|
||||
DLL_HEADER extern bool nodisplay;
|
||||
|
||||
|
||||
using netgen::parameters;
|
||||
@ -58,7 +49,6 @@ using netgen::RegisterUserFormats;
|
||||
extern "C" int Ng_ServerSocketManagerInit (int port);
|
||||
extern "C" int Ng_ServerSocketManagerRun (void);
|
||||
|
||||
bool nodisplay = false;
|
||||
bool shellmode = false;
|
||||
|
||||
|
||||
@ -70,6 +60,7 @@ bool shellmode = false;
|
||||
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
netgen::netgen_executable_started = true;
|
||||
|
||||
#ifdef PARALLEL
|
||||
int mpi_required = MPI_THREAD_MULTIPLE;
|
||||
@ -200,7 +191,7 @@ int main(int argc, char ** argv)
|
||||
// parse tcl-script
|
||||
int errcode;
|
||||
|
||||
bool internaltcl = false;
|
||||
bool internaltcl = INTERNAL_TCL_DEFAULT;
|
||||
if (shellmode)
|
||||
internaltcl = false;
|
||||
|
||||
@ -348,26 +339,6 @@ int Tcl_AppInit(Tcl_Interp * interp)
|
||||
// return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
if (Ng_Init(interp) == TCL_ERROR) {
|
||||
cerr << "Problem in Ng_Init: " << endl;
|
||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||
// cerr << interp->result << endl;
|
||||
// return TCL_ERROR;
|
||||
}
|
||||
|
||||
if (!nodisplay && Ng_Vis_Init(interp) == TCL_ERROR) {
|
||||
cerr << "Problem in Ng_Vis_Init: " << endl;
|
||||
cout << "result = " << Tcl_GetStringResult (interp) << endl;
|
||||
// cerr << interp->result << endl;
|
||||
// return TCL_ERROR;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef TRAFO
|
||||
// extern int Trafo_Init (Tcl_Interp * interp);
|
||||
// if (Trafo_Init(interp) == TCL_ERROR)
|
||||
@ -427,21 +398,3 @@ int Tcl_AppInit(Tcl_Interp * interp)
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// link MKL with netgen
|
||||
// necessary for MKL 11.x, since MKL complains if started
|
||||
// from the ngsolve shared library
|
||||
|
||||
#ifdef LINKMKL
|
||||
extern "C" double ddot_(int *n, double *dx, int *incx, double *dy,
|
||||
int *incy);
|
||||
void mkldummy()
|
||||
{
|
||||
int n = 1, one = 1;
|
||||
double a = 1, b = 1;
|
||||
ddot_(&n, &a, &one, &b, &one);
|
||||
}
|
||||
#endif
|
||||
|
146
ng/ngpkg.cpp
146
ng/ngpkg.cpp
@ -1994,91 +1994,26 @@ namespace netgen
|
||||
}
|
||||
|
||||
|
||||
#if TOGL_MAJOR_VERSION==1
|
||||
|
||||
#ifndef JPEGLIB
|
||||
static int Ng_SnapShot (struct Togl * togl,
|
||||
int argc, tcl_const char *argv[])
|
||||
static int Ng_SnapShot(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
|
||||
{
|
||||
const char * filename = argv[2];
|
||||
struct Togl *togl;
|
||||
if (Togl_GetToglFromObj(interp, argv[1], &togl) != TCL_OK)
|
||||
return TCL_ERROR;
|
||||
const char * filename = Tcl_GetString(argv[2]);
|
||||
|
||||
char str[250];
|
||||
char filename2[250];
|
||||
int len = strlen(filename);
|
||||
strcpy (filename2, filename);
|
||||
|
||||
filename2[len-3] = 'p';
|
||||
filename2[len-2] = 'p';
|
||||
filename2[len-1] = 'm';
|
||||
filename2[len] = 0;
|
||||
|
||||
cout << "Snapshot to file '" << filename << endl;
|
||||
|
||||
int w = Togl_Width (togl);
|
||||
w = int((w + 1) / 4) * 4 + 4;
|
||||
int h = Togl_Height (togl);
|
||||
|
||||
// unsigned char * buffer = new unsigned char[w*h*4];
|
||||
unsigned char * buffer = new unsigned char[w*h*3];
|
||||
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
ofstream outfile(filename2);
|
||||
outfile << "P6" << endl
|
||||
<< "# CREATOR: Netgen" << endl
|
||||
<< w << " " << h << endl
|
||||
<< "255" << endl;
|
||||
for (int i = 0; i < h; i++)
|
||||
for (int j = 0; j < w; j++)
|
||||
for (int k = 0; k < 3; k++)
|
||||
outfile.put (buffer[k+3*j+3*w*(h-i-1)]);
|
||||
outfile << flush;
|
||||
|
||||
delete[] buffer;
|
||||
|
||||
// convert image file (Unix/Linux only):
|
||||
sprintf(str,"convert -quality 100 %s %s", filename2, filename);
|
||||
|
||||
int err = system(str);
|
||||
if (err != 0)
|
||||
{
|
||||
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot convert image file", TCL_VOLATILE);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
sprintf(str,"rm %s", filename2);
|
||||
|
||||
err = system(str);
|
||||
if (err != 0)
|
||||
{
|
||||
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot delete temporary file", TCL_VOLATILE);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
return TCL_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else
|
||||
|
||||
|
||||
static int Ng_SnapShot (struct Togl * togl,
|
||||
int argc, tcl_const char *argv[])
|
||||
{
|
||||
const char * filename = argv[2];
|
||||
int len = strlen(filename);
|
||||
Array<char> buffer(w*h*3);
|
||||
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, &buffer[0]);
|
||||
|
||||
#ifdef JPEGLIB
|
||||
if (strcmp ("jpg", filename+len-3) == 0)
|
||||
{
|
||||
cout << "Snapshot to file '" << filename << "'" << endl;
|
||||
|
||||
int w = Togl_Width (togl);
|
||||
// w = int((w + 1) / 4) * 4 + 4;
|
||||
int h = Togl_Height (togl);
|
||||
|
||||
// unsigned char * buffer = new unsigned char[w*h*4];
|
||||
unsigned char * buffer = new unsigned char[w*h*3];
|
||||
glReadPixels (0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, buffer);
|
||||
|
||||
struct jpeg_compress_struct cinfo;
|
||||
struct jpeg_error_mgr jerr;
|
||||
FILE *outfile = fopen(filename,"wb");
|
||||
@ -2112,10 +2047,57 @@ namespace netgen
|
||||
fprintf( stdout, "done [ok]\n" );
|
||||
fflush( stdout );
|
||||
|
||||
free( buffer );
|
||||
return TCL_OK;
|
||||
}
|
||||
else
|
||||
#endif // JPEGLIB
|
||||
{
|
||||
char str[250];
|
||||
char filename2[250];
|
||||
int len = strlen(filename);
|
||||
strcpy (filename2, filename);
|
||||
|
||||
filename2[len-3] = 'p';
|
||||
filename2[len-2] = 'p';
|
||||
filename2[len-1] = 'm';
|
||||
filename2[len] = 0;
|
||||
|
||||
cout << "Snapshot to file '" << filename << endl;
|
||||
|
||||
int w = Togl_Width (togl);
|
||||
w = int((w + 1) / 4) * 4 + 4;
|
||||
int h = Togl_Height (togl);
|
||||
|
||||
ofstream outfile(filename2);
|
||||
outfile << "P6" << endl
|
||||
<< "# CREATOR: Netgen" << endl
|
||||
<< w << " " << h << endl
|
||||
<< "255" << endl;
|
||||
for (int i = 0; i < h; i++)
|
||||
for (int j = 0; j < w; j++)
|
||||
for (int k = 0; k < 3; k++)
|
||||
outfile.put (buffer[k+3*j+3*w*(h-i-1)]);
|
||||
outfile << flush;
|
||||
|
||||
// convert image file (Unix/Linux only):
|
||||
sprintf(str,"convert -quality 100 %s %s", filename2, filename);
|
||||
|
||||
int err = system(str);
|
||||
if (err != 0)
|
||||
{
|
||||
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot convert image file", TCL_VOLATILE);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
sprintf(str,"rm %s", filename2);
|
||||
|
||||
err = system(str);
|
||||
if (err != 0)
|
||||
{
|
||||
Tcl_SetResult (Togl_Interp(togl), (char*)"Cannot delete temporary file", TCL_VOLATILE);
|
||||
return TCL_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
{
|
||||
cout << "Snapshot to " << filename << " not supported" << endl;
|
||||
return TCL_ERROR;
|
||||
@ -2123,18 +2105,6 @@ namespace netgen
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
|
||||
// TODO: JPEGLIB for Togl2
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
#ifdef FFMPEG
|
||||
static int Ng_VideoClip(ClientData clientData, Tcl_Interp *interp, int argc, Tcl_Obj *const *argv)
|
||||
@ -3083,7 +3053,7 @@ void PlayAnimFile(const char* name, int speed, int maxcnt)
|
||||
Tcl_CreateObjCommand(interp, "reshape", reshape, NULL, NULL);
|
||||
|
||||
// Togl_TimerFunc( idle );
|
||||
// Togl_CreateCommand( (char*)"Ng_SnapShot", Ng_SnapShot);
|
||||
Tcl_CreateObjCommand(interp, "Ng_SnapShot", Ng_SnapShot, NULL, NULL);
|
||||
Tcl_CreateObjCommand(interp, "Ng_VideoClip", Ng_VideoClip, NULL, NULL);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
const char * ngscript[] = {""
|
||||
,"catch {lappend auto_path $env(NETGENDIR) }\n"
|
||||
,"catch {lappend auto_path $env(NETGENDIR)/../lib }\n"
|
||||
,"if {[catch {Ng_GetCommandLineParameter batchmode} result ]} {\n"
|
||||
,"load libgui[info sharedlibextension] gui\n"
|
||||
,"}\n"
|
||||
,"set batchmode [Ng_GetCommandLineParameter batchmode]\n"
|
||||
,"if {$batchmode==\"undefined\"} {\n"
|
||||
,"if {[catch {package require tkdnd } result ]} {\n"
|
||||
@ -922,7 +926,7 @@ const char * ngscript[] = {""
|
||||
,"global videoactive\n"
|
||||
,"if { $videoactive == 1 } {\n"
|
||||
,"puts \"addframe\"\n"
|
||||
,".ndraw Ng_VideoClip addframe\n"
|
||||
,"Ng_VideoClip .ndraw addframe\n"
|
||||
,"}\n"
|
||||
,"if { $result == 0 && $stopdemo == 0 } {\n"
|
||||
,"after 1 { demoredraw }\n"
|
||||
@ -949,7 +953,7 @@ const char * ngscript[] = {""
|
||||
,"}\n"
|
||||
,"set file [tk_getSaveFile -filetypes $types]\n"
|
||||
,"if {$file != \"\"} {\n"
|
||||
,".ndraw Ng_SnapShot $file }\n"
|
||||
,"Ng_SnapShot .ndraw $file }\n"
|
||||
,"}\n"
|
||||
,".ngmenu.file add cascade -label \"Video clip\" -menu .ngmenu.file.video\n"
|
||||
,"menu .ngmenu.file.video\n"
|
||||
@ -961,13 +965,13 @@ const char * ngscript[] = {""
|
||||
,"}\n"
|
||||
,"set file [tk_getSaveFile -filetypes $types]\n"
|
||||
,"if {$file != \"\"} {\n"
|
||||
,".ndraw Ng_VideoClip init $file\n"
|
||||
,"Ng_VideoClip .ndraw init $file\n"
|
||||
,"global videoactive\n"
|
||||
,"set videoactive 1\n"
|
||||
,"}\n"
|
||||
,"}\n"
|
||||
,".ngmenu.file.video add command -label \"add frame...\" \\\n"
|
||||
,"-command {.ndraw Ng_VideoClip addframe }\n"
|
||||
,"-command {Ng_VideoClip .ndraw addframe }\n"
|
||||
,".ngmenu.file.video add command -label \"one cycle\" \\\n"
|
||||
,"-command {\n"
|
||||
,"set visoptions.redrawperiodic 1\n"
|
||||
@ -975,13 +979,13 @@ const char * ngscript[] = {""
|
||||
,"puts \"j = $j\"\n"
|
||||
,"Ng_Vis_Set time [expr (1000 * $j / 100)]\n"
|
||||
,"redraw\n"
|
||||
,".ndraw Ng_VideoClip addframe\n"
|
||||
,"Ng_VideoClip .ndraw addframe\n"
|
||||
,"after 200\n"
|
||||
,"}\n"
|
||||
,"}\n"
|
||||
,".ngmenu.file.video add command -label \"finalize...\" \\\n"
|
||||
,"-command {\n"
|
||||
,".ndraw Ng_VideoClip finalize\n"
|
||||
,"Ng_VideoClip .ndraw finalize\n"
|
||||
,"global videoactive\n"
|
||||
,"set videoactive 0\n"
|
||||
,"}\n"
|
||||
@ -993,6 +997,7 @@ const char * ngscript[] = {""
|
||||
,"puts \"Thank you for using $progname\";\n"
|
||||
,"if { [catch { unload libngsolve[info sharedlibextension] ngsolve } result ] } {\n"
|
||||
,"}\n"
|
||||
,"after cancel { timer2 }\n"
|
||||
,"Ng_Exit;\n"
|
||||
,"destroy .\n"
|
||||
,"}\n"
|
||||
@ -1336,7 +1341,7 @@ const char * ngscript[] = {""
|
||||
,"global videoactive\n"
|
||||
,"if { $videoactive == 1 } {\n"
|
||||
,"puts \"addframe\"\n"
|
||||
,".ndraw Ng_VideoClip addframe\n"
|
||||
,"Ng_VideoClip .ndraw addframe\n"
|
||||
,"}\n"
|
||||
,"}\n"
|
||||
,"if { $multithread_redraw == 2 } {\n"
|
||||
@ -1345,7 +1350,7 @@ const char * ngscript[] = {""
|
||||
,"global videoactive\n"
|
||||
,"if { $videoactive == 1 } {\n"
|
||||
,"puts \"addframe\"\n"
|
||||
,".ndraw Ng_VideoClip addframe\n"
|
||||
,"Ng_VideoClip .ndraw addframe\n"
|
||||
,"}\n"
|
||||
,"after 1 { timer2 }\n"
|
||||
,"return\n"
|
||||
@ -2535,10 +2540,10 @@ const char * ngscript[] = {""
|
||||
,"wm deiconify $w\n"
|
||||
,"} {\n"
|
||||
,"toplevel $w\n"
|
||||
,"frame $w.face -borderwidth 3\n"
|
||||
,"ttk::frame $w.face -borderwidth 3\n"
|
||||
,"pack $w.face -fill x\n"
|
||||
,"ttk::label $w.face.lab -text \"face index:\"\n"
|
||||
,"ttk::label $w.face.ent -text 1 -padx 4\n"
|
||||
,"ttk::label $w.face.ent -text 1\n"
|
||||
,"ttk::button $w.face.next -text \"next\" -command {\n"
|
||||
,"set w .bcprop_dlg;\n"
|
||||
,"set facenr [$w.face.ent cget -text]\n"
|
||||
@ -2570,7 +2575,7 @@ const char * ngscript[] = {""
|
||||
,"redraw\n"
|
||||
,"}\n"
|
||||
,"pack $w.face.lab $w.face.ent $w.face.prev $w.face.next -side left\n"
|
||||
,"frame $w.bc -borderwidth 3\n"
|
||||
,"ttk::frame $w.bc -borderwidth 3\n"
|
||||
,"pack $w.bc -fill x\n"
|
||||
,"ttk::label $w.bc.lab -text \"bc property:\"\n"
|
||||
,"entry $w.bc.ent -width 5 -relief sunken\n"
|
||||
@ -2583,12 +2588,12 @@ const char * ngscript[] = {""
|
||||
,"Ng_BCProp setall [$w.bc.ent get];\n"
|
||||
,"}\n"
|
||||
,"pack $w.bc.lab $w.bc.ent $w.bc.but $w.bc.but2 -side left -expand yes\n"
|
||||
,"frame $w.bcname -borderwidth 3\n"
|
||||
,"ttk::frame $w.bcname -borderwidth 3\n"
|
||||
,"pack $w.bcname -fill x\n"
|
||||
,"ttk::label $w.bcname.lab -text \"bc name:\"\n"
|
||||
,"ttk::label $w.bcname.ent -text \"-\"\n"
|
||||
,"pack $w.bcname.lab $w.bcname.ent -side left -expand yes\n"
|
||||
,"frame $w.bu\n"
|
||||
,"ttk::frame $w.bu\n"
|
||||
,"pack $w.bu -fill x -ipady 3\n"
|
||||
,"ttk::button $w.bu.close -text \"Close\" -command { destroy .bcprop_dlg }\n"
|
||||
,"pack $w.bu.close -expand yes -side left\n"
|
||||
@ -5943,7 +5948,20 @@ const char * ngscript[] = {""
|
||||
,"Ng_SetVisParameters;\n"
|
||||
,"redraw\n"
|
||||
,"}\n"
|
||||
,"catch { source ${ngdir}/ngsolve.tcl }\n"
|
||||
,"set ngsolve_loaded 0\n"
|
||||
,"catch {\n"
|
||||
,"source ${ngdir}/ngsolve.tcl;\n"
|
||||
,"set ngsolve_loaded 1\n"
|
||||
,"}\n"
|
||||
,"set pathlist [split $::env(PATH) \\ [expr {$::tcl_platform(platform) == \"windows\" ? \";\" : \":\"}]]\n"
|
||||
,"foreach dir $pathlist {\n"
|
||||
,"if { $ngsolve_loaded != 1 } {\n"
|
||||
,"catch {\n"
|
||||
,"source ${dir}/ngsolve.tcl\n"
|
||||
,"set ngsolve_loaded 1\n"
|
||||
,"}\n"
|
||||
,"}\n"
|
||||
,"}\n"
|
||||
,"set scriptfilename [Ng_GetCommandLineParameter script]\n"
|
||||
,"if { $scriptfilename != \"undefined\" } {\n"
|
||||
,"if { [catch { source $scriptfilename } errstring] == 1 } {\n"
|
||||
@ -5968,4 +5986,5 @@ const char * ngscript[] = {""
|
||||
,"source startup.tcl }\n"
|
||||
,"catch { source ${ngdir}/demoapp.tcl }\n"
|
||||
,"catch { source ${ngdir}/dropsexp.tcl }\n"
|
||||
, nullptr
|
||||
};
|
||||
|
@ -40,5 +40,6 @@ for line in tclfiles["ng.tcl"].split('\n'):
|
||||
s = ',"' + line.replace('\\', r'\\').replace('"', r'\"') + '\\n"\n'
|
||||
onetclcpp.write(s)
|
||||
|
||||
onetclcpp.write('};'+'\n');
|
||||
onetclcpp.write(', nullptr\n');
|
||||
onetclcpp.write('};\n');
|
||||
onetclcpp.close();
|
||||
|
@ -28,7 +28,7 @@ if(NOT WIN32)
|
||||
endif(USE_GUI)
|
||||
endif(NOT WIN32)
|
||||
|
||||
target_link_libraries( nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${TK_LIBRARY} ${TCL_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} )
|
||||
target_link_libraries( nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} ${OPENGL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ${X11_Xmu_LIB} ${JPEG_LIBRARIES} ${MKL_LIBRARIES} ${ZLIB_LIBRARIES} ${OCC_LIBRARIES} )
|
||||
|
||||
if(USE_OCC AND NOT WIN32)
|
||||
target_link_libraries(nglib occ)
|
||||
@ -38,16 +38,5 @@ if(USE_PYTHON)
|
||||
target_link_libraries(nglib ${PYTHON_LIBRARIES})
|
||||
endif(USE_PYTHON)
|
||||
|
||||
# if(NOT WIN32)
|
||||
# add_executable(ng_vol ng_vol.cpp ${nglib_objects})
|
||||
# target_link_libraries( ng_vol nglib ${OCC_LIBRARIES} ${MPI_CXX_LIBRARIES} )
|
||||
# target_link_libraries( ng_vol nglib interface geom2d csg stl occ mesh )
|
||||
#
|
||||
# add_executable(ng_stl ng_stl.cpp ${nglib_objects})
|
||||
# target_link_libraries( ng_stl nglib ${OCC_LIBRARIES} ${OCC_OCAF_LIBRARIES} ${MPI_CXX_LIBRARIES} )
|
||||
# target_link_libraries( ng_stl nglib interface geom2d csg stl occ mesh )
|
||||
#
|
||||
# install(TARGETS nglib ng_vol ng_stl ${ng_install_dir})
|
||||
# endif(NOT WIN32)
|
||||
|
||||
install(TARGETS nglib ${ng_install_dir})
|
||||
install(TARGETS nglib ${NG_INSTALL_DIR})
|
||||
install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel)
|
||||
|
@ -1,5 +1,5 @@
|
||||
install( FILES
|
||||
shaft.geo mesh.py exportNeutral.py
|
||||
DESTINATION share/netgen/py_tutorials
|
||||
DESTINATION ${NG_INSTALL_DIR_RES}/${NG_INSTALL_SUFFIX}/py_tutorials
|
||||
COMPONENT netgen_tutorial
|
||||
)
|
||||
|
@ -17,8 +17,8 @@ def Export (mesh, filename):
|
||||
print (len(volels), file=f)
|
||||
for el in volels:
|
||||
print (el.index, end=" ", file=f)
|
||||
for j in el.vertices:
|
||||
print (j.nr, end=" ", file=f)
|
||||
for p in el.points:
|
||||
print (p.nr, end=" ", file=f)
|
||||
print(file=f)
|
||||
|
||||
|
||||
|
@ -3,28 +3,35 @@ from netgen.csg import *
|
||||
|
||||
from ngsolve import ngsglobals
|
||||
ngsglobals.msg_level = 2
|
||||
|
||||
# generate brick and mesh it
|
||||
geo1 = CSGeometry()
|
||||
geo1.Add (OrthoBrick( Pnt(0,0,0), Pnt(1,1,1) ))
|
||||
m1 = geo1.GenerateMesh (maxh=0.1)
|
||||
m1.Refine()
|
||||
m1.Refine()
|
||||
|
||||
|
||||
# generate sphere and mesh it
|
||||
geo2 = CSGeometry()
|
||||
geo2.Add (Sphere (Pnt(0.5,0.5,0.5), 0.1))
|
||||
m2 = geo2.GenerateMesh (maxh=0.05)
|
||||
m2.Refine()
|
||||
m2.Refine()
|
||||
|
||||
print ("********************")
|
||||
print ("** start merging **")
|
||||
print ("********************")
|
||||
print ("***************************")
|
||||
print ("** merging suface meshes **")
|
||||
print ("***************************")
|
||||
|
||||
# create an empty mesh
|
||||
mesh = Mesh()
|
||||
fd_outside = mesh.Add (FaceDescriptor(surfnr=1,domin=1))
|
||||
fd_inside = mesh.Add (FaceDescriptor(surfnr=2,domin=2,domout=1))
|
||||
|
||||
# a face-descriptor stores properties associated with a set of surface elements
|
||||
# bc .. boundary condition marker,
|
||||
# domin/domout .. domain-number in front/back of surface elements (0 = void),
|
||||
# surfnr .. number of the surface described by the face-descriptor
|
||||
|
||||
fd_outside = mesh.Add (FaceDescriptor(bc=1,domin=1,surfnr=1))
|
||||
fd_inside = mesh.Add (FaceDescriptor(bc=2,domin=2,domout=1,surfnr=2))
|
||||
# copy all boundary points from first mesh to new mesh.
|
||||
# pmap1 maps point-numbers from old to new mesh
|
||||
|
||||
pmap1 = { }
|
||||
for e in m1.Elements2D():
|
||||
@ -32,11 +39,17 @@ for e in m1.Elements2D():
|
||||
if (v not in pmap1):
|
||||
pmap1[v] = mesh.Add (m1[v])
|
||||
|
||||
|
||||
# copy surface elements from first mesh to new mesh
|
||||
# we have to map point-numbers:
|
||||
|
||||
for e in m1.Elements2D():
|
||||
mesh.Add (Element2D (fd_outside, [pmap1[v] for v in e.vertices]))
|
||||
|
||||
|
||||
|
||||
# same for the second mesh:
|
||||
|
||||
pmap2 = { }
|
||||
for e in m2.Elements2D():
|
||||
for v in e.vertices:
|
||||
|
@ -8,7 +8,7 @@ param.maxh = 10
|
||||
print (param)
|
||||
|
||||
m1 = GenerateMesh (geo, param)
|
||||
|
||||
m1.SecondOrder()
|
||||
|
||||
import exportNeutral
|
||||
exportNeutral.Export (m1, "shaft.mesh")
|
||||
@ -16,3 +16,4 @@ exportNeutral.Export (m1, "shaft.mesh")
|
||||
|
||||
|
||||
Save (m1, "mesh.vol", geo)
|
||||
|
||||
|
@ -1,5 +1,8 @@
|
||||
install(FILES __init__.py meshing.py csg.py geom2d.py stl.py
|
||||
DESTINATION ${PYTHON_PACKAGES_INSTALL_DIR}/netgen
|
||||
configure_file(__init__.py ${CMAKE_CURRENT_BINARY_DIR}/__init__.py @ONLY)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/__init__.py
|
||||
meshing.py csg.py geom2d.py stl.py gui.py NgOCC.py
|
||||
DESTINATION ${NG_INSTALL_DIR_PYTHON}/${NG_INSTALL_SUFFIX}
|
||||
COMPONENT netgen
|
||||
)
|
||||
|
||||
|
11
python/NgOCC.py
Normal file
11
python/NgOCC.py
Normal file
@ -0,0 +1,11 @@
|
||||
import libngpy
|
||||
from libngpy._NgOCC import *
|
||||
from libngpy._meshing import MeshingParameters
|
||||
|
||||
def NgOCC_meshing_func (geom, **args):
|
||||
if "mp" in args:
|
||||
return GenerateMesh (geom, args["mp"])
|
||||
else:
|
||||
return GenerateMesh (geom, MeshingParameters (**args))
|
||||
|
||||
OCCGeometry.GenerateMesh = NgOCC_meshing_func
|
@ -1,13 +1,13 @@
|
||||
import os
|
||||
from sys import path
|
||||
from sys import platform as __platform
|
||||
import sys
|
||||
|
||||
if __platform.startswith('linux'):
|
||||
path.append(os.path.dirname(__file__) + '/../../..')
|
||||
if __platform.startswith('win'):
|
||||
path.append(os.path.dirname(__file__) + '/../../../bin')
|
||||
if __platform.startswith('darwin'):
|
||||
path.append(os.path.dirname(__file__) + '/../../../../../MacOS')
|
||||
_netgen_bin_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..','@NETGEN_PYTHON_RPATH_BIN@'))
|
||||
_netgen_lib_dir=os.path.realpath(os.path.join(os.path.dirname(__file__),'..','@NETGEN_PYTHON_RPATH@'))
|
||||
|
||||
import libngpy
|
||||
del path
|
||||
if sys.platform.startswith('win'):
|
||||
os.environ['PATH'] += ';'+os.path.realpath(os.path.join(os.path.dirname(__file__),'../../../bin'))
|
||||
|
||||
del sys
|
||||
del os
|
||||
|
||||
from . import libngpy
|
||||
|
@ -1,8 +1,7 @@
|
||||
import libngpy
|
||||
from libngpy._csg import *
|
||||
from libngpy._meshing import MeshingParameters
|
||||
from libngpy._meshing import Pnt
|
||||
from libngpy._meshing import Vec
|
||||
from netgen.libngpy._csg import *
|
||||
from netgen.libngpy._meshing import MeshingParameters
|
||||
from netgen.libngpy._meshing import Pnt
|
||||
from netgen.libngpy._meshing import Vec
|
||||
|
||||
|
||||
try:
|
||||
|
@ -1,5 +1,5 @@
|
||||
from libngpy._geom2d import *
|
||||
from libngpy._meshing import *
|
||||
from netgen.libngpy._geom2d import *
|
||||
from netgen.libngpy._meshing import *
|
||||
|
||||
tmp_generate_mesh = SplineGeometry.GenerateMesh
|
||||
|
||||
|
15
python/gui.py
Normal file
15
python/gui.py
Normal file
@ -0,0 +1,15 @@
|
||||
import netgen
|
||||
|
||||
def StartGUI():
|
||||
from tkinter import Tk
|
||||
|
||||
global win
|
||||
win = Tk()
|
||||
win.tk.eval('lappend ::auto_path ' + netgen._netgen_lib_dir)
|
||||
win.tk.eval('lappend ::auto_path ' + netgen._netgen_bin_dir)
|
||||
# load with absolute path to avoid issues on MacOS
|
||||
win.tk.eval('load '+netgen._netgen_lib_dir.replace('\\','/')+'/libgui[info sharedlibextension] gui')
|
||||
win.tk.eval( netgen.libngpy._meshing._ngscript)
|
||||
|
||||
if not netgen.libngpy._meshing._netgen_executable_started:
|
||||
StartGUI()
|
@ -1 +1 @@
|
||||
from libngpy._meshing import *
|
||||
from netgen.libngpy._meshing import *
|
||||
|
@ -1,6 +1,5 @@
|
||||
import libngpy
|
||||
from libngpy._stl import *
|
||||
from libngpy._meshing import MeshingParameters
|
||||
from netgen.libngpy._stl import *
|
||||
from netgen.libngpy._meshing import MeshingParameters
|
||||
|
||||
|
||||
def stl_meshing_func (geom, **args):
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM ubuntu:15.10
|
||||
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
|
||||
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy
|
||||
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk
|
||||
ADD . /root/src/netgen
|
||||
|
@ -1,4 +1,4 @@
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER Matthias Hochsteger <matthias.hochsteger@tuwien.ac.at>
|
||||
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy
|
||||
RUN apt-get update && apt-get -y install python3 libpython3-dev libxmu-dev tk-dev tcl-dev cmake git g++ libglu1-mesa-dev ccache python3-pytest python3-numpy python3-tk
|
||||
ADD . /root/src/netgen
|
||||
|
11
tests/pytest/test_gui.py
Normal file
11
tests/pytest/test_gui.py
Normal file
@ -0,0 +1,11 @@
|
||||
import netgen
|
||||
import pytest
|
||||
|
||||
def test_gui():
|
||||
try:
|
||||
from tkinter import Tk
|
||||
win = Tk()
|
||||
except:
|
||||
pytest.skip("can't create a window")
|
||||
import netgen.gui
|
||||
|
@ -7,6 +7,6 @@ install( FILES
|
||||
twobricks.geo twocubes.geo twocyl.geo boundarycondition.geo
|
||||
hinge.stl part1.stl frame.step screw.step
|
||||
squarehole.in2d squarecircle.in2d square.in2d
|
||||
DESTINATION share/netgen
|
||||
DESTINATION ${NG_INSTALL_DIR_RES}/${NG_INSTALL_SUFFIX}
|
||||
COMPONENT netgen_tutorial
|
||||
)
|
||||
|
@ -1,3 +0,0 @@
|
||||
# dist_noinst_DATA = netgen.sln netgen.vcproj \
|
||||
# postBuild_netgen.bat nglib.sln nglib.vcproj \
|
||||
# postBuild_nglib.bat netgen.ico netgen.rc
|
Loading…
Reference in New Issue
Block a user