-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #240 from ngs333/cpp_dev
Merge from ngs333 search branch - Ctest related
- Loading branch information
Showing
12 changed files
with
195 additions
and
35 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
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,42 @@ | ||
# https://approvaltestscpp.readthedocs.io/en/latest/generated_docs/CMakeIntegration.html#make-cmake-clone-approvaltests-cpp-and-catch2 | ||
|
||
# Needs CMake 3.14 or above | ||
Include(FetchContent) | ||
|
||
# Names of targets added here: | ||
# ghc_filesystem Catch2::Catch2 ApprovalTests::ApprovalTests fmt::fmt | ||
#TODO: update git tags to latest stables? | ||
|
||
# ------------------------------------------------------------------- | ||
FetchContent_Declare(Catch2 | ||
GIT_REPOSITORY https://github.com/catchorg/Catch2.git | ||
GIT_TAG v3.4.0) | ||
FetchContent_MakeAvailable(Catch2) | ||
### v2.13.4? devel? 3.3.3 (latest of 3.) | ||
|
||
# ------------------------------------------------------------------- | ||
FetchContent_Declare(ApprovalTests | ||
GIT_REPOSITORY https://github.com/approvals/ApprovalTests.cpp.git | ||
GIT_TAG master) | ||
FetchContent_MakeAvailable(ApprovalTests) | ||
|
||
# ------------------------------------------------------------------- | ||
## The format libray was instead brought in with the rest of the C++23 features, | ||
## and added to the std namespace. See the toplevel CMakeLists file. | ||
#FetchContent_Declare(fmt | ||
# GIT_REPOSITORY https://github.com/fmtlib/fmt.git | ||
# GIT_TAG 7.1.3) | ||
#FetchContent_MakeAvailable(fmt) | ||
|
||
#FetchContent_Declare(fmt | ||
# GIT_REPOSITORY https://github.com/fmtlib/fmt.git | ||
# GIT_TAG 10.0.0 | ||
# SYSTEM | ||
# OVERRIDE_FIND_PACKAGE) | ||
#FetchContent_MakeAvailable(fmt) | ||
|
||
# ------------------------------------------------------------------- | ||
FetchContent_Declare(filesystem | ||
GIT_REPOSITORY https://github.com/gulrak/filesystem.git | ||
GIT_TAG v1.5.0) | ||
FetchContent_MakeAvailable(filesystem) |
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
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
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 |
---|---|---|
@@ -1,8 +1,9 @@ | ||
|
||
add_library(libFrencu create_xgrid.C gradient_c2l.C interp.C mosaic_util.C | ||
mpp.C mpp_domain.C mpp_io.C read_mosaic.C tool_util.C config.h | ||
create_xgrid_gpu.C) | ||
create_xgrid_gpu.C | ||
create_xgrid_aux.h) | ||
|
||
#add_sycl_to_target(TARGET libFrencu SOURCES create_xgrid.C ) #may need other .C files later | ||
#TODO: dd_sycl_to_target(TARGET libFrencu SOURCES create_xgrid.C ) #may need other .C files later | ||
add_dependencies(libFrencu libSearch) | ||
target_link_libraries(libFrencu libSearch) |
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
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
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 @@ | ||
|
||
#ifndef FREGRID_CREATE_XGRID_AUX_H | ||
#define FREGRID_CREATE_XGRID_AUX_H | ||
|
||
#include <cmath> | ||
#include <vector> | ||
#include <array> | ||
#include <algorithm> | ||
#include <span> | ||
#include <source_location> | ||
#include "BBox3D.h" | ||
#include "Polygon.h" | ||
#include "mosaic_util.h" | ||
#include "create_xgrid.h" | ||
|
||
bool checkBBoxViaPolySamples(std::span<double> yv, std::span<double> xv, | ||
nct::BBox3D & box, unsigned int npoints1D = 5 ) { | ||
bool passed = true; | ||
std::array<double, 3> pt{}; | ||
const auto [miny_it, maxy_it] = std::minmax_element(begin(yv), end(yv)); | ||
const double miny = *miny_it; | ||
const double maxy = *maxy_it; | ||
const auto [minx_it, maxx_it] = std::minmax_element(begin(xv), end(xv)); | ||
const double minx = *minx_it; | ||
const double maxx = *maxx_it; | ||
|
||
const unsigned int NDX{npoints1D}; | ||
const unsigned int NDY{npoints1D}; | ||
const double dy = (maxy - miny) / NDY; | ||
const double dx = (maxx - minx) / NDX; | ||
for (int i = 0; i < NDX; ++i) { | ||
auto ax = minx + i * dx; | ||
for (int j = 0; j < NDY; ++j) { | ||
latlon2xyz(miny + j * dy, ax, pt); | ||
auto contains_point = nct::BBox3D::contains(box, pt); | ||
if (!contains_point) { | ||
passed = false; | ||
//TODO: the polygon and the box can be saved to strstream | ||
printPolygon<double>(std::cout, xv, yv); | ||
std::cout << box << std::endl; | ||
auto str = std::format("< {:16.10e}, {:16.10e}, {:16.10e}>", pt[0],pt[1],pt[2]); | ||
std::cout << str <<std::endl; | ||
} | ||
} | ||
} | ||
return passed; | ||
} | ||
#endif //FREGRID_CREATE_XGRID_AUX_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 |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
add_library(libSearch INTERFACE Polygon.h Point3D.h BruteBoxQuery.h DITreeNode.h DistanceInterval.h DITree.h | ||
Partition.h Comparators.h BoxedObj.h BBox3D.h TreePerfStats.h) | ||
target_include_directories(libSearch INTERFACE ${CMAKE_SOURCE_DIR}/search) | ||
add_library(libSearch INTERFACE ) | ||
target_include_directories(libSearch INTERFACE .) | ||
|
||
|
||
|
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,14 @@ | ||
|
||
add_executable(bbox_tests bbox_tests.C) | ||
|
||
include_directories(${CMAKE_SOURCE_DIR}) | ||
include_directories(${CMAKE_SOURCE_DIR}/include) | ||
include_directories(include) | ||
|
||
#find_package(fmt REQUIRED) | ||
|
||
target_link_libraries(bbox_tests libFrencu Catch2WithMain tbb) | ||
include_directories(${CMAKE_SOURCE_DIR}/libfrencutils) | ||
|
||
|
||
|
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,47 @@ | ||
#include <array> | ||
#include <sstream> | ||
#include <string> | ||
// #include <fmt/format.h> | ||
//#include <format> | ||
|
||
#include <catch2/catch_test_macros.hpp> | ||
//#include "ApprovalTests.hpp" | ||
|
||
#include "constant.h" | ||
#include "create_xgrid.h" | ||
#include "create_xgrid_aux.h" | ||
|
||
TEST_CASE("TEST SIMPLE_POLY BOX") | ||
{ | ||
std::array<size_t,4> is {0,1,2,3}; | ||
//std::vector<double> lats{88.98,88.98, 88.72, 88.72 }; | ||
// std::vector<double> lons{ 251.7, 148.3,57.81, 342.2 }; | ||
std::vector<double> lats{0,1, 0, 1 }; | ||
std::vector<double> lons{ 44, 45, 46, 45}; | ||
for(int i = 0; i<4; i++){ | ||
lats[i] = lats[i] * D2R; | ||
lons[i] = lons[i] * D2R; | ||
} | ||
auto box = getBoxForSphericalPolygon(lats.data(), lons.data(), is); | ||
bool passed = checkBBoxViaPolySamples({lats.data(),4}, {lons.data(),4}, box, 5); | ||
|
||
REQUIRE( passed == true ); | ||
} | ||
|
||
|
||
TEST_CASE("TEST NIKI_POLY BOX") | ||
{ | ||
std::array<size_t,4> is {0,1,2,3}; | ||
std::vector<double> lats{88.98,88.98, 88.72, 88.72 }; | ||
std::vector<double> lons{ 251.7, 148.3,57.81, 342.2 }; | ||
for(int i = 0; i<4; i++){ | ||
lats[i] = lats[i] * D2R; | ||
lons[i] = lons[i] * D2R; | ||
} | ||
auto box = getBoxForSphericalPolygon(lats.data(), lons.data(), is); | ||
bool passed = checkBBoxViaPolySamples({lats.data(),4}, {lons.data(),4}, box, 5); | ||
|
||
REQUIRE( passed == true ); | ||
} | ||
|
||
//TODO: Many More Tests |
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,2 @@ | ||
#define CATCH_CONFIG_MAIN | ||
#include <catch2/catch_all.hpp> |