6 changed files with 53 additions and 44 deletions
@ -1,4 +1,4 @@ |
|||
exposed_library("frontend", os.scriptdir()) |
|||
add_rules("config.indirect_predicates.flags") |
|||
-- add_rules("library.force.distribute.header", {headers = path.join(os.scriptdir(), "interface", "construct_helper.hpp")}) |
|||
add_deps("implicit_surface_network_process", "shared_module") |
|||
add_deps("implicit_surface_network_process", "surface_integrator","shared_module") |
|||
@ -1,24 +1,24 @@ |
|||
#include <gtest/gtest.h> |
|||
#include "SurfaceIntegrator.hpp" |
|||
#include <timer/scoped_timer.hpp> |
|||
|
|||
using namespace internal; |
|||
#include <SurfaceIntegrator.hpp> |
|||
|
|||
// 一个简单的方程:f(v) = v^2 - 2, df = 2v,根为 sqrt(2)
|
|||
TEST(SurfaceAreaCalculatorTest, NewtonMethodConverges) |
|||
int main() |
|||
{ |
|||
labelled_timers_manager timer{}; |
|||
|
|||
auto F = [](double v) -> equation_intermediate_t { |
|||
implicit_equation_intermediate iei; |
|||
iei.f = v * v - 2.0; |
|||
iei.df = 2.0 * v; |
|||
return equation_intermediate_t{iei}; |
|||
}; |
|||
// box_descriptor_t box{
|
|||
// {0., 0., 0.},
|
|||
// {1., 1., 1.}
|
|||
// };
|
|||
// primitive_node_t node{PRIMITIVE_TYPE_BOX, &box};
|
|||
|
|||
double v_initial = 1.0; |
|||
double tolerance = 1e-8; |
|||
int max_iterations = 20; |
|||
// timer.push_timer("run-time under 10^6 loops (old)");
|
|||
|
|||
double root = newton_method(F, v_initial, tolerance, max_iterations); |
|||
// for (auto i = 0; i < 1'000'000; ++i) { auto result = evaluate(node, Eigen::Vector3d::Ones() * 2); }
|
|||
|
|||
EXPECT_NEAR(root, std::sqrt(2.0), tolerance); |
|||
// timer.pop_timer("run-time under 10^6 loops (old)");
|
|||
|
|||
// timer.print();
|
|||
|
|||
return 0; |
|||
} |
|||
@ -1,13 +1,14 @@ |
|||
add_requires("gtest") |
|||
|
|||
internal_library("surface_integral", "SI", os.scriptdir()) |
|||
internal_library("surface_integrator", "SI", os.scriptdir()) |
|||
add_rules("config.indirect_predicates.flags") |
|||
add_deps("primitive_process", "shared_module") |
|||
add_deps("primitive_process", "implicit_surface_network_process", "shared_module") |
|||
|
|||
|
|||
-- add Google Test target |
|||
target("newton_method_test") |
|||
set_kind("binary") |
|||
add_deps("surface_integral") -- depend on the internal library surface_integral |
|||
add_deps("surface_integrator") -- depend on the internal library surface_integral |
|||
add_files("test/SurfaceIntegrator_test.cpp") |
|||
add_packages("gtest") |
|||
target_end() |
|||
target_end() |
|||
|
|||
Loading…
Reference in new issue