QUGaR 0.0.4
Loading...
Searching...
No Matches
cart_grid_tp.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_LIBRARY_CART_GRID_TP_HPP
12#define QUGAR_LIBRARY_CART_GRID_TP_HPP
13
20
21#include <qugar/bbox.hpp>
22#include <qugar/point.hpp>
24#include <qugar/tolerance.hpp>
25#include <qugar/types.hpp>
26
27#include <array>
28#include <cstddef>
29#include <memory>
30#include <optional>
31#include <vector>
32
33namespace qugar {
34
35
39template<int dim> class CartGridTP
40{
43
44public:
46
47
49 explicit CartGridTP(const std::array<std::vector<real>, dim> &breaks);
50
55 CartGridTP(const BoundBox<dim> &domain, const std::array<std::size_t, dim> &n_intrvs_dir);
56
60 explicit CartGridTP(const std::array<std::size_t, dim> &n_intrvs_dir);
62
64
65
69 [[nodiscard]] const std::vector<real> &get_breaks(int dir) const;
70
73 [[nodiscard]] const BoundBox<dim> &get_domain() const;
74
81 [[nodiscard]] int get_cell_id(const PointType &point, const Tolerance &tolerance = Tolerance()) const;
82
91 [[nodiscard]] std::optional<int> at_cells_boundary(const PointType &point,
92 const Tolerance &tolerance = Tolerance()) const;
93
99 [[nodiscard]] bool on_boundary(int cell_id, int local_facet_id) const;
100
105 [[nodiscard]] std::vector<int> get_boundary_cells(int facet_id) const;
106
111 [[nodiscard]] int to_flat(const TensorIndexTP<dim> &tid) const;
112
117 [[nodiscard]] TensorIndexTP<dim> to_tensor(int fid) const;
118
123
124
128 [[nodiscard]] int get_num_cells() const;
129
134 [[nodiscard]] BoundBox<dim> get_cell_domain(int cell_fid) const;
135
137
138
139private:
141
142
143 std::array<std::vector<real>, dim> breaks_;
149};
150
155template<int dim> class SubCartGridTP
156{
157public:
164 const TensorIndexTP<dim> &indices_start,
165 const TensorIndexTP<dim> &indices_end);
166
171 SubCartGridTP(const CartGridTP<dim> &grid, const TensorIndexRangeTP<dim> &indices_range);
172
177 explicit SubCartGridTP(const CartGridTP<dim> &grid);
178
179private:
181 // NOLINTNEXTLINE (cppcoreguidelines-avoid-const-or-ref-data-members)
185
186public:
195
200 [[nodiscard]] int to_flat(const TensorIndexTP<dim> &tid) const;
201
205 [[nodiscard]] int get_num_cells() const;
206
210 [[nodiscard]] bool is_unique_cell() const;
211
214 [[nodiscard]] const TensorIndexRangeTP<dim> &get_range() const;
215
220 [[nodiscard]] std::array<std::shared_ptr<const SubCartGridTP<dim>>, 2> split() const;
221
225 [[nodiscard]] BoundBox<dim> get_domain() const;
226
230 [[nodiscard]] const CartGridTP<dim> &get_grid() const;
231
235 [[nodiscard]] int get_single_cell() const;
236};
237
238}// namespace qugar
239
240#endif// QUGAR_LIBRARY_CART_GRID_TP_HPP
Definition of Cartesian bounding box class.
Class representing a dim-dimensional Cartesian product bounding box.
Definition bbox.hpp:38
Class representing a dim-dimensional Cartesian tensor-product grid.
Definition cart_grid_tp.hpp:40
TensorIndexRangeTP< dim > range_
Indices range.
Definition cart_grid_tp.hpp:147
std::array< std::vector< real >, dim > breaks_
Breaks definining the cell intervals along the dim parametric directions.
Definition cart_grid_tp.hpp:143
CartGridTP(const BoundBox< dim > &domain, const std::array< std::size_t, dim > &n_intrvs_dir)
Construct a new CartGridTP object from a domain and the number of intervals per direction.
CartGridTP(const std::array< std::size_t, dim > &n_intrvs_dir)
Construct a new CartGridTP object from a [0,1] domain and the number of intervals per direction.
qugar::BoundBox< dim > domain_
Domain of the grid.
Definition cart_grid_tp.hpp:145
int get_num_cells() const
Gets the total number of cell.
std::vector< int > get_boundary_cells(int facet_id) const
Gets the list of cells belonging to given facet of the grid.
std::optional< int > at_cells_boundary(const PointType &point, const Tolerance &tolerance=Tolerance()) const
Checks if the given point is on the boundary of two cells (up to tolerance).
bool on_boundary(int cell_id, int local_facet_id) const
Checks if a cell's facet is on the grids boundary.
const std::vector< real > & get_breaks(int dir) const
Gets the breaks along the given direction dir.
TensorSizeTP< dim > get_num_cells_dir() const
Gets the number of cells per direction.
int get_cell_id(const PointType &point, const Tolerance &tolerance=Tolerance()) const
Get the id of the cell the given point belongs to.
const BoundBox< dim > & get_domain() const
Gets the grid's domain.
int to_flat(const TensorIndexTP< dim > &tid) const
Gets the flat index of a grid cell from the tensor index.
Point< dim > PointType
Point type.
Definition cart_grid_tp.hpp:42
BoundBox< dim > get_cell_domain(int cell_fid) const
Gets an cell's domain.
TensorIndexTP< dim > to_tensor(int fid) const
Gets the tensor index of a grid cell from the flat index.
CartGridTP(const std::array< std::vector< real >, dim > &breaks)
Construct a new CartGridTP object from its breaks.
Subgrid of a Cartesian grid TP. It is a subset of the cells of a given grid.
Definition cart_grid_tp.hpp:156
const CartGridTP< dim > & grid_
Parent grid.
Definition cart_grid_tp.hpp:182
SubCartGridTP(const CartGridTP< dim > &grid, const TensorIndexTP< dim > &indices_start, const TensorIndexTP< dim > &indices_end)
Constructor.
int get_single_cell() const
Gets the single cell in the subgrid.
TensorIndexRangeTP< dim > range_
Indices range.
Definition cart_grid_tp.hpp:184
BoundBox< dim > get_domain() const
Creates the bounding box of the subgrid's domain.
const CartGridTP< dim > & get_grid() const
Gets the parent grid.
TensorSizeTP< dim > get_num_cells_dir() const
Gets the number of cells (spans) per direction of the subgrid.
int get_num_cells() const
Gets the total number of cells of the subgrid.
int to_flat(const TensorIndexTP< dim > &tid) const
Gets the flat index of a grid cells from the tensor index.
bool is_unique_cell() const
Checks if the subgrid has only one cell.
std::array< std::shared_ptr< const SubCartGridTP< dim > >, 2 > split() const
Splits the current subgrid along the direction with a largest number of cells.
SubCartGridTP(const CartGridTP< dim > &grid, const TensorIndexRangeTP< dim > &indices_range)
Constructor.
SubCartGridTP(const CartGridTP< dim > &grid)
Constructor. Creates a subgrid containing the full grid.
const TensorIndexRangeTP< dim > & get_range() const
Gets a range describing the range of the subrid.
Class representing a dim-dimensional range defined by lower and upper tensor bounds.
Definition tensor_index_tp.hpp:243
Class representing a dim-dimensional tensor-product indices.
Definition tensor_index_tp.hpp:95
Class representing a dim-dimensional tensor-product sizes container.
Definition tensor_index_tp.hpp:38
Class for tolerance related computations.
Definition tolerance.hpp:33
QUGaR's main namespace.
Definition affine_transf.hpp:28
Vector< T, dim > Point
Class representing a dim-dimensional Point.
Definition point.hpp:34
Definition and implementation of Point class.
Declaration of tensor-product index and size related classes.
Definition of tolerance related functionalities.
Declaration of types.