polyhedral-gravity 2.0__tar.gz → 2.0.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/CMakeLists.txt +5 -0
  2. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/PKG-INFO +2 -1
  3. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/README.md +33 -9
  4. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/thrust.cmake +3 -3
  5. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/xsimd.cmake +1 -1
  6. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/polyhedral_gravity.egg-info/PKG-INFO +2 -1
  7. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/polyhedral_gravity.egg-info/SOURCES.txt +2 -0
  8. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/setup.py +8 -1
  9. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/calculation/GravityEvaluable.h +2 -2
  10. polyhedral_gravity-2.0.3/src/polyhedralGravity/calculation/GravityModel.cpp +24 -0
  11. polyhedral_gravity-2.0.3/src/polyhedralGravity/calculation/GravityModel.h +46 -0
  12. polyhedral_gravity-2.0/src/polyhedralGravity/calculation/GravityModel.cpp → polyhedral_gravity-2.0.3/src/polyhedralGravity/calculation/GravityModelDetail.cpp +37 -60
  13. polyhedral_gravity-2.0.3/src/polyhedralGravity/calculation/GravityModelDetail.h +207 -0
  14. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/calculation/MeshChecking.h +1 -1
  15. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/model/Polyhedron.h +1 -1
  16. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravityPython/PolyhedralGravityPython.cpp +6 -0
  17. polyhedral_gravity-2.0/src/polyhedralGravity/calculation/GravityModel.h +0 -242
  18. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/LICENSE +0 -0
  19. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/MANIFEST.in +0 -0
  20. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/FindSphinx.cmake +0 -0
  21. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/gtest.cmake +0 -0
  22. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/pybind11.cmake +0 -0
  23. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/spdlog.cmake +0 -0
  24. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/tbb.cmake +0 -0
  25. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/tetgen.cmake +0 -0
  26. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/cmake/yaml.cmake +0 -0
  27. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/polyhedral_gravity.egg-info/dependency_links.txt +0 -0
  28. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/polyhedral_gravity.egg-info/not-zip-safe +0 -0
  29. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/polyhedral_gravity.egg-info/top_level.txt +0 -0
  30. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/setup.cfg +0 -0
  31. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/CMakeLists.txt +0 -0
  32. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/main.cpp +0 -0
  33. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/CMakeLists.txt +0 -0
  34. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/calculation/GravityEvaluable.cpp +0 -0
  35. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/calculation/MeshChecking.cpp +0 -0
  36. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/calculation/PolyhedronTransform.h +0 -0
  37. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/input/ConfigSource.h +0 -0
  38. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/input/DataSource.h +0 -0
  39. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/input/TetgenAdapter.cpp +0 -0
  40. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/input/TetgenAdapter.h +0 -0
  41. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/input/YAMLConfigReader.cpp +0 -0
  42. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/input/YAMLConfigReader.h +0 -0
  43. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/model/GravityModelData.h +0 -0
  44. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/output/CSVWriter.cpp +0 -0
  45. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/output/CSVWriter.h +0 -0
  46. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/output/Logging.cpp +0 -0
  47. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/output/Logging.h +0 -0
  48. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/util/UtilityConstants.h +0 -0
  49. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/util/UtilityContainer.h +0 -0
  50. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravity/util/UtilityThrust.h +0 -0
  51. {polyhedral_gravity-2.0 → polyhedral_gravity-2.0.3}/src/polyhedralGravityPython/CMakeLists.txt +0 -0
@@ -46,6 +46,11 @@ option(BUILD_POLYHEDRAL_GRAVITY_TESTS "Set to on if the tests should be built (D
46
46
  message(STATUS "BUILD_POLYHEDRAL_GRAVITY_TESTS = ${BUILD_POLYHEDRAL_GRAVITY_TESTS}")
47
47
 
48
48
 
49
+ IF(_LIBCPP_DISABLE_AVAILABILITY)
50
+ message(STATUS "Disabling availability macros for libc++")
51
+ add_definitions(-D_LIBCPP_DISABLE_AVAILABILITY)
52
+ endif ()
53
+
49
54
  #######################################################
50
55
  # Including dependencies needed across multiple targets
51
56
  #######################################################
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyhedral_gravity
3
- Version: 2.0
3
+ Version: 2.0.3
4
4
  Summary: Package to compute full gravity tensor of a given constant density polyhedron for arbitrary points
5
5
  Author: Jonas Schuhmacher
6
6
  Author-email: jonas.schuhmacher@tum.de
7
+ License: GPLv3
7
8
  Requires-Python: >=3.6
8
9
  License-File: LICENSE
9
10
 
@@ -2,6 +2,16 @@
2
2
 
3
3
  ![Build and Test](https://github.com/schuhmaj/polyhedral-gravity-model-cpp/actions/workflows/ctest.yml/badge.svg)
4
4
  [![Documentation Status](https://readthedocs.org/projects/polyhedral-gravity-model-cpp/badge/?version=latest)](https://polyhedral-gravity-model-cpp.readthedocs.io/en/latest/?badge=latest)
5
+ ![GitHub](https://img.shields.io/github/license/esa/polyhedral-gravity-model)
6
+
7
+ ![PyPI](https://img.shields.io/pypi/v/polyhedral-gravity)
8
+ ![Static Badge](https://img.shields.io/badge/platform-linux--64_%7C_win--64_%7C_osx--64_%7C_linux--arm64_%7C_osx--arm64-lightgrey)
9
+ ![PyPI - Downloads](https://img.shields.io/pypi/dm/polyhedral-gravity)
10
+
11
+ ![Conda](https://img.shields.io/conda/v/conda-forge/polyhedral-gravity-model)
12
+ ![Conda](https://img.shields.io/conda/pn/conda-forge/polyhedral-gravity-model)
13
+ ![Conda](https://img.shields.io/conda/dn/conda-forge/polyhedral-gravity-model)
14
+
5
15
 
6
16
  This code is a validated implementation in C++17 of the Polyhedral Gravity Model
7
17
  by Tsoulis et al.. It was created in a collaborative project between
@@ -55,21 +65,35 @@ The python interface can be easily installed with
55
65
 
56
66
  conda install -c conda-forge polyhedral-gravity-model
57
67
 
58
- This is currently only supported for `x86-64` systems since
59
- one of the dependencies is not available on conda for `aarch64`.
60
- However, building from source with `pip` can also be done
61
- on `aarch64` as shown below.
62
-
63
68
  ### pip
64
69
 
65
- Use pip to install the python interface in your local python runtime.
66
- The module will be build using CMake and the using the above
67
- requirements. Just execute in repository root:
70
+ As a second option, you can also install the python interface with pip.
71
+
72
+ pip install polyhedral-gravity
73
+
74
+ Binaries for the most common platforms are available on PyPI including
75
+ Windows, Linux and macOS. For macOS and Linux, binaries for
76
+ `x86_64` and `aarch64` are provided.
77
+ In case `pip` uses the source distribution, please make sure that
78
+ you have a C++17 capable compiler, CMake and ninja-build installed.
79
+
80
+ ### From source
81
+
82
+ The module will be build using a C++17 capable compiler,
83
+ CMake and ninja-build. Just execute the following command in
84
+ the repository root folder:
68
85
 
69
86
  pip install .
70
87
 
71
88
  To modify the build options (like parallelization) have a look
72
- at the `setupy.py` and the [next paragraph](#build-c).
89
+ at the `setupy.py` and the [next paragraph](#build-c). The options
90
+ are modified by setting the environment variables before executing
91
+ the `pip install .` command, e.g.:
92
+
93
+ export POLYHEDRAL_GRAVITY_PARALLELIZATION="TBB"
94
+ pip install .
95
+
96
+
73
97
  (Optional: For a faster build you can install all dependencies available
74
98
  for your system in your local python environment. That way, they
75
99
  won't be fetched from GitHub.)
@@ -11,7 +11,7 @@ set(THRUST_ENABLE_EXAMPLES "OFF")
11
11
  # Set standard CPP Dialect to 17 (default of thrust would be 14)
12
12
  set(THRUST_CPP_DIALECT 17)
13
13
 
14
- find_package(Thrust 2.1.0 QUIET)
14
+ find_package(Thrust 1.16.0 QUIET)
15
15
 
16
16
  if (${Thrust_FOUND})
17
17
 
@@ -19,10 +19,10 @@ if (${Thrust_FOUND})
19
19
 
20
20
  else()
21
21
  message(STATUS "Using thrust from git repository")
22
- # Fetches the version 2.1.0 of the official NVIDIA Thrust repository
22
+ # Fetches the version 1.16.0 of the official NVIDIA Thrust repository
23
23
  FetchContent_Declare(thrust
24
24
  GIT_REPOSITORY https://github.com/NVIDIA/thrust.git
25
- GIT_TAG 2.1.0
25
+ GIT_TAG 1.16.0
26
26
  )
27
27
  FetchContent_MakeAvailable(thrust)
28
28
  endif()
@@ -3,7 +3,7 @@ include(FetchContent)
3
3
  message(STATUS "Setting up xsimd via CMake")
4
4
 
5
5
 
6
- find_package(xsimd 11.1.0 QUIET)
6
+ find_package(xsimd 11.1 QUIET)
7
7
 
8
8
  if (${xsimd_FOUND})
9
9
 
@@ -1,9 +1,10 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyhedral-gravity
3
- Version: 2.0
3
+ Version: 2.0.3
4
4
  Summary: Package to compute full gravity tensor of a given constant density polyhedron for arbitrary points
5
5
  Author: Jonas Schuhmacher
6
6
  Author-email: jonas.schuhmacher@tum.de
7
+ License: GPLv3
7
8
  Requires-Python: >=3.6
8
9
  License-File: LICENSE
9
10
 
@@ -24,6 +24,8 @@ src/polyhedralGravity/calculation/GravityEvaluable.cpp
24
24
  src/polyhedralGravity/calculation/GravityEvaluable.h
25
25
  src/polyhedralGravity/calculation/GravityModel.cpp
26
26
  src/polyhedralGravity/calculation/GravityModel.h
27
+ src/polyhedralGravity/calculation/GravityModelDetail.cpp
28
+ src/polyhedralGravity/calculation/GravityModelDetail.h
27
29
  src/polyhedralGravity/calculation/MeshChecking.cpp
28
30
  src/polyhedralGravity/calculation/MeshChecking.h
29
31
  src/polyhedralGravity/calculation/PolyhedronTransform.h
@@ -87,6 +87,12 @@ class CMakeBuild(build_ext):
87
87
  f"-D{option_name}={final_value}"
88
88
  ]
89
89
 
90
+ # Disable availability of standard libc++ on macOS if requested
91
+ if os.environ.get("_LIBCPP_DISABLE_AVAILABILITY"):
92
+ cmake_args += [
93
+ "-D_LIBCPP_DISABLE_AVAILABILITY=ON"
94
+ ]
95
+
90
96
  # Sets the CMake Generator if specified (this is separate from the other variables since it is given to
91
97
  # CMake vie the -G prefix
92
98
  final_generator = os.environ.get("CMAKE_GENERATOR", CMAKE_GENERATOR)
@@ -141,7 +147,7 @@ class CMakeBuild(build_ext):
141
147
  # --------------------------------------------------------------------------------
142
148
  setup(
143
149
  name="polyhedral_gravity",
144
- version="2.0",
150
+ version="2.0.3",
145
151
  author="Jonas Schuhmacher",
146
152
  author_email="jonas.schuhmacher@tum.de",
147
153
  description="Package to compute full gravity tensor of a given constant density polyhedron for arbitrary points",
@@ -152,6 +158,7 @@ setup(
152
158
  """,
153
159
  ext_modules=[CMakeExtension("polyhedral_gravity")],
154
160
  cmdclass={"build_ext": CMakeBuild},
161
+ license="GPLv3",
155
162
  license_file="LICENSE",
156
163
  zip_safe=False,
157
164
  python_requires=">=3.6",
@@ -6,12 +6,12 @@
6
6
  #include <sstream>
7
7
 
8
8
  #include "thrust/transform.h"
9
- #include "polyhedralGravity/calculation/GravityModel.h"
9
+ #include "thrust/execution_policy.h"
10
10
 
11
+ #include "polyhedralGravity/calculation/GravityModelDetail.h"
11
12
  #include "polyhedralGravity/input/TetgenAdapter.h"
12
13
  #include "polyhedralGravity/model/GravityModelData.h"
13
14
  #include "polyhedralGravity/model/Polyhedron.h"
14
- #include "thrust/execution_policy.h"
15
15
 
16
16
 
17
17
  namespace polyhedralGravity {
@@ -0,0 +1,24 @@
1
+ #include "GravityModel.h"
2
+
3
+ namespace polyhedralGravity::GravityModel {
4
+
5
+ GravityModelResult evaluate(
6
+ const PolyhedronOrSource &polyhedron,
7
+ double density, const Array3 &computationPoint, bool parallel) {
8
+ return std::get<GravityModelResult>(
9
+ std::visit([&parallel, &density, &computationPoint](const auto &polyhedron) {
10
+ GravityEvaluable evaluable{polyhedron, density};
11
+ return evaluable(computationPoint, parallel);
12
+ }, polyhedron));
13
+ }
14
+
15
+ std::vector<GravityModelResult>
16
+ evaluate(const PolyhedronOrSource &polyhedron, double density, const std::vector<Array3> &computationPoints,
17
+ bool parallel) {
18
+ return std::get<std::vector<GravityModelResult>>(std::visit([&parallel, &density, &computationPoints](const auto &polyhedron) {
19
+ GravityEvaluable evaluable{polyhedron, density};
20
+ return evaluable(computationPoints, parallel);
21
+ }, polyhedron));
22
+ }
23
+
24
+ }
@@ -0,0 +1,46 @@
1
+ #pragma once
2
+
3
+ #include <utility>
4
+ #include <array>
5
+ #include <vector>
6
+ #include <algorithm>
7
+ #include <variant>
8
+
9
+ #include "polyhedralGravity/calculation/GravityEvaluable.h"
10
+ #include "polyhedralGravity/model/GravityModelData.h"
11
+ #include "polyhedralGravity/model/Polyhedron.h"
12
+
13
+ /**
14
+ * Namespace containing the methods used to evaluate the polyhedrale Gravity Model
15
+ * @note Naming scheme corresponds to the following:
16
+ * evaluate() --> main Method for evaluating the gravity model
17
+ * *() --> Methods calculating one property for the evaluation
18
+ */
19
+ namespace polyhedralGravity::GravityModel {
20
+
21
+ /**
22
+ * Evaluates the polyhedrale gravity model for a given constant density polyhedron at computation
23
+ * point P.
24
+ * @param polyhedron - the polyhedron consisting of vertices and triangular faces
25
+ * @param density - the constant density in [kg/m^3]
26
+ * @param computationPoint - the computation Point P
27
+ * @param parallel - whether to evaluate in parallel or serial
28
+ * @return the GravityModelResult containing the potential, the acceleration and the change of acceleration
29
+ * at computation Point P
30
+ */
31
+ GravityModelResult evaluate(const PolyhedronOrSource &polyhedron, double density, const Array3 &computationPoint, bool parallel = true);
32
+
33
+ /**
34
+ * Evaluates the polyhedral gravity model for a given constant density polyhedron at multiple computation
35
+ * points.
36
+ * @param polyhedron - the polyhedron consisting of vertices and triangular faces
37
+ * @param density - the constant density in [kg/m^3]
38
+ * @param computationPoints - vector of computation points
39
+ * @param parallel - whether to evaluate in parallel or serial
40
+ * @return the GravityModelResult containing the potential, the acceleration and the change of acceleration
41
+ * foreach computation Point P
42
+ */
43
+ std::vector<GravityModelResult>
44
+ evaluate(const PolyhedronOrSource &polyhedron, double density, const std::vector<Array3> &computationPoints, bool parallel = true);
45
+
46
+ }
@@ -1,40 +1,19 @@
1
- #include "GravityModel.h"
2
-
3
- namespace polyhedralGravity::GravityModel {
4
-
5
- GravityModelResult evaluate(
6
- const PolyhedronOrSource &polyhedron,
7
- double density, const Array3 &computationPoint, bool parallel) {
8
- return std::get<GravityModelResult>(
9
- std::visit([&parallel, &density, &computationPoint](const auto &polyhedron) {
10
- GravityEvaluable evaluable{polyhedron, density};
11
- return evaluable(computationPoint, parallel);
12
- }, polyhedron));
13
- }
14
-
15
- std::vector<GravityModelResult>
16
- evaluate(const PolyhedronOrSource &polyhedron, double density, const std::vector<Array3> &computationPoints,
17
- bool parallel) {
18
- return std::get<std::vector<GravityModelResult>>(std::visit([&parallel, &density, &computationPoints](const auto &polyhedron) {
19
- GravityEvaluable evaluable{polyhedron, density};
20
- return evaluable(computationPoints, parallel);
21
- }, polyhedron));
22
- }
1
+ #include "GravityModelDetail.h"
23
2
 
3
+ namespace polyhedralGravity::GravityModel::detail {
24
4
 
25
- Array3Triplet detail::buildVectorsOfSegments(const Array3 &vertex0, const Array3 &vertex1, const Array3 &vertex2) {
5
+ Array3Triplet buildVectorsOfSegments(const Array3 &vertex0, const Array3 &vertex1, const Array3 &vertex2) {
26
6
  using util::operator-;
27
7
  //Calculate G_ij
28
8
  return {vertex1 - vertex0, vertex2 - vertex1, vertex0 - vertex2};
29
9
  }
30
10
 
31
- Array3 detail::buildUnitNormalOfPlane(const Array3 &segmentVector1, const Array3 &segmentVector2) {
11
+ Array3 buildUnitNormalOfPlane(const Array3 &segmentVector1, const Array3 &segmentVector2) {
32
12
  //Calculate N_i as (G_i1 * G_i2) / |G_i1 * G_i2| with * being the cross product
33
13
  return util::normal(segmentVector1, segmentVector2);
34
14
  }
35
15
 
36
- Array3Triplet
37
- detail::buildUnitNormalOfSegments(const Array3Triplet &segmentVectors, const Array3 &planeUnitNormal) {
16
+ Array3Triplet buildUnitNormalOfSegments(const Array3Triplet &segmentVectors, const Array3 &planeUnitNormal) {
38
17
  Array3Triplet segmentUnitNormal{};
39
18
  //Calculate n_ij as (G_ij * N_i) / |G_ig * N_i| with * being the cross product
40
19
  std::transform(segmentVectors.cbegin(), segmentVectors.end(), segmentUnitNormal.begin(),
@@ -44,7 +23,7 @@ namespace polyhedralGravity::GravityModel {
44
23
  return segmentUnitNormal;
45
24
  }
46
25
 
47
- double detail::computeUnitNormalOfPlaneDirection(const Array3 &planeUnitNormal, const Array3 &vertex0) {
26
+ double computeUnitNormalOfPlaneDirection(const Array3 &planeUnitNormal, const Array3 &vertex0) {
48
27
  using namespace util;
49
28
  //Calculate N_i * -G_i1 where * is the dot product and then use the inverted sgn
50
29
  //We abstain on the double multiplication with -1 in the line above and beyond since two
@@ -52,7 +31,7 @@ namespace polyhedralGravity::GravityModel {
52
31
  return sgn(dot(planeUnitNormal, vertex0), util::EPSILON);
53
32
  }
54
33
 
55
- HessianPlane detail::computeHessianPlane(const Array3 &p, const Array3 &q, const Array3 &r) {
34
+ HessianPlane computeHessianPlane(const Array3 &p, const Array3 &q, const Array3 &r) {
56
35
  using namespace util;
57
36
  constexpr Array3 origin{0.0, 0.0, 0.0};
58
37
  const auto crossProduct = cross(p - q, p - r);
@@ -62,14 +41,14 @@ namespace polyhedralGravity::GravityModel {
62
41
  return {crossProduct[0], crossProduct[1], crossProduct[2], d};
63
42
  }
64
43
 
65
- double detail::distanceBetweenOriginAndPlane(const HessianPlane &hessianPlane) {
44
+ double distanceBetweenOriginAndPlane(const HessianPlane &hessianPlane) {
66
45
  //Compute h_p as D/sqrt(A^2 + B^2 + C^2)
67
46
  return std::abs(hessianPlane.d / std::sqrt(
68
47
  hessianPlane.a * hessianPlane.a + hessianPlane.b * hessianPlane.b + hessianPlane.c * hessianPlane.c));
69
48
  }
70
49
 
71
- Array3 detail::projectPointOrthogonallyOntoPlane(const Array3 &planeUnitNormal, double planeDistance,
72
- const HessianPlane &hessianPlane) {
50
+ Array3 projectPointOrthogonallyOntoPlane(const Array3 &planeUnitNormal, double planeDistance,
51
+ const HessianPlane &hessianPlane) {
73
52
  using namespace util;
74
53
  //Calculate the projection point by (22) P'_ = N_i / norm(N_i) * h_i
75
54
  // norm(N_i) is always 1 since N_i is a "normed" vector --> we do not need this division
@@ -103,9 +82,8 @@ namespace polyhedralGravity::GravityModel {
103
82
  return orthogonalProjectionPoint;
104
83
  }
105
84
 
106
- Array3
107
- detail::computeUnitNormalOfSegmentsDirections(const Array3Triplet &vertices, const Array3 &projectionPointOnPlane,
108
- const Array3Triplet &segmentUnitNormalsForPlane) {
85
+ Array3 computeUnitNormalOfSegmentsDirections(const Array3Triplet &vertices, const Array3 &projectionPointOnPlane,
86
+ const Array3Triplet &segmentUnitNormalsForPlane) {
109
87
  using namespace util;
110
88
  std::array<double, 3> segmentNormalOrientations{};
111
89
  //Equation (23)
@@ -122,9 +100,9 @@ namespace polyhedralGravity::GravityModel {
122
100
  return segmentNormalOrientations;
123
101
  }
124
102
 
125
- Array3Triplet detail::projectPointOrthogonallyOntoSegments(const Array3 &projectionPointOnPlane,
126
- const Array3 &segmentNormalOrientations,
127
- const Array3Triplet &face) {
103
+ Array3Triplet
104
+ projectPointOrthogonallyOntoSegments(const Array3 &projectionPointOnPlane, const Array3 &segmentNormalOrientations,
105
+ const Array3Triplet &face) {
128
106
  auto counterJ = thrust::counting_iterator<unsigned int>(0);
129
107
  Array3Triplet orthogonalProjectionPointOnSegmentPerPlane{};
130
108
 
@@ -147,8 +125,8 @@ namespace polyhedralGravity::GravityModel {
147
125
  return orthogonalProjectionPointOnSegmentPerPlane;
148
126
  }
149
127
 
150
- Array3 detail::projectPointOrthogonallyOntoSegment(const Array3 &vertex1, const Array3 &vertex2,
151
- const Array3 &orthogonalProjectionPointOnPlane) {
128
+ Array3 projectPointOrthogonallyOntoSegment(const Array3 &vertex1, const Array3 &vertex2,
129
+ const Array3 &orthogonalProjectionPointOnPlane) {
152
130
  using namespace util;
153
131
  //Preparing our the planes/ equations in matrix form
154
132
  const Array3 matrixRow1 = vertex2 - vertex1;
@@ -156,16 +134,16 @@ namespace polyhedralGravity::GravityModel {
156
134
  const Array3 matrixRow3 = cross(matrixRow2, matrixRow1);
157
135
  const Array3 d = {dot(matrixRow1, orthogonalProjectionPointOnPlane),
158
136
  dot(matrixRow2, orthogonalProjectionPointOnPlane), dot(matrixRow3, vertex1)};
159
- Matrix<double, 3, 3> columnMatrix = transpose(Matrix<double, 3, 3>{matrixRow1, matrixRow2, matrixRow3});
137
+ Matrix<double, 3, 3> columnMatrix = transpose(Matrix < double, 3, 3 > {matrixRow1, matrixRow2, matrixRow3});
160
138
  //Calculation and solving the equations of above
161
139
  const double determinant = det(columnMatrix);
162
- return Array3{det(Matrix<double, 3, 3>{d, columnMatrix[1], columnMatrix[2]}),
163
- det(Matrix<double, 3, 3>{columnMatrix[0], d, columnMatrix[2]}),
164
- det(Matrix<double, 3, 3>{columnMatrix[0], columnMatrix[1], d})} / determinant;
140
+ return Array3{det(Matrix < double, 3, 3 > {d, columnMatrix[1], columnMatrix[2]}),
141
+ det(Matrix < double, 3, 3 > {columnMatrix[0], d, columnMatrix[2]}),
142
+ det(Matrix < double, 3, 3 > {columnMatrix[0], columnMatrix[1], d})} / determinant;
165
143
  }
166
144
 
167
- Array3 detail::distancesBetweenProjectionPoints(const Array3 &orthogonalProjectionPointOnPlane,
168
- const Array3Triplet &orthogonalProjectionPointOnSegments) {
145
+ Array3 distancesBetweenProjectionPoints(const Array3 &orthogonalProjectionPointOnPlane,
146
+ const Array3Triplet &orthogonalProjectionPointOnSegments) {
169
147
  std::array<double, 3> segmentDistances{};
170
148
  //The inner loop with the running j --> iterating over the segments
171
149
  //Using the values P'_i and P''_ij for the calculation of the distance
@@ -177,9 +155,9 @@ namespace polyhedralGravity::GravityModel {
177
155
  return segmentDistances;
178
156
  }
179
157
 
180
- std::array<Distance, 3> detail::distancesToSegmentEndpoints(const Array3Triplet &segmentVectorsForPlane,
181
- const Array3Triplet &orthogonalProjectionPointsOnSegmentForPlane,
182
- const Array3Triplet &face) {
158
+ std::array<Distance, 3> distancesToSegmentEndpoints(const Array3Triplet &segmentVectorsForPlane,
159
+ const Array3Triplet &orthogonalProjectionPointsOnSegmentForPlane,
160
+ const Array3Triplet &face) {
183
161
  std::array<Distance, 3> distancesForPlane{};
184
162
  auto counter = thrust::counting_iterator<unsigned int>(0);
185
163
  auto zip = util::zipPair(segmentVectorsForPlane, orthogonalProjectionPointsOnSegmentForPlane);
@@ -254,10 +232,10 @@ namespace polyhedralGravity::GravityModel {
254
232
  }
255
233
 
256
234
  std::array<TranscendentalExpression, 3>
257
- detail::computeTranscendentalExpressions(const std::array<Distance, 3> &distancesForPlane, double planeDistance,
258
- const Array3 &segmentDistancesForPlane,
259
- const Array3 &segmentNormalOrientationsForPlane,
260
- const Array3 &projectionPointVertexNorms) {
235
+ computeTranscendentalExpressions(const std::array<Distance, 3> &distancesForPlane, double planeDistance,
236
+ const Array3 &segmentDistancesForPlane,
237
+ const Array3 &segmentNormalOrientationsForPlane,
238
+ const Array3 &projectionPointVertexNorms) {
261
239
  std::array<TranscendentalExpression, 3> transcendentalExpressionsForPlane{};
262
240
 
263
241
  //Zip iterator consisting of 3D and 1D distances l1/l2 and s1/2 for this plane | h_pq | sigma_pq for this plane
@@ -326,11 +304,10 @@ namespace polyhedralGravity::GravityModel {
326
304
  return transcendentalExpressionsForPlane;
327
305
  }
328
306
 
329
- std::pair<double, Array3> detail::computeSingularityTerms(const Array3Triplet &segmentVectorsForPlane,
330
- const Array3 &segmentNormalOrientationForPlane,
331
- const Array3 &projectionPointVertexNorms,
332
- const Array3 &planeUnitNormal, double planeDistance,
333
- double planeNormalOrientation) {
307
+ std::pair<double, Array3>
308
+ computeSingularityTerms(const Array3Triplet &segmentVectorsForPlane, const Array3 &segmentNormalOrientationForPlane,
309
+ const Array3 &projectionPointVertexNorms, const Array3 &planeUnitNormal,
310
+ double planeDistance, double planeNormalOrientation) {
334
311
  //1. Case: If all sigma_pq for a given plane p are 1.0 then P' lies inside the plane S_p
335
312
  if (std::all_of(segmentNormalOrientationForPlane.cbegin(), segmentNormalOrientationForPlane.cend(),
336
313
  [](const double sigma) { return sigma == 1.0; })) {
@@ -406,8 +383,8 @@ namespace polyhedralGravity::GravityModel {
406
383
  Array3{0.0, 0.0, 0.0}); //sing beta = 0
407
384
  }
408
385
 
409
- Array3 detail::computeNormsOfProjectionPointAndVertices(const Array3 &orthogonalProjectionPointOnPlane,
410
- const Array3Triplet &face) {
386
+ Array3 computeNormsOfProjectionPointAndVertices(const Array3 &orthogonalProjectionPointOnPlane,
387
+ const Array3Triplet &face) {
411
388
  using namespace util;
412
389
  return {euclideanNorm(orthogonalProjectionPointOnPlane - face[0]),
413
390
  euclideanNorm(orthogonalProjectionPointOnPlane - face[1]),
@@ -415,4 +392,4 @@ namespace polyhedralGravity::GravityModel {
415
392
  }
416
393
 
417
394
 
418
- }
395
+ } // namespace polyhedralGravity::GravityModel::detail
@@ -0,0 +1,207 @@
1
+ #pragma once
2
+
3
+ #include <utility>
4
+ #include <array>
5
+ #include <vector>
6
+ #include <algorithm>
7
+ #include <variant>
8
+
9
+ #include "spdlog/spdlog.h"
10
+ #include "thrust/iterator/zip_iterator.h"
11
+ #include "thrust/iterator/transform_iterator.h"
12
+ #include "thrust/iterator/counting_iterator.h"
13
+ #include "thrust/transform.h"
14
+ #include "thrust/transform_reduce.h"
15
+ #include "thrust/execution_policy.h"
16
+ #include "xsimd/xsimd.hpp"
17
+
18
+ #include "polyhedralGravity/calculation/PolyhedronTransform.h"
19
+ #include "polyhedralGravity/input/TetgenAdapter.h"
20
+ #include "polyhedralGravity/model/Polyhedron.h"
21
+ #include "polyhedralGravity/model/GravityModelData.h"
22
+ #include "polyhedralGravity/util/UtilityConstants.h"
23
+ #include "polyhedralGravity/util/UtilityContainer.h"
24
+ #include "polyhedralGravity/util/UtilityThrust.h"
25
+ #include "polyhedralGravity/output/Logging.h"
26
+
27
+ namespace polyhedralGravity::GravityModel::detail {
28
+
29
+ /**
30
+ * Computes the segment vectors G_ij for one plane of the polyhedron according to Tsoulis (18).
31
+ * The segment vectors G_ij represent the vector from one vertex of the face to the neighboring vertex and
32
+ * depict every line segment of the triangular face (A-B-C)
33
+ * @param vertex0 - the first vertex A
34
+ * @param vertex1 - the second vertex B
35
+ * @param vertex2 - the third vertex C
36
+ * @return the segment vectors for a plane
37
+ */
38
+ Array3Triplet buildVectorsOfSegments(const Array3 &vertex0, const Array3 &vertex1, const Array3 &vertex2);
39
+
40
+ /**
41
+ * Computes the plane unit normal N_p for one plane p of the polyhedron according to Tsoulis (19).
42
+ * The plane unit normal is the outward pointing normal of the face from the polyhedron.
43
+ * @param segmentVector1 - first edge
44
+ * @param segmentVector2 - second edge
45
+ * @return plane unit normal
46
+ */
47
+ Array3 buildUnitNormalOfPlane(const Array3 &segmentVector1, const Array3 &segmentVector2);
48
+
49
+ /**
50
+ * Computes the segment unit normals n_pq for one plane p of the polyhedron according to Tsoulis (20).
51
+ * The segment unit normal n_pq represent the normal of one line segment of a polyhedrale face.
52
+ * @param segmentVectors - the segment vectors of the face G_p(0-2)
53
+ * @param planeUnitNormal - the plane unit normal N_p
54
+ * @return segment unit normals n_pq for plane p with q = {0, 1, 2}
55
+ */
56
+ Array3Triplet buildUnitNormalOfSegments(const Array3Triplet &segmentVectors, const Array3 &planeUnitNormal);
57
+
58
+ /**
59
+ * Computes the plane unit normal orientation/ direction sigma_p for one plane p of the polyhedron
60
+ * according to Tsoulis (21).
61
+ * The plane unit normal orientation values represents the relative position of computation point P
62
+ * with respect to the pointing direction of N_p. E. g. if N_p points to the half-space containing P, the
63
+ * inner product of N_p and -G_i1 will be positive, leading to a negative sigma_p.
64
+ * If sigma_p is zero than P and P' lie geometrically in the same plane --> P == P'.
65
+ * @param planeUnitNormal - the plane unit normal N_p
66
+ * @param vertex0 - the first vertex of the plane
67
+ * @return plane normal orientation
68
+ */
69
+ double computeUnitNormalOfPlaneDirection(const Array3 &planeUnitNormal, const Array3 &vertex0);
70
+
71
+ /**
72
+ * Calculates the Hessian Plane form spanned by three given points p, q, and r.
73
+ * @param p - first point on the plane
74
+ * @param q - second point on the plane
75
+ * @param r - third point on the plane
76
+ * @return HessianPlane
77
+ * @related Cross-Product method https://tutorial.math.lamar.edu/classes/calciii/eqnsofplanes.aspx
78
+ */
79
+ HessianPlane computeHessianPlane(const Array3 &p, const Array3 &q, const Array3 &r);
80
+
81
+ /**
82
+ * Calculates the (plane) distances h_p of computation point P to the plane S_p given in Hessian Form
83
+ * according to the following equation:
84
+ * h_p = D / sqrt(A^2+B^2+C^2)
85
+ * @param hessianPlane - Hessian Plane Form of S_p
86
+ * @return plane distance h_p
87
+ */
88
+ double distanceBetweenOriginAndPlane(const HessianPlane &hessianPlane);
89
+
90
+ /**
91
+ * Computes P' for a given plane p according to equation (22) of Tsoulis paper.
92
+ * P' is the orthogonal projection of the computation point P onto the plane S_p.
93
+ * @param planeUnitNormal - the plane unit normal N_p
94
+ * @param planeDistance - the distance from P to the plane h_p
95
+ * @param hessianPlane - the Hessian Plane Form
96
+ * @return P' for this plane
97
+ */
98
+ Array3 projectPointOrthogonallyOntoPlane(const Array3 &planeUnitNormal, double planeDistance,
99
+ const HessianPlane &hessianPlane);
100
+
101
+ /**
102
+ * Computes the segment normal orientations/ directions sigma_pq for a given plane p.
103
+ * If sigma_pq is negative, this denotes that n_pq points to the half-plane containing P'. Nn case
104
+ * sigma_pq is positive, P' resides in the other half-plane and if sigma_pq is zero, then P' lies directly
105
+ * on the segment pq.
106
+ * @param vertices - the vertices of this plane
107
+ * @param projectionPointOnPlane - the projection point P' for this plane
108
+ * @param segmentUnitNormalsForPlane - the segment unit normals sigma_pq for this plane
109
+ * @return the segment normal orientations for the plane p
110
+ */
111
+ Array3 computeUnitNormalOfSegmentsDirections(const Array3Triplet &vertices, const Array3 &projectionPointOnPlane,
112
+ const Array3Triplet &segmentUnitNormalsForPlane);
113
+
114
+ /**
115
+ * Computes the orthogonal projection Points P'' foreach segment q of a given plane p.
116
+ * @param projectionPointOnPlane - the projection Point P'
117
+ * @param segmentNormalOrientations - the segment normal orientations sigma_pq for this plane p
118
+ * @param face - the vertices of the plane p
119
+ * @return the orthogonal projection points of P on the segment P'' foreach segment q of p
120
+ */
121
+ Array3Triplet
122
+ projectPointOrthogonallyOntoSegments(const Array3 &projectionPointOnPlane, const Array3 &segmentNormalOrientations,
123
+ const Array3Triplet &face);
124
+
125
+ /**
126
+ * Calculates the point P'' for a given Segment consisting of vertices v1 and v2 and the orthogonal projection
127
+ * point P' for the plane consisting of those vertices. Solves the three equations given in (24), (25) and (26).
128
+ * @param vertex1 - first endpoint of segment
129
+ * @param vertex2 - second endpoint of segment
130
+ * @param orthogonalProjectionPointOnPlane - the orthogonal projection P' of P on this plane
131
+ * @return P'' for this segment
132
+ * @note If sigma_pq is zero then P'' == P', this is not checked by this method, but has to be assured first
133
+ */
134
+ Array3 projectPointOrthogonallyOntoSegment(const Array3 &vertex1, const Array3 &vertex2,
135
+ const Array3 &orthogonalProjectionPointOnPlane);
136
+
137
+ /**
138
+ * Computes the (segment) distances h_pq between P' for a given plane p and P'' for a given segment q of plane p.
139
+ * @param orthogonalProjectionPointOnPlane - the orthogonal projection point P' for p
140
+ * @param orthogonalProjectionPointOnSegments - the orthogonal projection points P'' for each segment q of p
141
+ * @return distances h_pq for plane p
142
+ */
143
+ Array3 distancesBetweenProjectionPoints(const Array3 &orthogonalProjectionPointOnPlane,
144
+ const Array3Triplet &orthogonalProjectionPointOnSegments);
145
+
146
+ /**
147
+ * Computes the 3D distances l1_pq and l2_pq between the computation point P and the line
148
+ * segment endpoints of each polyhedral segment for one plane.
149
+ * Computes the 1D distances s1_pq and s2_pq between orthogonal projection of P on the line
150
+ * segment P''_pq and the line segment endpoints for each polyhedral segment for one plane
151
+ * @param segmentVectorsForPlane - the segment vectors G_pq for plane p
152
+ * @param orthogonalProjectionPointsOnSegmentForPlane - the orthogonal projection Points P'' for plane p
153
+ * @param face - the vertices of plane p
154
+ * @return distances l1_pq and l2_pq and s1_pq and s2_pq foreach segment q of plane p
155
+ */
156
+ std::array<Distance, 3> distancesToSegmentEndpoints(const Array3Triplet &segmentVectorsForPlane,
157
+ const Array3Triplet &orthogonalProjectionPointsOnSegmentForPlane,
158
+ const Array3Triplet &face);
159
+
160
+ /**
161
+ * Calculates the Transcendental Expressions LN_pq and AN_pq for every line segment of the polyhedron for
162
+ * a given plane p.
163
+ * LN_pq is calculated according to (14) using the natural logarithm and AN_pq is calculated according
164
+ * to (15) using the arctan.
165
+ * @param distancesForPlane - the distances l1, l2, s1, s2 foreach segment q of plane p
166
+ * @param planeDistance - the plane distance h_p for plane p
167
+ * @param segmentDistancesForPlane - the segment distance h_pq for segment q of plane p
168
+ * @param segmentNormalOrientationsForPlane - the segment normal orientations n_pq for a plane p
169
+ * @param orthogonalProjectionPointOnPlane - the orthogonal projection point P' for plane p
170
+ * @param face - the vertices of plane p
171
+ * @return LN_pq and AN_pq foreach segment q of plane p
172
+ */
173
+ std::array<TranscendentalExpression, 3>
174
+ computeTranscendentalExpressions(const std::array<Distance, 3> &distancesForPlane, double planeDistance,
175
+ const Array3 &segmentDistancesForPlane,
176
+ const Array3 &segmentNormalOrientationsForPlane,
177
+ const Array3 &projectionPointVertexNorms);
178
+
179
+ /**
180
+ * Calculates the singularities (correction) terms according to the Flow text for a given plane p.
181
+ * @param segmentVectorsForPlane - the segment vectors for a given plane
182
+ * @param segmentNormalOrientationForPlane - the segment orientation sigma_pq
183
+ * @param projectionPointVertexNorms - the projection point P'
184
+ * @param planeUnitNormal - the plane unit normal N_p
185
+ * @param planeDistance - the plane distance h_p
186
+ * @param planeNormalOrientation - the plane normal orientation sigma_p
187
+ * @param face - the vertices of plane p
188
+ * @return the singularities for a plane p
189
+ */
190
+ std::pair<double, Array3>
191
+ computeSingularityTerms(const Array3Triplet &segmentVectorsForPlane, const Array3 &segmentNormalOrientationForPlane,
192
+ const Array3 &projectionPointVertexNorms, const Array3 &planeUnitNormal,
193
+ double planeDistance, double planeNormalOrientation);
194
+
195
+
196
+ /**
197
+ * Computes the L2 norms of the orthogonal projection point P' on a plane p with each vertex of that plane p.
198
+ * The values are later used to determine if P' is situated at a vertex.
199
+ * @param orthogonalProjectionPointOnPlane - the orthogonal projection point P'
200
+ * @param face - the vertices of plane p
201
+ * @return the norms of p and each vertex
202
+ */
203
+ Array3
204
+ computeNormsOfProjectionPointAndVertices(const Array3 &orthogonalProjectionPointOnPlane, const Array3Triplet &face);
205
+
206
+
207
+ } // namespace polyhedralGravity::GravityModel::detail
@@ -8,7 +8,7 @@
8
8
  #include "polyhedralGravity/model/GravityModelData.h"
9
9
  #include "polyhedralGravity/util/UtilityContainer.h"
10
10
  #include "polyhedralGravity/util/UtilityConstants.h"
11
- #include "polyhedralGravity/calculation/GravityModel.h"
11
+ #include "polyhedralGravity/calculation/PolyhedronTransform.h"
12
12
 
13
13
  namespace polyhedralGravity::MeshChecking {
14
14
 
@@ -9,7 +9,7 @@
9
9
  #include <tuple>
10
10
  #include <variant>
11
11
  #include <string>
12
- #include "GravityModelData.h"
12
+ #include "polyhedralGravity/model/GravityModelData.h"
13
13
 
14
14
  namespace polyhedralGravity {
15
15
 
@@ -1,5 +1,8 @@
1
1
  #include <tuple>
2
2
  #include <variant>
3
+ #include <string>
4
+ #include <array>
5
+ #include <vector>
3
6
  #include "pybind11/pybind11.h"
4
7
  #include "pybind11/stl.h"
5
8
 
@@ -21,12 +24,15 @@ PYBIND11_MODULE(polyhedral_gravity, m) {
21
24
  m.def("evaluate", [](const PolyhedralSource &polyhedralSource, double density,
22
25
  const std::variant<Array3, std::vector<Array3>> &computationPoints,
23
26
  bool parallel) -> std::variant<GravityModelResult, std::vector<GravityModelResult>> {
27
+ using namespace polyhedralGravity;
24
28
  if (std::holds_alternative<Array3>(computationPoints)) {
25
29
  return std::visit([&density, &computationPoints, parallel](const auto &source) {
30
+ using namespace polyhedralGravity;
26
31
  return GravityModel::evaluate(source, density, std::get<Array3>(computationPoints), parallel);
27
32
  }, polyhedralSource);
28
33
  } else {
29
34
  return std::visit([&density, &computationPoints, parallel](const auto &source) {
35
+ using namespace polyhedralGravity;
30
36
  return GravityModel::evaluate(source, density, std::get<std::vector<Array3>>(computationPoints),
31
37
  parallel);
32
38
  }, polyhedralSource);
@@ -1,242 +0,0 @@
1
- #pragma once
2
-
3
- #include <utility>
4
- #include <array>
5
- #include <vector>
6
- #include <algorithm>
7
- #include <variant>
8
-
9
- #include "polyhedralGravity/input/TetgenAdapter.h"
10
- #include "polyhedralGravity/model/Polyhedron.h"
11
- #include "polyhedralGravity/model/GravityModelData.h"
12
- #include "polyhedralGravity/calculation/GravityEvaluable.h"
13
- #include "polyhedralGravity/calculation/PolyhedronTransform.h"
14
- #include "polyhedralGravity/util/UtilityConstants.h"
15
- #include "polyhedralGravity/util/UtilityContainer.h"
16
- #include "spdlog/spdlog.h"
17
- #include "thrust/iterator/zip_iterator.h"
18
- #include "thrust/iterator/transform_iterator.h"
19
- #include "thrust/iterator/counting_iterator.h"
20
- #include "thrust/transform.h"
21
- #include "thrust/transform_reduce.h"
22
- #include "thrust/execution_policy.h"
23
- #include "polyhedralGravity/util/UtilityThrust.h"
24
- #include "polyhedralGravity/output/Logging.h"
25
- #include "xsimd/xsimd.hpp"
26
-
27
- /**
28
- * Namespace containing the methods used to evaluate the polyhedrale Gravity Model
29
- * @note Naming scheme corresponds to the following:
30
- * evaluate() --> main Method for evaluating the gravity model
31
- * *() --> Methods calculating one property for the evaluation
32
- */
33
- namespace polyhedralGravity::GravityModel {
34
-
35
- /**
36
- * Evaluates the polyhedrale gravity model for a given constant density polyhedron at computation
37
- * point P.
38
- * @param polyhedron - the polyhedron consisting of vertices and triangular faces
39
- * @param density - the constant density in [kg/m^3]
40
- * @param computationPoint - the computation Point P
41
- * @param parallel - whether to evaluate in parallel or serial
42
- * @return the GravityModelResult containing the potential, the acceleration and the change of acceleration
43
- * at computation Point P
44
- */
45
- GravityModelResult evaluate(const PolyhedronOrSource &polyhedron, double density, const Array3 &computationPoint, bool parallel = true);
46
-
47
- /**
48
- * Evaluates the polyhedral gravity model for a given constant density polyhedron at multiple computation
49
- * points.
50
- * @param polyhedron - the polyhedron consisting of vertices and triangular faces
51
- * @param density - the constant density in [kg/m^3]
52
- * @param computationPoints - vector of computation points
53
- * @param parallel - whether to evaluate in parallel or serial
54
- * @return the GravityModelResult containing the potential, the acceleration and the change of acceleration
55
- * foreach computation Point P
56
- */
57
- std::vector<GravityModelResult>
58
- evaluate(const PolyhedronOrSource &polyhedron, double density, const std::vector<Array3> &computationPoints, bool parallel = true);
59
-
60
- namespace detail {
61
-
62
- /**
63
- * Computes the segment vectors G_ij for one plane of the polyhedron according to Tsoulis (18).
64
- * The segment vectors G_ij represent the vector from one vertex of the face to the neighboring vertex and
65
- * depict every line segment of the triangular face (A-B-C)
66
- * @param vertex0 - the first vertex A
67
- * @param vertex1 - the second vertex B
68
- * @param vertex2 - the third vertex C
69
- * @return the segment vectors for a plane
70
- */
71
- Array3Triplet buildVectorsOfSegments(const Array3 &vertex0, const Array3 &vertex1, const Array3 &vertex2);
72
-
73
- /**
74
- * Computes the plane unit normal N_p for one plane p of the polyhedron according to Tsoulis (19).
75
- * The plane unit normal is the outward pointing normal of the face from the polyhedron.
76
- * @param segmentVector1 - first edge
77
- * @param segmentVector2 - second edge
78
- * @return plane unit normal
79
- */
80
- Array3 buildUnitNormalOfPlane(const Array3 &segmentVector1, const Array3 &segmentVector2);
81
-
82
- /**
83
- * Computes the segment unit normals n_pq for one plane p of the polyhedron according to Tsoulis (20).
84
- * The segment unit normal n_pq represent the normal of one line segment of a polyhedrale face.
85
- * @param segmentVectors - the segment vectors of the face G_p(0-2)
86
- * @param planeUnitNormal - the plane unit normal N_p
87
- * @return segment unit normals n_pq for plane p with q = {0, 1, 2}
88
- */
89
- Array3Triplet buildUnitNormalOfSegments(const Array3Triplet &segmentVectors, const Array3 &planeUnitNormal);
90
-
91
- /**
92
- * Computes the plane unit normal orientation/ direction sigma_p for one plane p of the polyhedron
93
- * according to Tsoulis (21).
94
- * The plane unit normal orientation values represents the relative position of computation point P
95
- * with respect to the pointing direction of N_p. E. g. if N_p points to the half-space containing P, the
96
- * inner product of N_p and -G_i1 will be positive, leading to a negative sigma_p.
97
- * If sigma_p is zero than P and P' lie geometrically in the same plane --> P == P'.
98
- * @param planeUnitNormal - the plane unit normal N_p
99
- * @param vertex0 - the first vertex of the plane
100
- * @return plane normal orientation
101
- */
102
- double computeUnitNormalOfPlaneDirection(const Array3 &planeUnitNormal, const Array3 &vertex0);
103
-
104
- /**
105
- * Calculates the Hessian Plane form spanned by three given points p, q, and r.
106
- * @param p - first point on the plane
107
- * @param q - second point on the plane
108
- * @param r - third point on the plane
109
- * @return HessianPlane
110
- * @related Cross-Product method https://tutorial.math.lamar.edu/classes/calciii/eqnsofplanes.aspx
111
- */
112
- HessianPlane computeHessianPlane(const Array3 &p, const Array3 &q, const Array3 &r);
113
-
114
- /**
115
- * Calculates the (plane) distances h_p of computation point P to the plane S_p given in Hessian Form
116
- * according to the following equation:
117
- * h_p = D / sqrt(A^2+B^2+C^2)
118
- * @param hessianPlane - Hessian Plane Form of S_p
119
- * @return plane distance h_p
120
- */
121
- double distanceBetweenOriginAndPlane(const HessianPlane &hessianPlane);
122
-
123
- /**
124
- * Computes P' for a given plane p according to equation (22) of Tsoulis paper.
125
- * P' is the orthogonal projection of the computation point P onto the plane S_p.
126
- * @param planeUnitNormal - the plane unit normal N_p
127
- * @param planeDistance - the distance from P to the plane h_p
128
- * @param hessianPlane - the Hessian Plane Form
129
- * @return P' for this plane
130
- */
131
- Array3 projectPointOrthogonallyOntoPlane(const Array3 &planeUnitNormal, double planeDistance,
132
- const HessianPlane &hessianPlane);
133
-
134
- /**
135
- * Computes the segment normal orientations/ directions sigma_pq for a given plane p.
136
- * If sigma_pq is negative, this denotes that n_pq points to the half-plane containing P'. Nn case
137
- * sigma_pq is positive, P' resides in the other half-plane and if sigma_pq is zero, then P' lies directly
138
- * on the segment pq.
139
- * @param vertices - the vertices of this plane
140
- * @param projectionPointOnPlane - the projection point P' for this plane
141
- * @param segmentUnitNormalsForPlane - the segment unit normals sigma_pq for this plane
142
- * @return the segment normal orientations for the plane p
143
- */
144
- Array3
145
- computeUnitNormalOfSegmentsDirections(const Array3Triplet &vertices, const Array3 &projectionPointOnPlane,
146
- const Array3Triplet &segmentUnitNormalsForPlane);
147
-
148
- /**
149
- * Computes the orthogonal projection Points P'' foreach segment q of a given plane p.
150
- * @param projectionPointOnPlane - the projection Point P'
151
- * @param segmentNormalOrientations - the segment normal orientations sigma_pq for this plane p
152
- * @param face - the vertices of the plane p
153
- * @return the orthogonal projection points of P on the segment P'' foreach segment q of p
154
- */
155
- Array3Triplet projectPointOrthogonallyOntoSegments(const Array3 &projectionPointOnPlane,
156
- const Array3 &segmentNormalOrientations,
157
- const Array3Triplet &face);
158
-
159
- /**
160
- * Calculates the point P'' for a given Segment consisting of vertices v1 and v2 and the orthogonal projection
161
- * point P' for the plane consisting of those vertices. Solves the three equations given in (24), (25) and (26).
162
- * @param vertex1 - first endpoint of segment
163
- * @param vertex2 - second endpoint of segment
164
- * @param orthogonalProjectionPointOnPlane - the orthogonal projection P' of P on this plane
165
- * @return P'' for this segment
166
- * @note If sigma_pq is zero then P'' == P', this is not checked by this method, but has to be assured first
167
- */
168
- Array3 projectPointOrthogonallyOntoSegment(const Array3 &vertex1, const Array3 &vertex2,
169
- const Array3 &orthogonalProjectionPointOnPlane);
170
-
171
- /**
172
- * Computes the (segment) distances h_pq between P' for a given plane p and P'' for a given segment q of plane p.
173
- * @param orthogonalProjectionPointOnPlane - the orthogonal projection point P' for p
174
- * @param orthogonalProjectionPointOnSegments - the orthogonal projection points P'' for each segment q of p
175
- * @return distances h_pq for plane p
176
- */
177
- Array3 distancesBetweenProjectionPoints(const Array3 &orthogonalProjectionPointOnPlane,
178
- const Array3Triplet &orthogonalProjectionPointOnSegments);
179
-
180
- /**
181
- * Computes the 3D distances l1_pq and l2_pq between the computation point P and the line
182
- * segment endpoints of each polyhedral segment for one plane.
183
- * Computes the 1D distances s1_pq and s2_pq between orthogonal projection of P on the line
184
- * segment P''_pq and the line segment endpoints for each polyhedral segment for one plane
185
- * @param segmentVectorsForPlane - the segment vectors G_pq for plane p
186
- * @param orthogonalProjectionPointsOnSegmentForPlane - the orthogonal projection Points P'' for plane p
187
- * @param face - the vertices of plane p
188
- * @return distances l1_pq and l2_pq and s1_pq and s2_pq foreach segment q of plane p
189
- */
190
- std::array<Distance, 3> distancesToSegmentEndpoints(const Array3Triplet &segmentVectorsForPlane,
191
- const Array3Triplet &orthogonalProjectionPointsOnSegmentForPlane,
192
- const Array3Triplet &face);
193
-
194
- /**
195
- * Calculates the Transcendental Expressions LN_pq and AN_pq for every line segment of the polyhedron for
196
- * a given plane p.
197
- * LN_pq is calculated according to (14) using the natural logarithm and AN_pq is calculated according
198
- * to (15) using the arctan.
199
- * @param distancesForPlane - the distances l1, l2, s1, s2 foreach segment q of plane p
200
- * @param planeDistance - the plane distance h_p for plane p
201
- * @param segmentDistancesForPlane - the segment distance h_pq for segment q of plane p
202
- * @param segmentNormalOrientationsForPlane - the segment normal orientations n_pq for a plane p
203
- * @param orthogonalProjectionPointOnPlane - the orthogonal projection point P' for plane p
204
- * @param face - the vertices of plane p
205
- * @return LN_pq and AN_pq foreach segment q of plane p
206
- */
207
- std::array<TranscendentalExpression, 3>
208
- computeTranscendentalExpressions(const std::array<Distance, 3> &distancesForPlane, double planeDistance,
209
- const Array3 &segmentDistancesForPlane,
210
- const Array3 &segmentNormalOrientationsForPlane,
211
- const Array3 &projectionPointVertexNorms);
212
-
213
- /**
214
- * Calculates the singularities (correction) terms according to the Flow text for a given plane p.
215
- * @param segmentVectorsForPlane - the segment vectors for a given plane
216
- * @param segmentNormalOrientationForPlane - the segment orientation sigma_pq
217
- * @param projectionPointVertexNorms - the projection point P'
218
- * @param planeUnitNormal - the plane unit normal N_p
219
- * @param planeDistance - the plane distance h_p
220
- * @param planeNormalOrientation - the plane normal orientation sigma_p
221
- * @param face - the vertices of plane p
222
- * @return the singularities for a plane p
223
- */
224
- std::pair<double, Array3> computeSingularityTerms(const Array3Triplet &segmentVectorsForPlane,
225
- const Array3 &segmentNormalOrientationForPlane,
226
- const Array3 &projectionPointVertexNorms,
227
- const Array3 &planeUnitNormal, double planeDistance,
228
- double planeNormalOrientation);
229
-
230
-
231
- /**
232
- * Computes the L2 norms of the orthogonal projection point P' on a plane p with each vertex of that plane p.
233
- * The values are later used to determine if P' is situated at a vertex.
234
- * @param orthogonalProjectionPointOnPlane - the orthogonal projection point P'
235
- * @param face - the vertices of plane p
236
- * @return the norms of p and each vertex
237
- */
238
- Array3 computeNormsOfProjectionPointAndVertices(const Array3 &orthogonalProjectionPointOnPlane,
239
- const Array3Triplet &face);
240
-
241
- }
242
- }