-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add dpnblist source code to dmff/dpnblist directory
- Loading branch information
Showing
560 changed files
with
255,080 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
cmake_minimum_required(VERSION 3.15) | ||
# project(dpnblist LANGUAGES CUDA CXX) | ||
project(dpnblist LANGUAGES CXX) | ||
|
||
# Set C++ standard | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
|
||
# Find CUDA | ||
find_package(CUDA QUIET) | ||
if (CUDA_FOUND) | ||
message(STATUS "CUDA found, compiling CUDA version") | ||
enable_language(CUDA) | ||
set(CUDA_NVCC_FLAGS 61) | ||
set(SOURCES | ||
src/pywrap.cpp | ||
src/nbList.cpp | ||
src/box.cpp | ||
src/nbSchAlg.cpp | ||
src/SchAlg/hashSchAlgGPU.cu | ||
src/SchAlg/hashSchAlgCPU.cpp | ||
src/SchAlg/octreeSchAlgCPU.cpp | ||
src/SchAlg/octreeSchAlgGPU.cu | ||
src/SchAlg/cellSchAlgCPU.cpp | ||
src/SchAlg/cellSchAlgGPU.cu | ||
) | ||
else() | ||
set(SOURCES | ||
src/pywrap_CPU.cpp | ||
src/nbList_CPU.cpp | ||
src/box.cpp | ||
src/nbSchAlg.cpp | ||
src/SchAlg/hashSchAlgCPU.cpp | ||
src/SchAlg/octreeSchAlgCPU.cpp | ||
src/SchAlg/cellSchAlgCPU.cpp | ||
) | ||
endif() | ||
|
||
# Find pybind11 | ||
find_package(pybind11 QUIET) | ||
if (NOT pybind11_FOUND) | ||
add_subdirectory(${CMAKE_SOURCE_DIR}/external/pybind11-2.11.1) | ||
endif() | ||
|
||
# Add the pybind11 module | ||
pybind11_add_module(dpnblist SHARED) | ||
target_sources(dpnblist PRIVATE ${SOURCES}) | ||
|
||
# Include directories | ||
target_include_directories(dpnblist PRIVATE | ||
${CMAKE_SOURCE_DIR}/src | ||
${CMAKE_SOURCE_DIR}/src/SchAlg | ||
) | ||
|
||
# Find and link OpenMP | ||
find_package(OpenMP REQUIRED) | ||
if(OpenMP_CXX_FOUND) | ||
target_link_libraries(dpnblist PUBLIC OpenMP::OpenMP_CXX) | ||
endif() | ||
|
||
# Find and link Python3 | ||
find_package(Python3 REQUIRED COMPONENTS Development) | ||
if (Python3_FOUND) | ||
target_link_libraries(dpnblist PUBLIC Python3::Python) | ||
endif() | ||
|
||
# Add subdirectory for tests | ||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
add_library(dpnblist ${SOURCES}) | ||
target_include_directories(dpnblist PRIVATE | ||
${CMAKE_SOURCE_DIR}/src | ||
${CMAKE_SOURCE_DIR}/src/SchAlg | ||
) | ||
target_link_libraries(dpnblist PUBLIC OpenMP::OpenMP_CXX Python3::Python) | ||
add_subdirectory(tests) | ||
endif() | ||
|
||
# Set position independent code | ||
set_target_properties(dpnblist PROPERTIES POSITION_INDEPENDENT_CODE ON) | ||
|
||
# Set compiler flags | ||
if (CUDA_FOUND) | ||
set(CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -Xcompiler -fopenmp -O3 -arch=sm_${CUDA_NVCC_FLAGS}") | ||
endif() | ||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -O3") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2024 Zhu Benhao | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# dpnblist | ||
Resable and Modular Neighborlist Lib | ||
|
||
### Installation | ||
you can follow the below commands to build the project | ||
``` | ||
cmake -B build | ||
cmake --build build | ||
``` | ||
then a .so lib will be generated, which can be used in python. | ||
|
||
### Usage | ||
In our neighbor list library, we provide a full type of neighbor list and include three different types of algorithms: cell list, octree, and hash methods, and support CPU and GPU. | ||
|
||
1. First, it is necessary to define a simulation system through the `box` class, mainly including two parameters, the `length` and `angle` of the simulation system, as shown in the table below: | ||
|
||
|Box Parameter | Data Type | | ||
|---|---| | ||
|length | list | | ||
|amgle | list | | ||
|
||
2. Then, specify different algorithms and platforms through the `NeighborList` class, with parameters as follows | ||
|
||
|Parameter| Data Type |Value| | ||
|---|---|---| | ||
|mode|string|"Linked_Cell-CPU" "Linked_Cell-GPU" "Octree-CPU" "Octree-GPU" "Hash-CPU" "Hash-GPU"| | ||
|
||
3. Finally, call the `build` method to generate the neighbor list, passing the `box`, `points`, and `cutoff` parameters. Then, use the `get_neighbor_pair` method to retrieve the neighbor list. | ||
|
||
Here's an example of usage: | ||
```python | ||
import nblist | ||
import numpy as np | ||
|
||
nblist.set_num_threads(4) | ||
print(nblist.get_max_threads()) | ||
num_particle = 30000 | ||
shape = (num_particle, 3) | ||
points = np.random.random(shape) * domain_size | ||
domain_size = [50.0, 50.0, 50.0] | ||
angle = [90.0, 90.0, 90.0] | ||
cutoff = 6.0 | ||
|
||
box = nblist.Box(domain_size, angle) | ||
nb = nblist.NeighborList("Linked_Cell-GPU") # Linked_Cell-GPU Linked_Cell-CPU Octree-GPU Octree-CPU Hash-GPU Hash-CPU | ||
nb.build(box, points, cutoff) | ||
pairs = nb.get_neighbor_pair() | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import dpnblist | ||
import numpy as np | ||
import time | ||
import freud | ||
|
||
dpnblist.set_num_threads(4) | ||
print(dpnblist.get_max_threads()) | ||
|
||
num_particle = 3000 | ||
domain_size = [50.0, 50.0, 50.0] | ||
angle = [90.0, 90.0, 90.0] | ||
shape = (num_particle, 3) | ||
inputs = np.random.random(shape) * domain_size | ||
cutoff = 6.0 | ||
|
||
box = dpnblist.Box(domain_size, angle) | ||
nb = dpnblist.NeighborList("Octree-CPU") # Linked_Cell-GPU Linked_Cell-CPU Octree-GPU Octree-CPU Hash-GPU Hash-CPU | ||
nb.build(box, inputs, cutoff) | ||
pairs = nb.get_neighbor_pair() | ||
lists = nb.get_neighbor_list() | ||
print(pairs[0:9]) | ||
print(lists[0:3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
# https://clang.llvm.org/docs/ClangFormatStyleOptions.html | ||
|
||
DisableFormat: false | ||
Language: Cpp | ||
Standard: Cpp11 | ||
IndentWidth: 4 | ||
TabWidth: 4 | ||
UseTab: Never | ||
ColumnLimit: 100 | ||
ReflowComments: false | ||
SortIncludes: false | ||
|
||
AlignConsecutiveAssignments: true | ||
AlignConsecutiveDeclarations: true | ||
AlignEscapedNewlinesLeft: false | ||
AlignOperands: true | ||
AlignTrailingComments: true | ||
AlignAfterOpenBracket: true | ||
DerivePointerAlignment: false | ||
PointerAlignment: Left | ||
IndentCaseLabels: true | ||
ContinuationIndentWidth: 8 | ||
NamespaceIndentation: Inner | ||
CompactNamespaces: true | ||
FixNamespaceComments: true | ||
AccessModifierOffset: -4 | ||
|
||
SpaceAfterControlStatementKeyword: false | ||
SpaceAfterCStyleCast: false | ||
SpaceBeforeAssignmentOperators: true | ||
SpaceBeforeParens: Never | ||
SpaceInEmptyParentheses: false | ||
SpacesBeforeTrailingComments: 1 | ||
SpacesInAngles: false | ||
SpacesInCStyleCastParentheses: false | ||
SpacesInContainerLiterals: false | ||
SpacesInParentheses: false | ||
SpacesInSquareBrackets: false | ||
Cpp11BracedListStyle: true | ||
|
||
KeepEmptyLinesAtTheStartOfBlocks: false | ||
MaxEmptyLinesToKeep: 1 | ||
BinPackArguments: true | ||
BinPackParameters: true | ||
AlwaysBreakAfterReturnType: None | ||
AlwaysBreakAfterDefinitionReturnType: None | ||
AlwaysBreakTemplateDeclarations: true | ||
BreakConstructorInitializersBeforeComma: true | ||
ConstructorInitializerAllOnOneLineOrOnePerLine: false | ||
ConstructorInitializerIndentWidth: 8 | ||
|
||
AllowShortIfStatementsOnASingleLine: false | ||
AllowShortLoopsOnASingleLine: false | ||
AllowShortBlocksOnASingleLine: true | ||
AllowShortCaseLabelsOnASingleLine: true | ||
AllowAllParametersOfDeclarationOnNextLine: true | ||
AllowShortFunctionsOnASingleLine: All | ||
|
||
BreakBeforeBinaryOperators: false | ||
BreakBeforeTernaryOperators: false | ||
BreakStringLiterals: true | ||
BreakBeforeBraces: Custom | ||
BraceWrapping: | ||
AfterClass: true | ||
AfterEnum: true | ||
AfterNamespace: false | ||
AfterStruct: true | ||
AfterUnion: true | ||
|
||
BeforeCatch: false | ||
BeforeElse: false | ||
IndentBraces: false | ||
AfterFunction: false | ||
AfterControlStatement: false | ||
|
||
# penalties not thought of yet | ||
PenaltyBreakBeforeFirstCallParameter: 19 | ||
PenaltyBreakComment: 60 | ||
PenaltyBreakString: 1000 | ||
PenaltyBreakFirstLessLess: 120 | ||
PenaltyExcessCharacter: 1000000 | ||
PenaltyReturnTypeOnItsOwnLine: 1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
Checks: '*, | ||
-altera-id-dependent-backward-branch, | ||
-altera-struct-pack-align, | ||
-altera-unroll-loops, | ||
-bugprone-easily-swappable-parameters, | ||
-bugprone-macro-parentheses, | ||
-bugprone-suspicious-include, | ||
-cppcoreguidelines-avoid-magic-numbers, | ||
-cppcoreguidelines-avoid-non-const-global-variables, | ||
-cppcoreguidelines-macro-usage, | ||
-cppcoreguidelines-non-private-member-variables-in-classes, | ||
-cppcoreguidelines-owning-memory, | ||
-cppcoreguidelines-pro-bounds-array-to-pointer-decay, | ||
-cppcoreguidelines-pro-bounds-constant-array-index, | ||
-cppcoreguidelines-pro-bounds-pointer-arithmetic, | ||
-cppcoreguidelines-pro-type-member-init, | ||
-cppcoreguidelines-pro-type-reinterpret-cast, | ||
-cppcoreguidelines-pro-type-union-access, | ||
-cppcoreguidelines-virtual-class-destructor, | ||
-fuchsia-default-arguments-calls, | ||
-fuchsia-default-arguments-declarations, | ||
-fuchsia-overloaded-operator, | ||
-google-build-using-namespace, | ||
-google-explicit-constructor, | ||
-google-readability-braces-around-statements, | ||
-google-readability-function-size, | ||
-google-readability-namespace-comments, | ||
-google-readability-todo, | ||
-google-runtime-int, | ||
-google-runtime-references, | ||
-hicpp-braces-around-statements, | ||
-hicpp-explicit-conversions, | ||
-hicpp-function-size, | ||
-hicpp-member-init, | ||
-hicpp-named-parameter, | ||
-hicpp-no-array-decay, | ||
-hicpp-no-assembler, | ||
-hicpp-signed-bitwise, | ||
-hicpp-uppercase-literal-suffix, | ||
-llvm-header-guard, | ||
-llvm-include-order, | ||
-llvm-namespace-comment, | ||
-llvmlibc-*, | ||
-misc-no-recursion, | ||
-misc-non-private-member-variables-in-classes, | ||
-modernize-concat-nested-namespaces, | ||
-modernize-use-default-member-init, | ||
-modernize-use-nodiscard, | ||
-modernize-use-trailing-return-type, | ||
-readability-braces-around-statements, | ||
-readability-function-cognitive-complexity, | ||
-readability-function-size, | ||
-readability-identifier-length, | ||
-readability-implicit-bool-conversion, | ||
-readability-magic-numbers, | ||
-readability-named-parameter, | ||
-readability-redundant-access-specifiers, | ||
-readability-uppercase-literal-suffix' | ||
|
||
WarningsAsErrors: '*' | ||
|
||
HeaderFilterRegex: '.*h$' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
trim_trailing_whitespace = true | ||
end_of_line = lf | ||
indent_style = space | ||
indent_size = 4 | ||
insert_final_newline = true | ||
|
||
[*.yml] | ||
indent_size = 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* text=auto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
github: onqtam | ||
patreon: onqtam | ||
custom: https://www.paypal.me/onqtam/10 | ||
|
29 changes: 29 additions & 0 deletions
29
dmff/dpnblist/external/doctest-2.4.11/.github/issue_template.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## Description | ||
<!-- | ||
If your issue is a bugreport, this means describing what you did, | ||
what did you want to happen and what actually did happen. | ||
If your issue is a feature request, describe the feature and why do you | ||
want it. | ||
--> | ||
|
||
|
||
### Steps to reproduce | ||
<!-- | ||
This is only relevant for bug reports, but if you do have one, | ||
please provide a minimal set of steps to reproduce the problem. | ||
Usually this means providing a small and self-contained code using doctest | ||
and specifying compiler flags/tools used if relevant. | ||
--> | ||
|
||
|
||
### Extra information | ||
<!-- | ||
Fill in any extra information that might be important for your issue. | ||
If your issue is a bugreport, definitely fill out at least the following. | ||
--> | ||
* doctest version: **v42.42.42** | ||
* Operating System: **Joe's discount operating system** | ||
* Compiler+version: **Hidden Dragon v1.2.3** |
Oops, something went wrong.