QUGaR 0.0.4
Loading...
Searching...
No Matches
qugar::CartGridTP< dim > Class Template Reference

Class representing a dim-dimensional Cartesian tensor-product grid. More...

#include <cart_grid_tp.hpp>

Public Member Functions

Constructors
 CartGridTP (const std::array< std::vector< real >, dim > &breaks)
 Construct a new CartGridTP object from its breaks.
 
 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.
 
Query methods
const std::vector< real > & get_breaks (int dir) const
 Gets the breaks along the given direction dir.
 
const BoundBox< dim > & get_domain () const
 Gets the grid's domain.
 
int get_cell_id (const PointType &point, const Tolerance &tolerance=Tolerance()) const
 Get the id of the cell the given point belongs to.
 
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.
 
std::vector< int > get_boundary_cells (int facet_id) const
 Gets the list of cells belonging to given facet of the grid.
 
int to_flat (const TensorIndexTP< dim > &tid) const
 Gets the flat index of a grid cell from the tensor index.
 
TensorIndexTP< dim > to_tensor (int fid) const
 Gets the tensor index of a grid cell from the flat index.
 
TensorSizeTP< dim > get_num_cells_dir () const
 Gets the number of cells per direction.
 
int get_num_cells () const
 Gets the total number of cell.
 
BoundBox< dim > get_cell_domain (int cell_fid) const
 Gets an cell's domain.
 

Private Types

using PointType = Point<dim>
 Point type.
 

Private Attributes

Members
std::array< std::vector< real >, dim > breaks_
 Breaks definining the cell intervals along the dim parametric directions.
 
qugar::BoundBox< dim > domain_
 Domain of the grid.
 
TensorIndexRangeTP< dim > range_
 Indices range.
 

Detailed Description

template<int dim>
class qugar::CartGridTP< dim >

Class representing a dim-dimensional Cartesian tensor-product grid.

Template Parameters
dimDimension of the grid's domain.

Member Typedef Documentation

◆ PointType

template<int dim>
using qugar::CartGridTP< dim >::PointType = Point<dim>
private

Point type.

Constructor & Destructor Documentation

◆ CartGridTP() [1/3]

template<int dim>
qugar::CartGridTP< dim >::CartGridTP ( const std::array< std::vector< real >, dim > & breaks)
explicit

Construct a new CartGridTP object from its breaks.

Parameters
breaksBreaks defining the cell intervals along the dim parametric directions.

◆ CartGridTP() [2/3]

template<int dim>
qugar::CartGridTP< dim >::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.

Parameters
domainDomain of the grid.
n_intrvs_dirNumber of cell intervals along the dim parametric directions.

◆ CartGridTP() [3/3]

template<int dim>
qugar::CartGridTP< dim >::CartGridTP ( const std::array< std::size_t, dim > & n_intrvs_dir)
explicit

Construct a new CartGridTP object from a [0,1] domain and the number of intervals per direction.

Parameters
n_intrvs_dirNumber of cell intervals along the dim parametric directions.

Member Function Documentation

◆ at_cells_boundary()

template<int dim>
std::optional< int > qugar::CartGridTP< dim >::at_cells_boundary ( const PointType & point,
const Tolerance & tolerance = Tolerance() ) const
nodiscard

Checks if the given point is on the boundary of two cells (up to tolerance).

Parameters
pointPoint to query.
toleranceTolerance to be used in checkings.
Returns
If the point is not at any boundary, the returned optiona type has no value. Otherwise, it contains the index of the constant direction (from 0 to dim-1) of the boundary. For instance, in a 2D grid, if the point lays in a vertical boundary between two cells, it returns 0, but if the boundary is horizontal, returns 1.

◆ get_boundary_cells()

template<int dim>
std::vector< int > qugar::CartGridTP< dim >::get_boundary_cells ( int facet_id) const
nodiscard

Gets the list of cells belonging to given facet of the grid.

Parameters
facet_idId of the grid facet. It must be in the range [0, dim*2).
Returns
List of cells on the facet.

◆ get_breaks()

template<int dim>
const std::vector< real > & qugar::CartGridTP< dim >::get_breaks ( int dir) const
nodiscard

Gets the breaks along the given direction dir.

Parameters
dirDirection along which the breaks are extracted.
Returns
Breaks along dir.

◆ get_cell_domain()

template<int dim>
BoundBox< dim > qugar::CartGridTP< dim >::get_cell_domain ( int cell_fid) const
nodiscard

Gets an cell's domain.

Parameters
cell_fidFlat id of the cell.
Returns
Bounding box of the cell's domain.

◆ get_cell_id()

template<int dim>
int qugar::CartGridTP< dim >::get_cell_id ( const PointType & point,
const Tolerance & tolerance = Tolerance() ) const
nodiscard

Get the id of the cell the given point belongs to.

Parameters
pointPoint to query.
toleranceTolerance to be used in checkings.
Returns
Id of the cell. If the point belongs to more than one cell, it returns the lowest index of the neighbor cells.

◆ get_domain()

template<int dim>
const BoundBox< dim > & qugar::CartGridTP< dim >::get_domain ( ) const
nodiscard

Gets the grid's domain.

Returns
Grid's domain.

◆ get_num_cells()

template<int dim>
int qugar::CartGridTP< dim >::get_num_cells ( ) const
nodiscard

Gets the total number of cell.

Returns
Total number of cells.

◆ get_num_cells_dir()

template<int dim>
TensorSizeTP< dim > qugar::CartGridTP< dim >::get_num_cells_dir ( ) const
nodiscard

Gets the number of cells per direction.

Returns
Number of cells per direction.

◆ on_boundary()

template<int dim>
bool qugar::CartGridTP< dim >::on_boundary ( int cell_id,
int local_facet_id ) const
nodiscard

Checks if a cell's facet is on the grids boundary.

Parameters
cell_idId of the cell whose facet is checked.
local_facet_idId of the local facet of the cell.
Returns
bool Whether the face is on the grid's boundary.

◆ to_flat()

template<int dim>
int qugar::CartGridTP< dim >::to_flat ( const TensorIndexTP< dim > & tid) const
nodiscard

Gets the flat index of a grid cell from the tensor index.

Parameters
tidTensor cell index to transform.
Returns
Flat cell index.

◆ to_tensor()

template<int dim>
TensorIndexTP< dim > qugar::CartGridTP< dim >::to_tensor ( int fid) const
nodiscard

Gets the tensor index of a grid cell from the flat index.

Parameters
fidFlat cell index to transform.
Returns
Tensor cell index.

Member Data Documentation

◆ breaks_

template<int dim>
std::array<std::vector<real>, dim> qugar::CartGridTP< dim >::breaks_
private

Breaks definining the cell intervals along the dim parametric directions.

◆ domain_

template<int dim>
qugar::BoundBox<dim> qugar::CartGridTP< dim >::domain_
private

Domain of the grid.

◆ range_

template<int dim>
TensorIndexRangeTP<dim> qugar::CartGridTP< dim >::range_
private

Indices range.


The documentation for this class was generated from the following file: