-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add functions to check if the provided interpolation points are valid #686
Merged
+248
−10
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
497e80b
Add functions to check if the provided interpolation points are valid
EmilyBourne 8cac707
Clang format
EmilyBourne beb82a7
Update current_cell_end_idx
EmilyBourne ba851ad
Add comments
EmilyBourne 014e302
Clang format
EmilyBourne 596cd07
Remove attribute and fix variable name
tpadioleau 5ca017d
Call new method
EmilyBourne b21db2b
Fix constness
tpadioleau c8622c5
Add tests
tpadioleau 0452340
Fix ordering of points in spline builder test
tpadioleau File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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,139 @@ | ||
// Copyright (C) The DDC development team, see COPYRIGHT.md file | ||
// | ||
// SPDX-License-Identifier: MIT | ||
|
||
#include <cstddef> | ||
#include <stdexcept> | ||
#include <vector> | ||
|
||
#include <ddc/ddc.hpp> | ||
#include <ddc/kernels/splines.hpp> | ||
|
||
#include <gtest/gtest.h> | ||
|
||
#include <Kokkos_Core.hpp> | ||
|
||
struct DimX | ||
{ | ||
static constexpr bool PERIODIC = true; | ||
}; | ||
|
||
using CoordX = ddc::Coordinate<DimX>; | ||
|
||
static constexpr std::size_t s_degree_x = 2; | ||
|
||
struct BSplinesX : ddc::UniformBSplines<DimX, s_degree_x> | ||
{ | ||
}; | ||
|
||
struct IDimX : ddc::NonUniformPointSampling<DimX> | ||
{ | ||
}; | ||
|
||
using execution_space = Kokkos::DefaultHostExecutionSpace; | ||
using memory_space = Kokkos::HostSpace; | ||
|
||
TEST(SplineBuilder, ShortInterpolationGrid) | ||
{ | ||
CoordX const x0(0.); | ||
CoordX const xN(1.); | ||
std::size_t const ncells = 5; | ||
|
||
ddc::init_discrete_space<BSplinesX>(x0, xN, ncells); | ||
|
||
// One point missing | ||
std::vector<double> const range {0.1, 0.3, 0.5, 0.7}; | ||
|
||
ddc::DiscreteDomain<IDimX> const interpolation_domain | ||
= ddc::init_discrete_space<IDimX>(IDimX::init<IDimX>(range)); | ||
|
||
EXPECT_THROW( | ||
(ddc::SplineBuilder< | ||
execution_space, | ||
memory_space, | ||
BSplinesX, | ||
IDimX, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::SplineSolver::GINKGO, | ||
IDimX>(interpolation_domain)), | ||
std::runtime_error); | ||
} | ||
|
||
TEST(SplineBuilder, LongInterpolationGrid) | ||
{ | ||
CoordX const x0(0.); | ||
CoordX const xN(1.); | ||
std::size_t const ncells = 5; | ||
|
||
ddc::init_discrete_space<BSplinesX>(x0, xN, ncells); | ||
|
||
// One point too much | ||
std::vector<double> const range {0.1, 0.3, 0.5, 0.7, 0.9, 0.95}; | ||
|
||
ddc::DiscreteDomain<IDimX> const interpolation_domain | ||
= ddc::init_discrete_space<IDimX>(IDimX::init<IDimX>(range)); | ||
|
||
EXPECT_THROW( | ||
(ddc::SplineBuilder< | ||
execution_space, | ||
memory_space, | ||
BSplinesX, | ||
IDimX, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::SplineSolver::GINKGO, | ||
IDimX>(interpolation_domain)), | ||
std::runtime_error); | ||
} | ||
|
||
TEST(SplineBuilder, BadShapeInterpolationGrid) | ||
{ | ||
CoordX const x0(0.); | ||
CoordX const xN(1.); | ||
std::size_t const ncells = 5; | ||
|
||
ddc::init_discrete_space<BSplinesX>(x0, xN, ncells); | ||
|
||
// All points end up in the first cell ]0, 0.2[ | ||
std::vector<double> const range {0.1, 0.11, 0.12, 0.13, 0.14}; | ||
|
||
ddc::DiscreteDomain<IDimX> const interpolation_domain | ||
= ddc::init_discrete_space<IDimX>(IDimX::init<IDimX>(range)); | ||
|
||
EXPECT_THROW( | ||
(ddc::SplineBuilder< | ||
execution_space, | ||
memory_space, | ||
BSplinesX, | ||
IDimX, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::SplineSolver::GINKGO, | ||
IDimX>(interpolation_domain)), | ||
std::runtime_error); | ||
} | ||
|
||
TEST(SplineBuilder, CorrectInterpolationGrid) | ||
{ | ||
CoordX const x0(0.); | ||
CoordX const xN(1.); | ||
std::size_t const ncells = 5; | ||
|
||
ddc::init_discrete_space<BSplinesX>(x0, xN, ncells); | ||
|
||
std::vector<double> const range {0.05, 0.15, 0.5, 0.85, 0.95}; | ||
|
||
ddc::DiscreteDomain<IDimX> const interpolation_domain | ||
= ddc::init_discrete_space<IDimX>(IDimX::init<IDimX>(range)); | ||
|
||
EXPECT_NO_THROW((ddc::SplineBuilder< | ||
execution_space, | ||
memory_space, | ||
BSplinesX, | ||
IDimX, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::BoundCond::PERIODIC, | ||
ddc::SplineSolver::GINKGO, | ||
IDimX>(interpolation_domain))); | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry but I don't get the logic of the check. Are we checking the number of points in each cell ? If so shouldn't
current_cell_end_idx
increment in the loop as soon aspoint > ddc::coordinate(current_cell_end_idx)
is true ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I agree. Either I missed something while copy/pasting or the error output isn't correct in Gysela either. I don't see where
current_cell_idx
is updatedThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 26840d5