From 5bac46422306aa59b2d4b5bcaee5977d89d6251c Mon Sep 17 00:00:00 2001 From: Matthew Parno Date: Fri, 22 Jul 2022 17:53:01 -0400 Subject: [PATCH] Added handling of other quadrature options. --- src/MapFactory.cpp | 102 ++++++++++++++++++++++++++++++++++++++ tests/Test_MapFactory.cpp | 47 +++++++++++++++--- 2 files changed, 142 insertions(+), 7 deletions(-) diff --git a/src/MapFactory.cpp b/src/MapFactory.cpp index d2e1fb5a..d82b63b8 100644 --- a/src/MapFactory.cpp +++ b/src/MapFactory.cpp @@ -63,6 +63,108 @@ std::shared_ptr> mpart::MapFactory::CreateCompon output->Coeffs() = Kokkos::View("Component Coefficients", mset.Size()); return output; } + + }else if(opts.quadType==QuadTypes::ClenshawCurtis){ + + ClenshawCurtisQuadrature quad(opts.quadPts, 1); + + if(opts.basisType==BasisTypes::ProbabilistHermite){ + + MultivariateExpansionWorker expansion(mset); + std::shared_ptr> output; + + switch(opts.posFuncType) { + case PosFuncTypes::SoftPlus: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + case PosFuncTypes::Exp: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + } + + output->SetCoeffs(Kokkos::View("Component Coefficients", mset.Size())); + return output; + + }else if(opts.basisType==BasisTypes::PhysicistHermite){ + + MultivariateExpansionWorker expansion(mset); + std::shared_ptr> output; + + switch(opts.posFuncType) { + case PosFuncTypes::SoftPlus: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + case PosFuncTypes::Exp: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + } + + output->SetCoeffs(Kokkos::View("Component Coefficients", mset.Size())); + return output; + + }else if(opts.basisType==BasisTypes::HermiteFunctions){ + + MultivariateExpansionWorker expansion(mset); + std::shared_ptr> output; + + switch(opts.posFuncType) { + case PosFuncTypes::SoftPlus: + output = std::make_shared>(mset, quad, opts.contDeriv); + case PosFuncTypes::Exp: + output = std::make_shared>(mset, quad, opts.contDeriv); + } + + output->Coeffs() = Kokkos::View("Component Coefficients", mset.Size()); + return output; + } + + }else if(opts.quadType==QuadTypes::AdaptiveClenshawCurtis){ + + unsigned int level = std::log2(opts.quadPts-2); + AdaptiveClenshawCurtis quad(level, opts.quadMaxSub, 1, nullptr, opts.quadAbsTol, opts.quadRelTol, QuadError::First, opts.quadMinSub); + + if(opts.basisType==BasisTypes::ProbabilistHermite){ + + MultivariateExpansionWorker expansion(mset); + std::shared_ptr> output; + + switch(opts.posFuncType) { + case PosFuncTypes::SoftPlus: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + case PosFuncTypes::Exp: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + } + + output->SetCoeffs(Kokkos::View("Component Coefficients", mset.Size())); + return output; + + }else if(opts.basisType==BasisTypes::PhysicistHermite){ + + MultivariateExpansionWorker expansion(mset); + std::shared_ptr> output; + + switch(opts.posFuncType) { + case PosFuncTypes::SoftPlus: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + case PosFuncTypes::Exp: + output = std::make_shared>(mset, quad, opts.contDeriv); break; + } + + output->SetCoeffs(Kokkos::View("Component Coefficients", mset.Size())); + return output; + + }else if(opts.basisType==BasisTypes::HermiteFunctions){ + + MultivariateExpansionWorker expansion(mset); + std::shared_ptr> output; + + switch(opts.posFuncType) { + case PosFuncTypes::SoftPlus: + output = std::make_shared>(mset, quad, opts.contDeriv); + case PosFuncTypes::Exp: + output = std::make_shared>(mset, quad, opts.contDeriv); + } + + output->Coeffs() = Kokkos::View("Component Coefficients", mset.Size()); + return output; + } + } diff --git a/tests/Test_MapFactory.cpp b/tests/Test_MapFactory.cpp index 14b6e079..cb0403a9 100644 --- a/tests/Test_MapFactory.cpp +++ b/tests/Test_MapFactory.cpp @@ -13,6 +13,7 @@ using MemorySpace = Kokkos::HostSpace; TEST_CASE( "Testing map component factory", "[MapFactoryComponent]" ) { + MapOptions options; options.basisType = BasisTypes::ProbabilistHermite; @@ -20,15 +21,47 @@ TEST_CASE( "Testing map component factory", "[MapFactoryComponent]" ) { unsigned int maxDegree = 5; FixedMultiIndexSet mset(dim,maxDegree); - std::shared_ptr> map = MapFactory::CreateComponent(mset, options); - REQUIRE(map!=nullptr); + SECTION("AdaptiveSimpson"){ + options.quadType = QuadTypes::AdaptiveSimpson; - unsigned int numPts = 100; - Kokkos::View pts("Points", dim, numPts); - for(unsigned int i=0; i> map = MapFactory::CreateComponent(mset, options); + REQUIRE(map!=nullptr); + + unsigned int numPts = 100; + Kokkos::View pts("Points", dim, numPts); + for(unsigned int i=0; i eval = map->Evaluate(pts); + } + + SECTION("ClenshawCurtis"){ + options.quadType = QuadTypes::ClenshawCurtis; + + std::shared_ptr> map = MapFactory::CreateComponent(mset, options); + REQUIRE(map!=nullptr); + + unsigned int numPts = 100; + Kokkos::View pts("Points", dim, numPts); + for(unsigned int i=0; i eval = map->Evaluate(pts); + } + + SECTION("AdaptiveClenshawCurtis"){ + options.quadType = QuadTypes::AdaptiveClenshawCurtis; + + std::shared_ptr> map = MapFactory::CreateComponent(mset, options); + REQUIRE(map!=nullptr); + + unsigned int numPts = 100; + Kokkos::View pts("Points", dim, numPts); + for(unsigned int i=0; i eval = map->Evaluate(pts); + Kokkos::View eval = map->Evaluate(pts); + } }