Loading [MathJax]/extensions/tex2jax.js
MeshKernel
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages Concepts
Hessian.hpp
1//---- GPL ---------------------------------------------------------------------
2//
3// Copyright (C) Stichting Deltares, 2011-2023.
4//
5// This program is free software: you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation version 3.
8//
9// This program is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13//
14// You should have received a copy of the GNU General Public License
15// along with this program. If not, see <http://www.gnu.org/licenses/>.
16//
17// contact: delft3d.support@deltares.nl
18// Stichting Deltares
19// P.O. Box 177
20// 2600 MH Delft, The Netherlands
21//
22// All indications and logos of, and references to, "Delft3D" and "Deltares"
23// are registered trademarks of Stichting Deltares, and remain the property of
24// Stichting Deltares. All rights reserved.
25//
26//------------------------------------------------------------------------------
27
28#pragma once
29
30#include <array>
31
32#include "MeshKernel/Definitions.hpp"
33#include "MeshKernel/Utilities/LinearAlgebra.hpp"
34
35namespace meshkernel
36{
37
39 using HessianDimension = std::array<UInt, 3>;
40
42 using MatrixColMajor = lin_alg::Matrix<double, Eigen::ColMajor>;
43
48 class Hessian
49 {
50 public:
52 Hessian() = default;
53
55 Hessian(const UInt dim1, const UInt dim2, const UInt dim3);
56
58 void resize(const UInt dim1, const UInt dim2, const UInt dim3);
59
63 UInt size(const UInt dim) const;
64
66 const HessianDimension& size() const;
67
69 UInt get1DIndex(const UInt dim2, const UInt dim3) const;
70
72 double operator()(const UInt dim1, const UInt dim2, const UInt dim3) const;
73
75 double& operator()(const UInt dim1, const UInt dim2, const UInt dim3);
76
80 double operator()(const UInt dim1, const UInt dim2) const;
81
83 const MatrixColMajor& getMatrix(const UInt dim) const;
84
86 MatrixColMajor& getMatrix(const UInt dim);
87
89 void zero();
90
91 private:
93 std::vector<MatrixColMajor> m_hessian;
94
96 HessianDimension m_dimensions{0, 0, 0};
97 };
98
99} // namespace meshkernel
100
102{
103 return m_dimensions[dim];
104}
105
107{
108 return m_dimensions;
109}
110
111inline meshkernel::UInt meshkernel::Hessian::get1DIndex(const UInt dim2, const UInt dim3) const
112{
113 return dim2 + m_dimensions[1] * dim3;
114}
115
116inline double meshkernel::Hessian::operator()(const UInt dim1, const UInt dim2, const UInt dim3) const
117{
118 return m_hessian[dim1](dim2, dim3);
119}
120
121inline double& meshkernel::Hessian::operator()(const UInt dim1, const UInt dim2, const UInt dim3)
122{
123 return m_hessian[dim1](dim2, dim3);
124}
125
126inline double meshkernel::Hessian::operator()(const UInt dim1, const UInt dim2) const
127{
128 return m_hessian[dim1](dim2);
129}
130
132{
133 return m_hessian[dim];
134}
135
137{
138 return m_hessian[dim];
139}
The hessian values.
Definition Hessian.hpp:49
const MatrixColMajor & getMatrix(const UInt dim) const
Get the matrix for a dimension.
Definition Hessian.hpp:131
UInt get1DIndex(const UInt dim2, const UInt dim3) const
Get the 1-dimension index of.
Definition Hessian.hpp:111
Hessian()=default
Default constructor.
double operator()(const UInt dim1, const UInt dim2, const UInt dim3) const
Get the value of the hessian.
Definition Hessian.hpp:116
void zero()
Set all entries to zero.
Hessian(const UInt dim1, const UInt dim2, const UInt dim3)
Constructor taking 3 parameters.
void resize(const UInt dim1, const UInt dim2, const UInt dim3)
Resize taking 3 parameters.
const HessianDimension & size() const
Get all the Hessian dimensions.
Definition Hessian.hpp:106
Contains the logic of the C++ static library.
Definition AveragingInterpolation.hpp:37
std::array< UInt, 3 > HessianDimension
Array containing dimensions of the hessian.
Definition Hessian.hpp:39
std::uint32_t UInt
Integer type used when indexing mesh graph entities.
Definition Definitions.hpp:39
lin_alg::Matrix< double, Eigen::ColMajor > MatrixColMajor
Define column major orientation.
Definition Hessian.hpp:42