Vulpes  0.1.0
Versatile and parallel compUtational Library for high-order discontinuous Polytopal Element Simulations
Loading...
Searching...
No Matches
abs_agg_model.hpp
Go to the documentation of this file.
1// ----------------------------------------------------------------------
2//
3// Copyright (C) 2024 - 2026 by the Vulpes authors.
4// This file is part of Vulpes.
5//
6// Vulpes is free software; you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10//
11// Vulpes is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14// General Public License for more details.
15//
16// You should have received a copy of the GNU General Public License
17// along with Vulpes. If not, see <http://www.gnu.org/licenses/>.
18//
19// ----------------------------------------------------------------------
20
21// Author: Matteo Caldana <matteo.caldana@polimi.it>
22
23#ifndef VULPES_GEOMETRY_AGGLOMERATION_ABS_AGG_MODEL_HPP_
24#define VULPES_GEOMETRY_AGGLOMERATION_ABS_AGG_MODEL_HPP_
25
26#include <algorithm>
27#include <iostream>
28#include <memory>
29#include <set>
30#include <stdexcept>
31#include <string>
32#include <vector>
33
37
38namespace vulpes {
39namespace geometry {
40
42
70template <typename MeshType>
72 public:
73 using float_t = double;
74 using index_t = int64_t;
75 using IndVec = std::vector<index_t>;
77 using ParamType = std::variant<index_t, float_t>;
79 static constexpr index_t dim = MeshType::self_dim;
80
117 virtual std::vector<MeshType> agglomerate(
118 const MeshType& mesh,
119 MethodType method_type,
120 ParamType params,
121 bool return_hierarchy = true,
122 const std::string& segregated_tag = "",
123 const IndVec& subset = {}) = 0;
124
139 virtual void directKWay(
140 const MeshType& mesh,
141 std::size_t n_groups,
142 IndexTrackerType& indicator,
143 const std::vector<bool>& agglomerate) = 0;
144
166 std::vector<IndVec> multFactor(
167 const MeshType& mesh,
168 const float_t target_h,
169 IndexTrackerType& indicator,
170 const std::vector<bool>& agglomerate);
171
192 std::vector<IndVec> bisectNRef(
193 const MeshType& mesh,
194 const index_t n_refs,
195 IndexTrackerType& indicator,
196 const std::vector<bool>& agglomerate);
197
198 protected:
216 std::vector<IndVec> invokeMethod(
217 const MeshType& mesh,
218 MethodType method_type,
219 ParamType params,
220 const std::string& segregation_tag,
221 const IndVec& subset);
222
235 const MeshType& mesh, const IndVec& subgraph) = 0;
236
251 const IndVec& subset, IndexTrackerType& indicator, index_t& max_id);
252
269 void groupToBisection(
270 const IndVec& subset,
271 const IndVec& classes,
272 IndexTrackerType& indicator,
273 index_t new_id);
274
275 protected:
278};
279
284
285} // namespace geometry
286} // namespace vulpes
287
288#endif // VULPES_GEOMETRY_AGGLOMERATION_ABS_AGG_MODEL_HPP_
Definition crs_map.hpp:72
A class that uses a linked list to keep track of all the indices of a vector that are equal to a cert...
Definition index_tracker.hpp:47
Defines an abstract interface for mesh agglomeration strategies.
Definition abs_agg_model.hpp:71
virtual IndVec bisectSubGraph(const MeshType &mesh, const IndVec &subgraph)=0
Backend implementation of a single bisection operation.
virtual std::vector< MeshType > agglomerate(const MeshType &mesh, MethodType method_type, ParamType params, bool return_hierarchy=true, const std::string &segregated_tag="", const IndVec &subset={})=0
Agglomerates a mesh according to a selected strategy.
std::vector< IndVec > invokeMethod(const MeshType &mesh, MethodType method_type, ParamType params, const std::string &segregation_tag, const IndVec &subset)
Dispatches to the correct agglomeration method to compute cell labels.
Definition abs_agg_model.cpp:75
double float_t
Definition abs_agg_model.hpp:73
datastructure::IndexTracker< index_t > IndexTrackerType
Definition abs_agg_model.hpp:78
datastructure::CrsMap< index_t, index_t > MapType
Definition abs_agg_model.hpp:76
std::vector< IndVec > multFactor(const MeshType &mesh, const float_t target_h, IndexTrackerType &indicator, const std::vector< bool > &agglomerate)
Partitions the mesh based on a multiplicative factor strategy.
Definition abs_agg_model.cpp:262
static constexpr index_t dim
Definition abs_agg_model.hpp:79
std::vector< IndVec > bisectNRef(const MeshType &mesh, const index_t n_refs, IndexTrackerType &indicator, const std::vector< bool > &agglomerate)
Applies recursive bisection n_refs times.
Definition abs_agg_model.cpp:162
void connectedComponents(const IndVec &subset, IndexTrackerType &indicator, index_t &max_id)
Splits a set of cells into its connected components.
Definition abs_agg_model.cpp:216
std::variant< index_t, float_t > ParamType
Definition abs_agg_model.hpp:77
std::vector< index_t > IndVec
Definition abs_agg_model.hpp:75
MapType m_dual_map
The dual graph of the mesh, cached for performance.
Definition abs_agg_model.hpp:277
int64_t index_t
Definition abs_agg_model.hpp:74
virtual void directKWay(const MeshType &mesh, std::size_t n_groups, IndexTrackerType &indicator, const std::vector< bool > &agglomerate)=0
Performs a direct k-way partition on the (sub)mesh.
void groupToBisection(const IndVec &subset, const IndVec &classes, IndexTrackerType &indicator, index_t new_id)
Post-processes a binary labeling to ensure two connected partitions.
Definition abs_agg_model.cpp:328
Definition abs_agg_model.cpp:40
MethodType
Definition abs_agg_model.hpp:41
@ MultFactor
Definition abs_agg_model.hpp:41
@ SegregateBisection
Definition abs_agg_model.hpp:41
@ DirectKWay
Definition abs_agg_model.hpp:41
@ BisectNRef
Definition abs_agg_model.hpp:41
Definition cell_manager.hpp:38