DDC 0.1.0
Loading...
Searching...
No Matches
spline_boundary_conditions.hpp
1// Copyright (C) The DDC development team, see COPYRIGHT.md file
2//
3// SPDX-License-Identifier: MIT
4
5#pragma once
6
7#include <cstddef>
8#include <ostream>
9#include <stdexcept>
10
11namespace ddc {
12
13/** @brief An enum representing a spline boundary condition. Please refer to
14 * Emily Bourne's thesis (https://www.theses.fr/2022AIXM0412.pdf)
15 */
16enum class BoundCond {
17 PERIODIC, ///< Periodic boundary condition u(1)=u(n)
18 HERMITE, ///< Hermite boundary condition
19 GREVILLE, ///< Use Greville points instead of conditions on derivative for B-Spline interpolation
20};
21
22/**
23 * @brief Prints a boundary condition in a std::ostream.
24 *
25 * @param out The stream in which the boundary condition is printed.
26 * @param degree The boundary condition.
27 *
28 * @return The stream in which the boundary condition is printed.
29 **/
30static inline std::ostream& operator<<(std::ostream& out, ddc::BoundCond const bc)
31{
32 if (bc == ddc::BoundCond::PERIODIC) {
33 return out << "PERIODIC";
34 }
35
36 if (bc == ddc::BoundCond::HERMITE) {
37 return out << "HERMITE";
38 }
39
40 if (bc == ddc::BoundCond::GREVILLE) {
41 return out << "GREVILLE";
42 }
43
44 throw std::runtime_error("ddc::BoundCond not handled");
45}
46
47/**
48 * @brief Return the number of equations needed to describe a given boundary condition.
49 *
50 * @param bc The boundary condition.
51 * @param degree The degree of the spline.
52 *
53 * @return The number of equations.
54 **/
55constexpr int n_boundary_equations(ddc::BoundCond const bc, std::size_t const degree)
56{
58 return 0;
59 }
60
61 if (bc == ddc::BoundCond::HERMITE) {
62 return degree / 2;
63 }
64
65 throw std::runtime_error("ddc::BoundCond not handled");
66}
67
68} // namespace ddc
The top-level namespace of DDC.
constexpr int n_boundary_equations(ddc::BoundCond const bc, std::size_t const degree)
Return the number of equations needed to describe a given boundary condition.
BoundCond
An enum representing a spline boundary condition.
@ GREVILLE
Use Greville points instead of conditions on derivative for B-Spline interpolation.
@ HERMITE
Hermite boundary condition.
@ PERIODIC
Periodic boundary condition u(1)=u(n)