├── .jenkins ├── CMakeLists.txt ├── CONTRIBUTING.md ├── LICENSE ├── PackagesList.cmake ├── README.md ├── TPLsList.cmake ├── Version.cmake ├── cmake ├── .ycm_extra_conf.py.in ├── CodeCompletion.cmake ├── CodeFormat.cmake ├── DataTransferKit_ETIHelperMacros.h.in ├── DataTransferKit_config.hpp.in ├── Dependencies.cmake ├── ETI.cmake ├── ExplicitInstantiationSupport.cmake ├── FindSphinx.cmake ├── RepositoryDependenciesSetup.cmake └── TPLs │ ├── FindTPLArborX.cmake │ ├── FindTPLBoostOrg.cmake │ └── FindTPLTrilinos.cmake ├── docs ├── CMakeLists.txt ├── doxygen │ ├── CMakeLists.txt │ └── Doxyfile.in ├── ext │ └── scope.py └── source │ ├── api.rst │ ├── coding_guidelines.rst │ ├── conf.py │ ├── developer_tools.rst │ ├── index.rst │ ├── install.rst │ ├── overview.rst │ └── requirements.readthedocs.txt ├── packages ├── Benchmarks │ ├── CMakeLists.txt │ └── HybridTransport │ │ ├── CMakeLists.txt │ │ ├── src │ │ ├── CMakeLists.txt │ │ ├── DTK_Benchmark_CartesianMesh.cpp │ │ ├── DTK_Benchmark_CartesianMesh.hpp │ │ ├── DTK_Benchmark_DeterministicMesh.cpp │ │ ├── DTK_Benchmark_DeterministicMesh.hpp │ │ ├── DTK_Benchmark_MonteCarloMesh.cpp │ │ └── DTK_Benchmark_MonteCarloMesh.hpp │ │ └── test │ │ ├── CMakeLists.txt │ │ ├── tstCartesianMesh.cpp │ │ ├── tstDeterministicMesh.cpp │ │ ├── tstMonteCarloMesh.cpp │ │ └── unit_test_main.cpp ├── CMakeLists.txt ├── Discretization │ ├── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ ├── DTK_CellTypes.h │ │ ├── DTK_DiscretizationHelpers.hpp │ │ ├── DTK_ETI_NT.tmpl │ │ ├── DTK_FE.cpp │ │ ├── DTK_FE.hpp │ │ ├── DTK_FETypes.h │ │ ├── DTK_InterpolationFunctor.hpp │ │ ├── DTK_Interpolation_decl.hpp │ │ ├── DTK_Interpolation_def.hpp │ │ ├── DTK_Mesh.hpp │ │ ├── DTK_PointInCellFunctor.hpp │ │ ├── DTK_PointInCell_decl.hpp │ │ ├── DTK_PointInCell_def.hpp │ │ ├── DTK_PointSearch_decl.hpp │ │ ├── DTK_PointSearch_def.hpp │ │ └── DTK_Topology.hpp │ └── test │ │ ├── CMakeLists.txt │ │ ├── MeshGenerator.hpp │ │ ├── mixed_2d.txt │ │ ├── mixed_3d.txt │ │ ├── structured_2d.txt │ │ ├── structured_3d.txt │ │ ├── tstInterpolation.cpp │ │ ├── tstMeshGenerator.cpp │ │ ├── tstPointInCell.cpp │ │ ├── tstPointSearch.cpp │ │ └── unit_test_main.cpp ├── Meshfree │ ├── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ ├── DTK_CompactlySupportedRadialBasisFunctions.hpp │ │ ├── DTK_DetailsMovingLeastSquaresOperatorImpl.hpp │ │ ├── DTK_DetailsNearestNeighborOperatorImpl.hpp │ │ ├── DTK_DetailsPolynomialMatrix.hpp │ │ ├── DTK_DetailsSVDImpl.hpp │ │ ├── DTK_DetailsSplineProlongationOperator.hpp │ │ ├── DTK_ETI_NT.tmpl │ │ ├── DTK_MovingLeastSquaresOperator_decl.hpp │ │ ├── DTK_MovingLeastSquaresOperator_def.hpp │ │ ├── DTK_MultivariatePolynomialBasis.hpp │ │ ├── DTK_NearestNeighborOperator_decl.hpp │ │ ├── DTK_NearestNeighborOperator_def.hpp │ │ ├── DTK_PointCloudOperator.hpp │ │ ├── DTK_SplineOperator_decl.hpp │ │ └── DTK_SplineOperator_def.hpp │ └── test │ │ ├── CMakeLists.txt │ │ ├── PointCloudProblemGenerator │ │ ├── ExodusProblemGenerator.hpp │ │ ├── ExodusProblemGenerator_def.hpp │ │ └── PointCloudProblemGenerator.hpp │ │ ├── tstCompactlySupportedRadialBasisFunctions.cpp │ │ ├── tstDetailsCommunicationHelpers.cpp │ │ ├── tstMeshfreeOperators.cpp │ │ ├── tstMeshfreeOperatorsSimpleProblem.cpp │ │ ├── tstMultivariatePolynomialBasis.cpp │ │ ├── tstNearestNeighborExodusGenerator.cpp │ │ ├── tstNearestNeighborOperator.cpp │ │ ├── tstSVD.cpp │ │ └── unit_test_main.cpp ├── Utils │ ├── CMakeLists.txt │ ├── src │ │ ├── CMakeLists.txt │ │ ├── DTK_ConfigDefs.hpp │ │ ├── DTK_Core.cpp │ │ ├── DTK_Core.hpp │ │ ├── DTK_DBC.cpp │ │ ├── DTK_DBC.hpp │ │ ├── DTK_DetailsUtils.hpp │ │ ├── DTK_SWIG.hpp │ │ ├── DTK_SanitizerMacros.hpp │ │ ├── DTK_Types.h │ │ └── DTK_Version.hpp │ └── test │ │ ├── CMakeLists.txt │ │ ├── tstDBC.cpp │ │ ├── tstMiscellaneous.cpp │ │ └── unit_test_main.cpp └── dummy.cc └── scripts ├── changelog.sh ├── check_format_cpp.sh ├── check_no_trailing_whitespaces_or_tabs.sh ├── export_point_cloud_to_vtu.py ├── hooks └── pre-commit ├── leak_blacklist.txt ├── performance_plot.py ├── set_kokkos_env.sh ├── setup_hooks.sh └── undefined_blacklist.txt /.jenkins: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent none 3 | environment { 4 | // Get rid of Read -1, expected , errno =1 error 5 | // See https://github.com/open-mpi/ompi/issues/4948 6 | OMPI_MCA_btl_vader_single_copy_mechanism = 'none' 7 | // Remove warning: "A high-performance Open MPI point-to-point 8 | // messaging module was unable to find any relevant network 9 | // interfaces." 10 | OMPI_MCA_btl_base_warn_component_unused = '0' 11 | // Run MPI as root 12 | OMPI_ALLOW_RUN_AS_ROOT = '1' 13 | OMPI_ALLOW_RUN_AS_ROOT_CONFIRM = '1' 14 | OMPI_CXX = '/opt/trilinos/bin/nvcc_wrapper' 15 | } 16 | 17 | stages { 18 | stage('Test') { 19 | parallel { 20 | stage('CUDA-11.0') { 21 | agent { 22 | dockerfile { 23 | filename "Dockerfile" 24 | dir "docker" 25 | label 'nvidia-docker && volta' 26 | } 27 | } 28 | steps { 29 | sh 'rm -rf build && mkdir -p build' 30 | dir('build') { 31 | sh ''' 32 | cmake \ 33 | -D BUILD_SHARED_LIBS=ON \ 34 | -D CMAKE_BUILD_TYPE=Debug \ 35 | -D DataTransferKit_ENABLE_DataTransferKit=ON \ 36 | -D DataTransferKit_ENABLE_TESTS=ON \ 37 | -D TPL_Trilinos_DIR=${TRILINOS_DIR} \ 38 | -D TPL_BoostOrg_INCLUDE_DIRS=${BOOST_DIR}/include \ 39 | -D CMAKE_CXX_EXTENSIONS=OFF \ 40 | -D CMAKE_CXX_FLAGS="--expt-extended-lambda" \ 41 | -D DataTransferKit_ENABLE_OpenMP=ON \ 42 | .. 43 | ''' 44 | sh 'make VERBOSE=1 -j8' 45 | sh 'ctest --no-compress-output -T Test' 46 | } 47 | } 48 | post { 49 | always { 50 | xunit([CTest(deleteOutputFiles: true, failIfNotNew: true, pattern: 'build/Testing/**/Test.xml', skipNoTestFiles: false, stopProcessingIfError: true)]) 51 | } 52 | } 53 | } 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ------------ 3 | 4 | Contributing to DTK is easy. Just send us a [pull request](https://help.github.com/articles/using-pull-requests/). 5 | When you send your request, make `master` the destination branch on the 6 | [DTK repository](https://github.com/ORNL-CEES/DataTransferKit). 7 | 8 | Your PR must pass DTK's tests. We enforce these guidelines with Jenkins CI. 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright 2012-2020 the DataTransferKit authors 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | * Neither the name of the copyright holder nor the names of its 15 | contributors may be used to endorse or promote products derived from this 16 | software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /PackagesList.cmake: -------------------------------------------------------------------------------- 1 | TRIBITS_REPOSITORY_DEFINE_PACKAGES( 2 | DataTransferKit . ST 3 | ) 4 | 5 | TRIBITS_ALLOW_MISSING_EXTERNAL_PACKAGES() 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Data Transfer Kit (DTK) ARCHIVED AND NOT MAINTAINED ANYMORE 2 | ======================= 3 | 4 | [![Build Status](https://cloud.cees.ornl.gov/jenkins-ci/buildStatus/icon?job=DataTransferKit-continuous)](https://cloud.cees.ornl.gov/jenkins-ci/job/DataTransferKit-continuous/) 5 | [![Documentation Status](http://readthedocs.org/projects/datatransferkit/badge/?version=latest)](http://datatransferkit.readthedocs.io/en/latest/?badge=latest) 6 | [![codecov](https://codecov.io/gh/ORNL-CEES/DataTransferKit/branch/master/graph/badge.svg)](https://codecov.io/gh/ORNL-CEES/DataTransferKit) 7 | 8 | DTK is an open-source software library designed to provide scalable parallel 9 | solution transfer services for multiphysics simulations. 10 | 11 | This is the development version of the library. The API, code capabilities, 12 | and data structures are subject to change. Stable versions of the library can 13 | be found as [tagged 14 | releases](https://github.com/ORNL-CEES/DataTransferKit/releases). 15 | 16 | Documentation 17 | ------------- 18 | 19 | The documentation and the installation instructions can be found 20 | [here](http://datatransferkit.readthedocs.org). 21 | 22 | Questions, Bug Reporting, and Issue Tracking 23 | -------------------------------------------- 24 | 25 | Questions, bug reporting and issue tracking are provided by GitHub. Please 26 | report all bugs by creating a new issue with the bug tag. You can ask 27 | questions by creating a new issue with the question tag. 28 | 29 | Contributing 30 | ------------ 31 | We encourage you to contribute to DataTransferKit! Please check out the 32 | [guidelines](CONTRIBUTING.md) about how to proceed. 33 | 34 | License 35 | ------- 36 | 37 | DTK has a [BSD 3-clause open-source license](LICENSE). 38 | -------------------------------------------------------------------------------- /TPLsList.cmake: -------------------------------------------------------------------------------- 1 | IF (${PACKAGE_NAME}_TRILINOS_TPL) 2 | SET(TRILINOS_TPL 3 | Trilinos "cmake/TPLs/" SS 4 | ) 5 | ELSE() 6 | SET(TRILINOS_TPL "") 7 | ENDIF() 8 | 9 | IF (${PACKAGE_NAME}_ARBORX_TPL) 10 | SET(ARBORX_TPL 11 | ArborX "cmake/TPLs/" SS 12 | ) 13 | ELSE() 14 | SET(ARBORX_TPL "") 15 | ENDIF() 16 | 17 | TRIBITS_REPOSITORY_DEFINE_TPLS( 18 | BoostOrg "cmake/TPLs/" SS 19 | MPI "${${PROJECT_NAME}_TRIBITS_DIR}/core/std_tpls/" SS 20 | Netcdf "${${PROJECT_NAME}_TRIBITS_DIR}/common_tpls/" SS 21 | ${TRILINOS_TPL} 22 | ${ARBORX_TPL} 23 | ) 24 | -------------------------------------------------------------------------------- /Version.cmake: -------------------------------------------------------------------------------- 1 | SET(DataTransferKit_VERSION 3.1.0) 2 | SET(DataTransferKit_MAJOR_VERSION 3) 3 | SET(DataTransferKit_MAJOR_MINOR_VERSION 030100) 4 | SET(DataTransferKit_VERSION_STRING "3.1.0 (Dev)") 5 | SET(DataTransferKit_ENABLE_DEVELOPMENT_MODE_DEFAULT ON) # Change to 'OFF' for a release 6 | -------------------------------------------------------------------------------- /cmake/.ycm_extra_conf.py.in: -------------------------------------------------------------------------------- 1 | # This file is NOT licensed under the GPLv3, which is the license for the rest 2 | # of YouCompleteMe. 3 | # 4 | # Here's the license text for this file: 5 | # 6 | # This is free and unencumbered software released into the public domain. 7 | # 8 | # Anyone is free to copy, modify, publish, use, compile, sell, or 9 | # distribute this software, either in source code form or as a compiled 10 | # binary, for any purpose, commercial or non-commercial, and by any 11 | # means. 12 | # 13 | # In jurisdictions that recognize copyright laws, the author or authors 14 | # of this software dedicate any and all copyright interest in the 15 | # software to the public domain. We make this dedication for the benefit 16 | # of the public at large and to the detriment of our heirs and 17 | # successors. We intend this dedication to be an overt act of 18 | # relinquishment in perpetuity of all present and future rights to this 19 | # software under copyright law. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | # IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 25 | # OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 26 | # ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | # OTHER DEALINGS IN THE SOFTWARE. 28 | # 29 | # For more information, please refer to 30 | 31 | import os 32 | import ycm_core 33 | 34 | # These are the compilation flags that will be used in case there's no 35 | # compilation database set (by default, one is not set). 36 | # CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR. 37 | flags = [ 38 | '-Wall', 39 | '-Wextra', 40 | #'-Werror', 41 | #'-Wc++98-compat', 42 | '-Wno-long-long', 43 | '-Wno-variadic-macros', 44 | '-fexceptions', 45 | '-DNDEBUG', 46 | # You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM 47 | # source code needs it. 48 | '-DUSE_CLANG_COMPLETER', 49 | # THIS IS IMPORTANT! Without a "-std=" flag, clang won't know which 50 | # language to use when compiling headers. So it will guess. Badly. So C++ 51 | # headers will be compiled as C headers. You don't want that so ALWAYS specify 52 | # a "-std=". 53 | # For a C project, you would set this to something like 'c99' instead of 54 | # 'c++11'. 55 | '-std=c++14', 56 | # ...and the same thing goes for the magic -x option which specifies the 57 | # language that the files to be compiled are written in. This is mostly 58 | # relevant for c++ headers. 59 | # For a C project, you would set this to 'c' instead of 'c++'. 60 | '-x', 61 | 'c++', 62 | '-isystem', 63 | '../BoostParts', 64 | '-isystem', 65 | # This path will only work on OS X, but extra paths that don't exist are not 66 | # harmful 67 | '/System/Library/Frameworks/Python.framework/Headers', 68 | '-isystem', 69 | '../llvm/include', 70 | '-isystem', 71 | '../llvm/tools/clang/include', 72 | '-I', 73 | '.', 74 | '-I', 75 | './ClangCompleter', 76 | '-isystem', 77 | './tests/gmock/gtest', 78 | '-isystem', 79 | './tests/gmock/gtest/include', 80 | '-isystem', 81 | './tests/gmock', 82 | '-isystem', 83 | './tests/gmock/include', 84 | ] 85 | 86 | 87 | # Set this to the absolute path to the folder (NOT the file!) containing the 88 | # compile_commands.json file to use that instead of 'flags'. See here for 89 | # more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html 90 | # 91 | # You can get CMake to generate this file for you by adding: 92 | # set( CMAKE_EXPORT_COMPILE_COMMANDS 1 ) 93 | # to your CMakeLists.txt file. 94 | # 95 | # Most projects will NOT need to set this to anything; you can just change the 96 | # 'flags' list of compilation flags. Notice that YCM itself uses that approach. 97 | compilation_database_folder = '@CMAKE_BINARY_DIR@' 98 | 99 | if os.path.exists( compilation_database_folder ): 100 | database = ycm_core.CompilationDatabase( compilation_database_folder ) 101 | else: 102 | database = None 103 | 104 | SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ] 105 | 106 | def DirectoryOfThisScript(): 107 | return os.path.dirname( os.path.abspath( __file__ ) ) 108 | 109 | 110 | def MakeRelativePathsInFlagsAbsolute( flags, working_directory ): 111 | if not working_directory: 112 | return list( flags ) 113 | new_flags = [] 114 | make_next_absolute = False 115 | path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ] 116 | for flag in flags: 117 | new_flag = flag 118 | 119 | if make_next_absolute: 120 | make_next_absolute = False 121 | if not flag.startswith( '/' ): 122 | new_flag = os.path.join( working_directory, flag ) 123 | 124 | for path_flag in path_flags: 125 | if flag == path_flag: 126 | make_next_absolute = True 127 | break 128 | 129 | if flag.startswith( path_flag ): 130 | path = flag[ len( path_flag ): ] 131 | new_flag = path_flag + os.path.join( working_directory, path ) 132 | break 133 | 134 | if new_flag: 135 | new_flags.append( new_flag ) 136 | return new_flags 137 | 138 | 139 | def IsHeaderFile( filename ): 140 | extension = os.path.splitext( filename )[ 1 ] 141 | return extension in [ '.h', '.hxx', '.hpp', '.hh' ] 142 | 143 | 144 | def GetCompilationInfoForFile( filename ): 145 | # The compilation_commands.json file generated by CMake does not have entries 146 | # for header files. So we do our best by asking the db for flags for a 147 | # corresponding source file, if any. If one exists, the flags for that file 148 | # should be good enough. 149 | if IsHeaderFile( filename ): 150 | basename = os.path.splitext( filename )[ 0 ] 151 | for extension in SOURCE_EXTENSIONS: 152 | replacement_file = basename + extension 153 | if os.path.exists( replacement_file ): 154 | compilation_info = database.GetCompilationInfoForFile( 155 | replacement_file ) 156 | if compilation_info.compiler_flags_: 157 | return compilation_info 158 | return None 159 | return database.GetCompilationInfoForFile( filename ) 160 | 161 | 162 | def FlagsForFile( filename, **kwargs ): 163 | if database: 164 | # Bear in mind that compilation_info.compiler_flags_ does NOT return a 165 | # python list, but a "list-like" StringVec object 166 | compilation_info = GetCompilationInfoForFile( filename ) 167 | if not compilation_info: 168 | return None 169 | 170 | final_flags = MakeRelativePathsInFlagsAbsolute( 171 | compilation_info.compiler_flags_, 172 | compilation_info.compiler_working_dir_ ) 173 | 174 | # NOTE: This is just for YouCompleteMe; it's highly likely that your project 175 | # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR 176 | # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT. 177 | try: 178 | final_flags.remove( '-stdlib=libc++' ) 179 | except ValueError: 180 | pass 181 | else: 182 | relative_to = DirectoryOfThisScript() 183 | final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to ) 184 | 185 | return { 'flags': final_flags } 186 | -------------------------------------------------------------------------------- /cmake/CodeCompletion.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable/Disable output of compile commands during generation." FORCE) 2 | 3 | configure_file( 4 | ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/.ycm_extra_conf.py.in 5 | ${${PACKAGE_NAME}_SOURCE_DIR}/.ycm_extra_conf.py 6 | @ONLY 7 | ) 8 | -------------------------------------------------------------------------------- /cmake/CodeFormat.cmake: -------------------------------------------------------------------------------- 1 | if(NOT CLANG_FORMAT_EXECUTABLE) 2 | find_program(CLANG_FORMAT_EXECUTABLE 3 | NAMES 4 | clang-format-6.0 5 | clang-format-mp-6.0 6 | clang-format 7 | ) 8 | if(CLANG_FORMAT_EXECUTABLE) 9 | message("-- Found clang-format: ${CLANG_FORMAT_EXECUTABLE}") 10 | else() 11 | message(FATAL_ERROR "-- clang-format not found") 12 | endif() 13 | else() 14 | message("-- Using clang-format: ${CLANG_FORMAT_EXECUTABLE}") 15 | if(NOT EXISTS ${CLANG_FORMAT_EXECUTABLE}) 16 | message(FATAL_ERROR "-- clang-format path is invalid") 17 | endif() 18 | endif() 19 | 20 | # Check that the version of clang-format is the correct one 21 | execute_process( 22 | COMMAND ${CLANG_FORMAT_EXECUTABLE} -version 23 | OUTPUT_VARIABLE CLANG_FORMAT_VERSION 24 | ) 25 | if(NOT CLANG_FORMAT_VERSION MATCHES "6.0") 26 | message(FATAL_ERROR "You must use clang-format version 6.0") 27 | endif() 28 | 29 | # Add a custom target that applies the C++ code formatting style to the source 30 | add_custom_target(format-cpp 31 | COMMAND 32 | CLANG_FORMAT_EXE=${CLANG_FORMAT_EXECUTABLE} 33 | ${${PACKAGE_NAME}_SOURCE_DIR}/scripts/check_format_cpp.sh --apply-patch 34 | WORKING_DIRECTORY ${${PACKAGE_NAME}_SOURCE_DIR} 35 | ) 36 | 37 | # Add a test that checks the code is formatted properly 38 | add_test( 39 | NAME check_format_cpp 40 | COMMAND ${${PACKAGE_NAME}_SOURCE_DIR}/scripts/check_format_cpp.sh 41 | WORKING_DIRECTORY ${${PACKAGE_NAME}_SOURCE_DIR} 42 | ) 43 | set_tests_properties( check_format_cpp PROPERTIES 44 | ENVIRONMENT CLANG_FORMAT_EXE=${CLANG_FORMAT_EXECUTABLE} 45 | ) 46 | -------------------------------------------------------------------------------- /cmake/DataTransferKit_ETIHelperMacros.h.in: -------------------------------------------------------------------------------- 1 | #ifndef DTK_ETIHELPERMACROS_H_ 2 | #define DTK_ETIHELPERMACROS_H_ 3 | 4 | #include 5 | #include 6 | 7 | @DTK_ETIMACRO_SL@ 8 | 9 | @DTK_ETIMACRO_SL_REAL@ 10 | 11 | @DTK_ETIMACRO_L@ 12 | 13 | @DTK_ETIMACRO_SLG@ 14 | 15 | @DTK_ETIMACRO_SLG_REAL@ 16 | 17 | @DTK_ETIMACRO_LG@ 18 | 19 | @DTK_ETIMACRO_SLGN@ 20 | 21 | @DTK_ETIMACRO_SLGN_REAL@ 22 | 23 | @DTK_ETIMACRO_SN@ 24 | 25 | @DTK_ETIMACRO_SN_REAL@ 26 | 27 | @DTK_ETIMACRO_LGN@ 28 | 29 | @DTK_ETIMACRO_N@ 30 | 31 | @DTK_ETI_TYPEDEFS@ 32 | 33 | #endif // DTK_ETIHELPERMACROS_H_ 34 | -------------------------------------------------------------------------------- /cmake/DataTransferKit_config.hpp.in: -------------------------------------------------------------------------------- 1 | #ifndef DTK_CONFIG_HPP 2 | #define DTK_CONFIG_HPP 3 | 4 | #cmakedefine DataTransferKit_VERSION_STRING "@DataTransferKit_VERSION_STRING@" 5 | 6 | #cmakedefine DataTransferKit_GIT_COMMIT_HASH "@DataTransferKit_GIT_COMMIT_HASH@" 7 | 8 | #cmakedefine HAVE_DTK_BOOST 9 | 10 | #cmakedefine01 HAVE_DTK_DBC 11 | 12 | #cmakedefine HAVE_DATATRANSFERKIT_EXPLICIT_INSTANTIATION 13 | 14 | #cmakedefine HAVE_DTK_NETCDF 15 | 16 | #endif // DTK_CONFIG_HPP 17 | -------------------------------------------------------------------------------- /cmake/Dependencies.cmake: -------------------------------------------------------------------------------- 1 | SET(${PACKAGE_NAME}_Trilinos_REQUIRED_COMPONENTS Belos Intrepid2 Stratimikos Teuchos Thyra Tpetra) 2 | SET(${PACKAGE_NAME}_Trilinos_OPTIONAL_COMPONENTS "") 3 | 4 | IF (${PACKAGE_NAME}_ARBORX_TPL) 5 | SET(ARBORX_PACKAGE "ArborX" 6 | ) 7 | ELSE() 8 | SET(ARBORX_PACKAGE "" 9 | ) 10 | ENDIF() 11 | 12 | IF (${PACKAGE_NAME}_TRILINOS_TPL) 13 | TRIBITS_PACKAGE_DEFINE_DEPENDENCIES( 14 | LIB_REQUIRED_TPLS 15 | MPI 16 | Trilinos 17 | BoostOrg 18 | ${ARBORX_PACKAGE} 19 | LIB_OPTIONAL_TPLS 20 | BoostOrg 21 | Netcdf 22 | TEST_OPTIONAL_TPLS 23 | # BoostOrg is listed twice to have -isystem added to the include directories for the TPL when compiling the tests. 24 | # This is a known limitation of TriBITS (c.f. https://tribits.org/doc/TribitsDevelopersGuide.html#project-name-tpl-system-include-dirs) 25 | BoostOrg 26 | ) 27 | ELSE() 28 | TRIBITS_PACKAGE_DEFINE_DEPENDENCIES( 29 | LIB_REQUIRED_PACKAGES 30 | ${${PACKAGE_NAME}_Trilinos_REQUIRED_COMPONENTS} 31 | LIB_OPTIONAL_PACKAGES 32 | ${${PACKAGE_NAME}_Trilinos_OPTIONAL_COMPONENTS} 33 | LIB_REQUIRED_TPLS 34 | MPI 35 | LIB_OPTIONAL_TPLS 36 | BoostOrg 37 | Netcdf 38 | TEST_OPTIONAL_TPLS 39 | # BoostOrg is listed twice to have -isystem added to the include directories for the TPL when compiling the tests. 40 | # This is a known limitation of TriBITS (c.f. https://tribits.org/doc/TribitsDevelopersGuide.html#project-name-tpl-system-include-dirs) 41 | BoostOrg 42 | ) 43 | ENDIF() 44 | -------------------------------------------------------------------------------- /cmake/ExplicitInstantiationSupport.cmake: -------------------------------------------------------------------------------- 1 | include(Join) 2 | MESSAGE(STATUS "${PACKAGE_NAME}: Processing ETI / test support") 3 | 4 | # DataTransferKit ETI type fields. S, LO, GO, N correspond to the four 5 | # template parameters of most Tpetra classes: Scalar, LocalOrdinal, 6 | # GlobalOrdinal, and Node. DataTransferKit shares these with Tpetra, because 7 | # DataTransferKit only works with Tpetra linear algebra objects. 8 | SET(${PACKAGE_NAME}_ETI_FIELDS "S|LO|GO|N") 9 | 10 | # Set up a pattern that excludes all complex Scalar types. 11 | # TriBITS' ETI system knows how to interpret this pattern. 12 | TRIBITS_ETI_TYPE_EXPANSION(${PACKAGE_NAME}_ETI_EXCLUDE_SET_COMPLEX "S=std::complex|std::complex" "LO=.*" "GO=.*" "N=.*") 13 | 14 | # TriBITS' ETI system expects a set of types to be a string, delimited 15 | # by |. Each template parameter (e.g., Scalar, LocalOrdinal, ...) has 16 | # its own set. The JOIN commands below set up those lists. We use 17 | # the following sets that DataTransferKit defines: 18 | # 19 | # Scalar: DataTransferKit_ETI_SCALARS 20 | # LocalOrdinal: DataTransferKit_ETI_LORDS 21 | # GlobalOrdinal: DataTransferKit_ETI_GORDS 22 | # Node: DataTransferKit_ETI_NODES 23 | # 24 | # Note that the Scalar set from Tpetra includes the Scalar = 25 | # GlobalOrdinal case. However, DataTransferKit's CMake logic excludes this, 26 | # so we don't have to worry about it here. 27 | 28 | JOIN(${PACKAGE_NAME}_ETI_SCALARS "|" FALSE ${${PACKAGE_NAME}_ETI_SCALARS}) 29 | JOIN(${PACKAGE_NAME}_ETI_LORDS "|" FALSE ${${PACKAGE_NAME}_ETI_LORDS} ) 30 | JOIN(${PACKAGE_NAME}_ETI_GORDS "|" FALSE ${${PACKAGE_NAME}_ETI_GORDS} ) 31 | JOIN(${PACKAGE_NAME}_ETI_NODES "|" FALSE ${${PACKAGE_NAME}_ETI_NODES} ) 32 | 33 | MESSAGE(STATUS "Enabled Scalar types: ${${PACKAGE_NAME}_ETI_SCALARS}") 34 | MESSAGE(STATUS "Enabled LocalOrdinal types: ${${PACKAGE_NAME}_ETI_LORDS}") 35 | MESSAGE(STATUS "Enabled GlobalOrdinal types: ${${PACKAGE_NAME}_ETI_GORDS}") 36 | MESSAGE(STATUS "Enabled Node types: ${${PACKAGE_NAME}_ETI_NODES}") 37 | 38 | # Construct the "type expansion" string that TriBITS' ETI system 39 | # expects. Even if ETI is OFF, we will use this to generate macros 40 | # for instantiating tests. 41 | TRIBITS_ETI_TYPE_EXPANSION(SingleScalarInsts 42 | "S=${${PACKAGE_NAME}_ETI_SCALARS}" 43 | "N=${${PACKAGE_NAME}_ETI_NODES}" 44 | "LO=${${PACKAGE_NAME}_ETI_LORDS}" 45 | "GO=${${PACKAGE_NAME}_ETI_GORDS}") 46 | 47 | ASSERT_DEFINED(${PACKAGE_NAME}_ENABLE_EXPLICIT_INSTANTIATION) 48 | IF(${PACKAGE_NAME}_ENABLE_EXPLICIT_INSTANTIATION) 49 | MESSAGE(STATUS "User/Downstream ETI set: ${${PACKAGE_NAME}_ETI_LIBRARYSET}") 50 | TRIBITS_ADD_ETI_INSTANTIATIONS(${PACKAGE_NAME} ${SingleScalarInsts}) 51 | MESSAGE(STATUS "Excluded type combinations: ${${PACKAGE_NAME}_ETI_EXCLUDE_SET}") 52 | ELSE() 53 | TRIBITS_ETI_TYPE_EXPANSION(${PACKAGE_NAME}_ETI_LIBRARYSET 54 | "S=${${PACKAGE_NAME}_ETI_SCALARS}" 55 | "N=${${PACKAGE_NAME}_ETI_NODES}" 56 | "LO=${${PACKAGE_NAME}_ETI_LORDS}" 57 | "GO=${${PACKAGE_NAME}_ETI_GORDS}") 58 | ENDIF() 59 | MESSAGE(STATUS "Set of enabled types, before exclusions: ${${PACKAGE_NAME}_ETI_LIBRARYSET}") 60 | 61 | # 62 | # Generate the instantiation macros. These go into 63 | # DataTransferKit_ETIHelperMacros.h, which is generated from 64 | # DataTransferKit_ETIHelperMacros.h.in (in this directory). 65 | # 66 | TRIBITS_ETI_GENERATE_MACROS("${${PACKAGE_NAME}_ETI_FIELDS}" "${${PACKAGE_NAME}_ETI_LIBRARYSET}" "${${PACKAGE_NAME}_ETI_EXCLUDE_SET}" 67 | list_of_manglings eti_typedefs 68 | "DTK_INSTANTIATE_L(LO)" DTK_ETIMACRO_L 69 | "DTK_INSTANTIATE_SL(S,LO)" DTK_ETIMACRO_SL 70 | "DTK_INSTANTIATE_LG(LO,GO)" DTK_ETIMACRO_LG 71 | "DTK_INSTANTIATE_SLG(S,LO,GO)" DTK_ETIMACRO_SLG 72 | "DTK_INSTANTIATE_LGN(LO,GO,N)" DTK_ETIMACRO_LGN 73 | "DTK_INSTANTIATE_SLGN(S,LO,GO,N)" DTK_ETIMACRO_SLGN 74 | "DTK_INSTANTIATE_SN(S,N)" DTK_ETIMACRO_SN 75 | "DTK_INSTANTIATE_N(N)" DTK_ETIMACRO_N 76 | ) 77 | TRIBITS_ETI_GENERATE_MACROS("${${PACKAGE_NAME}_ETI_FIELDS}" "${${PACKAGE_NAME}_ETI_LIBRARYSET}" 78 | "${${PACKAGE_NAME}_ETI_EXCLUDE_SET};${${PACKAGE_NAME}_ETI_EXCLUDE_SET_COMPLEX}" 79 | list_of_manglings eti_typedefs 80 | "DTK_INSTANTIATE_SL_REAL(S,LO,GO)" DTK_ETIMACRO_SL_REAL 81 | "DTK_INSTANTIATE_SLG_REAL(S,LO,GO)" DTK_ETIMACRO_SLG_REAL 82 | "DTK_INSTANTIATE_SLGN_REAL(S,LO,GO,N)" DTK_ETIMACRO_SLGN_REAL 83 | "DTK_INSTANTIATE_SN_REAL(S,N)" DTK_ETIMACRO_SN_REAL 84 | ) 85 | 86 | # Generate "mangled" typedefs. Macros sometimes get grumpy when types 87 | # have spaces, colons, or angle brackets in them. This includes types 88 | # like "long long" or "std::complex". Thus, we define 89 | # typedefs that remove the offending characters. The typedefs also 90 | # get written to the generated header file. 91 | TRIBITS_ETI_GENERATE_TYPEDEF_MACRO(DTK_ETI_TYPEDEFS "DTK_ETI_MANGLING_TYPEDEFS" "${eti_typedefs}") 92 | 93 | # Generate the header file ${PACKAGE_NAME}_ETIHelperMacros.h, from the file 94 | # ${PACKAGE_NAME}_ETIHelperMacros.h.in 95 | CONFIGURE_FILE( 96 | ${${PACKAGE_NAME}_SOURCE_DIR}/cmake/${PACKAGE_NAME}_ETIHelperMacros.h.in 97 | ${${PACKAGE_NAME}_BINARY_DIR}/${PACKAGE_NAME}_ETIHelperMacros.h) 98 | -------------------------------------------------------------------------------- /cmake/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | find_program(SPHINX_EXECUTABLE NAMES sphinx-build sphinx-build-2.7 2 | HINTS 3 | $ENV{SPHINX_DIR} 4 | PATH_SUFFIXES bin 5 | DOC "Sphinx documentation generator" 6 | ) 7 | 8 | include(FindPackageHandleStandardArgs) 9 | 10 | find_package_handle_standard_args(Sphinx DEFAULT_MSG 11 | SPHINX_EXECUTABLE 12 | ) 13 | 14 | mark_as_advanced(SPHINX_EXECUTABLE) 15 | -------------------------------------------------------------------------------- /cmake/RepositoryDependenciesSetup.cmake: -------------------------------------------------------------------------------- 1 | SET_DEFAULT(DataTransferKit_REPOSITORY_MASTER_EMAIL_ADDRESS coupler-infrastructure@casl-dev.ornl.gov) 2 | 3 | SET(TPL_ENABLE_BoostOrg "${TPL_ENABLE_Boost}") 4 | -------------------------------------------------------------------------------- /cmake/TPLs/FindTPLArborX.cmake: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(ArborX REQUIRED 2 | CONFIG 3 | HINTS 4 | ${TPL_ArborX_DIR}/lib/cmake/ArborX 5 | ${TPL_ArborX_DIR} 6 | ) 7 | GET_TARGET_PROPERTY(ArborX_INCLUDE_DIRS ArborX::ArborX INTERFACE_INCLUDE_DIRECTORIES) 8 | GLOBAL_SET(TPL_ArborX_INCLUDE_DIRS "${ArborX_INCLUDE_DIRS}") 9 | GLOBAL_SET(TPL_ArborX_LIBRARIES "") 10 | GLOBAL_SET(TPL_ArborX_LIBRARY_DIRS "") 11 | MESSAGE("${TPL_ArborX_INCLUDE_DIRS},${TPL_ArborX_LIBRARIES},${TPL_ArborX_LIBRARY_DIRS}") 12 | -------------------------------------------------------------------------------- /cmake/TPLs/FindTPLBoostOrg.cmake: -------------------------------------------------------------------------------- 1 | GLOBAL_SET(BoostOrg_INCLUDE_DIRS "${Boost_INCLUDE_DIRS}") 2 | GLOBAL_SET(BoostOrg_LIBRARY_DIRS "${Boost_LIBRARY_DIRS}") 3 | 4 | TRIBITS_TPL_FIND_INCLUDE_DIRS_AND_LIBRARIES( 5 | BoostOrg 6 | REQUIRED_HEADERS boost/property_tree/json_parser.hpp 7 | boost/property_tree/ptree.hpp 8 | boost/math/tools/polynomial.hpp 9 | boost/math/tools/rational.hpp 10 | boost/geometry.hpp 11 | boost/range.hpp 12 | boost/program_options.hpp 13 | boost/test/unit_test.hpp 14 | ) 15 | 16 | # Use CMake FindBoost module to check version is sufficient 17 | SET(BOOST_INCLUDEDIR ${TPL_BoostOrg_INCLUDE_DIRS}) 18 | MESSAGE(STATUS "BOOST_INCLUDEDIR: ${BOOST_INCLUDEDIR}") 19 | SET(Boost_NO_SYSTEM_PATHS ON) 20 | FIND_PACKAGE(Boost 1.61.0 REQUIRED) 21 | -------------------------------------------------------------------------------- /cmake/TPLs/FindTPLTrilinos.cmake: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(Trilinos REQUIRED 2 | CONFIG 3 | HINTS 4 | ${TPL_Trilinos_DIR}/lib/cmake/Trilinos 5 | ${TPL_Trilinos_DIR} 6 | COMPONENTS 7 | ${${PACKAGE_NAME}_Trilinos_REQUIRED_COMPONENTS} 8 | OPTIONAL_COMPONENTS 9 | ${${PACKAGE_NAME}_Trilinos_OPTIONAL_COMPONENTS} 10 | ) 11 | GLOBAL_SET(TPL_Trilinos_INCLUDE_DIRS "${Trilinos_INCLUDE_DIRS};${Trilinos_LIBRARY_DIRS}") 12 | GLOBAL_SET(TPL_Trilinos_LIBRARIES "${Trilinos_LIBRARIES};${Trilinos_TPL_LIBRARIES}") 13 | GLOBAL_SET(TPL_Trilinos_LIBRARY_DIRS "${Trilinos_LIBRARY_DIRS};${Trilinos_TPL_LIBRARY_DIRS}") 14 | -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(Sphinx REQUIRED) 2 | 3 | ADD_CUSTOM_TARGET(docs ALL 4 | ${SPHINX_EXECUTABLE} 5 | -q -b html 6 | "${CMAKE_CURRENT_SOURCE_DIR}/source" 7 | "${CMAKE_CURRENT_BINARY_DIR}/html" 8 | COMMENT "Building HTML documentation with Sphinx" 9 | ) 10 | 11 | INSTALL(DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/html" 12 | DESTINATION "${CMAKE_INSTALL_PREFIX}/docs" 13 | ) 14 | -------------------------------------------------------------------------------- /docs/doxygen/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | FIND_PACKAGE(Doxygen REQUIRED) 2 | CONFIGURE_FILE( 3 | ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in 4 | ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 5 | @ONLY 6 | ) 7 | ADD_CUSTOM_TARGET(doxygen 8 | ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile 9 | COMMENT "Generating API documentation with Doxygen" 10 | ) 11 | -------------------------------------------------------------------------------- /docs/ext/scope.py: -------------------------------------------------------------------------------- 1 | # Inspired from https://gist.github.com/kakawait/9215487 visited on June 14th, 2017 2 | # See https://github.com/sphinx-doc/sphinx/issues/1717#issuecomment-74420054 3 | # and https://github.com/sphinx-doc/sphinx/issues/1717#issuecomment-74679763 4 | # 5 | # Sphinx extension to conditionaly inculde files 6 | 7 | import os, re 8 | from sphinx import addnodes 9 | 10 | docs_to_remove = [] 11 | 12 | def setup(app): 13 | app.ignore = [] 14 | app.connect('builder-inited', builder_inited) 15 | app.connect('env-get-outdated', env_get_outdated) 16 | app.connect('doctree-read', doctree_read) 17 | app.add_config_value("scope_donotinclude", [], '') 18 | 19 | def builder_inited(app): 20 | for doc in app.env.found_docs: 21 | first_directive = None 22 | for suffix in app.env.config.source_suffix: 23 | _file = app.env.srcdir + os.sep + doc + suffix 24 | if os.path.isfile(_file): 25 | with open(_file, 'r') as fin: 26 | first_directive = fin.readline() + fin.readline() 27 | if first_directive: 28 | # check whether the first two lines of a file match 29 | # ``` 30 | # .. meta:: 31 | # :scope: 32 | # ``` 33 | # and add file if belongs to the "donotinclude" list 34 | m = re.match(r'^\.\. meta::\s+:scope: ([a-zA-Z0-9_-]+)', first_directive) 35 | if m and m.group(1) in app.config.scope_donotinclude: 36 | docs_to_remove.append(doc) 37 | app.env.found_docs.difference_update(docs_to_remove) 38 | 39 | def env_get_outdated(app, env, added, changed, removed): 40 | added.difference_update(docs_to_remove) 41 | changed.difference_update(docs_to_remove) 42 | removed.update(docs_to_remove) 43 | return [] 44 | 45 | def doctree_read(app, doctree): 46 | for toctreenode in doctree.traverse(addnodes.toctree): 47 | for e in toctreenode['entries']: 48 | ref = str(e[1]) 49 | if ref in docs_to_remove: 50 | toctreenode['entries'].remove(e) 51 | -------------------------------------------------------------------------------- /docs/source/api.rst: -------------------------------------------------------------------------------- 1 | .. meta:: 2 | :scope: doxygen 3 | 4 | DataTransferKit API 5 | =================== 6 | 7 | 8 | C API 9 | ----- 10 | 11 | .. doxygenfile:: DTK_C_API.h 12 | -------------------------------------------------------------------------------- /docs/source/coding_guidelines.rst: -------------------------------------------------------------------------------- 1 | Coding Style Guidelines 2 | ======================= 3 | 4 | DataTransferKit developers follow a set of style guidelines and use the clang 5 | format tool to create a consistent appearance to all source code committed to 6 | the repository. 7 | 8 | ClangFormat 9 | ----------- 10 | 11 | ClangFormat (version 6.0) is used to check the C++ code formatting style in 12 | DTK. A pull request that does not comply will be rejected. Configure with 13 | ``-D DataTransferKit_ENABLE_ClangFormat=ON`` and do ``make format-cpp`` to 14 | apply the formatting style before your commit. Alternatively, run 15 | ``ctest -V -R check_format_cpp`` display the diff without applying the 16 | changes. 17 | 18 | Style Guide 19 | ----------- 20 | 21 | The following conventions are used in the code. 22 | 23 | Names of classes, structs, and enumerations are camel case and capitalized: 24 | 25 | .. code-block:: c++ 26 | 27 | class ExampleClassName {}; 28 | 29 | Function names are camel case and not capitalized: 30 | 31 | .. code-block:: c++ 32 | 33 | void exampleFunctionName() const; 34 | 35 | Variable names are lower case and have underscores to separate words: 36 | 37 | .. code-block:: c++ 38 | 39 | double example_double_var; 40 | std::vector example_vec_var; 41 | 42 | If a variable is class data prefixed with a ``_``: 43 | 44 | .. code-block:: c++ 45 | 46 | class ExampleClass 47 | { 48 | public: 49 | int _a_public_var; 50 | private: 51 | double _class_double_var; 52 | std::vector _example_vec_var; 53 | protected: 54 | std::string _a_protected_string; 55 | }; 56 | 57 | Previously, the convention for class data was to prefix the variable name with 58 | ``d_`` so this will be seen throughout the code. We will be transitioning to 59 | the ``_`` prefix convention in future work and slowly transition existing 60 | code. 61 | 62 | When a function as both input and output arguments, the inputs should come 63 | first: 64 | 65 | .. code-block:: c++ 66 | 67 | void myFunction(int const input_1, int const input_2, int &output) 68 | 69 | The ``clang-format`` tool described above enforces spacing, line breaks, and 70 | other general file formatting requirements. Header files are suffixed with 71 | ``.hpp`` and non-templated implementation files are suffixed with 72 | ``.cpp``. Header guards are needed for all header files following the 73 | convention of ``DTK_CLASSNAME_HPP``. For example: 74 | 75 | .. code-block:: c++ 76 | 77 | #ifndef DTK_EXAMPLECLASS_HPP 78 | #define DTK_EXAMPLECLASS_HPP 79 | 80 | class ExampleClass 81 | { 82 | // Class definition... 83 | }; 84 | 85 | #endif 86 | 87 | -------------------------------------------------------------------------------- /docs/source/developer_tools.rst: -------------------------------------------------------------------------------- 1 | Developer Tools 2 | =============== 3 | 4 | Using SWIG to generate Fortran 5 | ------------------------------ 6 | Change the declaration for ``DTK_UserApplicationHandle`` by replacing 7 | ``struct _DTK_UserApplicationHandle *`` to ``void *`` in ``DTK_C_API.h`` and run 8 | 9 | .. code:: bash 10 | 11 | $ swig -fortran dtk.i 12 | 13 | using Fortran-enabled SWIG `fork `_ (``fortran`` 14 | branch). This would generate two files: ``dtk_wrap.cxx`` and 15 | ``DataTransferKit.f90``. Move them to ``DTK_Fortran_wrap.cpp`` and 16 | ``DTK_Fortran_API.F90``, respectively. 17 | 18 | .. note: 19 | 20 | The Fortran file must have the uppercase extension: F90. The only reason for 21 | that is that preprocessing with Doxygen would not honor 22 | DOXYGEN_SHOULD_SKIP_THIS otherwise. 23 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | .. DataTransferKit documentation master file, created by 2 | sphinx-quickstart on Fri Nov 20 11:03:37 2015. 3 | You can adapt this file completely to your liking, but it should at least 4 | contain the root `toctree` directive. 5 | 6 | DataTransferKit Documentation 7 | ============================= 8 | 9 | Contents: 10 | 11 | .. toctree:: 12 | :maxdepth: 2 13 | 14 | overview 15 | install 16 | api 17 | developer_tools 18 | coding_guidelines 19 | 20 | 21 | 22 | Indices and tables 23 | ================== 24 | 25 | * :ref:`genindex` 26 | * :ref:`modindex` 27 | * :ref:`search` 28 | 29 | -------------------------------------------------------------------------------- /docs/source/install.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | This section provide guidelines for installing DataTransferKit and its TPLs. 5 | 6 | Install third-party libraries 7 | ----------------------------- 8 | 9 | The following third party libraries (TPLs) are used by DTK: 10 | 11 | +------------------------+-------------------------------------+---------+ 12 | | Packages | Dependency | Version | 13 | +========================+=====================================+=========+ 14 | | Boost | Required | 1.61.0 | 15 | +------------------------+-------------------------------------+---------+ 16 | | BLAS/LAPACK | Required | N/A | 17 | +------------------------+-------------------------------------+---------+ 18 | | MPI | Required | N/A | 19 | +------------------------+-------------------------------------+---------+ 20 | | Trilinos | Required | 12.X | 21 | +------------------------+-------------------------------------+---------+ 22 | 23 | The dependencies of DataTransferKit may be built using `Spack 24 | `_ package manager. You need to install the 25 | following packages: 26 | 27 | .. code:: 28 | 29 | $ spack install openblas 30 | $ spack install boost 31 | $ spack install mpi 32 | $ spack install trilinos 33 | 34 | Once installed, the module files for the packages must be loaded into the 35 | environment by doing 36 | 37 | .. code:: 38 | 39 | $ spack load openblas 40 | $ spack load boost 41 | $ spack load openmpi 42 | $ spack load trilinos 43 | 44 | 45 | DTK submodules 46 | -------------- 47 | 48 | DTK uses submodules for some of its dependencies. There are two ways to 49 | initialize the dependencies. The easiest way is to pass the ``--recursive`` 50 | option to the ``git clone`` command which will automatically initialize and 51 | update submodulesin the DataTransferKit repository. 52 | 53 | An alternative way to initialize submodules is to manually run the following 54 | commands: 55 | 56 | .. code:: 57 | 58 | $ git submodule init 59 | $ git submodule update 60 | 61 | The current dependencies are: 62 | 63 | * `ArborX repository `_ (required) 64 | 65 | The ArborX repository is a geometric search library used in DTK. 66 | 67 | * `DTKData repository `_ (optional) 68 | The DTKData repository contains mesh files used in DTK examples. 69 | 70 | Building DTK 71 | ------------ 72 | 73 | DTK is configured and built using `TriBITS `_. 74 | 75 | Create a ``do-configure`` script such as: 76 | 77 | .. code-block:: bash 78 | 79 | EXTRA_ARGS=$@ 80 | 81 | cmake \ 82 | -D CMAKE_BUILD_TYPE=Release \ 83 | -D TPL_ENABLE_MPI=ON \ 84 | -D TPL_ENABLE_BLAS=ON \ 85 | -D TPL_ENABLE_LAPACK=ON \ 86 | -D TPL_ENABLE_Boost=ON \ 87 | -D Trilinos_ENABLE_EXPLICIT_INSTANTIATION=ON \ 88 | -D Tpetra_INST_INT_LONG_LONG=OFF \ 89 | -D Trilinos_ENABLE_ALL_OPTIONAL_PACKAGES=OFF \ 90 | -D Trilinos_EXTRA_REPOSITORIES="DataTransferKit" \ 91 | -D Trilinos_ENABLE_DataTransferKit=ON \ 92 | -D DataTransferKit_ENABLE_DBC=ON \ 93 | -D DataTransferKit_ENABLE_TESTS=ON \ 94 | -D DataTransferKit_ENABLE_EXAMPLES=ON \ 95 | $EXTRA_ARGS \ 96 | $TRILINOS_DIR 97 | 98 | and run it from your build directory: 99 | 100 | .. code:: 101 | 102 | $ mkdir build && cd build 103 | $ ../do-configure 104 | 105 | More install scripts can be found in ``scripts/``. 106 | 107 | .. note:: 108 | 109 | The above ``do-configure`` script may get outdated. You can always refer to 110 | ``scripts/docker_cmake`` which is used in the Jenkins CI builds and 111 | therefore is required to be always up-to-date. 112 | 113 | Build this documentation 114 | ------------------------ 115 | 116 | Building documentation requires `sphinx `_. 117 | (Re)configure with ``-D DataTransferKit_ENABLE_ReadTheDocs=ON`` and run: 118 | 119 | .. code:: 120 | 121 | $ make docs 122 | 123 | Open the ``index.html`` in the directory ``DataTransferKit/docs/html``. 124 | 125 | Generate Doxygen documentation 126 | ------------------------------ 127 | 128 | Configure with ``-D DataTransferKit_ENABLE_Doxygen=ON`` and run: 129 | 130 | .. code:: 131 | 132 | $ make doxygen 133 | 134 | Checkout ``DataTransferKit/docs/doxygen/html/index.html``. 135 | -------------------------------------------------------------------------------- /docs/source/overview.rst: -------------------------------------------------------------------------------- 1 | Getting started with DTK 2 | ======================== 3 | 4 | Overview 5 | -------- 6 | 7 | `DataTransferKit `_ is an 8 | open-source software library of parallel solution transfer services for 9 | multiphysics simulations. DTK uses a general operator design to provide 10 | scalable algorithms for solution transfer between shared volumes and surfaces. 11 | 12 | DTK was originally developed at the University of Wisconsin - Madison as part of 13 | the Computational Nuclear Engineering Group (`CNERG `_) 14 | and is now actively developed at the Oak Ridge National Laboratory as part of 15 | the Computational Engineering and Energy Sciences (`CEES 16 | `_) group. 17 | 18 | DTK is supported and used by the following projects and programs: 19 | 20 | * Exascale Computing Project (`ECP ALExa 21 | `_) 22 | 23 | * Oak Ridge National Laboratory (ORNL) Laboratory Directed Research and 24 | Development (`LDRD 25 | `_) 26 | 27 | * Consortium for Advanced Simulation of Light Water Reactors (`CASL 28 | `_) 29 | 30 | * Nuclear Energy Advanced Modeling and Simulation (`NEAMS 31 | `_) 32 | 33 | * National Highway Traffic Safety Administration (`NHTSA 34 | `_) 35 | 36 | DataTransferKit Development Team 37 | -------------------------------- 38 | 39 | DTK is developed and maintained by: 40 | 41 | * `Stuart Slattery `_ 42 | 43 | * `Damien Lebrun-Grandie `_ 44 | 45 | * `Bruno Turcksin `_ 46 | 47 | * `Andrey Prokopenko `_ 48 | 49 | Alumni: 50 | 51 | * `Roger Pawlowski `_ 52 | 53 | * `Alex McCaskey `_ 54 | 55 | 56 | DataTransferKit Packages 57 | ------------------------ 58 | 59 | DTK has the following packages: 60 | 61 | **Utils** 62 | General utilities for software development including exception handling, 63 | and other functional programming tools 64 | 65 | **Meshfree** 66 | Point cloud based operators (e.g., nearest neighbor, moving least squares, 67 | spline interpolation) 68 | 69 | **Discretization** 70 | Mesh based operators (e.g., interpolation, L2 projection) 71 | 72 | **Benchmarks** 73 | Mesh and partitioning infrastructure of problems relevant to DTK 74 | 75 | Questions, Bug Reporting, and Issue Tracking 76 | -------------------------------------------- 77 | 78 | Questions, bug reporting and issue tracking are provided by GitHub. Please 79 | report all bugs by creating a new issue. You can ask questions by creating a 80 | new issue with the question tag. 81 | 82 | 83 | Publications 84 | ------------ 85 | 86 | Publications to date related to DataTransferKit: 87 | 88 | * S. Slattery, *"Mesh-Free Data Transfer Algorithms for Partitioned 89 | Multiphysics Problems: Conservation, Accuracy, and Parallelism"*, Journal of 90 | Computational Physics, vol. 307, pp. 164-188, 2016. 91 | 92 | * S. Slattery, S. Hamilton, T. Evans, *"A Modified Moving Least Square 93 | Algorithm for Solution Transfer on a Spacer Grid Surface"*, ANS MC2015 - 94 | Joint International Conference on Mathematics and Computation (M&C), 95 | Supercomputing in Nuclear Applications (SNA) and the Monte Carlo (MC) 96 | Method, Nashville, Tennessee · April 19–23, 2015, on CD-ROM, American 97 | Nuclear Society, LaGrange Park, IL (2015). 98 | 99 | * R. Schmidt, K. Belcourt, R. Hooper, R. Pawlowski, K. Clarno, S. Simunovic, S. Slattery, J. Turner, S. Palmtag, 100 | *"An Approach for Coupled-Code Multiphysics Core Simulations from a Common 101 | *Input"*, Annals of Nuclear Energy, Volume 84, pp. 140-152, 2014. 102 | 103 | * S. Slattery, P.P.H. Wilson, R. Pawlowski, *“The Data Transfer Kit: A 104 | Geometric Rendezvous-Based Tool for Multiphysics Data Transfer”*, 105 | International Conference on Mathematics and Computational Methods Applied to 106 | Nuclear Science & Engineering (M&C 2013), American Nuclear Society, Sun 107 | Valley, ID, May 5-9, 2013. 108 | -------------------------------------------------------------------------------- /docs/source/requirements.readthedocs.txt: -------------------------------------------------------------------------------- 1 | sphinx==1.7.5 2 | breathe==4.10 3 | -------------------------------------------------------------------------------- /packages/Benchmarks/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(HybridTransport) 2 | -------------------------------------------------------------------------------- /packages/Benchmarks/HybridTransport/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(src) 2 | 3 | TRIBITS_ADD_TEST_DIRECTORIES(test) 4 | -------------------------------------------------------------------------------- /packages/Benchmarks/HybridTransport/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(HEADERS "") 2 | SET(SOURCES "") 3 | 4 | SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}) 5 | APPEND_GLOB(HEADERS ${DIR}/*.h) 6 | APPEND_GLOB(HEADERS ${DIR}/*.hpp) 7 | APPEND_GLOB(SOURCES ${DIR}/*.cpp) 8 | 9 | 10 | # Must glob the binary dir last to get all of the auto-generated headers 11 | SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_BINARY_DIR}) 12 | APPEND_GLOB(HEADERS ${DIR}/*.hpp) 13 | 14 | # 15 | # C) Define the targets for package's library(s) 16 | # 17 | 18 | TRIBITS_ADD_LIBRARY( 19 | dtk_hybridtransport 20 | HEADERS ${HEADERS} 21 | SOURCES ${SOURCES} 22 | DEPLIBS dtk_utils 23 | ADDED_LIB_TARGET_NAME_OUT DTK_HYBRIDTRANSPORT_LIBNAME 24 | ) 25 | 26 | # We need to set the linker language explicitly here for CUDA builds. 27 | SET_PROPERTY( 28 | TARGET ${DTK_HYBRIDTRANSPORT_LIBNAME} 29 | APPEND PROPERTY LINKER_LANGUAGE CXX 30 | ) 31 | -------------------------------------------------------------------------------- /packages/Benchmarks/HybridTransport/src/DTK_Benchmark_DeterministicMesh.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file DTK_Benchmark_DeterministicMesh.hpp 13 | * \brief Deterministic mesh interface for the hybrid transport benchmark. 14 | */ 15 | //---------------------------------------------------------------------------// 16 | 17 | #ifndef DTK_DETERMINISTICMESH_HPP 18 | #define DTK_DETERMINISTICMESH_HPP 19 | 20 | #include "DTK_Benchmark_CartesianMesh.hpp" 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace DataTransferKit 29 | { 30 | namespace Benchmark 31 | { 32 | //---------------------------------------------------------------------------// 33 | /*! 34 | * \class DeterministicMesh 35 | * \brief Mesh and partitioner for deterministic transport simulations. 36 | * 37 | * This partitioner does a very simple partitioning where the partitioner 38 | * calculates some "optimal" number of blocks which is most square. The 39 | * partitioner tries to make each block (mesh on a processor) the same size. 40 | * If the number of cells in each direction does not divide evenly, then cells 41 | * are added to each direction starting at \e (i=0,j=0). The mesh is 42 | * decomposed into \e B blocks. 43 | * 44 | * The resulting partitioning is used to create the needed data in the base 45 | * class with mesh data being accessed through the base class 46 | * interface. Really think about this class as a decorator for the base class 47 | * which provides an initial partitioning. 48 | */ 49 | class DeterministicMesh 50 | { 51 | public: 52 | /*! 53 | * \brief Uniform cell size constructor. The global list of node locations 54 | * will be composed from the given number of cells in uniform intervals. 55 | * 56 | * \param comm The parallel communicator over which the mesh is built. 57 | * 58 | * \param num_cells_i The global number of mesh cells in the X direction. 59 | * 60 | * \param num_cells_j The global number of mesh cells in the Y direction. 61 | * 62 | * \param num_cells_k The global number of mesh cells in the Z direction. 63 | * 64 | * \param delta_x The size of the mesh cells in the X direction. 65 | * 66 | * \param delta_y The size of the mesh cells in the Y direction. 67 | * 68 | * \param delta_z The size of the mesh cells in the Z direction. 69 | */ 70 | DeterministicMesh( const Teuchos::RCP> &comm, 71 | const int num_cells_i, const int num_cells_j, 72 | const int num_cells_k, const double delta_x, 73 | const double delta_y, const double delta_z ); 74 | 75 | /*! 76 | * \brief Global edge constructor. A global list of node locations will be 77 | * used to create and partition the mesh. 78 | * 79 | * \param comm The parallel communicator over which the mesh is built. 80 | * 81 | * \param global_x_edges Global list of node locations in the X direction. 82 | * 83 | * \param global_y_edges Global list of node locations in the Y direction. 84 | * 85 | * \param global_z_edges Global list of node locations in the Z direction. 86 | */ 87 | DeterministicMesh( const Teuchos::RCP> &comm, 88 | const std::vector &global_x_edges, 89 | const std::vector &global_y_edges, 90 | const std::vector &global_z_edges ); 91 | 92 | /*! 93 | * \brief Get the local Cartesian mesh owned by this process. 94 | */ 95 | std::shared_ptr cartesianMesh() const 96 | { 97 | return _cartesian_mesh; 98 | } 99 | 100 | private: 101 | // Partition the mesh. 102 | void partition( const Teuchos::RCP> &comm, 103 | const std::vector &global_x_edges, 104 | const std::vector &global_y_edges, 105 | const std::vector &global_z_edges ); 106 | 107 | private: 108 | // The Cartesian mesh owned by this process. 109 | std::shared_ptr _cartesian_mesh; 110 | }; 111 | 112 | //---------------------------------------------------------------------------// 113 | 114 | } // end namespace Benchmark 115 | } // end namespace DataTransferKit 116 | 117 | #endif // end DTK_DETERMINISTICMESH_HPP 118 | -------------------------------------------------------------------------------- /packages/Benchmarks/HybridTransport/src/DTK_Benchmark_MonteCarloMesh.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file DTK_Benchmark_MonteCarloMesh.hpp 13 | * \brief MonteCarlo mesh interface for the hybrid transport benchmark. 14 | */ 15 | //---------------------------------------------------------------------------// 16 | 17 | #ifndef DTK_MONTECARLOMESH_HPP 18 | #define DTK_MONTECARLOMESH_HPP 19 | 20 | #include "DTK_Benchmark_CartesianMesh.hpp" 21 | 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | 28 | namespace DataTransferKit 29 | { 30 | namespace Benchmark 31 | { 32 | //---------------------------------------------------------------------------// 33 | /*! 34 | * \class MonteCarloMesh 35 | * \brief Mesh and partitioner for Monte Carlo transport simulations. 36 | * 37 | * Monte Carlo grids are typically subdivided into a small number of "blocks", 38 | * which can be interpreted as grid partitions, and "sets" which can be 39 | * interpreted as a number of replications of the grid. 40 | * 41 | * The block decomposition, or spatial partitioning of the mesh, is always 42 | * computed with user provided planes indicating the spatial boundaries of 43 | * each block. The underlying grid is then subdivided into blocks based on the 44 | * plane locations. If a plane intersects a cell, that cell is assigned to 45 | * both blocks adjacent to the plane. 46 | * 47 | * Note that the boundary mesh planes don't have to contain the grid - we will 48 | * just use them to carve out partitions from the background grid. 49 | * 50 | * The resulting partitioning is used to create the needed data in the base 51 | * class with mesh data being accessed through the base class 52 | * interface. Really think about this class as a decorator for the base class 53 | * which provides an initial partitioning. 54 | */ 55 | class MonteCarloMesh 56 | { 57 | public: 58 | /*! 59 | * \brief Uniform cell size constructor. 60 | * 61 | * Builds a regular grid with a uniform cell size and partitions it using 62 | * the input boundary mesh arrays. 63 | * 64 | * \param comm The communicator over which the mesh will be partitioned. 65 | * 66 | * \param num_sets The number of sets over which to decompose the 67 | * mesh. This is the total number of times the mesh is replicated. 68 | * 69 | * \param num_cells_i The global number of mesh cells in the X direction. 70 | * 71 | * \param num_cells_j The global number of mesh cells in the Y direction. 72 | * 73 | * \param num_cells_k The global number of mesh cells in the Z direction. 74 | * 75 | * \param delta_x The size of the mesh cells in the X direction. 76 | * 77 | * \param delta_y The size of the mesh cells in the Y direction. 78 | * 79 | * \param delta_z The size of the mesh cells in the Z direction. 80 | * 81 | * \param x_bnd_mesh The boundary mesh node locations in the x direction. 82 | * 83 | * \param y_bnd_mesh The boundary mesh node locations in the y direction. 84 | * 85 | * \param z_bnd_mesh The boundary mesh node locations in the z direction. 86 | */ 87 | MonteCarloMesh( const Teuchos::RCP> &comm, 88 | const int num_sets, const int num_cells_i, 89 | const int num_cells_j, const int num_cells_k, 90 | const double delta_x, const double delta_y, 91 | const double delta_z, const std::vector &x_bnd_mesh, 92 | const std::vector &y_bnd_mesh, 93 | const std::vector &z_bnd_mesh ); 94 | 95 | /*! 96 | * \brief Global edge constructor. A global list of node locations will be 97 | * used to create the mesh. The mesh will be partitioned using the input 98 | * boundary mesh arrays. 99 | * 100 | * \param comm The parallel communicator over which the mesh is built. 101 | * 102 | * \param num_sets The number of sets over which to decompose the 103 | * mesh. This is the total number of times the mesh is replicated. 104 | * 105 | * \param global_x_edges Global list of node locations in the X direction. 106 | * 107 | * \param global_y_edges Global list of node locations in the Y direction. 108 | * 109 | * \param global_z_edges Global list of node locations in the Z direction. 110 | * 111 | * \param x_bnd_mesh The boundary mesh node locations in the x direction. 112 | * 113 | * \param y_bnd_mesh The boundary mesh node locations in the y direction. 114 | * 115 | * \param z_bnd_mesh The boundary mesh node locations in the z direction. 116 | */ 117 | MonteCarloMesh( const Teuchos::RCP> &comm, 118 | const int num_sets, 119 | const std::vector &global_x_edges, 120 | const std::vector &global_y_edges, 121 | const std::vector &global_z_edges, 122 | const std::vector &x_bnd_mesh, 123 | const std::vector &y_bnd_mesh, 124 | const std::vector &z_bnd_mesh ); 125 | 126 | /*! 127 | * \brief Get the local Cartesian mesh owned by this process. 128 | */ 129 | std::shared_ptr cartesianMesh() const 130 | { 131 | return _cartesian_mesh; 132 | } 133 | 134 | private: 135 | // Partition the mesh. 136 | void partition( const Teuchos::RCP> &comm, 137 | const int num_sets, 138 | const std::vector &global_x_edges, 139 | const std::vector &global_y_edges, 140 | const std::vector &global_z_edges, 141 | const std::vector &x_bnd_mesh, 142 | const std::vector &y_bnd_mesh, 143 | const std::vector &z_bnd_mesh ); 144 | 145 | // Calculate local edge arrays. 146 | void computeLocalEdges( const std::vector &global_edges, 147 | const std::vector &bnd_mesh, 148 | const int my_block, 149 | std::vector &local_edges, 150 | int &offset ) const; 151 | 152 | private: 153 | // The Cartesian mesh owned by this process. 154 | std::shared_ptr _cartesian_mesh; 155 | }; 156 | 157 | //---------------------------------------------------------------------------// 158 | 159 | } // end namespace Benchmark 160 | } // end namespace DataTransferKit 161 | 162 | #endif // end DTK_MONTECARLOMESH_HPP 163 | -------------------------------------------------------------------------------- /packages/Benchmarks/HybridTransport/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # ##---------------------------------------------------------------------------## 2 | # ## TESTS 3 | # ##---------------------------------------------------------------------------## 4 | 5 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 6 | CartesianMesh 7 | SOURCES tstCartesianMesh.cpp unit_test_main.cpp 8 | COMM serial mpi 9 | STANDARD_PASS_OUTPUT 10 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 11 | ) 12 | 13 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 14 | DeterministicMesh 15 | SOURCES tstDeterministicMesh.cpp unit_test_main.cpp 16 | COMM serial mpi 17 | STANDARD_PASS_OUTPUT 18 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 19 | ) 20 | 21 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 22 | MonteCarloMesh 23 | SOURCES tstMonteCarloMesh.cpp unit_test_main.cpp 24 | COMM serial mpi 25 | STANDARD_PASS_OUTPUT 26 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 27 | ) 28 | -------------------------------------------------------------------------------- /packages/Benchmarks/HybridTransport/test/unit_test_main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | int main( int argc, char *argv[] ) 18 | { 19 | Teuchos::GlobalMPISession mpiSession( &argc, &argv ); 20 | Teuchos::UnitTestRepository::setGloballyReduceTestResult( true ); 21 | Kokkos::initialize( argc, argv ); 22 | int return_val = 23 | Teuchos::UnitTestRepository::runUnitTestsFromMain( argc, argv ); 24 | Kokkos::finalize(); 25 | return return_val; 26 | } 27 | -------------------------------------------------------------------------------- /packages/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(Utils) 2 | 3 | IF(DataTransferKit_ARBORX_TPL) 4 | # Create a dummy library 5 | SET(HEADERS "") 6 | SET(SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/dummy.cc") 7 | 8 | TRIBITS_ADD_LIBRARY( 9 | dtk_search 10 | HEADERS ${HEADERS} 11 | SOURCES ${SOURCES} 12 | ADDED_LIB_TARGET_NAME_OUT DTK_SEARCH_LIBNAME 13 | ) 14 | ELSE() 15 | SET(ARBORX_ENABLE_MPI TRUE) 16 | CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/Search/src/ArborX_Config.hpp.in 17 | ${CMAKE_CURRENT_BINARY_DIR}/Search/src/ArborX_Config.hpp) 18 | 19 | SET(HEADERS "") 20 | SET(SOURCES "") 21 | 22 | FOREACH(dir ${CMAKE_CURRENT_SOURCE_DIR}/Search/src 23 | ${CMAKE_CURRENT_SOURCE_DIR}/Search/src/details 24 | ${CMAKE_CURRENT_SOURCE_DIR}/Search/src/geometry 25 | ${CMAKE_CURRENT_SOURCE_DIR}/Search/src/kokkos_ext 26 | ${CMAKE_CURRENT_BINARY_DIR}/Search/src ) 27 | APPEND_GLOB(HEADERS ${dir}/*.hpp) 28 | APPEND_GLOB(SOURCES ${dir}/*.cpp) 29 | TRIBITS_INCLUDE_DIRECTORIES(${dir}) 30 | ENDFOREACH() 31 | 32 | TRIBITS_ADD_LIBRARY( 33 | dtk_search 34 | HEADERS ${HEADERS} 35 | SOURCES ${SOURCES} 36 | DEPLIBS dtk_utils 37 | ADDED_LIB_TARGET_NAME_OUT DTK_SEARCH_LIBNAME 38 | ) 39 | 40 | # We need to set the linker language explicitly here for CUDA builds. 41 | SET_PROPERTY( 42 | TARGET ${DTK_SEARCH_LIBNAME} 43 | APPEND PROPERTY LINKER_LANGUAGE CXX 44 | ) 45 | ENDIF() 46 | 47 | ADD_SUBDIRECTORY(Discretization) 48 | ADD_SUBDIRECTORY(Meshfree) 49 | ADD_SUBDIRECTORY(Benchmarks) 50 | -------------------------------------------------------------------------------- /packages/Discretization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(src) 2 | 3 | TRIBITS_ADD_TEST_DIRECTORIES(test) 4 | -------------------------------------------------------------------------------- /packages/Discretization/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE(TribitsCreateClientTemplateHeaders) 2 | 3 | SET(HEADERS "") 4 | SET(SOURCES "") 5 | 6 | SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}) 7 | APPEND_GLOB(HEADERS ${DIR}/*.h) 8 | APPEND_GLOB(HEADERS ${DIR}/*.hpp) 9 | APPEND_GLOB(SOURCES ${DIR}/*.cpp) 10 | TRIBITS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}) 11 | 12 | 13 | # Must glob the binary dir last to get all of the auto-generated headers 14 | SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_BINARY_DIR}) 15 | APPEND_GLOB(HEADERS ${DIR}/*.hpp) 16 | APPEND_SET(HEADERS ${PACKAGE_BINARY_DIR}/${PACKAGE_NAME}_config.hpp) 17 | APPEND_SET(HEADERS ${PACKAGE_BINARY_DIR}/${PACKAGE_NAME}_ETIHelperMacros.h) 18 | 19 | # Explicitly instantiate classes. 20 | IF (${PACKAGE_NAME}_ENABLE_EXPLICIT_INSTANTIATION) 21 | 22 | # Generate ETI .cpp files for DataTransferKit::PointInCell. 23 | DTK_PROCESS_ALL_N_TEMPLATES(POINTINCELL_OUTPUT_FILES 24 | "DTK_ETI_NT.tmpl" "PointInCell" "POINTINCELL" 25 | "${${PACKAGE_NAME}_ETI_NODES}" TRUE) 26 | LIST(APPEND SOURCES ${POINTINCELL_OUTPUT_FILES}) 27 | 28 | # Generate ETI .cpp files for DataTransferKit::PointSearch. 29 | DTK_PROCESS_ALL_N_TEMPLATES(POINTSEARCH_OUTPUT_FILES 30 | "DTK_ETI_NT.tmpl" "PointSearch" "POINTSEARCH" 31 | "${${PACKAGE_NAME}_ETI_NODES}" TRUE) 32 | LIST(APPEND SOURCES ${POINTSEARCH_OUTPUT_FILES}) 33 | 34 | # Generate ETI .cpp files for DataTransferKit::Interpolation. 35 | DTK_PROCESS_ALL_N_TEMPLATES(INTERPOLATION_OUTPUT_FILES 36 | "DTK_ETI_NT.tmpl" "Interpolation" "INTERPOLATION" 37 | "${${PACKAGE_NAME}_ETI_NODES}" TRUE) 38 | LIST(APPEND SOURCES ${INTERPOLATION_OUTPUT_FILES}) 39 | 40 | ENDIF() 41 | 42 | 43 | # 44 | # C) Define the targets for package's library(s) 45 | # 46 | 47 | TRIBITS_ADD_LIBRARY( 48 | dtk_discretization 49 | HEADERS ${HEADERS} 50 | SOURCES ${SOURCES} 51 | DEPLIBS dtk_utils dtk_search 52 | ADDED_LIB_TARGET_NAME_OUT DTK_DISCRETIZATION_LIBNAME 53 | ) 54 | 55 | # We need to set the linker language explicitly here for CUDA builds. 56 | SET_PROPERTY( 57 | TARGET ${DTK_DISCRETIZATION_LIBNAME} 58 | APPEND PROPERTY LINKER_LANGUAGE CXX 59 | ) 60 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_CellTypes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file 13 | * \brief DTK supported cell topology types. 14 | */ 15 | #ifndef DTK_CELLTYPES_H 16 | #define DTK_CELLTYPES_H 17 | 18 | /*! 19 | * \brief Cell topology enumeration. 20 | * 21 | * The following standard cell topology types are supported by DTK. 22 | */ 23 | typedef enum { 24 | DTK_TRI_3 = 0, 25 | DTK_TRI_6, 26 | DTK_QUAD_4, 27 | DTK_QUAD_9, 28 | DTK_TET_4, 29 | DTK_TET_10, 30 | DTK_TET_11, 31 | DTK_HEX_8, 32 | DTK_HEX_20, 33 | DTK_HEX_27, 34 | DTK_PYRAMID_5, 35 | DTK_PYRAMID_13, 36 | DTK_WEDGE_6, 37 | DTK_WEDGE_15, 38 | DTK_WEDGE_18, 39 | DTK_N_TOPO 40 | } DTK_CellTopology; 41 | 42 | #endif // DTK_CELLTYPES_H 43 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_ETI_NT.tmpl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | // WARNING: This file is automatically generated by CMake, and written 13 | // to Trilinos' build (not source) directory. DO NOT EDIT THIS FILE! 14 | // If you run CMake again, it will overwrite any changes that you 15 | // made. Furthermore, it would be unwise to assume anything about 16 | // this file: it may disappear at any time, and its name, location, or 17 | // contents may change at any time. 18 | // 19 | // CMake takes each expression in the original .tmpl file enclosed by 20 | // "at" symbols ("a" with a circle around it), and replaces it in the 21 | // generated .cpp file with a string defined by Tpetra's CMake logic 22 | // (see CMakeLists.txt in this directory). Thus, the original .tmpl 23 | // file is NOT syntactically correct C++, but the .cpp file generated 24 | // by running CMake on it IS a syntactically correct C++ file. 25 | 26 | #include "DataTransferKit_config.hpp" 27 | 28 | #if defined(HAVE_DATATRANSFERKIT_EXPLICIT_INSTANTIATION) 29 | 30 | // We protect the contents of this file with macros, to assist 31 | // applications that circumvent Trilinos' build system. (We do NOT 32 | // recommend this.) That way, they can still build this file, but as 33 | // long as the macros have correct definitions, they won't build 34 | // anything that's not enabled. 35 | 36 | #include "DTK_@CLASS_NAME@_decl.hpp" 37 | #include "DTK_@CLASS_NAME@_def.hpp" 38 | #include "DataTransferKit_ETIHelperMacros.h" 39 | 40 | namespace DataTransferKit { 41 | 42 | DTK_ETI_MANGLING_TYPEDEFS() 43 | 44 | DTK_@CLASS_MACRO_NAME@_INSTANT( @NT_MANGLED_NAME@ ) 45 | 46 | } // namespace DataTransferKit 47 | 48 | #endif // Whether we should build this specialization 49 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_FE.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | namespace DataTransferKit 15 | { 16 | FE getFE( DTK_CellTopology topo, DTK_FEType fe_type ) 17 | { 18 | if ( topo == DTK_HEX_8 ) 19 | { 20 | switch ( fe_type ) 21 | { 22 | case DTK_HCURL: 23 | { 24 | return FE::HEX_HCURL_1; 25 | } 26 | case DTK_HDIV: 27 | { 28 | return FE::HEX_HDIV_1; 29 | } 30 | case DTK_HGRAD: 31 | { 32 | return FE::HEX_HGRAD_1; 33 | } 34 | default: 35 | return FE::DUMMY; 36 | } 37 | } 38 | else if ( topo == DTK_HEX_27 ) 39 | { 40 | if ( fe_type == DTK_HGRAD ) 41 | return FE::HEX_HGRAD_2; 42 | else 43 | return FE::DUMMY; 44 | } 45 | else if ( ( topo == DTK_PYRAMID_5 ) && ( fe_type == DTK_HGRAD ) ) 46 | { 47 | return FE::PYR_HGRAD_1; 48 | } 49 | else if ( topo == DTK_QUAD_4 ) 50 | { 51 | switch ( fe_type ) 52 | { 53 | case DTK_HCURL: 54 | { 55 | return FE::QUAD_HCURL_1; 56 | } 57 | case DTK_HDIV: 58 | { 59 | return FE::QUAD_HDIV_1; 60 | } 61 | case DTK_HGRAD: 62 | { 63 | return FE::QUAD_HGRAD_1; 64 | } 65 | default: 66 | return FE::DUMMY; 67 | } 68 | } 69 | else if ( ( topo == DTK_QUAD_9 ) && ( fe_type == DTK_HGRAD ) ) 70 | { 71 | return FE::QUAD_HGRAD_2; 72 | } 73 | else if ( topo == DTK_TET_4 ) 74 | { 75 | switch ( fe_type ) 76 | { 77 | case DTK_HCURL: 78 | { 79 | return FE::TET_HCURL_1; 80 | } 81 | case DTK_HDIV: 82 | { 83 | return FE::TET_HDIV_1; 84 | } 85 | case DTK_HGRAD: 86 | { 87 | return FE::TET_HGRAD_1; 88 | } 89 | default: 90 | return FE::DUMMY; 91 | } 92 | } 93 | else if ( ( topo == DTK_TET_10 ) && ( fe_type == DTK_HGRAD ) ) 94 | { 95 | return FE::TET_HGRAD_2; 96 | } 97 | else if ( ( topo == DTK_TRI_3 ) && ( fe_type == DTK_HGRAD ) ) 98 | { 99 | return FE::TRI_HGRAD_1; 100 | } 101 | else if ( ( topo == DTK_TRI_6 ) && ( fe_type == DTK_HGRAD ) ) 102 | { 103 | return FE::TRI_HGRAD_2; 104 | } 105 | else if ( ( topo == DTK_WEDGE_6 ) && ( fe_type == DTK_HGRAD ) ) 106 | { 107 | return FE::WEDGE_HGRAD_1; 108 | } 109 | else if ( ( topo == DTK_WEDGE_18 ) && ( fe_type == DTK_HGRAD ) ) 110 | { 111 | return FE::WEDGE_HGRAD_2; 112 | } 113 | else 114 | return FE::DUMMY; 115 | } 116 | } // namespace DataTransferKit 117 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_FETypes.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file 13 | * \brief DTK supported finite element types. 14 | */ 15 | #ifndef DTK_FETYPES_H 16 | #define DTK_FETYPES_H 17 | 18 | /*! 19 | * \brief Finite element types enumeration. 20 | * 21 | * The following standard finite element types are supported by DTK. 22 | */ 23 | typedef enum { DTK_HGRAD = 0, DTK_HDIV, DTK_HCURL, DTK_N_FEM } DTK_FEType; 24 | 25 | #endif // DTK_FETYPES_H 26 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_InterpolationFunctor.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_INTERPOLATION_FUNCTOR_HPP 13 | #define DTK_INTERPOLATION_FUNCTOR_HPP 14 | 15 | #include 16 | #include 17 | 18 | namespace DataTransferKit 19 | { 20 | namespace Functor 21 | { 22 | template 23 | class Interpolation 24 | { 25 | public: 26 | Interpolation( unsigned int const dim, 27 | Kokkos::View reference_points, 28 | Kokkos::View cell_dofs_ids, 29 | Kokkos::View dof_values, 30 | Kokkos::View output ) 31 | : _dim( dim ) 32 | , _n_basis( cell_dofs_ids.extent( 1 ) ) 33 | , _n_fields( dof_values.extent( 1 ) ) 34 | , _basis_values( "basis_values", output.extent( 0 ), _n_basis, dim ) 35 | , _reference_points( reference_points ) 36 | , _cell_dofs_ids( cell_dofs_ids ) 37 | , _dof_values( dof_values ) 38 | , _output( output ) 39 | { 40 | DTK_REQUIRE( _output.extent( 1 ) == dof_values.extent( 1 ) ); 41 | } 42 | 43 | KOKKOS_INLINE_FUNCTION 44 | void operator()( int const i ) const 45 | { 46 | auto ref_point = Kokkos::subview( _reference_points, i, Kokkos::ALL() ); 47 | auto basis_values = 48 | Kokkos::subview( _basis_values, i, Kokkos::ALL(), Kokkos::ALL() ); 49 | BasisType::getValues( basis_values, ref_point ); 50 | 51 | for ( unsigned int j = 0; j < _n_basis; ++j ) 52 | for ( unsigned int d = 0; d < _dim; ++d ) 53 | for ( unsigned int k = 0; k < _n_fields; ++k ) 54 | _output( i, k ) += basis_values( j, d ) * 55 | _dof_values( _cell_dofs_ids( i, j ), k ); 56 | } 57 | 58 | private: 59 | unsigned int const _dim; 60 | unsigned int const _n_basis; 61 | unsigned int const _n_fields; 62 | Kokkos::DynRankView _basis_values; 63 | Kokkos::View _reference_points; 64 | Kokkos::View _cell_dofs_ids; 65 | Kokkos::View _dof_values; 66 | Kokkos::View _output; 67 | }; 68 | 69 | template 70 | class HgradInterpolation 71 | { 72 | public: 73 | HgradInterpolation( 74 | Kokkos::View reference_points, 75 | Kokkos::View cell_dofs_ids, 76 | Kokkos::View dof_values, 77 | Kokkos::View output ) 78 | : _n_basis( cell_dofs_ids.extent( 1 ) ) 79 | , _n_fields( dof_values.extent( 1 ) ) 80 | , _basis_values( "basis_values", output.extent( 0 ), _n_basis ) 81 | , _reference_points( reference_points ) 82 | , _cell_dofs_ids( cell_dofs_ids ) 83 | , _dof_values( dof_values ) 84 | , _output( output ) 85 | { 86 | DTK_REQUIRE( _output.extent( 1 ) == dof_values.extent( 1 ) ); 87 | } 88 | 89 | KOKKOS_INLINE_FUNCTION 90 | void operator()( int const i ) const 91 | { 92 | auto ref_point = Kokkos::subview( _reference_points, i, Kokkos::ALL() ); 93 | auto basis_values = Kokkos::subview( _basis_values, i, Kokkos::ALL() ); 94 | BasisType::getValues( basis_values, ref_point ); 95 | 96 | for ( unsigned int j = 0; j < _n_basis; ++j ) 97 | for ( unsigned int k = 0; k < _n_fields; ++k ) 98 | _output( i, k ) += basis_values( j ) * 99 | _dof_values( _cell_dofs_ids( i, j ), k ); 100 | } 101 | 102 | private: 103 | unsigned int _n_basis; 104 | unsigned int _n_fields; 105 | // We cannot use Scalar because in Basis_HGRAD_PYR_C1_FEM there is a 106 | // check that basis_values and ref_point have the same type. 107 | Kokkos::View _basis_values; 108 | Kokkos::View _reference_points; 109 | Kokkos::View _cell_dofs_ids; 110 | Kokkos::View _dof_values; 111 | Kokkos::View _output; 112 | }; 113 | } // namespace Functor 114 | } // namespace DataTransferKit 115 | 116 | #endif 117 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_Interpolation_def.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_INTERPOLATION_DEF_HPP 13 | #define DTK_INTERPOLATION_DEF_HPP 14 | 15 | #include 16 | #include 17 | 18 | namespace DataTransferKit 19 | { 20 | template 21 | Interpolation::Interpolation( 22 | MPI_Comm comm, Mesh const &mesh, 23 | Kokkos::View points_coordinates, 24 | Kokkos::View cell_dof_ids, DTK_FEType fe_type ) 25 | : _point_search( comm, mesh, points_coordinates ) 26 | { 27 | // Fill up _finite_element, i.e., fill up a map between topo_id and FE 28 | Topologies topologies; 29 | for ( unsigned int topo_id = 0; topo_id < DTK_N_TOPO; ++topo_id ) 30 | _finite_elements[topo_id] = getFE( topologies[topo_id].topo, fe_type ); 31 | 32 | // Change the format of cell_dofs_ids 33 | filter_dofs_ids( mesh.cell_topologies, cell_dof_ids, fe_type ); 34 | } 35 | 36 | template 37 | void Interpolation::filter_dofs_ids( 38 | Kokkos::View cell_topologies, 39 | Kokkos::View cell_dof_ids, DTK_FEType fe_type ) 40 | { 41 | // We need to filter the dof_ids and only keep the cells where a point 42 | // was found. Because multiple points may be in the same cells, the 43 | // cells may be duplicated. 44 | // TODO do this on the device 45 | auto cell_topologies_host = Kokkos::create_mirror_view( cell_topologies ); 46 | Kokkos::deep_copy( cell_topologies_host, cell_topologies ); 47 | 48 | unsigned int const n_cells = cell_topologies.extent( 0 ); 49 | // We need to compute the number of basis function for each cell because the 50 | // number of basis functions is different for HGRAD, HDIV, and HCURL. 51 | // Therefore, knowing the number of nodes in the topology is not enough. 52 | std::vector dof_offset( n_cells + 1 ); 53 | for ( unsigned int i = 0; i < n_cells; ++i ) 54 | { 55 | auto fe = getFE( cell_topologies_host( i ), fe_type ); 56 | dof_offset[i + 1] = dof_offset[i] + getCardinality( fe ); 57 | } 58 | 59 | auto cell_dof_ids_host = Kokkos::create_mirror_view( cell_dof_ids ); 60 | Kokkos::deep_copy( cell_dof_ids_host, cell_dof_ids ); 61 | std::array>, DTK_N_TOPO> 62 | filtered_dof_ids; 63 | // For each topo_id (finite element type) we reformat cell_dof_ids 64 | for ( unsigned int topo_id = 0; topo_id < DTK_N_TOPO; ++topo_id ) 65 | { 66 | unsigned int const n_dofs_per_cell = 67 | getCardinality( _finite_elements[topo_id] ); 68 | auto cell_indices_host = 69 | Kokkos::create_mirror_view( _point_search._cell_indices[topo_id] ); 70 | Kokkos::deep_copy( cell_indices_host, 71 | _point_search._cell_indices[topo_id] ); 72 | 73 | // For each cell which contains a target point, we reformat cell_dof_ids 74 | for ( unsigned int i = 0; 75 | i < _point_search._query_ids[topo_id].extent( 0 ); ++i ) 76 | { 77 | unsigned int const cell_id = 78 | _point_search 79 | ._cell_indices_map[topo_id][cell_indices_host( i )]; 80 | unsigned int const offset = dof_offset[cell_id]; 81 | std::vector current_cell_dof_ids( n_dofs_per_cell ); 82 | for ( unsigned int j = 0; j < n_dofs_per_cell; ++j ) 83 | current_cell_dof_ids[j] = cell_dof_ids_host( offset + j ); 84 | filtered_dof_ids[topo_id].push_back( current_cell_dof_ids ); 85 | } 86 | } 87 | 88 | // Copy in a Kokkos::View and then move it to the device 89 | for ( unsigned int topo_id = 0; topo_id < DTK_N_TOPO; ++topo_id ) 90 | { 91 | unsigned int const fe_n_cells = filtered_dof_ids[topo_id].size(); 92 | unsigned int const n_dofs_per_cell = 93 | ( fe_n_cells > 0 ) ? filtered_dof_ids[topo_id][0].size() : 0; 94 | _dofs_ids[topo_id] = Kokkos::View( 95 | "cell_dofs_ids_" + std::to_string( topo_id ), fe_n_cells, 96 | n_dofs_per_cell ); 97 | auto dofs_ids_host = Kokkos::create_mirror_view( _dofs_ids[topo_id] ); 98 | for ( unsigned int i = 0; i < fe_n_cells; ++i ) 99 | for ( unsigned int j = 0; j < n_dofs_per_cell; ++j ) 100 | dofs_ids_host( i, j ) = filtered_dof_ids[topo_id][i][j]; 101 | Kokkos::deep_copy( _dofs_ids[topo_id], dofs_ids_host ); 102 | } 103 | } 104 | 105 | } // namespace DataTransferKit 106 | 107 | // Explicit instantiation macro 108 | #define DTK_INTERPOLATION_INSTANT( NODE ) \ 109 | template class Interpolation; 110 | 111 | #endif 112 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_Mesh.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_MESH_HPP 13 | #define DTK_MESH_HPP 14 | 15 | #include 16 | 17 | #include 18 | 19 | namespace DataTransferKit 20 | { 21 | template 22 | struct Mesh 23 | { 24 | public: 25 | Mesh( Kokkos::View cell_topologies_, 26 | Kokkos::View cells_, 27 | Kokkos::View nodes_coordinates_ ) 28 | : cell_topologies( cell_topologies_ ) 29 | , cells( cells_ ) 30 | , nodes_coordinates( nodes_coordinates_ ) 31 | { 32 | } 33 | 34 | /// cell_topologies (n cells) 35 | Kokkos::View cell_topologies; 36 | /// Cells vertices associated to each cell (n cells * n vertices per cell) 37 | Kokkos::View cells; 38 | /// Nodes_coordinates coordinates of all the nodes in the mesh( n 39 | /// vertices, dim ) 40 | Kokkos::View nodes_coordinates; 41 | }; 42 | } // namespace DataTransferKit 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_PointInCellFunctor.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_POINT_IN_CELL_FUNCTOR_HPP 13 | #define DTK_POINT_IN_CELL_FUNCTOR_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace DataTransferKit 20 | { 21 | namespace Functor 22 | { 23 | template 24 | class PointInCell 25 | { 26 | public: 27 | PointInCell( double threshold, 28 | Kokkos::View physical_points, 29 | Kokkos::View cells, 30 | Kokkos::View coarse_search_output_cells, 31 | Kokkos::View reference_points, 32 | Kokkos::View point_in_cell ) 33 | : _threshold( threshold ) 34 | , _physical_points( physical_points ) 35 | , _cells( cells ) 36 | , _coarse_search_output_cells( coarse_search_output_cells ) 37 | , _reference_points( reference_points ) 38 | , _point_in_cell( point_in_cell ) 39 | { 40 | } 41 | 42 | KOKKOS_INLINE_FUNCTION 43 | void operator()( unsigned int const i ) const 44 | { 45 | // Extract the indices computed by the coarse search 46 | int const cell_index = _coarse_search_output_cells( i ); 47 | // Get the subviews corresponding the reference point (dim), the 48 | // physical point (dim), the current cell (nodes, dim) 49 | using ExecutionSpace = typename DeviceType::execution_space; 50 | Kokkos::View ref_point( 51 | _reference_points, i, Kokkos::ALL() ); 52 | Kokkos::View phys_point( 53 | _physical_points, i, Kokkos::ALL() ); 54 | Kokkos::View nodes( 55 | _cells, cell_index, Kokkos::ALL(), Kokkos::ALL() ); 56 | 57 | // Compute the reference point and return true if the 58 | // point is inside the cell 59 | Intrepid2::Impl::CellTools::Serial::mapToReferenceFrame< 60 | typename CellType::basis_type>( ref_point, phys_point, nodes ); 61 | _point_in_cell[i] = 62 | CellType::topo_type::checkPointInclusion( ref_point, _threshold ); 63 | } 64 | 65 | private: 66 | double _threshold; 67 | Kokkos::View _physical_points; 68 | Kokkos::View _cells; 69 | Kokkos::View _coarse_search_output_cells; 70 | Kokkos::View _reference_points; 71 | Kokkos::View _point_in_cell; 72 | }; 73 | } // namespace Functor 74 | } // namespace DataTransferKit 75 | 76 | #endif 77 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_PointInCell_decl.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_POINT_IN_CELL_DECL_HPP 13 | #define DTK_POINT_IN_CELL_DECL_HPP 14 | 15 | #include "DTK_ConfigDefs.hpp" 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | namespace DataTransferKit 22 | { 23 | template 24 | class PointInCell 25 | { 26 | public: 27 | /** 28 | * Performs the local search. 29 | * @param[in] physical_points The coordinates of the points in the 30 | * physical space (coarse_output_size, dim) 31 | * @param[in] cells Cells owned by the processor (n_cells, n_nodes, dim) 32 | * @param[in] coarse_search_output_cells Indices of local cells from the 33 | * coarse search (coarse_output_size) 34 | * @param[in] cell_topo Topology of the cells in \p cells 35 | * @param[out] reference_points The coordinates of the points in the 36 | * reference space (coarse_output_size, dim) 37 | * @param[out] point_in_cell Booleans with value true if the point is in 38 | * the cell and false otherwise (coarse_output_size) 39 | */ 40 | static void 41 | search( Kokkos::View physical_points, 42 | Kokkos::View cells, 43 | Kokkos::View coarse_search_output_cells, 44 | DTK_CellTopology cell_topo, 45 | Kokkos::View reference_points, 46 | Kokkos::View point_in_cell ); 47 | 48 | /** 49 | * Same function as above. However, the function is virtual so that the user 50 | * can provide their own implementation. If the function is not overriden, 51 | * it throws an exception. 52 | * @param[in] physical_points The coordinates of the points in the 53 | * physical space (coarse_output_size, dim) 54 | * @param[in] cells Cells owned by the processor (n_cells, n_nodes, dim) 55 | * @param[in] coarse_search_output_cells Indices of local cells from the 56 | * coarse search (coarse_output_size) 57 | * @param[in] cell_topo Topology of the cells in \p cells 58 | * @param[out] reference_points The coordinates of the points in the 59 | * reference space (coarse_output_size, dim) 60 | * @param[out] point_in_cell Booleans with value true if the point is in 61 | * the cell and false otherwise (coarse_output_size) 62 | */ 63 | virtual void 64 | search( Kokkos::View physical_points, 65 | Kokkos::View cells, 66 | Kokkos::View coarse_search_output_cells, 67 | std::string cell_topo, 68 | Kokkos::View reference_points, 69 | Kokkos::View point_in_cell ) 70 | { 71 | (void)physical_points; 72 | (void)cells; 73 | (void)coarse_search_output_cells; 74 | (void)cell_topo; 75 | (void)reference_points; 76 | (void)point_in_cell; 77 | 78 | throw DataTransferKitNotImplementedException(); 79 | } 80 | 81 | static double threshold; 82 | }; 83 | 84 | // Default value for threshold matches the inclusion tolerance in DTK-2.0 which 85 | // is arbitrary and might need adjustement in client code. See 86 | // https://github.com/ORNL-CEES/DataTransferKit/blob/dtk-2.0/packages/Adapters/Libmesh/src/DTK_LibmeshEntityLocalMap.cpp#L58 87 | template 88 | double PointInCell::threshold = 1e-6; 89 | } // namespace DataTransferKit 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_PointInCell_def.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_POINT_IN_CELL_DEF_HPP 13 | #define DTK_POINT_IN_CELL_DEF_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | namespace DataTransferKit 20 | { 21 | // Because search is static, we cannot use a private function so put the 22 | // function in its own namespace. 23 | namespace internal 24 | { 25 | template 26 | void pointInCell( double threshold, 27 | Kokkos::View physical_points, 28 | Kokkos::View cells, 29 | Kokkos::View coarse_search_output_cells, 30 | Kokkos::View reference_points, 31 | Kokkos::View point_in_cell ) 32 | { 33 | using ExecutionSpace = typename DeviceType::execution_space; 34 | int const n_ref_pts = reference_points.extent( 0 ); 35 | 36 | // Functor::PointInCell uses Intrepid2 which assumme that the coordinates of 37 | // the point is double not float. 38 | Kokkos::View physical_dp_points( 39 | "physical_dp_points", physical_points.extent( 0 ), 40 | physical_points.extent( 1 ) ); 41 | Kokkos::deep_copy( physical_dp_points, physical_points ); 42 | Kokkos::View dp_cells( 43 | "dp_cells", cells.extent( 0 ), cells.extent( 1 ), cells.extent( 2 ) ); 44 | Kokkos::deep_copy( dp_cells, cells ); 45 | Kokkos::View reference_dp_points( 46 | "reference_dp_points", reference_points.extent( 0 ), 47 | reference_points.extent( 1 ) ); 48 | Kokkos::deep_copy( reference_dp_points, reference_points ); 49 | 50 | Functor::PointInCell search_functor( 51 | threshold, physical_dp_points, dp_cells, coarse_search_output_cells, 52 | reference_dp_points, point_in_cell ); 53 | Kokkos::parallel_for( DTK_MARK_REGION( "point_in_cell" ), 54 | Kokkos::RangePolicy( 0, n_ref_pts ), 55 | search_functor ); 56 | 57 | Kokkos::deep_copy( physical_points, physical_dp_points ); 58 | Kokkos::deep_copy( cells, dp_cells ); 59 | Kokkos::deep_copy( reference_points, reference_dp_points ); 60 | } 61 | } // namespace internal 62 | 63 | template 64 | void PointInCell::search( 65 | Kokkos::View physical_points, 66 | Kokkos::View cells, 67 | Kokkos::View coarse_search_output_cells, 68 | DTK_CellTopology cell_topo, 69 | Kokkos::View reference_points, 70 | Kokkos::View point_in_cell ) 71 | { 72 | // Check the size of the Views 73 | DTK_REQUIRE( reference_points.extent( 0 ) == point_in_cell.extent( 0 ) ); 74 | DTK_REQUIRE( reference_points.extent( 0 ) == physical_points.extent( 0 ) ); 75 | DTK_REQUIRE( reference_points.extent( 1 ) == physical_points.extent( 1 ) ); 76 | DTK_REQUIRE( reference_points.extent( 1 ) == cells.extent( 2 ) ); 77 | 78 | // Perform the point in cell search. We hide the template parameters used by 79 | // Intrepid2, using the CellType template. 80 | // Note that if the Newton solver does not converge, Intrepid2 will just 81 | // return the last results and there is no way to know that the coordinates 82 | // in the reference frames where not found. 83 | switch ( cell_topo ) 84 | { 85 | case DTK_HEX_8: 86 | { 87 | internal::pointInCell( 88 | threshold, physical_points, cells, coarse_search_output_cells, 89 | reference_points, point_in_cell ); 90 | break; 91 | } 92 | case DTK_HEX_27: 93 | { 94 | internal::pointInCell( 95 | threshold, physical_points, cells, coarse_search_output_cells, 96 | reference_points, point_in_cell ); 97 | break; 98 | } 99 | case DTK_PYRAMID_5: 100 | { 101 | internal::pointInCell( 102 | threshold, physical_points, cells, coarse_search_output_cells, 103 | reference_points, point_in_cell ); 104 | break; 105 | } 106 | case DTK_QUAD_4: 107 | { 108 | internal::pointInCell( 109 | threshold, physical_points, cells, coarse_search_output_cells, 110 | reference_points, point_in_cell ); 111 | break; 112 | } 113 | case DTK_QUAD_9: 114 | { 115 | internal::pointInCell( 116 | threshold, physical_points, cells, coarse_search_output_cells, 117 | reference_points, point_in_cell ); 118 | break; 119 | } 120 | case DTK_TET_4: 121 | { 122 | internal::pointInCell( 123 | threshold, physical_points, cells, coarse_search_output_cells, 124 | reference_points, point_in_cell ); 125 | break; 126 | } 127 | case DTK_TET_10: 128 | { 129 | internal::pointInCell( 130 | threshold, physical_points, cells, coarse_search_output_cells, 131 | reference_points, point_in_cell ); 132 | break; 133 | } 134 | case DTK_TRI_3: 135 | { 136 | internal::pointInCell( 137 | threshold, physical_points, cells, coarse_search_output_cells, 138 | reference_points, point_in_cell ); 139 | break; 140 | } 141 | case DTK_TRI_6: 142 | { 143 | internal::pointInCell( 144 | threshold, physical_points, cells, coarse_search_output_cells, 145 | reference_points, point_in_cell ); 146 | break; 147 | } 148 | case DTK_WEDGE_6: 149 | { 150 | internal::pointInCell( 151 | threshold, physical_points, cells, coarse_search_output_cells, 152 | reference_points, point_in_cell ); 153 | break; 154 | } 155 | case DTK_WEDGE_18: 156 | { 157 | internal::pointInCell( 158 | threshold, physical_points, cells, coarse_search_output_cells, 159 | reference_points, point_in_cell ); 160 | break; 161 | } 162 | default: 163 | { 164 | throw DataTransferKitNotImplementedException(); 165 | } 166 | } 167 | Kokkos::fence(); 168 | } 169 | } // namespace DataTransferKit 170 | 171 | // Explicit instantiation macro 172 | #define DTK_POINTINCELL_INSTANT( NODE ) \ 173 | template class PointInCell; 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_PointSearch_decl.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_POINT_SEARCH_DECL_HPP 13 | #define DTK_POINT_SEARCH_DECL_HPP 14 | 15 | #include "DTK_ConfigDefs.hpp" 16 | #include 17 | #include 18 | #include 19 | 20 | #include 21 | 22 | #include 23 | 24 | #include 25 | #include 26 | 27 | namespace DataTransferKit 28 | { 29 | /** 30 | * This class performs the search of a set of given points in a given mesh and 31 | * returns the cell(s) on which each point has been found as well as the 32 | * position of the points in the reference frame. 33 | */ 34 | template 35 | class PointSearch 36 | { 37 | public: 38 | /** 39 | * Constructor. The search of the points is done in the constructor but 40 | * the results is not send back to the calling processor. 41 | * @param comm 42 | * @param mesh mesh of the domain of interest 43 | * @param points_coordinates coordinates in the physical frame of the points 44 | * that we are looking for. 45 | * For a more detailed documentation on \p cell_topologies, \p 46 | * cells, and \p nodes_coordinates see the documentation of CellList. 47 | */ 48 | PointSearch( MPI_Comm comm, Mesh const &mesh, 49 | Kokkos::View points_coordinates ); 50 | 51 | /** 52 | * Return the result of the search. The tuple contains the rank where the 53 | * points are found, the cell indices associated to the points (local IDs), 54 | * the coordinates of the points in the frame of reference, and the query 55 | * ids associated to each point. 56 | */ 57 | std::tuple, Kokkos::View, 58 | Kokkos::View, 59 | Kokkos::View> 60 | getSearchResults() const; 61 | 62 | /** 63 | * Perform the distributed search and sends the points and the cell indices 64 | * to the processors owning the cells. 65 | * 66 | * @note This function should be private but lambda functions can 67 | * only be called from a public function in CUDA. 68 | */ 69 | std::tuple, 70 | Kokkos::View, Kokkos::View, 71 | Kokkos::View> 72 | performDistributedSearch( 73 | Kokkos::View points_coord, 74 | Kokkos::View bounding_boxes ); 75 | 76 | /** 77 | * Keep cell_indices, points, query_ids, and ranks that satisfy a given 78 | * topology. 79 | * 80 | * @note This function should be private but lambda functions can 81 | * only be called from a public function in CUDA. 82 | */ 83 | std::tuple, 84 | Kokkos::View, 85 | Kokkos::View, Kokkos::View> 86 | filterTopology( 87 | Kokkos::View topo, unsigned int topo_id, 88 | unsigned int size, 89 | Kokkos::View bounding_box_to_cell, 90 | Kokkos::View cell_indices, 91 | Kokkos::View points, 92 | Kokkos::View query_ids, 93 | Kokkos::View ranks ); 94 | 95 | /** 96 | * Keep data corresponding to points found inside the reference cell. 97 | * 98 | * @note This function should be private but lambda functions can 99 | * only be called from a public function in CUDA. 100 | */ 101 | Kokkos::View filterInCell( 102 | Kokkos::View filtered_per_topo_point_in_cell, 103 | Kokkos::View 104 | filtered_per_topo_reference_points, 105 | Kokkos::View filtered_per_topo_cell_indices, 106 | Kokkos::View filtered_per_topo_query_ids, 107 | Kokkos::View filtered_per_topo_ranks, 108 | unsigned int topo_id ); 109 | 110 | private: 111 | /** 112 | * Compute the number of cells associated to each topology. 113 | */ 114 | std::array computeNCellsPerTopology( 115 | Kokkos::View cell_topologies ); 116 | 117 | /** 118 | * Compute the position in the reference frame of candidates found by the 119 | * search. 120 | */ 121 | Kokkos::View performPointInCell( 122 | Kokkos::View cells, 123 | Kokkos::View bounding_box_to_cell, 124 | Kokkos::View imported_cell_indices, 125 | Kokkos::View imported_points, 126 | Kokkos::View imported_query_ids, 127 | Kokkos::View imported_ranks, 128 | Kokkos::View topo, unsigned int topo_id, 129 | unsigned int size ); 130 | 131 | /** 132 | * Build the target-to-source distributor. 133 | */ 134 | void build_distributor( std::array, 135 | DTK_N_TOPO> const &filtered_ranks ); 136 | 137 | template 138 | friend class Interpolation; 139 | 140 | MPI_Comm _comm; 141 | ArborX::Details::Distributor _target_to_source_distributor; 142 | unsigned int _dim; 143 | std::array, DTK_N_TOPO> 144 | _reference_points; 145 | std::array, DTK_N_TOPO> _query_ids; 146 | std::array, DTK_N_TOPO> _cell_indices; 147 | std::array, DTK_N_TOPO> _cell_indices_map; 148 | }; 149 | } // namespace DataTransferKit 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /packages/Discretization/src/DTK_Topology.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_TOPOLOGY_HPP 13 | #define DTK_TOPOLOGY_HPP 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | #include 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | 31 | namespace DataTransferKit 32 | { 33 | struct Topology 34 | { 35 | Topology() = default; 36 | 37 | Topology( unsigned int d, unsigned int n, DTK_CellTopology t ) 38 | : dim( d ) 39 | , n_nodes( n ) 40 | , topo( t ) 41 | { 42 | } 43 | 44 | unsigned int dim; 45 | unsigned int n_nodes; 46 | DTK_CellTopology topo; 47 | }; 48 | 49 | class Topologies 50 | { 51 | public: 52 | Topologies() 53 | { 54 | _topologies[DTK_TRI_3] = Topology( 2, 3, DTK_TRI_3 ); 55 | _topologies[DTK_TRI_6] = Topology( 2, 6, DTK_TRI_6 ); 56 | _topologies[DTK_QUAD_4] = Topology( 2, 4, DTK_QUAD_4 ); 57 | _topologies[DTK_QUAD_9] = Topology( 2, 9, DTK_QUAD_9 ); 58 | _topologies[DTK_TET_4] = Topology( 3, 4, DTK_TET_4 ); 59 | _topologies[DTK_TET_10] = Topology( 3, 10, DTK_TET_10 ); 60 | _topologies[DTK_TET_11] = Topology( 3, 11, DTK_TET_11 ); 61 | _topologies[DTK_HEX_8] = Topology( 3, 8, DTK_HEX_8 ); 62 | _topologies[DTK_HEX_20] = Topology( 3, 20, DTK_HEX_20 ); 63 | _topologies[DTK_HEX_27] = Topology( 3, 27, DTK_HEX_27 ); 64 | _topologies[DTK_PYRAMID_5] = Topology( 3, 5, DTK_PYRAMID_5 ); 65 | _topologies[DTK_PYRAMID_13] = Topology( 3, 13, DTK_PYRAMID_13 ); 66 | _topologies[DTK_WEDGE_6] = Topology( 3, 6, DTK_WEDGE_6 ); 67 | _topologies[DTK_WEDGE_15] = Topology( 3, 15, DTK_WEDGE_15 ); 68 | _topologies[DTK_WEDGE_18] = Topology( 3, 18, DTK_WEDGE_18 ); 69 | } 70 | 71 | Topology &operator[]( int const i ) { return _topologies[i]; } 72 | Topology const &operator[]( int const i ) const { return _topologies[i]; } 73 | 74 | private: 75 | std::array _topologies; 76 | }; 77 | 78 | struct HEX_8 79 | { 80 | typedef Intrepid2::Impl::Basis_HGRAD_HEX_C1_FEM basis_type; 81 | typedef Intrepid2::Impl::Hexahedron<8> topo_type; 82 | }; 83 | 84 | struct HEX_27 85 | { 86 | typedef Intrepid2::Impl::Basis_HGRAD_HEX_DEG2_FEM basis_type; 87 | typedef Intrepid2::Impl::Hexahedron<27> topo_type; 88 | }; 89 | 90 | struct PYRAMID_5 91 | { 92 | typedef Intrepid2::Impl::Basis_HGRAD_PYR_C1_FEM basis_type; 93 | typedef Intrepid2::Impl::Pyramid<5> topo_type; 94 | }; 95 | 96 | struct QUAD_4 97 | { 98 | typedef Intrepid2::Impl::Basis_HGRAD_QUAD_C1_FEM basis_type; 99 | typedef Intrepid2::Impl::Quadrilateral<4> topo_type; 100 | }; 101 | 102 | struct QUAD_9 103 | { 104 | typedef Intrepid2::Impl::Basis_HGRAD_QUAD_DEG2_FEM basis_type; 105 | typedef Intrepid2::Impl::Quadrilateral<9> topo_type; 106 | }; 107 | 108 | struct TET_4 109 | { 110 | typedef Intrepid2::Impl::Basis_HGRAD_TET_C1_FEM basis_type; 111 | typedef Intrepid2::Impl::Tetrahedron<4> topo_type; 112 | }; 113 | 114 | struct TET_10 115 | { 116 | typedef Intrepid2::Impl::Basis_HGRAD_TET_C2_FEM basis_type; 117 | typedef Intrepid2::Impl::Tetrahedron<10> topo_type; 118 | }; 119 | 120 | struct TRI_3 121 | { 122 | typedef Intrepid2::Impl::Basis_HGRAD_TRI_C1_FEM basis_type; 123 | typedef Intrepid2::Impl::Triangle<3> topo_type; 124 | }; 125 | 126 | struct TRI_6 127 | { 128 | typedef Intrepid2::Impl::Basis_HGRAD_TRI_C2_FEM basis_type; 129 | typedef Intrepid2::Impl::Triangle<6> topo_type; 130 | }; 131 | 132 | struct WEDGE_6 133 | { 134 | typedef Intrepid2::Impl::Basis_HGRAD_WEDGE_C1_FEM basis_type; 135 | typedef Intrepid2::Impl::Wedge<6> topo_type; 136 | }; 137 | 138 | struct WEDGE_18 139 | { 140 | typedef Intrepid2::Impl::Basis_HGRAD_WEDGE_DEG2_FEM basis_type; 141 | typedef Intrepid2::Impl::Wedge<18> topo_type; 142 | }; 143 | } // namespace DataTransferKit 144 | 145 | #endif 146 | -------------------------------------------------------------------------------- /packages/Discretization/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##---------------------------------------------------------------------------## 2 | ## TESTS 3 | ##---------------------------------------------------------------------------## 4 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 5 | Interpolation 6 | SOURCES tstInterpolation.cpp unit_test_main.cpp 7 | COMM serial mpi 8 | NUM_MPI_PROCS 4 9 | STANDARD_PASS_OUTPUT 10 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 11 | ENVIRONMENT CUDA_LAUNCH_BLOCKING=1 12 | ) 13 | 14 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 15 | PointInCell 16 | SOURCES tstPointInCell.cpp unit_test_main.cpp 17 | COMM serial mpi 18 | NUM_MPI_PROCS 1 19 | STANDARD_PASS_OUTPUT 20 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 21 | ) 22 | 23 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 24 | MeshGenerator 25 | SOURCES tstMeshGenerator.cpp unit_test_main.cpp 26 | COMM serial mpi 27 | NUM_MPI_PROCS 4 28 | STANDARD_PASS_OUTPUT 29 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 30 | ) 31 | TRIBITS_COPY_FILES_TO_BINARY_DIR( 32 | test 33 | SOURCE_FILES structured_2d.txt structured_3d.txt mixed_2d.txt mixed_3d.txt 34 | ) 35 | 36 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 37 | PointSearch 38 | SOURCES tstPointSearch.cpp unit_test_main.cpp 39 | COMM serial mpi 40 | NUM_MPI_PROCS 4 41 | STANDARD_PASS_OUTPUT 42 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 43 | ) 44 | -------------------------------------------------------------------------------- /packages/Discretization/test/mixed_2d.txt: -------------------------------------------------------------------------------- 1 | 2 10 2 | 0.0 0.0 3 | 1.5 0.0 4 | 3.0 0.0 5 | 0.0 1.0 6 | 1.0 1.0 7 | 2.0 1.0 8 | 3.0 1.0 9 | 0.0 2.0 10 | 1.5 2.0 11 | 3.0 2.0 12 | 6 13 | 4 0 1 4 3 14 | 3 1 5 4 15 | 4 1 2 6 5 16 | 4 3 4 8 7 17 | 3 4 5 8 18 | 4 5 6 9 8 19 | -------------------------------------------------------------------------------- /packages/Discretization/test/mixed_3d.txt: -------------------------------------------------------------------------------- 1 | 3 19 2 | 0.0 0.0 0.0 3 | 1.5 0.0 0.0 4 | 3.0 0.0 0.0 5 | 0.0 1.0 0.0 6 | 1.0 1.0 0.0 7 | 2.0 1.0 0.0 8 | 3.0 1.0 0.0 9 | 0.0 2.0 0.0 10 | 1.5 2.0 0.0 11 | 3.0 2.0 0.0 12 | 0.0 0.0 1.0 13 | 1.5 0.0 1.0 14 | 3.0 0.0 1.0 15 | 0.0 1.0 1.0 16 | 1.5 1.0 1.0 17 | 3.0 1.0 1.0 18 | 0.0 2.0 1.0 19 | 1.5 2.0 1.0 20 | 3.0 2.0 1.0 21 | 6 22 | 8 0 1 4 3 10 11 14 13 23 | 4 1 5 4 11 24 | 8 1 2 6 5 11 12 15 14 25 | 8 3 4 8 7 13 14 17 16 26 | 4 4 5 8 17 27 | 8 5 6 9 8 14 15 18 17 28 | -------------------------------------------------------------------------------- /packages/Discretization/test/structured_2d.txt: -------------------------------------------------------------------------------- 1 | 2 20 2 | 0.0 0.0 3 | 1.0 0.0 4 | 2.0 0.0 5 | 3.0 0.0 6 | 4.0 0.0 7 | 0.0 1.0 8 | 1.0 1.0 9 | 2.0 1.0 10 | 3.0 1.0 11 | 4.0 1.0 12 | 0.0 2.0 13 | 1.0 2.0 14 | 2.0 2.0 15 | 3.0 2.0 16 | 4.0 2.0 17 | 0.0 3.0 18 | 1.0 3.0 19 | 2.0 3.0 20 | 3.0 3.0 21 | 4.0 3.0 22 | 12 23 | 4 0 1 6 5 24 | 4 1 2 7 6 25 | 4 2 3 8 7 26 | 4 3 4 9 8 27 | 4 5 6 11 10 28 | 4 6 7 12 11 29 | 4 7 8 13 12 30 | 4 8 9 14 13 31 | 4 10 11 16 15 32 | 4 11 12 17 16 33 | 4 12 13 18 17 34 | 4 13 14 19 18 35 | -------------------------------------------------------------------------------- /packages/Discretization/test/structured_3d.txt: -------------------------------------------------------------------------------- 1 | 3 60 2 | 0.0 0.0 0.0 3 | 1.0 0.0 0.0 4 | 2.0 0.0 0.0 5 | 0.0 1.0 0.0 6 | 1.0 1.0 0.0 7 | 2.0 1.0 0.0 8 | 0.0 2.0 0.0 9 | 1.0 2.0 0.0 10 | 2.0 2.0 0.0 11 | 0.0 3.0 0.0 12 | 1.0 3.0 0.0 13 | 2.0 3.0 0.0 14 | 0.0 0.0 1.0 15 | 1.0 0.0 1.0 16 | 2.0 0.0 1.0 17 | 0.0 1.0 1.0 18 | 1.0 1.0 1.0 19 | 2.0 1.0 1.0 20 | 0.0 2.0 1.0 21 | 1.0 2.0 1.0 22 | 2.0 2.0 1.0 23 | 0.0 3.0 1.0 24 | 1.0 3.0 1.0 25 | 2.0 3.0 1.0 26 | 0.0 0.0 2.0 27 | 1.0 0.0 2.0 28 | 2.0 0.0 2.0 29 | 0.0 1.0 2.0 30 | 1.0 1.0 2.0 31 | 2.0 1.0 2.0 32 | 0.0 2.0 2.0 33 | 1.0 2.0 2.0 34 | 2.0 2.0 2.0 35 | 0.0 3.0 2.0 36 | 1.0 3.0 2.0 37 | 2.0 3.0 2.0 38 | 0.0 0.0 3.0 39 | 1.0 0.0 3.0 40 | 2.0 0.0 3.0 41 | 0.0 1.0 3.0 42 | 1.0 1.0 3.0 43 | 2.0 1.0 3.0 44 | 0.0 2.0 3.0 45 | 1.0 2.0 3.0 46 | 2.0 2.0 3.0 47 | 0.0 3.0 3.0 48 | 1.0 3.0 3.0 49 | 2.0 3.0 3.0 50 | 0.0 0.0 4.0 51 | 1.0 0.0 4.0 52 | 2.0 0.0 4.0 53 | 0.0 1.0 4.0 54 | 1.0 1.0 4.0 55 | 2.0 1.0 4.0 56 | 0.0 2.0 4.0 57 | 1.0 2.0 4.0 58 | 2.0 2.0 4.0 59 | 0.0 3.0 4.0 60 | 1.0 3.0 4.0 61 | 2.0 3.0 4.0 62 | 24 63 | 8 0 1 4 3 12 13 16 15 64 | 8 1 2 5 4 13 14 17 16 65 | 8 3 4 7 6 15 16 19 18 66 | 8 4 5 8 7 16 17 20 19 67 | 8 6 7 10 9 18 19 22 21 68 | 8 7 8 11 10 19 20 23 22 69 | 8 12 13 16 15 24 25 28 27 70 | 8 13 14 17 16 25 26 29 28 71 | 8 15 16 19 18 27 28 31 30 72 | 8 16 17 20 19 28 29 32 31 73 | 8 18 19 22 21 30 31 34 33 74 | 8 19 20 23 22 31 32 35 34 75 | 8 24 25 28 27 36 37 40 39 76 | 8 25 26 29 28 37 38 41 40 77 | 8 27 28 31 30 39 40 43 42 78 | 8 28 29 32 31 40 41 44 43 79 | 8 30 31 34 33 42 43 46 45 80 | 8 31 32 35 34 43 44 47 46 81 | 8 36 37 40 39 48 49 52 51 82 | 8 37 38 41 40 49 50 53 52 83 | 8 39 40 43 42 51 52 55 54 84 | 8 40 41 44 43 52 53 56 55 85 | 8 42 43 46 45 54 55 58 57 86 | 8 43 44 47 46 55 56 59 58 87 | -------------------------------------------------------------------------------- /packages/Discretization/test/unit_test_main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | int main( int argc, char *argv[] ) 18 | { 19 | Teuchos::GlobalMPISession mpiSession( &argc, &argv ); 20 | Teuchos::UnitTestRepository::setGloballyReduceTestResult( true ); 21 | Kokkos::initialize( argc, argv ); 22 | int return_val = 23 | Teuchos::UnitTestRepository::runUnitTestsFromMain( argc, argv ); 24 | Kokkos::finalize(); 25 | return return_val; 26 | } 27 | -------------------------------------------------------------------------------- /packages/Meshfree/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(src) 2 | 3 | TRIBITS_ADD_TEST_DIRECTORIES(test) 4 | -------------------------------------------------------------------------------- /packages/Meshfree/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | INCLUDE(TribitsCreateClientTemplateHeaders) 2 | 3 | # 4 | # A) Package-specific configuration options 5 | # 6 | 7 | # 8 | # B) Define the header and source files (and directories) 9 | # 10 | 11 | SET(HEADERS "") 12 | SET(SOURCES "") 13 | 14 | SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_SOURCE_DIR}) 15 | APPEND_GLOB(HEADERS ${DIR}/*.h) 16 | APPEND_GLOB(HEADERS ${DIR}/*.hpp) 17 | APPEND_GLOB(SOURCES ${DIR}/*.cpp) 18 | TRIBITS_CREATE_CLIENT_TEMPLATE_HEADERS(${DIR}) 19 | 20 | 21 | # Must glob the binary dir last to get all of the auto-generated headers 22 | SET_AND_INC_DIRS(DIR ${CMAKE_CURRENT_BINARY_DIR}) 23 | APPEND_GLOB(HEADERS ${DIR}/*.hpp) 24 | APPEND_SET(HEADERS ${PACKAGE_BINARY_DIR}/${PACKAGE_NAME}_config.hpp) 25 | APPEND_SET(HEADERS ${PACKAGE_BINARY_DIR}/${PACKAGE_NAME}_ETIHelperMacros.h) 26 | 27 | # Explicitly instantiate classes. 28 | IF (${PACKAGE_NAME}_ENABLE_EXPLICIT_INSTANTIATION) 29 | 30 | # Generate ETI .cpp files for DataTransferKit::NearestNeighborOperator 31 | DTK_PROCESS_ALL_N_TEMPLATES(NEARESTNEIGHBOROPERATOR_OUTPUT_FILES 32 | "DTK_ETI_NT.tmpl" "NearestNeighborOperator" "NEARESTNEIGHBOROPERATOR" 33 | "${${PACKAGE_NAME}_ETI_NODES}" TRUE) 34 | LIST(APPEND SOURCES ${NEARESTNEIGHBOROPERATOR_OUTPUT_FILES}) 35 | 36 | # Generate ETI .cpp files for DataTransferKit::MovingLeastSquaresOperator 37 | DTK_PROCESS_ALL_N_TEMPLATES(MOVINGLEASTSQUARESOPERATOR_OUTPUT_FILES 38 | "DTK_ETI_NT.tmpl" "MovingLeastSquaresOperator" "MOVING_LEAST_SQUARES_OPERATOR" 39 | "${${PACKAGE_NAME}_ETI_NODES}" TRUE) 40 | LIST(APPEND SOURCES ${MOVINGLEASTSQUARESOPERATOR_OUTPUT_FILES}) 41 | 42 | # Generate ETI .cpp files for DataTransferKit::SplineOperator 43 | DTK_PROCESS_ALL_N_TEMPLATES(SPLINEOPERATOR_OUTPUT_FILES 44 | "DTK_ETI_NT.tmpl" "SplineOperator" "SPLINE_OPERATOR" 45 | "${${PACKAGE_NAME}_ETI_NODES}" TRUE) 46 | LIST(APPEND SOURCES ${SPLINEOPERATOR_OUTPUT_FILES}) 47 | 48 | ENDIF() 49 | 50 | # 51 | # C) Define the targets for package's library(s) 52 | # 53 | 54 | TRIBITS_ADD_LIBRARY( 55 | dtk_meshfree 56 | HEADERS ${HEADERS} 57 | SOURCES ${SOURCES} 58 | DEPLIBS dtk_utils dtk_search 59 | ADDED_LIB_TARGET_NAME_OUT DTK_MESHFREE_LIBNAME 60 | ) 61 | 62 | # We need to set the linker language explicitly here for CUDA builds. 63 | SET_PROPERTY( 64 | TARGET ${DTK_MESHFREE_LIBNAME} 65 | APPEND PROPERTY LINKER_LANGUAGE CXX 66 | ) 67 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_CompactlySupportedRadialBasisFunctions.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_COMPACTLY_SUPPORTED_RADIAL_BASIS_FUNCTIONS_HPP 13 | #define DTK_COMPACTLY_SUPPORTED_RADIAL_BASIS_FUNCTIONS_HPP 14 | 15 | #include 16 | 17 | #include // log, sqrt 18 | 19 | namespace DataTransferKit 20 | { 21 | 22 | template 23 | class RadialBasisFunction 24 | { 25 | public: 26 | KOKKOS_FUNCTION 27 | RadialBasisFunction( double radius ) 28 | : _radius( radius ) 29 | { 30 | // FIXME check precondition radius is greater than zero 31 | } 32 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 33 | { 34 | return _rbf( x / _radius ); 35 | } 36 | 37 | private: 38 | double _radius; 39 | RBF _rbf; 40 | }; 41 | 42 | template 43 | struct Wendland; 44 | 45 | template <> 46 | struct Wendland<0> 47 | { 48 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 49 | { 50 | return ( 1.0 - x ) * ( 1.0 - x ); 51 | } 52 | }; 53 | 54 | template <> 55 | struct Wendland<2> 56 | { 57 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 58 | { 59 | return ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * 60 | ( 4.0 * x + 1.0 ); 61 | } 62 | }; 63 | 64 | template <> 65 | struct Wendland<4> 66 | { 67 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 68 | { 69 | return ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * 70 | ( 1.0 - x ) * ( 1.0 - x ) * ( 35.0 * x * x + 18.0 * x + 3.0 ); 71 | } 72 | }; 73 | 74 | template <> 75 | struct Wendland<6> 76 | { 77 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 78 | { 79 | return ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * 80 | ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * 81 | ( 32.0 * x * x * x + 25.0 * x * x + 8.0 * x + 1.0 ); 82 | } 83 | }; 84 | 85 | template 86 | struct Wu; 87 | 88 | template <> 89 | struct Wu<2> 90 | { 91 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 92 | { 93 | return ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * 94 | ( 3.0 * x * x * x + 12.0 * x * x + 16.0 * x + 4.0 ); 95 | } 96 | }; 97 | 98 | template <> 99 | struct Wu<4> 100 | { 101 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 102 | { 103 | return ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * ( 1.0 - x ) * 104 | ( 1.0 - x ) * ( 1.0 - x ) * 105 | ( 5.0 * x * x * x * x * x + 30.0 * x * x * x * x + 106 | 72.0 * x * x * x + 82.0 * x * x + 36.0 * x + 6.0 ); 107 | } 108 | }; 109 | 110 | template 111 | struct Buhmann; 112 | 113 | template <> 114 | struct Buhmann<2> 115 | { 116 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 117 | { 118 | return 2.0 * x * x * x * x * log( x ) - 7.0 / 2.0 * x * x * x * x + 119 | 16 / 3.0 * x * x * x - 2 * x * x + 1.0 / 6.0; 120 | } 121 | }; 122 | 123 | template <> 124 | struct Buhmann<3> 125 | { 126 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 127 | { 128 | return x * x * x * x * x * x * x * x - 129 | 84.0 / 5.0 * x * x * x * x * x * x + 130 | 1024.0 / 5.0 * x * x * x * x * sqrt( x ) - 131 | 378.0 * x * x * x * x + 1024.0 / 5.0 * x * x * x * sqrt( x ) - 132 | 84.0 / 5.0 * x * x + 1.0; 133 | } 134 | }; 135 | 136 | template <> 137 | struct Buhmann<4> 138 | { 139 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const 140 | { 141 | return 99.0 / 35.0 * x * x * x * x * x * x * x * x - 142 | 132.0 * x * x * x * x * x * x + 143 | 9216.0 / 35.0 * x * x * x * x * x * sqrt( x ) - 144 | 11264.0 / 35.0 * x * x * x * x * sqrt( x ) + 145 | 198.0 * x * x * x * x - 396.0 / 5.0 * x * x + 1.0; 146 | } 147 | }; 148 | 149 | } // namespace DataTransferKit 150 | 151 | #endif 152 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_DetailsSplineProlongationOperator.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_SPLINE_PROLONGATION_OPERATOR_HPP 13 | #define DTK_SPLINE_PROLONGATION_OPERATOR_HPP 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | #include 25 | 26 | namespace DataTransferKit 27 | { 28 | 29 | template 31 | class SplineProlongationOperator 32 | : public Tpetra::Operator 33 | { 34 | using Map = Tpetra::Map; 35 | using MultiVector = 36 | Tpetra::MultiVector; 37 | 38 | public: 39 | // Constructor. 40 | SplineProlongationOperator( const int num_polynomial_dofs, 41 | const Teuchos::RCP &domain_map ) 42 | : _domain_map( domain_map ) 43 | { 44 | // Create a range map. 45 | Teuchos::ArrayView domain_elements = 46 | _domain_map->getLocalElementList(); 47 | _lda = domain_elements.size(); 48 | 49 | const auto old_size = domain_elements.size(); 50 | Teuchos::Array global_ids( old_size + 51 | num_polynomial_dofs ); 52 | if ( _domain_map->getComm()->getRank() == 0 ) 53 | { 54 | GlobalOrdinal max_id = _domain_map->getMaxAllGlobalIndex() + 1; 55 | 56 | global_ids( 0, old_size ).assign( domain_elements ); 57 | for ( int i = 0; i < num_polynomial_dofs; ++i ) 58 | { 59 | global_ids[old_size + i] = max_id + i; 60 | } 61 | domain_elements = global_ids(); 62 | } 63 | _range_map = Tpetra::createNonContigMapWithNode( 65 | domain_elements, _domain_map->getComm() ); 66 | DTK_ENSURE( Teuchos::nonnull( _range_map ) ); 67 | } 68 | 69 | //! The Map associated with the domain of this operator, which must be 70 | //! compatible with X.getMap(). 71 | Teuchos::RCP getDomainMap() const override 72 | { 73 | return _domain_map; 74 | } 75 | 76 | //! The Map associated with the range of this operator, which must be 77 | //! compatible with Y.getMap(). 78 | Teuchos::RCP getRangeMap() const override { return _range_map; } 79 | 80 | //! \brief Computes the operator-multivector application. 81 | /*! Loosely, performs \f$Y = \alpha \cdot A^{\textrm{mode}} \cdot X + 82 | \beta \cdot Y\f$. However, the details of operation vary according to 83 | the values of \c alpha and \c beta. Specifically - if beta == 84 | 0, apply() must overwrite \c Y, so that any values in \c Y 85 | (including NaNs) are ignored. - if alpha == 0, apply() 86 | may short-circuit the operator, so that any values in \c X 87 | (including NaNs) are ignored. 88 | */ 89 | void 90 | apply( const MultiVector &X, MultiVector &Y, 91 | Teuchos::ETransp mode = Teuchos::NO_TRANS, 92 | Scalar alpha = Teuchos::ScalarTraits::one(), 93 | Scalar beta = Teuchos::ScalarTraits::zero() ) const override 94 | { 95 | DTK_REQUIRE( _domain_map->isSameAs( *( X.getMap() ) ) ); 96 | DTK_REQUIRE( _range_map->isSameAs( *( Y.getMap() ) ) ); 97 | DTK_REQUIRE( X.getNumVectors() == Y.getNumVectors() ); 98 | 99 | using DeviceType = typename Node::device_type; 100 | using ExecutionSpace = typename DeviceType::execution_space; 101 | 102 | auto x_view = X.getLocalViewDevice(Tpetra::Access::ReadOnly); 103 | auto y_view = Y.getLocalViewDevice(Tpetra::Access::ReadWrite); 104 | 105 | auto const num_vectors = x_view.extent_int( 1 ); 106 | 107 | Y.scale( beta ); 108 | Kokkos::parallel_for( DTK_MARK_REGION( "spline_prolongation::apply" ), 109 | Kokkos::RangePolicy( 0, _lda ), 110 | KOKKOS_LAMBDA( int const i ) { 111 | for ( int j = 0; j < num_vectors; ++j ) 112 | y_view( i, j ) += alpha * x_view( i, j ); 113 | } ); 114 | } 115 | /// \brief Whether this operator supports applying the transpose or 116 | /// conjugate transpose. 117 | bool hasTransposeApply() const override { return false; } 118 | 119 | private: 120 | int _lda; 121 | Teuchos::RCP _domain_map; 122 | Teuchos::RCP _range_map; 123 | }; 124 | 125 | } // end namespace DataTransferKit 126 | 127 | #endif 128 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_ETI_NT.tmpl: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | // WARNING: This file is automatically generated by CMake, and written 13 | // to Trilinos' build (not source) directory. DO NOT EDIT THIS FILE! 14 | // If you run CMake again, it will overwrite any changes that you 15 | // made. Furthermore, it would be unwise to assume anything about 16 | // this file: it may disappear at any time, and its name, location, or 17 | // contents may change at any time. 18 | // 19 | // CMake takes each expression in the original .tmpl file enclosed by 20 | // "at" symbols ("a" with a circle around it), and replaces it in the 21 | // generated .cpp file with a string defined by Tpetra's CMake logic 22 | // (see CMakeLists.txt in this directory). Thus, the original .tmpl 23 | // file is NOT syntactically correct C++, but the .cpp file generated 24 | // by running CMake on it IS a syntactically correct C++ file. 25 | 26 | #include "DataTransferKit_config.hpp" 27 | 28 | #if defined(HAVE_DATATRANSFERKIT_EXPLICIT_INSTANTIATION) 29 | 30 | // We protect the contents of this file with macros, to assist 31 | // applications that circumvent Trilinos' build system. (We do NOT 32 | // recommend this.) That way, they can still build this file, but as 33 | // long as the macros have correct definitions, they won't build 34 | // anything that's not enabled. 35 | 36 | #include "DTK_@CLASS_NAME@_decl.hpp" 37 | #include "DTK_@CLASS_NAME@_def.hpp" 38 | #include "DataTransferKit_ETIHelperMacros.h" 39 | 40 | namespace DataTransferKit { 41 | 42 | DTK_ETI_MANGLING_TYPEDEFS() 43 | 44 | DTK_@CLASS_MACRO_NAME@_INSTANT( @NT_MANGLED_NAME@ ) 45 | 46 | } // namespace DataTransferKit 47 | 48 | #endif // Whether we should build this specialization 49 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_MovingLeastSquaresOperator_decl.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_MOVING_LEAST_SQUARES_OPERATOR_DECL_HPP 13 | #define DTK_MOVING_LEAST_SQUARES_OPERATOR_DECL_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | namespace DataTransferKit 22 | { 23 | 24 | /** 25 | * This class implements a function reconstruction technique for arbitrary point 26 | * cloud based on a moving least square discretization. In this method, support 27 | * and subsequently the data transfer operator is constructed through solutions 28 | * to local least square kernels defined by compactly supported radial basis 29 | * functions. 30 | * 31 | * The class is templated on the DeviceType, the radial basis function 32 | * (Wendland<0>, Wendland<2>, Wendland<4>, Wendland<6>, Wu<2>, Wu<4>, 33 | * Buhmann<2>, Buhmann<3>, or Buhmann<4>) and polynonial basis (, 34 | * , or ). 35 | */ 36 | template , 38 | typename PolynomialBasis = MultivariatePolynomialBasis> 39 | class MovingLeastSquaresOperator : public PointCloudOperator 40 | { 41 | public: 42 | using device_type = DeviceType; 43 | using ExecutionSpace = typename DeviceType::execution_space; 44 | using polynomial_basis = PolynomialBasis; 45 | using radial_basis_function = CompactlySupportedRadialBasisFunction; 46 | 47 | MovingLeastSquaresOperator( 48 | MPI_Comm comm, 49 | Kokkos::View source_points, 50 | Kokkos::View target_points ); 51 | 52 | void 53 | apply( Kokkos::View source_values, 54 | Kokkos::View target_values ) const override; 55 | 56 | private: 57 | MPI_Comm _comm; 58 | unsigned int const _n_source_points; 59 | Kokkos::View _offset; 60 | Kokkos::View _ranks; 61 | Kokkos::View _indices; 62 | Kokkos::View _coeffs; 63 | }; 64 | 65 | } // end namespace DataTransferKit 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_MultivariatePolynomialBasis.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_MULTIVARIATE_POLYNOMIAL_BASIS_HPP 13 | #define DTK_MULTIVARIATE_POLYNOMIAL_BASIS_HPP 14 | 15 | // FIXME: KOKKOS_INLINE_FUNCTION is undefined in Kokkos_Array.hpp, had to 16 | // separate out the two includes below so that Kokkos_Macros.hpp is included 17 | // 1st. Headers can be regrouped after 18 | // [kokkos/kokkos#1579](https://github.com/kokkos/kokkos/pull/1579) makes it 19 | // into Trilinos. 20 | #include 21 | 22 | #include 23 | 24 | namespace DataTransferKit 25 | { 26 | 27 | struct Constant 28 | { 29 | }; 30 | 31 | struct Linear 32 | { 33 | }; 34 | 35 | struct Quadratic 36 | { 37 | }; 38 | 39 | namespace Details 40 | { 41 | 42 | template 43 | struct Size 44 | { 45 | }; 46 | 47 | template 48 | struct Size 49 | { 50 | static int constexpr value = 1; 51 | }; 52 | 53 | template <> 54 | struct Size 55 | { 56 | static int constexpr value = 4; 57 | }; 58 | 59 | template <> 60 | struct Size 61 | { 62 | static int constexpr value = 10; 63 | }; 64 | 65 | template <> 66 | struct Size 67 | { 68 | static int constexpr value = 3; 69 | }; 70 | 71 | template <> 72 | struct Size 73 | { 74 | static int constexpr value = 6; 75 | }; 76 | 77 | } // namespace Details 78 | 79 | template 80 | struct MultivariatePolynomialBasis 81 | { 82 | static int constexpr size = Details::Size::value; 83 | 84 | template 85 | KOKKOS_INLINE_FUNCTION Kokkos::Array 86 | operator()( Point const &p ) const; 87 | }; 88 | 89 | // Definition below is required (until C++17) to avoid link-time errors 90 | // c.f. https://en.cppreference.com/w/cpp/language/definition#ODR-use 91 | template 92 | int constexpr MultivariatePolynomialBasis::size; 93 | 94 | // NOTE: For now relying on Point::operator[]( int i ) to access the coordinates 95 | // which make it possible to use various types such as DTK::Point or 96 | // Kokkos::Array 97 | 98 | template <> 99 | template 100 | KOKKOS_INLINE_FUNCTION 101 | Kokkos::Array::size> 102 | MultivariatePolynomialBasis::operator()( Point const & ) const 103 | { 104 | return {{1.}}; 105 | } 106 | 107 | template <> 108 | template 109 | KOKKOS_INLINE_FUNCTION 110 | Kokkos::Array::size> 111 | MultivariatePolynomialBasis::operator()( Point const &p ) const 112 | { 113 | return {{1., p[0], p[1], p[2]}}; 114 | } 115 | 116 | template <> 117 | template 118 | KOKKOS_INLINE_FUNCTION 119 | Kokkos::Array::size> 120 | MultivariatePolynomialBasis:: 121 | operator()( Point const &p ) const 122 | { 123 | return {{1., p[0], p[1], p[2], p[0] * p[0], p[0] * p[1], p[0] * p[2], 124 | p[1] * p[1], p[1] * p[2], p[2] * p[2]}}; 125 | } 126 | 127 | template <> 128 | template 129 | KOKKOS_INLINE_FUNCTION 130 | Kokkos::Array::size> 131 | MultivariatePolynomialBasis::operator()( Point const & ) const 132 | { 133 | return {{1.}}; 134 | } 135 | 136 | template <> 137 | template 138 | KOKKOS_INLINE_FUNCTION 139 | Kokkos::Array::size> 140 | MultivariatePolynomialBasis::operator()( Point const &p ) const 141 | { 142 | return {{1., p[0], p[1]}}; 143 | } 144 | 145 | template <> 146 | template 147 | KOKKOS_INLINE_FUNCTION 148 | Kokkos::Array::size> 149 | MultivariatePolynomialBasis:: 150 | operator()( Point const &p ) const 151 | { 152 | return {{1., p[0], p[1], p[0] * p[0], p[0] * p[1], p[1] * p[1]}}; 153 | } 154 | 155 | } // namespace DataTransferKit 156 | 157 | #endif 158 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_NearestNeighborOperator_decl.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_NEAREST_NEIGHBOR_OPERATOR_DECL_HPP 13 | #define DTK_NEAREST_NEIGHBOR_OPERATOR_DECL_HPP 14 | 15 | #include 16 | 17 | #include 18 | 19 | namespace DataTransferKit 20 | { 21 | 22 | /** 23 | * This class assigns the value of the field at the target point with the value 24 | * of the field at the closest source source point. 25 | */ 26 | template 27 | class NearestNeighborOperator : public PointCloudOperator 28 | { 29 | using ExecutionSpace = typename DeviceType::execution_space; 30 | 31 | public: 32 | NearestNeighborOperator( 33 | MPI_Comm comm, 34 | Kokkos::View source_points, 35 | Kokkos::View target_points ); 36 | 37 | void 38 | apply( Kokkos::View source_values, 39 | Kokkos::View target_values ) const override; 40 | 41 | private: 42 | MPI_Comm _comm; 43 | Kokkos::View _indices; 44 | Kokkos::View _ranks; 45 | int const _size; 46 | }; 47 | 48 | } // namespace DataTransferKit 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_NearestNeighborOperator_def.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_NEAREST_NEIGHBOR_OPERATOR_DEF_HPP 13 | #define DTK_NEAREST_NEIGHBOR_OPERATOR_DEF_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | #include 19 | 20 | namespace DataTransferKit 21 | { 22 | 23 | template 24 | NearestNeighborOperator::NearestNeighborOperator( 25 | MPI_Comm comm, Kokkos::View source_points, 26 | Kokkos::View target_points ) 27 | : _comm( comm ) 28 | , _indices( "indices", 0 ) 29 | , _ranks( "ranks", 0 ) 30 | , _size( source_points.extent_int( 0 ) ) 31 | { 32 | // NOTE: instead of checking the pre-condition that there is at least one 33 | // source point passed to one of the rank, we let the tree handle the 34 | // communication and just check that the tree is not empty. 35 | 36 | using ExecutionSpace = typename DeviceType::execution_space; 37 | using MemorySpace = typename DeviceType::memory_space; 38 | // Build distributed search tree over the source points. 39 | ArborX::DistributedTree search_tree( _comm, ExecutionSpace{}, 40 | source_points ); 41 | 42 | // Tree must have at least one leaf, otherwise it makes little sense to 43 | // perform the search for nearest neighbors. 44 | DTK_CHECK( !search_tree.empty() ); 45 | 46 | // Query nearest neighbor for all target points. 47 | auto nearest_queries = Details::NearestNeighborOperatorImpl< 48 | DeviceType>::makeNearestNeighborQueries( target_points ); 49 | 50 | // Perform the actual search. 51 | using PairIndexRank = Kokkos::pair; 52 | Kokkos::View offset( "offset", 0 ); 53 | Kokkos::View index_rank( "index_rank", 0 ); 54 | search_tree.query( ExecutionSpace{}, nearest_queries, index_rank, offset ); 55 | 56 | // Split the pair 57 | Kokkos::View indices( "indices", 0 ); 58 | Kokkos::View ranks( "ranks", 0 ); 59 | Details::splitIndexRank( index_rank, indices, ranks ); 60 | 61 | // Check post-condition that we did find a nearest neighbor to all target 62 | // points. 63 | DTK_ENSURE( ArborX::lastElement( offset ) == 64 | target_points.extent_int( 0 ) ); 65 | 66 | // Save results. 67 | // NOTE: we don't bother keeping `offset` around since it is just `[0, 1, 2, 68 | // ..., n_target_poins]` 69 | _indices = indices; 70 | _ranks = ranks; 71 | } 72 | 73 | template 74 | void NearestNeighborOperator::apply( 75 | Kokkos::View source_values, 76 | Kokkos::View target_values ) const 77 | { 78 | // Precondition: check that the source and target are properly sized 79 | DTK_REQUIRE( _indices.extent( 0 ) == target_values.extent( 0 ) ); 80 | DTK_REQUIRE( _size == source_values.extent_int( 0 ) ); 81 | 82 | auto values = Details::NearestNeighborOperatorImpl::fetch( 83 | _comm, _ranks, _indices, source_values ); 84 | 85 | Kokkos::deep_copy( target_values, values ); 86 | } 87 | 88 | } // namespace DataTransferKit 89 | 90 | // Explicit instantiation macro 91 | #define DTK_NEARESTNEIGHBOROPERATOR_INSTANT( NODE ) \ 92 | template class NearestNeighborOperator; 93 | 94 | #endif 95 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_PointCloudOperator.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_POINT_CLOUD_OPERATOR_DECL_HPP 13 | #define DTK_POINT_CLOUD_OPERATOR_DECL_HPP 14 | 15 | #include 16 | 17 | #include 18 | 19 | namespace DataTransferKit 20 | { 21 | /** 22 | * Base class for the MeshFree methods. 23 | */ 24 | template 25 | class PointCloudOperator 26 | { 27 | public: 28 | virtual ~PointCloudOperator() = default; 29 | 30 | /** 31 | * Compute the values of a field at the target points given the values at 32 | * the source points. 33 | */ 34 | virtual void 35 | apply( Kokkos::View source_values, 36 | Kokkos::View target_values ) const = 0; 37 | }; 38 | 39 | } // end namespace DataTransferKit 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /packages/Meshfree/src/DTK_SplineOperator_decl.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_SPLINE_OPERATOR_DECL_HPP 13 | #define DTK_SPLINE_OPERATOR_DECL_HPP 14 | 15 | #include 16 | #include 17 | #include 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | 25 | #include 26 | 27 | namespace DataTransferKit 28 | { 29 | 30 | /** 31 | * This class implements a function reconstruction technique for arbitrary point 32 | * cloud based on a spline discretization. In this method, support 33 | * and subsequently the data transfer operator is constructed through solutions 34 | * to local least square kernels defined by compactly supported radial basis 35 | * functions. 36 | * 37 | * The class is templated on the DeviceType, the radial basis function 38 | * (Wendland<0>, Wendland<2>, Wendland<4>, Wendland<6>, Wu<2>, Wu<4>, 39 | * Buhmann<2>, Buhmann<3>, or Buhmann<4>) and polynonial basis (, 40 | * , or ). 41 | */ 42 | template , 44 | typename PolynomialBasis = MultivariatePolynomialBasis> 45 | class SplineOperator : public PointCloudOperator 46 | { 47 | static_assert( std::is_same>::value, 49 | "Only implemented for linear basis functions!" ); 50 | using LO = int; 51 | using GO = long long; 52 | using NO = Kokkos::Compat::KokkosDeviceWrapperNode< 53 | typename DeviceType::execution_space>; 54 | using SC = Coordinate; 55 | 56 | using CrsMatrix = Tpetra::CrsMatrix; 57 | using Map = Tpetra::Map; 58 | using Operator = Tpetra::Operator; 59 | using Vector = Tpetra::MultiVector; 60 | 61 | public: 62 | using device_type = DeviceType; 63 | using ExecutionSpace = typename DeviceType::execution_space; 64 | using polynomial_basis = PolynomialBasis; 65 | using radial_basis_function = CompactlySupportedRadialBasisFunction; 66 | 67 | SplineOperator( 68 | MPI_Comm comm, 69 | Kokkos::View source_points, 70 | Kokkos::View target_points ); 71 | 72 | void 73 | apply( Kokkos::View source_values, 74 | Kokkos::View target_values ) const override; 75 | 76 | private: 77 | MPI_Comm _comm; 78 | 79 | // Prolongation operator. 80 | Teuchos::RCP S; 81 | 82 | // Coefficient matrix polynomial component. 83 | Teuchos::RCP P; 84 | 85 | // Coefficient matrix basis component. 86 | Teuchos::RCP M; 87 | 88 | // Evaluation matrix polynomial component. 89 | Teuchos::RCP Q; 90 | 91 | // Evaluation matrix basis component. 92 | Teuchos::RCP N; 93 | 94 | // Coupling matrix 95 | Teuchos::RCP> _thyra_operator; 96 | 97 | // Source vector 98 | Teuchos::RCP _source; 99 | 100 | // Destination vector 101 | Teuchos::RCP _destination; 102 | 103 | // Source vector 104 | Teuchos::RCP> _thyra_X; 105 | 106 | // Destination vector 107 | Teuchos::RCP> _thyra_Y; 108 | 109 | Teuchos::RCP buildPolynomialOperator( 110 | Teuchos::RCP domain_map, Teuchos::RCP range_map, 111 | Kokkos::View points ); 112 | 113 | Teuchos::RCP buildBasisOperator( 114 | Teuchos::RCP domain_map, Teuchos::RCP range_map, 115 | Kokkos::View source_points, 116 | Kokkos::View target_points, 117 | int const knn ); 118 | }; 119 | 120 | } // end namespace DataTransferKit 121 | 122 | #endif 123 | -------------------------------------------------------------------------------- /packages/Meshfree/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ##---------------------------------------------------------------------------## 2 | ## TESTS 3 | ##---------------------------------------------------------------------------## 4 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 5 | NearestNeighborOperator 6 | SOURCES tstNearestNeighborOperator.cpp unit_test_main.cpp 7 | COMM serial mpi 8 | NUM_MPI_PROCS 4 9 | STANDARD_PASS_OUTPUT 10 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 11 | ) 12 | 13 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 14 | DetailsCommunicationHelpers 15 | SOURCES tstDetailsCommunicationHelpers.cpp unit_test_main.cpp 16 | COMM serial mpi 17 | NUM_MPI_PROCS 4 18 | STANDARD_PASS_OUTPUT 19 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 20 | ) 21 | 22 | IF (HAVE_DTK_BOOST AND ((BOOST_VERSION VERSION_EQUAL 1.62.0) OR (BOOST_VERSION VERSION_GREATER 1.62.0))) 23 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 24 | CompactlySupportedRadialBasisFunctions 25 | SOURCES tstCompactlySupportedRadialBasisFunctions.cpp unit_test_main.cpp 26 | COMM serial mpi 27 | NUM_MPI_PROCS 1 28 | STANDARD_PASS_OUTPUT 29 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 30 | ) 31 | ENDIF() 32 | 33 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 34 | MultivariatePolynomialBasis 35 | SOURCES tstMultivariatePolynomialBasis.cpp unit_test_main.cpp 36 | COMM serial mpi 37 | NUM_MPI_PROCS 1 38 | STANDARD_PASS_OUTPUT 39 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 40 | ) 41 | 42 | IF (HAVE_DTK_NETCDF AND DTK_DATA_DIR) 43 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 44 | NearestNeighborExodusGenerator 45 | SOURCES tstNearestNeighborExodusGenerator.cpp unit_test_main.cpp 46 | COMM serial mpi 47 | STANDARD_PASS_OUTPUT 48 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 49 | ENVIRONMENT CUDA_LAUNCH_BLOCKING=1 50 | ) 51 | 52 | TRIBITS_COPY_FILES_TO_BINARY_DIR( 53 | ExodusGeneratorFiles 54 | SOURCE_FILES coarse_sphere.exo fine_sphere.exo 55 | SOURCE_DIR ${DTK_DATA_DIR}/exodus/ 56 | DEST_DIR ${CMAKE_CURRENT_BINARY_DIR} 57 | EXEDEPS NearestNeighborExodusGenerator 58 | ) 59 | ENDIF() 60 | 61 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 62 | MeshfreeOperators 63 | SOURCES tstMeshfreeOperators.cpp unit_test_main.cpp 64 | COMM serial mpi 65 | NUM_MPI_PROCS 4 66 | STANDARD_PASS_OUTPUT 67 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 68 | ) 69 | 70 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 71 | MeshfreeOperatorsSimpleProblem 72 | SOURCES tstMeshfreeOperatorsSimpleProblem.cpp unit_test_main.cpp 73 | COMM serial mpi 74 | NUM_MPI_PROCS 1 75 | STANDARD_PASS_OUTPUT 76 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 77 | ) 78 | 79 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 80 | SVD 81 | SOURCES tstSVD.cpp unit_test_main.cpp 82 | COMM serial mpi 83 | NUM_MPI_PROCS 1 84 | STANDARD_PASS_OUTPUT 85 | FAIL_REGULAR_EXPRESSION "data race;leak;runtime error" 86 | ) 87 | -------------------------------------------------------------------------------- /packages/Meshfree/test/PointCloudProblemGenerator/ExodusProblemGenerator.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_EXODUSPROBLEMGENERATOR_HPP 13 | #define DTK_EXODUSPROBLEMGENERATOR_HPP 14 | 15 | #include "DTK_ConfigDefs.hpp" 16 | #include "DTK_Types.h" 17 | #include "PointCloudProblemGenerator.hpp" 18 | 19 | #include 20 | 21 | #include 22 | 23 | #include 24 | #include 25 | 26 | namespace DataTransferKit 27 | { 28 | //---------------------------------------------------------------------------// 29 | // Generate point cloud problem by reading exodus files. 30 | // 31 | // The generator reads exodus files and extracts the node coordinates and 32 | // partitions them across the given communicator. 33 | // 34 | // Source files are partitioned in x where each rank gets an even subdivision 35 | // of space in the x dimension: 36 | // 37 | // | | o | | | 38 | // | o o | o | o o | o o o | 39 | // | o | o o | o | o o | 40 | // | o o | o | o | o o o | 41 | // | | | o | | 42 | // | rank = 0 | rank = 1 | ...... | rank = comm_size - 1 | 43 | // 44 | // Target files are partitioned in y where each rank gets an even subdivision 45 | // of space in the y dimension. 46 | // 47 | // --------------------------------- 48 | // o o o o 49 | // rank = 0 o o o 50 | // o o o o 51 | // --------------------------------- 52 | // o o o o 53 | // rank = 1 o o o o o 54 | // o o oo o o 55 | // --------------------------------- 56 | // oo o o o o oo 57 | // .... o o o o o o 58 | // o oo o o oo o o 59 | // --------------------------------- 60 | // o o o oo 61 | // rank = o o o o 62 | // comm_size - 1 o oo ooooo 63 | // 64 | // --------------------------------- 65 | // 66 | // In the uniquely owned case, mesh nodes are given one single, unique 67 | // destination in the partitioning. 68 | // 69 | // In the ghosted case, mesh elements are given one unique destination and 70 | // all nodes belonging to that element are sent to that 71 | // destination. Therefore, nodes owned by multiple elements with different 72 | // destinations will be sent to multiple ranks and thus ghosted. 73 | // 74 | template 75 | class ExodusProblemGenerator 76 | : public PointCloudProblemGenerator 77 | { 78 | public: 79 | // Constructor. 80 | ExodusProblemGenerator( MPI_Comm comm, 81 | const std::string &source_exodus_file, 82 | const std::string &target_exodus_file ); 83 | 84 | // Create a problem where all points are uniquely owned (i.e. no 85 | // ghosting). Both source and target fields have one component and are 86 | // initialized to zero. 87 | void createUniquelyOwnedProblem( 88 | Kokkos::View 89 | &src_coords, 90 | Kokkos::View &src_field, 91 | Kokkos::View 92 | &tgt_coords, 93 | Kokkos::View &tgt_field ) 94 | override; 95 | 96 | // Create a general problem where points may exist on multiple 97 | // processors. Both source and target fields have 1 component and are 98 | // initialized to zero. 99 | void createGhostedProblem( 100 | Kokkos::View 101 | &src_coords, 102 | Kokkos::View 103 | &src_gids, 104 | Kokkos::View &src_field, 105 | Kokkos::View 106 | &tgt_coords, 107 | Kokkos::View 108 | &tgt_gids, 109 | Kokkos::View &tgt_field ) 110 | override; 111 | 112 | private: 113 | // Get host views of node data from file. 114 | template 115 | void getNodeDataFromFile( 116 | const std::string &exodus_file, 117 | Kokkos::View &coords, 118 | Kokkos::View &gids ); 119 | 120 | // Partition a point cloud in a given dimension with one-to-one mapping. 121 | template 122 | void partitionUniquelyOwned( const int dim, const std::string &exodus_file, 123 | Kokkos::View &partitioned_coords ); 125 | 126 | // Partition a point cloud in a given dimension with ghosted connectivity 127 | // mapping. 128 | template 129 | void partitionGhostedConnectivity( 130 | const int dim, const std::string &exodus_file, 131 | Kokkos::View 132 | &partitioned_coords, 133 | Kokkos::View 134 | &partitioned_gids ); 135 | 136 | // Given a netcdf handle and a dimension name get the length of that 137 | // dimension. 138 | size_t getNetcdfDimensionLength( const int nc_id, 139 | const std::string &dim_name ); 140 | 141 | private: 142 | // Comm 143 | MPI_Comm _comm; 144 | 145 | // Filenames 146 | std::string _src_exodus_file; 147 | std::string _tgt_exodus_file; 148 | }; 149 | 150 | //---------------------------------------------------------------------------// 151 | 152 | } // namespace DataTransferKit 153 | 154 | //---------------------------------------------------------------------------// 155 | // Template includes 156 | //---------------------------------------------------------------------------// 157 | 158 | #include "ExodusProblemGenerator_def.hpp" 159 | 160 | //---------------------------------------------------------------------------// 161 | 162 | #endif // end DTK_EXODUSPROBLEMGENERATOR_HPP 163 | -------------------------------------------------------------------------------- /packages/Meshfree/test/PointCloudProblemGenerator/PointCloudProblemGenerator.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_POINTCLOUDPROBLEMGENERATOR_HPP 13 | #define DTK_POINTCLOUDPROBLEMGENERATOR_HPP 14 | 15 | #include "DTK_ConfigDefs.hpp" 16 | #include "DTK_Types.h" 17 | 18 | #include 19 | 20 | namespace DataTransferKit 21 | { 22 | //---------------------------------------------------------------------------// 23 | template 24 | class PointCloudProblemGenerator 25 | { 26 | public: 27 | virtual ~PointCloudProblemGenerator() = default; 28 | 29 | /*! 30 | * \brief Create a problem where all points are uniquely owned (i.e. no 31 | * ghosting) 32 | * 33 | * \param src_coords Coordinates of the source points. Layout: 34 | * (point,dim). 35 | * 36 | * \param src_field Multi-component field defined on the source points. At 37 | * a minimum will be allocated and filled with zeros. Some implementations 38 | * may choose to fill this view with non-zero data. Layout: (point,comp). 39 | * 40 | * \param tgt_coords Coordinates of the target points. Layout: 41 | * (point,dim). 42 | * 43 | * \param tgt_field Multi-component field defined on the target points. At 44 | * a minimum will be allocated and filled with zeros. Some implementations 45 | * may choose to fill this view with non-zero data corresponding to the 46 | * expected result of transferring the src_field from the source points to 47 | * the target points. Layout: (point,comp). 48 | */ 49 | virtual void createUniquelyOwnedProblem( 50 | Kokkos::View 51 | &src_coords, 52 | Kokkos::View &src_field, 53 | Kokkos::View 54 | &tgt_coords, 55 | Kokkos::View 56 | &tgt_field ) = 0; 57 | 58 | /*! 59 | * \brief Create a general problem where points may exist on multiple 60 | * processors. Points have a unique global id. 61 | * 62 | * \param src_coords Coordinates of the source points. Layout: 63 | * (point,dim). 64 | * 65 | * \param src_gids Global ids of the source points. A global id will 66 | * appear only once on a given processor but may appear on multiple 67 | * processors. Layout: (point). 68 | * 69 | * \param src_field Multi-component field defined on the source points. At 70 | * a minimum will be allocated and filled with zeros. Some implementations 71 | * may choose to fill this view with non-zero data. Layout: (point,comp). 72 | * 73 | * \param tgt_coords Coordinates of the target points. Layout: 74 | * (point,dim). 75 | * 76 | * \param tgt_gids Global ids of the target points. A global id will 77 | * appear only once on a given processor but may appear on multiple 78 | * processors. Layout: (point). 79 | * 80 | * \param tgt_field Multi-component field defined on the target points. At 81 | * a minimum will be allocated and filled with zeros. Some implementations 82 | * may choose to fill this view with non-zero data corresponding to the 83 | * expected result of transferring the src_field from the source points to 84 | * the target points. Layout: (point,comp). 85 | */ 86 | virtual void createGhostedProblem( 87 | Kokkos::View 88 | &src_coords, 89 | Kokkos::View 90 | &src_gids, 91 | Kokkos::View &src_field, 92 | Kokkos::View 93 | &tgt_coords, 94 | Kokkos::View 95 | &tgt_gids, 96 | Kokkos::View 97 | &tgt_field ) = 0; 98 | }; 99 | 100 | //---------------------------------------------------------------------------// 101 | 102 | } // namespace DataTransferKit 103 | 104 | #endif // end DTK_POINTCLOUDPROBLEMGENERATOR_HPP 105 | -------------------------------------------------------------------------------- /packages/Meshfree/test/tstCompactlySupportedRadialBasisFunctions.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | #include 15 | 16 | #include 17 | 18 | #include 19 | #include 20 | 21 | template 22 | void check_polynomial( boost::math::tools::polynomial const &poly, 23 | std::vector const &radii, 24 | RadialBasisFunction const &rbf, 25 | Teuchos::FancyOStream &out, bool &success ) 26 | { 27 | using ExecutionSpace = typename DeviceType::execution_space; 28 | int const n = radii.size(); 29 | Kokkos::View r( "radii", n ); 30 | auto r_host = Kokkos::create_mirror_view( r ); 31 | for ( int i = 0; i < n; ++i ) 32 | r_host( i ) = radii[i]; 33 | Kokkos::deep_copy( r, r_host ); 34 | 35 | std::vector p = poly.data(); 36 | std::vector values; 37 | for ( auto const &x : radii ) 38 | values.push_back( 39 | boost::math::tools::evaluate_polynomial( p.data(), x, p.size() ) ); 40 | 41 | Kokkos::View v( "values", n ); 42 | Kokkos::parallel_for( "evaluate", 43 | Kokkos::RangePolicy( 0, n ), 44 | KOKKOS_LAMBDA( int i ) { v( i ) = rbf( r( i ) ); } ); 45 | Kokkos::fence(); 46 | auto v_host = Kokkos::create_mirror_view( v ); 47 | Kokkos::deep_copy( v_host, v ); 48 | double const relative_tolerance = 1.0e-8; 49 | TEST_COMPARE_FLOATING_ARRAYS( v_host, values, relative_tolerance ); 50 | } 51 | 52 | TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( CompactlySupportedRadialBasisFunctions, 53 | polynomial_rbf, DeviceType ) 54 | { 55 | int const n = 10; 56 | std::vector r( n ); 57 | for ( int i = 0; i < n; ++i ) 58 | r[i] = static_cast( i ) / n; 59 | 60 | check_polynomial( 61 | boost::math::tools::pow( 62 | boost::math::tools::polynomial{1.0, -1.0}, 2 ), 63 | r, DataTransferKit::Wendland<0>(), out, success ); 64 | 65 | check_polynomial( 66 | boost::math::tools::pow( 67 | boost::math::tools::polynomial{1.0, -1.0}, 4 ) * 68 | boost::math::tools::polynomial{1.0, 4.0}, 69 | r, DataTransferKit::Wendland<2>(), out, success ); 70 | 71 | check_polynomial( 72 | boost::math::tools::pow( 73 | boost::math::tools::polynomial{1.0, -1.0}, 6 ) * 74 | boost::math::tools::polynomial{3.0, 18.0, 35.0}, 75 | r, DataTransferKit::Wendland<4>(), out, success ); 76 | 77 | check_polynomial( 78 | boost::math::tools::pow( 79 | boost::math::tools::polynomial{1.0, -1.0}, 8 ) * 80 | boost::math::tools::polynomial{1.0, 8.0, 25.0, 32.0}, 81 | r, DataTransferKit::Wendland<6>(), out, success ); 82 | 83 | check_polynomial( 84 | boost::math::tools::pow( 85 | boost::math::tools::polynomial{1.0, -1.0}, 4 ) * 86 | boost::math::tools::polynomial{4.0, 16.0, 12.0, 3.0}, 87 | r, DataTransferKit::Wu<2>(), out, success ); 88 | 89 | check_polynomial( 90 | boost::math::tools::pow( 91 | boost::math::tools::polynomial{1.0, -1.0}, 6 ) * 92 | boost::math::tools::polynomial{6.0, 36.0, 82.0, 72.0, 30.0, 93 | 5.0}, 94 | r, DataTransferKit::Wu<4>(), out, success ); 95 | } 96 | 97 | TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( CompactlySupportedRadialBasisFunctions, 98 | wrap_rbf, DeviceType ) 99 | { 100 | struct X 101 | { 102 | KOKKOS_INLINE_FUNCTION double operator()( double x ) const { return x; } 103 | }; 104 | DataTransferKit::RadialBasisFunction rbf( 2. ); 105 | TEST_EQUALITY( rbf( 1. ), .5 ); 106 | TEST_EQUALITY( rbf( 2. ), 1. ); 107 | TEST_EQUALITY( rbf( 4. ), 2. ); 108 | } 109 | 110 | // Include the test macros. 111 | #include "DataTransferKit_ETIHelperMacros.h" 112 | 113 | // Create the test group 114 | #define UNIT_TEST_GROUP( NODE ) \ 115 | using DeviceType##NODE = typename NODE::device_type; \ 116 | TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \ 117 | CompactlySupportedRadialBasisFunctions, polynomial_rbf, \ 118 | DeviceType##NODE ) \ 119 | TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( \ 120 | CompactlySupportedRadialBasisFunctions, wrap_rbf, DeviceType##NODE ) 121 | // Demangle the types 122 | DTK_ETI_MANGLING_TYPEDEFS() 123 | 124 | // Instantiate the tests 125 | DTK_INSTANTIATE_N( UNIT_TEST_GROUP ) 126 | -------------------------------------------------------------------------------- /packages/Meshfree/test/tstMultivariatePolynomialBasis.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include 17 | 18 | #include 19 | 20 | template 21 | void checkBasisEvaluation( PolynomialBasis const &b, Point const &x, 22 | std::vector const &b_ref, bool &success, 23 | Teuchos::FancyOStream &out ) 24 | { 25 | TEST_COMPARE_ARRAYS( b( x ), b_ref ); 26 | } 27 | 28 | // NOTE: The extra pairs of parentheses below around 29 | // MultivariatePolynomialBasis::size in TEST_EQUALITY() macro are needed. 30 | // Without them, the Teuchos unit testing macro yields the folowing error: 31 | // 32 | // error: macro "TEST_EQUALITY" passed 3 arguments, but takes just 2 33 | 34 | TEUCHOS_UNIT_TEST( MultivariatePolynomialBasis, 2D ) 35 | { 36 | using DataTransferKit::Constant; 37 | using DataTransferKit::Linear; 38 | using DataTransferKit::MultivariatePolynomialBasis; 39 | using DataTransferKit::Quadratic; 40 | // FIXME 41 | using Point = Kokkos::Array; 42 | 43 | // (X, Y) -> [ 1 ] 44 | TEST_EQUALITY( ( MultivariatePolynomialBasis::size ), 1 ); 45 | checkBasisEvaluation( MultivariatePolynomialBasis(), 46 | Point{{0., 0.}}, {1.}, success, out ); 47 | 48 | // (X, Y) -> [ 1, X, Y ] 49 | TEST_EQUALITY( ( MultivariatePolynomialBasis::size ), 3 ); 50 | checkBasisEvaluation( MultivariatePolynomialBasis(), 51 | Point{{0., 1.}}, {{1., 0., 1.}}, success, out ); 52 | 53 | // (X, Y) -> [ 1, X, Y, X^2, XY, Y^2 ] 54 | TEST_EQUALITY( ( MultivariatePolynomialBasis::size ), 6 ); 55 | checkBasisEvaluation( MultivariatePolynomialBasis(), 56 | Point{{1., 2.}}, {{1., 1., 2., 1., 2., 4.}}, success, 57 | out ); 58 | } 59 | 60 | TEUCHOS_UNIT_TEST( MultivariatePolynomialBasis, 3D ) 61 | { 62 | using ArborX::Point; 63 | using DataTransferKit::Constant; 64 | using DataTransferKit::Linear; 65 | using DataTransferKit::MultivariatePolynomialBasis; 66 | using DataTransferKit::Quadratic; 67 | 68 | // (X, Y, Z) -> [ 1 ] 69 | TEST_EQUALITY( ( MultivariatePolynomialBasis::size ), 1 ); 70 | checkBasisEvaluation( MultivariatePolynomialBasis(), 71 | Point{{0., 0., 0.}}, {1.}, success, out ); 72 | 73 | // (X, Y, Z) -> [ 1, X, Y, Z ] 74 | TEST_EQUALITY( ( MultivariatePolynomialBasis::size ), 4 ); 75 | checkBasisEvaluation( MultivariatePolynomialBasis(), 76 | Point{{0., 1., 2.}}, {{1., 0., 1., 2.}}, success, 77 | out ); 78 | 79 | // (X, Y, Z) -> [ 1, X, Y, Z, X^2, XY, XZ, Y^2, YZ, Z^2 ] 80 | TEST_EQUALITY( ( MultivariatePolynomialBasis::size ), 10 ); 81 | checkBasisEvaluation( 82 | MultivariatePolynomialBasis(), Point{{0., 1., 2.}}, 83 | {{1., 0., 1., 2., 0., 0., 0., 1., 2., 4.}}, success, out ); 84 | } 85 | -------------------------------------------------------------------------------- /packages/Meshfree/test/tstSVD.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | #include 18 | 19 | #include 20 | #include 21 | 22 | template 23 | void check_result( Kokkos::View matrices, 24 | Kokkos::View inv_matrices, 25 | int const n_matrices, int matrix_size, 26 | std::set const &rank_deficiency, 27 | Teuchos::FancyOStream &out, bool &success ) 28 | { 29 | auto matrices_host = Kokkos::create_mirror_view( matrices ); 30 | Kokkos::deep_copy( matrices_host, matrices ); 31 | auto inv_matrices_host = Kokkos::create_mirror_view( inv_matrices ); 32 | Kokkos::deep_copy( inv_matrices_host, inv_matrices ); 33 | 34 | // Multiply the matrices with their inverse and check that the result is the 35 | // identity matrix. 36 | int const offset = matrix_size * matrix_size; 37 | for ( int m = 0; m < n_matrices; ++m ) 38 | { 39 | std::vector> result( 40 | matrix_size, std::vector( matrix_size, 0. ) ); 41 | for ( int i = 0; i < matrix_size; ++i ) 42 | for ( int j = 0; j < matrix_size; ++j ) 43 | for ( int k = 0; k < matrix_size; ++k ) 44 | result[i][j] += 45 | inv_matrices_host[m * offset + i * matrix_size + k] * 46 | matrices_host[m * offset + k * matrix_size + j]; 47 | 48 | // Check that the result is the identity 49 | double const relative_tolerance = 1e-12; 50 | for ( int i = 0; i < matrix_size; ++i ) 51 | for ( int j = 0; j < matrix_size; ++j ) 52 | { 53 | if ( ( i == j ) && ( rank_deficiency.count( i ) == 0 ) ) 54 | { 55 | TEST_FLOATING_EQUALITY( result[i][i], 1., 56 | relative_tolerance ); 57 | } 58 | else 59 | { 60 | TEST_FLOATING_EQUALITY( result[i][j] + 1, 1., 61 | relative_tolerance ); 62 | } 63 | } 64 | } 65 | } 66 | 67 | TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( SVD, full_rank, DeviceType ) 68 | { 69 | int const n_matrices = 10; 70 | int const matrix_size = 32; 71 | int const size = n_matrices * matrix_size * matrix_size; 72 | Kokkos::View matrices( "matrices", size ); 73 | Kokkos::View inv_matrices( "inv_matrices", size ); 74 | // For magic number 3, see comment in 75 | // DTK_DetailsMovingLeastSquaresOperatorImpl.hpp 76 | Kokkos::View aux( "aux", matrix_size, 77 | 3 * n_matrices * matrix_size ); 78 | 79 | // Fill the matrices 80 | auto matrices_host = Kokkos::create_mirror_view( matrices ); 81 | std::default_random_engine random_engine; 82 | std::uniform_real_distribution distribution( -1000, 1000 ); 83 | for ( int i = 0; i < size; ++i ) 84 | matrices_host( i ) = distribution( random_engine ); 85 | Kokkos::deep_copy( matrices, matrices_host ); 86 | 87 | DataTransferKit::Details::SVDFunctor svd_functor( 88 | matrix_size, matrices, inv_matrices, aux ); 89 | size_t n_underdetermined = 0; 90 | using ExecutionSpace = typename DeviceType::execution_space; 91 | Kokkos::parallel_reduce( 92 | DTK_MARK_REGION( "compute_svd_inverse" ), 93 | Kokkos::RangePolicy( 0, n_matrices ), svd_functor, 94 | n_underdetermined ); 95 | 96 | std::set rank_deficiency; 97 | 98 | check_result( matrices, inv_matrices, n_matrices, matrix_size, 99 | rank_deficiency, out, success ); 100 | } 101 | 102 | TEUCHOS_UNIT_TEST_TEMPLATE_1_DECL( SVD, rank_deficient, DeviceType ) 103 | { 104 | int const n_matrices = 10; 105 | int const matrix_size = 40; 106 | int const size = n_matrices * matrix_size * matrix_size; 107 | Kokkos::View matrices( "matrices", size ); 108 | Kokkos::View inv_matrices( "inv_matrices", size ); 109 | // For magic number 3, see comment in 110 | // DTK_DetailsMovingLeastSquaresOperatorImpl.hpp 111 | Kokkos::View aux( "aux", matrix_size, 112 | 3 * n_matrices * matrix_size ); 113 | 114 | // Fill the matrices 115 | auto matrices_host = Kokkos::create_mirror_view( matrices ); 116 | std::default_random_engine random_engine; 117 | std::uniform_real_distribution distribution( -1000, 1000 ); 118 | std::set rank_deficiency; 119 | rank_deficiency.insert( 3 ); 120 | unsigned int pos = 0; 121 | for ( int i = 0; i < n_matrices; ++i ) 122 | { 123 | for ( int j = 0; j < matrix_size; ++j ) 124 | { 125 | for ( int k = 0; k < matrix_size; ++k ) 126 | { 127 | if ( rank_deficiency.count( k ) == 0 ) 128 | matrices_host( pos ) = distribution( random_engine ); 129 | else 130 | matrices_host( pos ) = 0.; 131 | ++pos; 132 | } 133 | } 134 | } 135 | Kokkos::deep_copy( matrices, matrices_host ); 136 | 137 | DataTransferKit::Details::SVDFunctor svd_functor( 138 | matrix_size, matrices, inv_matrices, aux ); 139 | size_t n_underdetermined = 0; 140 | using ExecutionSpace = typename DeviceType::execution_space; 141 | Kokkos::parallel_reduce( 142 | DTK_MARK_REGION( "compute_svd_inverse" ), 143 | Kokkos::RangePolicy( 0, n_matrices ), svd_functor, 144 | n_underdetermined ); 145 | 146 | TEST_EQUALITY( n_underdetermined, n_matrices ); 147 | 148 | check_result( matrices, inv_matrices, n_matrices, matrix_size, 149 | rank_deficiency, out, success ); 150 | } 151 | 152 | // Include the test macros. 153 | #include "DataTransferKit_ETIHelperMacros.h" 154 | 155 | // Create the test group 156 | #define UNIT_TEST_GROUP( NODE ) \ 157 | using DeviceType##NODE = typename NODE::device_type; \ 158 | TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( SVD, full_rank, DeviceType##NODE ) \ 159 | TEUCHOS_UNIT_TEST_TEMPLATE_1_INSTANT( SVD, rank_deficient, \ 160 | DeviceType##NODE ) 161 | // Demangle the types 162 | DTK_ETI_MANGLING_TYPEDEFS() 163 | 164 | // Instantiate the tests 165 | DTK_INSTANTIATE_N( UNIT_TEST_GROUP ) 166 | -------------------------------------------------------------------------------- /packages/Meshfree/test/unit_test_main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | int main( int argc, char *argv[] ) 18 | { 19 | Teuchos::GlobalMPISession mpiSession( &argc, &argv ); 20 | Teuchos::UnitTestRepository::setGloballyReduceTestResult( true ); 21 | Kokkos::initialize( argc, argv ); 22 | int return_val = 23 | Teuchos::UnitTestRepository::runUnitTestsFromMain( argc, argv ); 24 | Kokkos::finalize(); 25 | return return_val; 26 | } 27 | -------------------------------------------------------------------------------- /packages/Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | ADD_SUBDIRECTORY(src) 2 | 3 | TRIBITS_ADD_TEST_DIRECTORIES(test) 4 | -------------------------------------------------------------------------------- /packages/Utils/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | SET(HEADERS "") 2 | SET(SOURCES "") 3 | 4 | APPEND_SET(HEADERS 5 | ${PACKAGE_BINARY_DIR}/${PACKAGE_NAME}_config.hpp 6 | DTK_ConfigDefs.hpp 7 | DTK_Core.hpp 8 | DTK_DBC.hpp 9 | DTK_DetailsUtils.hpp 10 | DTK_SanitizerMacros.hpp 11 | DTK_Types.h 12 | DTK_Version.hpp 13 | ) 14 | 15 | APPEND_SET(SOURCES 16 | DTK_Core.cpp 17 | DTK_DBC.cpp 18 | ) 19 | 20 | TRIBITS_ADD_LIBRARY( 21 | dtk_utils 22 | HEADERS ${HEADERS} 23 | SOURCES ${SOURCES} 24 | ADDED_LIB_TARGET_NAME_OUT DTK_UTILS_LIBNAME 25 | ) 26 | TARGET_INCLUDE_DIRECTORIES( 27 | ${DTK_UTILS_LIBNAME} 28 | PUBLIC 29 | "$" # the latter to find config 30 | "$" 31 | ) 32 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_ConfigDefs.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file DTK_ConfigDefs.hpp 13 | * \brief Kokkos helpers. 14 | */ 15 | //---------------------------------------------------------------------------// 16 | 17 | #ifndef DTK_CONFIGDEFS_HPP 18 | #define DTK_CONFIGDEFS_HPP 19 | 20 | #include "DataTransferKit_config.hpp" 21 | 22 | #include 23 | 24 | #include "DTK_Types.h" 25 | 26 | #define DTK_MARK_REGION( x ) std::string( "DTK_" ) + x 27 | 28 | #endif // #ifndef DTK_CONFIGDEFS_HPP 29 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_Core.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | #include "DTK_Core.hpp" 12 | #include "DTK_DBC.hpp" 13 | 14 | namespace DataTransferKit 15 | { 16 | namespace 17 | { // anonymous 18 | 19 | // Whether one of the Tpetra::initialize() functions has been called before. 20 | bool dtkIsInitialized = false; 21 | 22 | // Whether DTK initialized Kokkos. DTK's finalize() only finalizes 23 | // Kokkos if it initialized Kokkos. Otherwise, something else 24 | // initialized Kokkos and is responsible for finalizing it. 25 | bool dtkInitializedKokkos = false; 26 | 27 | // Initialize Kokkos, if it needs initialization. 28 | template 29 | void initKokkos( Args &&... args ) 30 | { 31 | if ( !dtkInitializedKokkos ) 32 | { 33 | // Kokkos doesn't have a global is_initialized(). However, 34 | // Kokkos::initialize() always initializes the default execution 35 | // space, so it suffices to check whether that was initialized. 36 | const bool kokkosIsInitialized = Kokkos::is_initialized(); 37 | 38 | if ( !kokkosIsInitialized ) 39 | { 40 | // Kokkos will remove all arguments Kokkos recognizes which start 41 | // with '--kokkos' (e.g.,--kokkos-threads) 42 | Kokkos::initialize( std::forward( args )... ); 43 | dtkInitializedKokkos = true; 44 | } 45 | } 46 | 47 | const bool kokkosIsInitialized = Kokkos::is_initialized(); 48 | 49 | if ( !kokkosIsInitialized ) 50 | throw DataTransferKitException( "At the end of initKokkos, Kokkos" 51 | " is not initialized. Please report" 52 | " this bug to the DTK developers." ); 53 | } 54 | 55 | } // namespace 56 | 57 | template 58 | void initialize( Args &&... args ) 59 | { 60 | if ( !dtkIsInitialized ) 61 | initKokkos( std::forward( args )... ); 62 | dtkIsInitialized = true; 63 | } 64 | 65 | bool isInitialized() { return dtkIsInitialized; } 66 | 67 | void finalize() 68 | { 69 | if ( !dtkIsInitialized ) 70 | return; 71 | 72 | // DTK should only finalize Kokkos if it initialized it 73 | if ( dtkInitializedKokkos ) 74 | Kokkos::finalize(); 75 | 76 | dtkIsInitialized = false; 77 | } 78 | 79 | // ETI for initialize 80 | template void initialize( int &argc, char **&argv ); 81 | template <> 82 | void initialize( int *&&argc, char ***&&argv ) 83 | { 84 | initialize( *argc, *argv ); 85 | } 86 | template void initialize<>(); 87 | } // namespace DataTransferKit 88 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_Core.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file 13 | * \brief DTK initialization routines. 14 | */ 15 | #ifndef DTK_CORE_HPP 16 | #define DTK_CORE_HPP 17 | 18 | #include 19 | 20 | namespace DataTransferKit 21 | { 22 | 23 | // NOTE: trying to follow Tpetra 24 | // (trilinos/packages/tpetra/core/src/Tpetra_Core.hpp) 25 | 26 | /*! Initialize DTK 27 | * 28 | * Will initialize Kokkos if it was not previously initialized. 29 | */ 30 | template 31 | void initialize( Args &&... args ); 32 | 33 | /*! Whether DTK is in initialized state */ 34 | bool isInitialized(); 35 | 36 | /*! Finalize DTK 37 | * 38 | * Will finalize Kokkos if it was initialized by DTK. 39 | */ 40 | 41 | void finalize(); 42 | } // namespace DataTransferKit 43 | 44 | #endif // DTK_CORE_HPP 45 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_DBC.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file DTK_DBC.cpp 13 | * \author Stuart Slattery 14 | * \brief Assertions for error handling and Design-by-Contract. 15 | */ 16 | //---------------------------------------------------------------------------// 17 | 18 | #include 19 | 20 | #include "DTK_DBC.hpp" 21 | 22 | #include 23 | 24 | namespace DataTransferKit 25 | { 26 | //---------------------------------------------------------------------------// 27 | // Assertion functions. 28 | //---------------------------------------------------------------------------// 29 | /*! 30 | * \brief Build an assertion output from advanced constructor arguments. 31 | * 32 | * \param cond A string containing the assertion condition that failed. 33 | * 34 | * \param file A string containing the file name in which the assertion failed. 35 | * 36 | * \param line The line number at which the assertion failed. 37 | * 38 | * \return DataTransferKitException output. 39 | */ 40 | std::string DataTransferKitException::generate_output( const std::string &cond, 41 | const std::string &file, 42 | const int line ) const 43 | { 44 | std::ostringstream output; 45 | output << "DataTransferKit DataTransferKitException: " << cond 46 | << ", failed in " << file << ", line " << line << "." << std::endl; 47 | return output.str(); 48 | } 49 | 50 | //---------------------------------------------------------------------------// 51 | // Throw functions. 52 | //---------------------------------------------------------------------------// 53 | /*! 54 | * \brief Throw a DataTransferKit::DataTransferKitException. 55 | * 56 | * \param cond A string containing the assertion condition that failed. 57 | * 58 | * \param file A string containing the file name in which the assertion failed. 59 | * 60 | * \param line The line number at which the assertion failed. 61 | */ 62 | void throwDataTransferKitException( const std::string &cond, 63 | const std::string &file, const int line ) 64 | { 65 | #ifdef HAVE_TEUCHOS_STACKTRACE 66 | // If Teuchos stacktrace is turned on, store the stack before we throw so 67 | // we can get it later. 68 | Teuchos::store_stacktrace(); 69 | #endif 70 | throw DataTransferKitException( cond, file, line ); 71 | } 72 | 73 | //---------------------------------------------------------------------------// 74 | /*! 75 | * \brief Throw a DataTransferKit::DataTransferKitException when an error code 76 | * fails. 77 | * 78 | * \param cond A string containing the assertion condition that failed. 79 | * 80 | * \param file A string containing the file name in which the assertion failed. 81 | * 82 | * \param line The line number at which the assertion failed. 83 | * 84 | * \param error_code 85 | */ 86 | void errorCodeFailure( const std::string &cond, const std::string &file, 87 | const int line, const int error_code ) 88 | { 89 | #ifdef HAVE_TEUCHOS_STACKTRACE 90 | // If Teuchos stacktrace is turned on, store the stack before we throw so 91 | // we can get it later. 92 | Teuchos::store_stacktrace(); 93 | #endif 94 | std::ostringstream output_msg; 95 | output_msg << "Error code : " << cond << ", failed in " << file << ":" 96 | << line << std::endl 97 | << "with error code:" << std::endl 98 | << "\"" << error_code << "\"" << std::endl; 99 | throw DataTransferKitException( output_msg.str() ); 100 | } 101 | 102 | //---------------------------------------------------------------------------// 103 | /*! 104 | * \brief Throw a DataTransferKit::DataTransferKitException when a user 105 | * function is missing. 106 | * 107 | * \param cond The missing function. 108 | */ 109 | void missingUserFunction( const std::string &cond ) 110 | { 111 | std::ostringstream output_msg; 112 | output_msg << "Missing user function : " << cond << std::endl; 113 | throw DataTransferKitException( output_msg.str() ); 114 | } 115 | 116 | //---------------------------------------------------------------------------// 117 | 118 | } // namespace DataTransferKit 119 | 120 | //---------------------------------------------------------------------------// 121 | // end DTK_DBC.cpp 122 | //---------------------------------------------------------------------------// 123 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_DetailsUtils.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2021 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_DETAILS_UTILS_HPP 13 | #define DTK_DETAILS_UTILS_HPP 14 | 15 | #include 16 | 17 | namespace DataTransferKit 18 | { 19 | namespace Details 20 | { 21 | template 22 | void splitIndexRank( 23 | Kokkos::View *, DeviceType> index_rank, 24 | Kokkos::View &indices, 25 | Kokkos::View &ranks ) 26 | { 27 | using ExecutionSpace = typename DeviceType::execution_space; 28 | 29 | auto const n_pairs = index_rank.extent( 0 ); 30 | Kokkos::realloc( indices, n_pairs ); 31 | Kokkos::realloc( ranks, n_pairs ); 32 | Kokkos::parallel_for( DTK_MARK_REGION( "split_pairs" ), 33 | Kokkos::RangePolicy( 0, n_pairs ), 34 | KOKKOS_LAMBDA( int i ) { 35 | indices( i ) = index_rank( i ).first; 36 | ranks( i ) = index_rank( i ).second; 37 | } ); 38 | } 39 | } // namespace Details 40 | } // namespace DataTransferKit 41 | #endif 42 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_SWIG.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2017 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | ****************************************************************************/ 9 | /*! 10 | * \file 11 | * \brief SWIG macros. 12 | */ 13 | //---------------------------------------------------------------------------// 14 | #ifndef DTK_SWIG_HPP 15 | #define DTK_SWIG_HPP 16 | 17 | #ifndef SWIGEXPORT 18 | #if defined( __GNUC__ ) 19 | #define SWIGEXPORT __attribute__( ( visibility( "default" ) ) ) 20 | #else 21 | #define SWIGEXPORT 22 | #endif 23 | #endif 24 | 25 | /* Intel's compiler complains if a variable which was never initialised is 26 | * cast to void, which is a common idiom which we use to indicate that we 27 | * are aware a variable isn't used. So we just silence that warning. 28 | * See: https://github.com/swig/swig/issues/192 for more discussion. 29 | */ 30 | #ifdef __INTEL_COMPILER 31 | #pragma warning disable 592 32 | #endif 33 | 34 | #endif // end DTK_SWIG_HPP 35 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_SanitizerMacros.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file DTK_SanitizerMacros.hpp 13 | * \author Bruno Turcksin 14 | * \brief Macros to suppress sanitizer checks. 15 | */ 16 | //---------------------------------------------------------------------------// 17 | 18 | #if defined( __clang__ ) 19 | #define IGNORE_UNDEFINED_SANITIZE \ 20 | __attribute__( ( no_sanitize( "undefined" ) ) ) 21 | #else 22 | #define IGNORE_UNDEFINED_SANITIZE 23 | #endif 24 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_Types.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | /*! 12 | * \file 13 | * \brief DTK hardcoded types. 14 | */ 15 | #ifndef DTK_TYPES_H 16 | #define DTK_TYPES_H 17 | 18 | #ifdef __cplusplus 19 | #include 20 | #else 21 | #ifndef DOXYGEN_SHOULD_SKIP_THIS 22 | #include 23 | #endif 24 | #endif 25 | 26 | namespace DataTransferKit { 27 | 28 | //! Coordinate typedef. 29 | typedef double Coordinate; 30 | 31 | //! Local ordinal typedef. 32 | typedef int LocalOrdinal; 33 | 34 | //! Global ordinal typedef. 35 | typedef long long GlobalOrdinal; 36 | 37 | } 38 | 39 | #endif // DTK_TYPES_H 40 | -------------------------------------------------------------------------------- /packages/Utils/src/DTK_Version.hpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #ifndef DTK_VERSION_HPP 13 | #define DTK_VERSION_HPP 14 | 15 | #include 16 | 17 | #include 18 | 19 | namespace DataTransferKit 20 | { 21 | 22 | inline std::string version() { return DataTransferKit_VERSION_STRING; } 23 | 24 | inline std::string gitCommitHash() { return DataTransferKit_GIT_COMMIT_HASH; } 25 | } // namespace DataTransferKit 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /packages/Utils/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 2 | Miscellaneous_test 3 | SOURCES tstMiscellaneous.cpp unit_test_main.cpp 4 | COMM serial mpi 5 | NUM_MPI_PROCS 1 6 | STANDARD_PASS_OUTPUT 7 | FAIL_REGULAR_EXPRESSION "data race;data race;leak;runtime error" 8 | ) 9 | 10 | TRIBITS_ADD_EXECUTABLE_AND_TEST( 11 | DBC_test 12 | SOURCES tstDBC.cpp unit_test_main.cpp 13 | COMM serial mpi 14 | STANDARD_PASS_OUTPUT 15 | FAIL_REGULAR_EXPRESSION "data race;data race;leak;runtime error" 16 | ) 17 | -------------------------------------------------------------------------------- /packages/Utils/test/tstMiscellaneous.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2020 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | #include 18 | #include 19 | 20 | TEUCHOS_UNIT_TEST( DataTransferKitRuntimeAPI, return_version ) 21 | { 22 | auto const dtk_version = DataTransferKit::version(); 23 | TEST_ASSERT( !dtk_version.empty() ); 24 | std::cout << "DataTransferKit version " << dtk_version << std::endl; 25 | 26 | auto const dtk_commit_hash = DataTransferKit::gitCommitHash(); 27 | TEST_ASSERT( !dtk_commit_hash.empty() ); 28 | std::cout << "DataTransferKit commit hash " << dtk_commit_hash << std::endl; 29 | } 30 | 31 | namespace dummy 32 | { 33 | struct Foo 34 | { 35 | Foo( std::ostream &os ) { os << DTK_MARK_REGION( "hello world" ); } 36 | }; 37 | void bar( std::ostream &os ) { os << DTK_MARK_REGION( "it works" ); } 38 | } // namespace dummy 39 | 40 | TEUCHOS_UNIT_TEST( DataTransferKitMacros, mark_parallel_region ) 41 | { 42 | std::stringstream ss; 43 | dummy::Foo foo( ss ); 44 | TEST_EQUALITY( ss.str(), "DTK_hello world" ); 45 | 46 | ss.clear(); 47 | ss.str( "" ); 48 | dummy::bar( ss ); 49 | TEST_EQUALITY( ss.str(), "DTK_it works" ); 50 | } 51 | -------------------------------------------------------------------------------- /packages/Utils/test/unit_test_main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | * Copyright (c) 2012-2018 by the DataTransferKit authors * 3 | * All rights reserved. * 4 | * * 5 | * This file is part of the DataTransferKit library. DataTransferKit is * 6 | * distributed under a BSD 3-clause license. For the licensing terms see * 7 | * the LICENSE file in the top-level directory. * 8 | * * 9 | * SPDX-License-Identifier: BSD-3-Clause * 10 | ****************************************************************************/ 11 | 12 | #include 13 | 14 | #include 15 | #include 16 | 17 | int main( int argc, char *argv[] ) 18 | { 19 | Teuchos::GlobalMPISession mpiSession( &argc, &argv ); 20 | Teuchos::UnitTestRepository::setGloballyReduceTestResult( true ); 21 | Kokkos::initialize( argc, argv ); 22 | int return_val = 23 | Teuchos::UnitTestRepository::runUnitTestsFromMain( argc, argv ); 24 | Kokkos::finalize(); 25 | return return_val; 26 | } 27 | -------------------------------------------------------------------------------- /packages/dummy.cc: -------------------------------------------------------------------------------- 1 | // This file is necessary to create a dummy dtk_search library when ArborX is a 2 | // TPL 3 | -------------------------------------------------------------------------------- /scripts/changelog.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | [[ ! -f LICENSE ]] && echo "Call the script from DTK root" && exit 1 4 | 5 | ARGS=( 6 | # --token XXX 7 | --no-pull-requests 8 | --include-labels 'bug,enhancement,New Feature' 9 | --enhancement-labels 'enhancement,New Feature' 10 | ) 11 | github_changelog_generator ORNL-CEES/DataTransferKit "${ARGS[@]}" 12 | -------------------------------------------------------------------------------- /scripts/check_format_cpp.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | clang_format_executable=${CLANG_FORMAT_EXE:-clang-format-6.0} 4 | 5 | this_program=$(basename "$0") 6 | usage="Usage: 7 | $this_program [options] -- check format of the C++ source files 8 | 9 | Options: 10 | -h --help Print help and exit 11 | -q --quiet Quiet mode (do not print the diff) 12 | -p --apply-patch Apply diff patch to the source files" 13 | 14 | verbose=1 15 | apply_patch=0 16 | 17 | #echo "Arguments: $# $@" 18 | 19 | while [ $# -gt 0 ] 20 | do 21 | case $1 in 22 | -p|--apply-patch) 23 | apply_patch=1 24 | ;; 25 | -q|--quiet) 26 | verbose=0 27 | ;; 28 | -h|--help) 29 | echo "$usage" 30 | exit 0 31 | ;; 32 | *) 33 | echo "$this_program: Unkown argument '$1'. See '$this_program --help'." 34 | exit -1 35 | ;; 36 | esac 37 | 38 | shift 39 | done 40 | 41 | # shamelessy redirecting everything to /dev/null in quiet mode 42 | if [ $verbose -eq 0 ]; then 43 | exec &>/dev/null 44 | fi 45 | 46 | cpp_source_files=$(git ls-files packages | grep -E ".hpp$|.cpp$|.h$|.c$" | grep -v -f .clang-format-ignore) 47 | 48 | unformatted_files=() 49 | for file in $cpp_source_files; do 50 | diff -u \ 51 | <(cat $file) \ 52 | --label a/$file \ 53 | <($clang_format_executable $file) \ 54 | --label b/$file >&1 55 | if [ $? -eq 1 ]; then 56 | unformatted_files+=($file) 57 | fi 58 | done 59 | 60 | n_unformatted_files=${#unformatted_files[@]} 61 | if [ $n_unformatted_files -ne 0 ]; then 62 | echo "${#unformatted_files[@]} file(s) not formatted properly:" 63 | for file in ${unformatted_files[@]}; do 64 | echo " $file" 65 | if [ $apply_patch -eq 1 ]; then 66 | $clang_format_executable -i $file 67 | fi 68 | done 69 | else 70 | echo "OK" 71 | fi 72 | exit $n_unformatted_files 73 | -------------------------------------------------------------------------------- /scripts/check_no_trailing_whitespaces_or_tabs.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | grep \ 4 | --exclude={*.doc,*.eps,*.gif,*.jpg,*.pdf,*.png} \ 5 | --exclude={.project,.cproject} \ 6 | --exclude={*Makefile*,*makefile*} \ 7 | --exclude=.gitmodules \ 8 | --exclude=DTK_Fortran_wrap.cpp \ 9 | --exclude-dir=data \ 10 | --exclude-dir=Search \ 11 | --exclude-dir=cmake/tribits \ 12 | --regexp '[[:blank:]]$' \ 13 | --regexp $'\t' \ 14 | --line-number $(git ls-files) 15 | test $? -eq 1 16 | -------------------------------------------------------------------------------- /scripts/export_point_cloud_to_vtu.py: -------------------------------------------------------------------------------- 1 | import pyevtk 2 | import numpy as np 3 | 4 | # Input and output file are hardcoded at this time but that can be changed if 5 | # necessary 6 | input_filename = 'point_cloud.txt' 7 | # If output_path is ./point_cloud, the script will output in the current 8 | # directory a file named point_cloud.vtu 9 | output_path = './point_cloud' 10 | 11 | point_cloud = np.genfromtxt(input_filename, delimiter=' ') 12 | x = np.ascontiguousarray(point_cloud[:,0]) 13 | y = np.ascontiguousarray(point_cloud[:,1]) 14 | z = np.ascontiguousarray(point_cloud[:,2]) 15 | pyevtk.hl.pointsToVTK(output_path, x, y, z, data={"val" : 16 | np.ones([len(point_cloud)])}) 17 | -------------------------------------------------------------------------------- /scripts/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # An example hook script to verify what is about to be committed. 4 | # Called by "git commit" with no arguments. The hook should 5 | # exit with non-zero status after issuing an appropriate message if 6 | # it wants to stop the commit. 7 | # 8 | # To enable this hook, rename this file to "pre-commit". 9 | 10 | if git rev-parse --verify HEAD >/dev/null 2>&1 11 | then 12 | against=HEAD 13 | else 14 | # Initial commit: diff against an empty tree object 15 | against=4b825dc642cb6eb9a060e54bf8d69288fbee4904 16 | fi 17 | 18 | # If there are whitespace errors, print the offending file names and fail. 19 | git diff-index --cached --check $against 20 | if [[ $? != 0 ]]; then 21 | whitespace_failed=1 22 | else 23 | whitespace_failed=0; 24 | fi 25 | 26 | # If there are formatting errors, print the offending file names and fail. 27 | format_failed=0; 28 | git_clang_name="GIT_CLANG_NAME" 29 | if [[ "$git_clang_name" != "" ]]; then 30 | gcf="$($git_clang_name --diff $against)" 31 | if [[ ${gcf} != "no modified files to format" ]] && 32 | [[ ${gcf} != *" did not modify any files" ]]; then 33 | echo "${gcf}" 34 | lineno=`echo -e $gcf | wc -l` 35 | if [[ $lineno -gt 0 ]]; then format_failed=1; fi 36 | fi 37 | fi 38 | 39 | # Final check 40 | if [[ $whitespace_failed != 0 ]] || [[ $format_failed != 0 ]]; then 41 | echo "Before committing, please fix:" 42 | [[ $whitespace_failed != 0 ]] && echo " - whitespace errors" 43 | [[ $format_failed != 0 ]] && echo " - formatting errors" 44 | exit 1 45 | fi 46 | -------------------------------------------------------------------------------- /scripts/leak_blacklist.txt: -------------------------------------------------------------------------------- 1 | leak:libmpi.so 2 | leak:libopen-pal.so 3 | leak:exe 4 | -------------------------------------------------------------------------------- /scripts/performance_plot.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | ############################################################################### 4 | # Plot the evolution of the timings 5 | ############################################################################### 6 | 7 | import csv 8 | import getopt 9 | import numpy as np 10 | import pylab 11 | import sys 12 | 13 | # Read the command line arguments 14 | argv = sys.argv[1:] 15 | opts, args = getopt.getopt(argv, 'hi:', ['input_file=']) 16 | 17 | # Parse the arguments 18 | for opt, arg in opts: 19 | if opt == '-h': 20 | print('python performance_plot.py -i input_file') 21 | sys.exit() 22 | elif opt in ('-i', '--input_file'): 23 | input_file = arg 24 | 25 | # Extract the name of the benchmarks. We will use them as the title of our 26 | # plots 27 | titles = [] 28 | with open(input_file, 'r') as f: 29 | n_benchmarks = int(f.readline()) 30 | for i in range(n_benchmarks): 31 | titles.append(f.readline()) 32 | timing_types = f.readline().split() 33 | 34 | # Extract the commit hashes and the timings 35 | data = [[] for i in range(n_benchmarks)] 36 | commit_hash = [] 37 | build_number = [] 38 | with open(input_file, 'r') as f: 39 | reader = csv.reader(f) 40 | for i in range(n_benchmarks + 2): 41 | reader.next() 42 | counter = 0 43 | for row in reader: 44 | if counter == 0: 45 | commit_hash.append(row) 46 | row = reader.next() 47 | build_number.append(row) 48 | row = reader.next() 49 | data[counter].append(row) 50 | counter = (counter + 1) % n_benchmarks 51 | 52 | # Plot the timings 53 | for i in range(n_benchmarks): 54 | for j in range(len(timing_types)): 55 | timing = [] 56 | for d in data[i]: 57 | timing.append(d[j]) 58 | pylab.plot(timing) 59 | pylab.xticks(np.arange(len(build_number)), build_number, rotation=90) 60 | pylab.ylabel('Time ($\mu$s)') 61 | pylab.title(titles[i]) 62 | pylab.grid(True, which="both") 63 | pylab.tight_layout() 64 | pylab.savefig(timing_types[j] + '_' + str(i) + '.png') 65 | pylab.clf() 66 | pylab.cla() 67 | -------------------------------------------------------------------------------- /scripts/set_kokkos_env.sh: -------------------------------------------------------------------------------- 1 | # set nvcc as the underlying C++ compiler for Open MPI 2 | export OMPI_CXX=$TRILINOS_DIR/packages/kokkos/bin/nvcc_wrapper 3 | 4 | # set nvcc as the underlying C++ compiler for MPICH 5 | export MPICH_CXX=$TRILINOS_DIR/packages/kokkos/bin/nvcc_wrapper 6 | 7 | # set the original C++ compiler as the underlying compiler for the nvcc 8 | # wrapper 9 | export NVCC_WRAPPER_DEFAULT_COMPILER=$PATH_TO_CXX_COMPILER 10 | -------------------------------------------------------------------------------- /scripts/setup_hooks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cwd=`pwd` 4 | if [[ "$cwd" != *"/scripts" ]]; then 5 | echo "./setup_hooks.sh must be called from scripts dir" 6 | exit 1 7 | fi 8 | 9 | cp hooks/pre-commit ../.git/hooks/pre-commit 10 | 11 | ## If there are formatting errors, print the offending lines and fail. 12 | # Find clang-format that is used with git 13 | git_clang_name="" 14 | for name in "git-clang-format-mp-6.0" "git-clang-format-6.0" "git-clang-format" ; do 15 | which $name > /dev/null 2>&1 16 | if [[ $? == 0 ]]; then 17 | git_clang_name="$name" 18 | break; 19 | fi 20 | done 21 | 22 | # Fix the git-clang-format name in the hook (even if it's empty) 23 | # We use suffix to unify Linux and Darwin 24 | sed -i.bak "s/GIT_CLANG_NAME/$git_clang_name/" ../.git/hooks/pre-commit 25 | rm ../.git/hooks/pre-commit.bak 26 | 27 | if [[ $git_clang_name == "" ]]; then 28 | echo "Did not find git-clang-format" 29 | exit 0 30 | fi 31 | 32 | # We actually do have some version of clang-format 33 | clang_format="" 34 | for name in "clang-format-mp-6.0" "clang-format-6.0" "clang-format"; do 35 | which $name > /dev/null 2>&1 36 | if [[ $? == 0 ]]; then 37 | clang_format="$name" 38 | break 39 | fi 40 | done 41 | if [[ $clang_format == "" ]]; then 42 | # Found git-clang-format but not clang-format, weird. 43 | echo "Found git-clang-format but not clang-format, weird" 44 | exit 1 45 | fi 46 | 47 | # Check clang-format version 48 | clang_version=`$clang_format --version | awk '{print $3}' | cut -f 1,2 -d .` 49 | if [[ $clang_version != "6.0" ]]; then 50 | echo "Clang-format version is bad: $clang_version" 51 | git_clang_name="" 52 | clang_format="" 53 | fi 54 | 55 | git config clangFormat.style file 56 | git config clangFormat.extension .hpp,.cpp 57 | git config clangFormat.binary $clang_format 58 | -------------------------------------------------------------------------------- /scripts/undefined_blacklist.txt: -------------------------------------------------------------------------------- 1 | # This two problems seem related 2 | src:/scratch/source/trilinos/release/packages/stk/stk_mesh/* 3 | src:/usr/bin/../lib/gcc/x86_64-linux-gnu/5.4.0/../../../../include/c\+\+/5.4.0/bits/* 4 | --------------------------------------------------------------------------------