QUGaR 0.0.9
Loading...
Searching...
No Matches
tpms_lib.hpp
Go to the documentation of this file.
1// --------------------------------------------------------------------------
2//
3// Copyright (C) 2025-present by Pablo Antolin
4//
5// This file is part of the QUGaR library.
6//
7// SPDX-License-Identifier: MIT
8//
9// --------------------------------------------------------------------------
10
11#ifndef QUGAR_IMPL_TPMS_LIB_HPP
12#define QUGAR_IMPL_TPMS_LIB_HPP
13
20
22#include <qugar/vector.hpp>
23
24#include <qugar/numbers.hpp>
25#include <qugar/point.hpp>
26#include <qugar/types.hpp>
27
31
32template<int dim> class TPMSBase : public qugar::impl::ImplicitFunc<dim>
33{
34protected:
38 template<int dim_aux = dim>
39 requires(dim == dim_aux && dim_aux == 2)
40 TPMSBase(const Vector<real, 2> &mnq, real z) : z_(z)
41 {
42 mnq_(0) = mnq(0);
43 mnq_(1) = mnq(1);
44 }
45
48 template<int dim_aux = dim>
49 requires(dim == dim_aux && dim_aux == 3)
50 explicit TPMSBase(const Vector<real, 3> &mnq) : mnq_(mnq)
51 {}
52
53 TPMSBase() = default;
54
57
60};
61
62// NOLINTNEXTLINE (cppcoreguidelines-macro-usage)
63#define declare_tpms(TPMS_NAME) \
64 template<int dim> class TPMS_NAME : public TPMSBase<dim> \
65 { \
66 using Parent = TPMSBase<dim>; \
67 template<typename T> using Gradient = qugar::impl::ImplicitFunc<dim>::template Gradient<T>; \
68 template<typename T> using Hessian = qugar::impl::ImplicitFunc<dim>::template Hessian<T>; \
69 \
70 public: \
71 TPMS_NAME() = default; \
72 \
73 template<int dim_aux = dim> \
74 requires(dim == dim_aux && dim_aux == 2) \
75 explicit TPMS_NAME(const Vector<real, dim> &mnq, real z) : Parent(mnq, z) \
76 {} \
77 \
78 template<int dim_aux = dim> \
79 requires(dim == dim_aux && dim_aux == 3) \
80 explicit TPMS_NAME(const Vector<real, dim> &mnq) : Parent(mnq) \
81 {} \
82 \
83 [[nodiscard]] virtual real operator()(const Point<dim> &point) const final; \
84 \
85 [[nodiscard]] virtual ::algoim::Interval<dim> operator()( \
86 const Point<dim, ::algoim::Interval<dim>> &point) const final; \
87 \
88 [[nodiscard]] virtual Gradient<real> grad(const Point<dim> &point) const final; \
89 \
90 [[nodiscard]] virtual Gradient<::algoim::Interval<dim>> grad( \
91 const Point<dim, ::algoim::Interval<dim>> &point) const final; \
92 \
93 [[nodiscard]] virtual Hessian<real> hessian(const Point<dim> &point) const final; \
94 \
95 private: \
96 template<typename T> [[nodiscard]] T eval_(const Point<3, T> &point) const; \
97 \
98 template<typename T> [[nodiscard]] Gradient<T> grad_(const Point<3, T> &point) const; \
99 \
100 template<typename T> [[nodiscard]] Hessian<T> hessian_(const Point<3, T> &point) const; \
101 };
102
110
118declare_tpms(SchoenIWP);
119
127declare_tpms(SchoenFRD);
128
137declare_tpms(FischerKochS);
138
146declare_tpms(SchwarzDiamond);
147
154declare_tpms(SchwarzPrimitive);
155
156}// namespace qugar::impl::tpms
157
158
159#endif// QUGAR_IMPL_TPMS_LIB_HPP
Domain functions.
Definition domain_function.hpp:41
Definition tpms_lib.hpp:33
Vector< real, 3 > mnq_
Function periods.
Definition tpms_lib.hpp:56
TPMSBase(const Vector< real, 2 > &mnq, real z)
Definition tpms_lib.hpp:40
TPMSBase(const Vector< real, 3 > &mnq)
Definition tpms_lib.hpp:50
real z_
Constant z coordinate for 2D functions.
Definition tpms_lib.hpp:59
Declaration of a few implicit functions template class ready to be consumed by Algoim.
Definition tpms_lib.hpp:30
constexpr real zero
Real zero value.
Definition numbers.hpp:20
constexpr real one
Real one value.
Definition numbers.hpp:22
double real
Definition types.hpp:18
::algoim::uvector< T, dim > Vector
Class representing a vector.
Definition vector.hpp:31
Declaration of constant values.
Definition and implementation of Point class.
#define declare_tpms(TPMS_NAME)
Definition tpms_lib.hpp:63
Declaration of types.