QUGaR 0.0.4
Loading...
Searching...
No Matches
reparam_mesh.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_REPARAM_MESH_HPP
12#define QUGAR_REPARAM_MESH_HPP
13
20
21#include <qugar/bbox.hpp>
23#include <qugar/point.hpp>
24#include <qugar/tolerance.hpp>
26
27#include <cstddef>
28#include <memory>
29#include <span>
30#include <string>
31#include <vector>
32
33
34namespace qugar {
35
47template<int dim, int range> class ReparamMesh
48{
49public:
53 static const int chebyshev_order = 7;
54
58 explicit ReparamMesh(int order);
59
61 virtual ~ReparamMesh() = default;
62
63protected:
65 int order_;
67 std::vector<Point<range>> points_;
69 std::vector<std::size_t> connectivity_;
71 std::vector<std::size_t> wires_connectivity_;
72
73public:
84 void merge(const ReparamMesh<dim, range> &mesh);
85
90 template<int aux_dim = dim>
91 requires(aux_dim == dim && dim == range)
92 void add_full_cell(const BoundBox<dim> &domain, bool wirebasket);
93
102 template<int aux_dim = dim>
103 requires(aux_dim == dim && dim == range)
104 void add_full_cells(const CartGridTP<dim> &grid, const std::vector<int> &cell_ids, bool wirebasket);
105
112 [[nodiscard]] bool use_Chebyshev() const;
113
121 [[nodiscard]] static bool use_Chebyshev(int order);
122
129 void insert_cell_point(const Point<range> &point, int cell_id, int pt_id);
130
138
147 void scale_points(const std::vector<int> &point_ids,
148 const BoundBox<range> &old_domain,
149 const BoundBox<range> &new_domain);
150
158 void scale_points(const BoundBox<range> &old_domain, const BoundBox<range> &new_domain);
159
163 [[nodiscard]] const std::vector<Point<range>> &get_points() const;
164
168 [[nodiscard]] const std::vector<std::size_t> &get_connectivity() const;
169
173 [[nodiscard]] const std::vector<std::size_t> &get_wires_connectivity() const;
174
178 [[nodiscard]] int get_order() const;
179
183 [[nodiscard]] std::size_t get_num_cells() const;
184
188 [[nodiscard]] std::size_t get_num_points() const;
189
193 [[nodiscard]] std::size_t get_num_points_per_cell() const;
194
211 void write_VTK_file(const std::string &filename) const;
212
219 void permute_cell_directions(std::size_t cell_id);
220
227 void reserve_cells(std::size_t n_new_cells);
228
239 int allocate_cells(std::size_t n_new_cells);
240
241protected:
251 template<int sub_dim>
252 [[nodiscard]] bool check_edge_in_subdomain(const std::vector<std::size_t> &edge_points_ids,
253 const BoundBox<range> &domain,
254 const Tolerance &tol) const;
255
261 [[nodiscard]] bool check_subentity_degenerate(const std::vector<std::size_t> &points_ids, const Tolerance &tol) const;
262
270 template<int aux_dim = dim>
271 requires(aux_dim == dim && 1 < dim)
272 [[nodiscard]] std::vector<std::size_t> get_edge_points(int cell_id, int edge_id) const;
273
281 void sort_edge_points(std::span<std::size_t> edge_points_ids) const;
282
284
286};
287
288template<int dim, bool levelset>
289std::shared_ptr<const ReparamMesh<levelset ? dim - 1 : dim, dim>>
290 create_reparameterization(const UnfittedDomain<dim> &unf_domain, int n_pts_dir);
291
292template<int dim, bool levelset>
293std::shared_ptr<const ReparamMesh<levelset ? dim - 1 : dim, dim>>
294 create_reparameterization(const UnfittedDomain<dim> &unf_domain, const std::vector<int> &cells, int n_pts_dir);
295
296
297}// namespace qugar
298
299#endif// QUGAR_REPARAM_MESH_HPP
Definition of Cartesian bounding box class.
Definition of Cartesian grid 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
Class for storing an implicit domain reparameterization using Lagrange cells.
Definition reparam_mesh.hpp:48
void permute_cell_directions(std::size_t cell_id)
Permutes the directions of the given cell.
void add_full_cell(const BoundBox< dim > &domain, bool wirebasket)
Adds a full cell to the mesh corresponding to the given domain.
void add_full_cells(const CartGridTP< dim > &grid, const std::vector< int > &cell_ids, bool wirebasket)
Adds full cells to the mesh corresponding to the grid.
std::size_t get_num_points_per_cell() const
Retrieves the number of points per cell, that depends on the reparameterization order.
std::size_t get_num_cells() const
Retrieves the number of reparameterization cells.
const std::vector< Point< range > > & get_points() const
Retrieves the points the reparameterization points.
bool check_edge_in_subdomain(const std::vector< std::size_t > &edge_points_ids, const BoundBox< range > &domain, const Tolerance &tol) const
Checks if a reparameterization cell's edge belongs to a subentity of a domain.
void purge_duplicate_wirebasket_edges()
std::vector< std::size_t > wires_connectivity_
Cells wires' connectivity.
Definition reparam_mesh.hpp:71
bool check_subentity_degenerate(const std::vector< std::size_t > &points_ids, const Tolerance &tol) const
Checks if a reparameterization cell's sub-entity is degenerate (it has zero length).
static bool use_Chebyshev(int order)
Determines whether the Chebyshev nodes are used, or equally spaced nodes.
virtual ~ReparamMesh()=default
Default virtual destructor.
std::vector< std::size_t > connectivity_
Cells' connectivity.
Definition reparam_mesh.hpp:69
std::size_t get_num_points() const
Retrieves the number of points.
void reserve_cells(std::size_t n_new_cells)
Reserves memory for a specified number of cells.
void sort_edge_points(std::span< std::size_t > edge_points_ids) const
Sorts the given edge points by their IDs.
void merge(const ReparamMesh< dim, range > &mesh)
Merges the given mesh into the current mesh.
void merge_coincident_points(const Tolerance &tol)
Merges coincident points in the reparameterization up to tolerance.
bool use_Chebyshev() const
Determines whether the Chebyshev nodes are used, or equally spaced nodes.
int order_
Reparameterization order (number of points per direction).
Definition reparam_mesh.hpp:65
int allocate_cells(std::size_t n_new_cells)
Allocates memory for a specified number of cells.
void insert_cell_point(const Point< range > &point, int cell_id, int pt_id)
This method sets the given point point, with index pt_id, to the cell designed by cell_id.
void write_VTK_file(const std::string &filename) const
Writes the reparameterization data to a VTK file.
void scale_points(const BoundBox< range > &old_domain, const BoundBox< range > &new_domain)
Scales points from an old domain to a new domain.
int get_order() const
Retrieves the reparameterization's order.
std::vector< std::size_t > get_edge_points(int cell_id, int edge_id) const
Gets the ids of the points of an edge of a reparameterization cell.
const std::vector< std::size_t > & get_connectivity() const
Retrieves the reparameterization connectivity.
ReparamMesh(int order)
Constructor.
static const int chebyshev_order
Definition reparam_mesh.hpp:53
std::vector< Point< range > > points_
Vector of points.
Definition reparam_mesh.hpp:67
const std::vector< std::size_t > & get_wires_connectivity() const
Retrieves the wirebasket reparameterization connectivity.
void scale_points(const std::vector< int > &point_ids, const BoundBox< range > &old_domain, const BoundBox< range > &new_domain)
Scales points from an old domain to a new domain.
void sort_wirebasket_edges()
Class for tolerance related computations.
Definition tolerance.hpp:33
Definition unfitted_domain.hpp:49
QUGaR's main namespace.
Definition affine_transf.hpp:28
std::shared_ptr< const ReparamMesh< levelset ? dim - 1 :dim, dim > > create_reparameterization(const UnfittedDomain< dim > &unf_domain, int n_pts_dir)
Vector< T, dim > Point
Class representing a dim-dimensional Point.
Definition point.hpp:34
Definition and implementation of Point class.
Definition of tolerance related functionalities.
Declaration of of UnfittedDomain class.