Finite Volume Solver  prototype
A framework to build finite volume solvers for the AG Klein at the Freie Universität Berlin.
CartesianCoordinates.hpp
Go to the documentation of this file.
1 // Copyright (c) 2018 Maikel Nadolski
2 //
3 // Permission is hereby granted, free of charge, to any person obtaining a copy
4 // of this software and associated documentation files (the "Software"), to deal
5 // in the Software without restriction, including without limitation the rights
6 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 // copies of the Software, and to permit persons to whom the Software is
8 // furnished to do so, subject to the following conditions:
9 //
10 // The above copyright notice and this permission notice shall be included in
11 // all copies or substantial portions of the Software.
12 //
13 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
19 // SOFTWARE.
20 
21 #ifndef FUB_CARTESIAN_COORDINATES_HPP
22 #define FUB_CARTESIAN_COORDINATES_HPP
23 
24 #include "fub/core/mdspan.hpp"
25 #include "fub/ext/Eigen.hpp"
26 
27 namespace fub {
28 
29 /// This class handles uniform cartesian cell coordinates.
30 ///
31 /// It stores lower and upper node coordinate bounds, cell widths and cell
32 /// extents. You can also compute cell and nodes coordinates with this class.
34 public:
35  /// This constructs a coordinate object given domain bounds, cell width and
36  /// cell extents.
37  ///
38  /// \param[in] lower Coordinates of lowest node.
39  /// \param[in] upper Coordinates of the highest node.
40  /// \param[in] dx Widths of cells
41  /// \param[in] extents Number of cells for all coordinate direction.
42  CartesianCoordinates(const Eigen::Vector3d& lower,
43  const Eigen::Vector3d& upper, const Eigen::Vector3d& dx,
44  dynamic_extents<3> extents) noexcept;
45 
46  /// Returns coordinates of the mid point of a cell in given cell indices.
47  ///
48  /// \param[in] i The cell index in X direction
49  /// \param[in] j The cell index in Y direction
50  /// \param[in] k The cell index in Z direction
51  ///
52  /// \see Same as CartesianCoordinates::CellCoordinates(i, j, k)
53  Eigen::Vector3d operator()(std::ptrdiff_t i, std::ptrdiff_t j = 0,
54  std::ptrdiff_t k = 0) const;
55 
56  /// Returns coordinates of the mid point of a cell in given cell indices.
57  ///
58  /// \param[in] i The cell index in X direction
59  /// \param[in] j The cell index in Y direction
60  /// \param[in] k The cell index in Z direction
61  ///
62  /// \return A three-dimensional Eigen::Vector3d.
63  ///
64  /// \see Same as CartesianCoordinates::operator()(i, j, k)
65  Eigen::Vector3d CellCoordinates(std::ptrdiff_t i, std::ptrdiff_t j,
66  std::ptrdiff_t k) const;
67 
68  /// Returns coordinates of a nodes in given nodes indices.
69  ///
70  /// \param[in] i The cell index in X direction
71  /// \param[in] j The cell index in Y direction
72  /// \param[in] k The cell index in Z direction
73  Eigen::Vector3d NodeCoordinates(std::ptrdiff_t i, std::ptrdiff_t j,
74  std::ptrdiff_t k) const;
75 
76  /// Returns the cell width size.
77  const Eigen::Vector3d& dx() const noexcept { return dx_; }
78 
79  /// Returns the most upper node coordinates (inclusive).
80  const Eigen::Vector3d& GetUpper() const noexcept { return upper_; }
81 
82  /// Returns the lowest node coordinates (inclusive).
83  const Eigen::Vector3d& GetLower() const noexcept { return lower_; }
84 
85 private:
86  Eigen::Vector3d lower_;
87  Eigen::Vector3d upper_;
88  Eigen::Vector3d dx_;
90 };
91 
92 } // namespace fub
93 
94 #endif
This class handles uniform cartesian cell coordinates.
Definition: CartesianCoordinates.hpp:33
Eigen::Vector3d dx_
Definition: CartesianCoordinates.hpp:88
Eigen::Vector3d lower_
Definition: CartesianCoordinates.hpp:86
CartesianCoordinates(const Eigen::Vector3d &lower, const Eigen::Vector3d &upper, const Eigen::Vector3d &dx, dynamic_extents< 3 > extents) noexcept
This constructs a coordinate object given domain bounds, cell width and cell extents.
Eigen::Vector3d upper_
Definition: CartesianCoordinates.hpp:87
const Eigen::Vector3d & dx() const noexcept
Returns the cell width size.
Definition: CartesianCoordinates.hpp:77
Eigen::Vector3d operator()(std::ptrdiff_t i, std::ptrdiff_t j=0, std::ptrdiff_t k=0) const
Returns coordinates of the mid point of a cell in given cell indices.
Eigen::Vector3d CellCoordinates(std::ptrdiff_t i, std::ptrdiff_t j, std::ptrdiff_t k) const
Returns coordinates of the mid point of a cell in given cell indices.
const Eigen::Vector3d & GetLower() const noexcept
Returns the lowest node coordinates (inclusive).
Definition: CartesianCoordinates.hpp:83
const Eigen::Vector3d & GetUpper() const noexcept
Returns the most upper node coordinates (inclusive).
Definition: CartesianCoordinates.hpp:80
dynamic_extents< 3 > extents_
Definition: CartesianCoordinates.hpp:89
Eigen::Vector3d NodeCoordinates(std::ptrdiff_t i, std::ptrdiff_t j, std::ptrdiff_t k) const
Returns coordinates of a nodes in given nodes indices.
An extents object defines a multidimensional index space which is the Cartesian product of integers e...
Definition: mdspan.hpp:208
The fub namespace.
Definition: AnyBoundaryCondition.hpp:31
typename dynamic_extents_< make_index_sequence< Rank > >::type dynamic_extents
Definition: mdspan.hpp:725