CoMMA 1.3.2
A geometric agglomerator for unstructured meshes
Loading...
Searching...
No Matches
ARComputer.h
Go to the documentation of this file.
1#ifndef COMMA_PROJECT_ARCOMPUTER_H
2#define COMMA_PROJECT_ARCOMPUTER_H
3
4/*
5 * CoMMA
6 *
7 * Copyright © 2024 ONERA
8 *
9 * Authors: Nicolas Lantos, Alberto Remigi, and Riccardo Milani
10 * Contributors: Karim Anemiche
11 *
12 * This Source Code Form is subject to the terms of the Mozilla Public
13 * License, v. 2.0. If a copy of the MPL was not distributed with this
14 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
15 */
16
17#include <cmath>
18#include <memory>
19#include <numeric>
20#include <unordered_map>
21#include <unordered_set>
22#include <vector>
23
24#include "CoMMA/Dual_Graph.h"
25#include "CoMMA/Util.h"
26
27namespace comma {
28
35template<typename IndexT, typename RealT, typename IntT>
37public:
39 RealT _measure;
40
43
46
49
54
58 RealT _sq_diam;
59
62 std::vector<RealT> _sum_centers;
63
65 std::unordered_map<IndexT, IntT> _external_facets;
66
82 explicit CellFeatures(
83 const RealT measure = std::numeric_limits<RealT>::min(),
84 const RealT external_weights = 0.0,
85 const RealT internal_weights = 0.0,
86 const IntT n_internal_faces = 0,
87 const RealT min_edge = std::numeric_limits<RealT>::max(),
88 const RealT diam = std::numeric_limits<RealT>::min(),
89 const std::vector<RealT> sum_centers = std::vector<RealT>{},
90 const std::unordered_map<IndexT, IntT> external_facets =
91 std::unordered_map<IndexT, IntT>{}
92 ) :
93 _measure(measure),
94 _external_weights(external_weights),
95 _internal_weights(internal_weights),
96 _n_internal_faces(n_internal_faces),
97 _sq_min_edge(min_edge * min_edge),
98 _sq_diam(diam * diam),
99 _sum_centers(sum_centers),
100 _external_facets(external_facets){};
101
105 const IndexT index, std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
106 ) :
107 _measure(graph->_volumes[index]),
108 _external_weights(graph->estimated_total_weight(index)),
111 _sq_min_edge(std::numeric_limits<RealT>::max()),
112 _sq_diam(std::numeric_limits<RealT>::min()),
113 _external_facets({{index, graph->get_total_n_faces(index)}}) {
114 _sum_centers = graph->_centers[index];
115 for (auto &xyz : _sum_centers) {
116 xyz *= graph->_volumes[index];
117 }
118 }
119
124
129
134 ) noexcept = default;
135
140 ) = default;
141
145 template<unsigned int dim>
146 inline RealT constexpr get_radius() const {
147 if constexpr (dim < 2) {
148 return _measure;
149 } else if constexpr (dim == 2) {
150 return sqrt(_measure);
151 } else if constexpr (dim == 3) {
152 return cbrt(_measure);
153 } else {
154 return pow(_measure, 1.0 / dim);
155 }
156 }
157};
158
167template<typename IndexT, typename RealT, typename IntT>
169public:
173 explicit ARComputer(std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph) :
174 _graph(graph){};
175
177 virtual ~ARComputer() = default;
178
193 const IndexT i_fc,
194 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
195 const std::unordered_set<IndexT> &fc_of_cc,
196 // out
197 IntT &shared_faces,
198 RealT &aspect_ratio,
200 ) const = 0;
201
202protected:
206 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> _graph;
207
219 const IndexT i_fc,
220 const std::unordered_set<IndexT> &fc_of_cc,
221 RealT &shared_weights,
222 std::unordered_set<IndexT> &shared_faces
223 ) const {
224 shared_weights = 0.;
225 auto n_it = this->_graph->neighbours_cbegin(i_fc);
226 auto w_it = this->_graph->weights_cbegin(i_fc);
227 for (; n_it != this->_graph->neighbours_cend(i_fc); ++n_it, ++w_it) {
228 if (*n_it != i_fc && (fc_of_cc.count(*n_it) != 0)) {
229 shared_faces.insert(*n_it);
230 shared_weights += *w_it;
231 }
232 }
233 }
234
243 const IndexT i_fc,
244 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
245 const std::unordered_set<IndexT> &fc_of_cc,
247 ) const {
248 const std::vector<RealT> &cen_fc = this->_graph->_centers[i_fc];
249 RealT max_diam = cc_feats._sq_diam, min_edge = cc_feats._sq_min_edge;
250 for (const auto i_fc_cc : fc_of_cc) {
251 const auto dist = squared_euclidean_distance<RealT>(
252 cen_fc, this->_graph->_centers[i_fc_cc]
253 );
254 if (dist > max_diam) max_diam = dist;
255 if (dist < min_edge) min_edge = dist;
256 } // for i_fc_cc
257 new_feats._sq_diam = max_diam;
258 new_feats._sq_min_edge = min_edge;
259 }
260
269 inline std::vector<RealT> compute_and_update_barycenter(
270 const IndexT i_fc,
271 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
272 const std::unordered_set<IndexT> &fc_of_cc,
274 ) const {
275 new_feats._sum_centers = cc_feats._sum_centers;
276 const auto &cur_c = this->_graph->_centers[i_fc];
277 std::vector<RealT> bary(cur_c.size());
278 const RealT ov_N = 1. / (fc_of_cc.size() + 1);
279 for (auto i = decltype(cur_c.size()){0}; i < cur_c.size(); ++i) {
280 new_feats._sum_centers[i] += this->_graph->_volumes[i_fc] * cur_c[i];
281 bary[i] = new_feats._sum_centers[i] * ov_N;
282 }
283 return bary;
284 }
285
298 template<bool compute_weights = false, bool update_facets = false>
300 const IndexT i_fc,
301 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
302 const std::unordered_set<IndexT> &fc_of_cc,
303 IntT &n_shared_faces,
305 ) const {
306 new_feats._measure = cc_feats._measure + this->_graph->_volumes[i_fc];
307 RealT shared_weights{};
308 std::unordered_set<IndexT> shared_faces{};
309 this->compute_shared_faces(i_fc, fc_of_cc, shared_weights, shared_faces);
310 n_shared_faces = static_cast<IntT>(shared_faces.size());
311 new_feats._n_internal_faces = cc_feats._n_internal_faces + n_shared_faces;
312 if constexpr (compute_weights) {
313 new_feats._external_weights = cc_feats._external_weights
314 + this->_graph->estimated_total_weight(i_fc) - 2 * shared_weights;
315 new_feats._internal_weights = cc_feats._internal_weights + shared_weights;
316 }
317 if constexpr (update_facets) {
318 new_feats._external_facets = cc_feats._external_facets; // OK copy
319 for (const auto &face : shared_faces) {
320 new_feats._external_facets.at(face)--;
321 }
322 new_feats._external_facets[i_fc] =
323 this->_graph->get_total_n_faces(i_fc) - n_shared_faces;
324 }
325 }
326
336 template<unsigned int dim>
337 inline RealT constexpr x_over_radius(
338 const RealT sqx, const CellFeatures<IndexT, RealT, IntT> &feats
339 ) const {
340 if constexpr (dim < 2) {
341 return sqrt(sqx) / feats.template get_radius<dim>();
342 } else if constexpr (dim == 2) {
343 return sqx / feats._measure;
344 } else if constexpr (dim == 3) {
345 return _cb(sqx) / _sq(feats._measure);
346 } else {
347 return int_power<dim>(sqx) / _sq(feats._measure);
348 }
349 }
350};
351
360template<typename IndexT, typename RealT, typename IntT, unsigned int dim>
361class ARDiamOverRadius : public ARComputer<IndexT, RealT, IntT> {
362public:
367 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
368 ) :
369 ARComputer<IndexT, RealT, IntT>(graph){};
370
372 ~ARDiamOverRadius() override = default;
373
388 const IndexT i_fc,
389 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
390 const std::unordered_set<IndexT> &fc_of_cc,
391 // out
392 IntT &shared_faces,
393 RealT &aspect_ratio,
395 ) const override {
396 // Update
397 this->template update_basic_features<>(
398 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
399 );
401 i_fc, cc_feats, fc_of_cc, new_feats
402 );
403 // Compute AR
404 aspect_ratio =
405 this->template x_over_radius<dim>(new_feats._sq_diam, new_feats);
406 }
407};
408
415template<typename IndexT, typename RealT, typename IntT>
417public:
421 explicit AROverMeasure(std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
422 ) :
423 ARComputer<IndexT, RealT, IntT>(graph){};
424
426 ~AROverMeasure() override = default;
427
442 const IndexT i_fc,
443 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
444 const std::unordered_set<IndexT> &fc_of_cc,
445 // out
446 IntT &shared_faces,
447 RealT &aspect_ratio,
449 ) const override {
450 // Update
451 this->template update_basic_features<>(
452 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
453 );
454 // Compute AR
455 aspect_ratio = 1. / new_feats._measure;
456 }
457};
458
465template<typename IndexT, typename RealT, typename IntT>
467public:
472 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
473 ) :
474 ARComputer<IndexT, RealT, IntT>(graph){};
475
477 ~ARDiamOverMinEdge() override = default;
478
493 const IndexT i_fc,
494 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
495 const std::unordered_set<IndexT> &fc_of_cc,
496 // out
497 IntT &shared_faces,
498 RealT &aspect_ratio,
500 ) const override {
501 // Update
502 this->template update_basic_features<>(
503 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
504 );
505 this->update_approximated_geometric_features(
506 i_fc, cc_feats, fc_of_cc, new_feats
507 );
508 // Compute AR
509 // If only 2 cells (hence the reference coarse cell is only one cell), max
510 // and min are the same, hence use only max
511 aspect_ratio = fc_of_cc.size() == 1
512 ? new_feats._sq_diam
513 : new_feats._sq_diam / new_feats._sq_min_edge;
514 }
515};
516
528template<typename IndexT, typename RealT, typename IntT, unsigned int dim>
530public:
535 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
536 ) :
537 ARComputer<IndexT, RealT, IntT>(graph){};
538
540 ~ARExternalWeightOverRadius() override = default;
541
556 const IndexT i_fc,
557 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
558 const std::unordered_set<IndexT> &fc_of_cc,
559 // out
560 IntT &shared_faces,
561 RealT &aspect_ratio,
563 ) const override {
564 // Update
565 this->template update_basic_features<true>(
566 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
567 );
568 // Compute AR
569 aspect_ratio = this->compute_AR(new_feats);
570 }
571
572protected:
579 inline RealT constexpr compute_AR(
581 ) const {
582 if constexpr (dim < 2) {
583 return feats._external_weights / feats.template get_radius<dim>();
584 } else if constexpr (dim == 2) {
585 // return feats._external_weights / feats.template get_radius<dim>();
586 return _sq(feats._external_weights) / feats._measure;
587 } else if constexpr (dim == 3) {
588 // return sqrt(feats._external_weights) / feats.template
589 // get_radius<dim>();
590 return _cb(feats._external_weights) / _sq(feats._measure);
591 } else {
592 // return pow(feats._external_weights, 1.0 / (dim - 1))
593 // / feats.template get_radius<dim>();
594 return int_power<dim>(feats._external_weights)
595 / int_power<dim - 1>(feats._measure);
596 }
597 }
598};
599
605template<typename IndexT, typename RealT, typename IntT>
607public:
611 explicit ARDiameter(std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph) :
612 ARComputer<IndexT, RealT, IntT>(graph){};
613
615 ~ARDiameter() override = default;
616
631 const IndexT i_fc,
632 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
633 const std::unordered_set<IndexT> &fc_of_cc,
634 // out
635 IntT &shared_faces,
636 RealT &aspect_ratio,
638 ) const override {
639 // Update
640 this->template update_basic_features<>(
641 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
642 );
643 this->update_approximated_geometric_features(
644 i_fc, cc_feats, fc_of_cc, new_feats
645 );
646 // Compute AR
647 aspect_ratio = new_feats._sq_diam;
648 }
649};
650
658template<typename IndexT, typename RealT, typename IntT>
660public:
665 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
666 ) :
667 ARComputer<IndexT, RealT, IntT>(graph){};
668
670 ~ARExternalWeights() override = default;
671
686 const IndexT i_fc,
687 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
688 const std::unordered_set<IndexT> &fc_of_cc,
689 // out
690 IntT &shared_faces,
691 RealT &aspect_ratio,
693 ) const override {
694 // Update
695 this->template update_basic_features<true>(
696 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
697 );
698 // Compute AR
699 aspect_ratio = new_feats._external_weights;
700 }
701};
702
709template<typename IndexT, typename RealT, typename IntT>
711public:
716 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
717 ) :
718 ARComputer<IndexT, RealT, IntT>(graph){};
719
721 ~AROverInternalWeights() override = default;
722
737 const IndexT i_fc,
738 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
739 const std::unordered_set<IndexT> &fc_of_cc,
740 // out
741 IntT &shared_faces,
742 RealT &aspect_ratio,
744 ) const override {
745 // Update
746 this->template update_basic_features<true>(
747 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
748 );
749 // Compute AR
750 aspect_ratio = 1. / new_feats._internal_weights;
751 }
752};
753
763template<typename IndexT, typename RealT, typename IntT, unsigned int dim>
765public:
771 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph
772 ) :
773 ARComputer<IndexT, RealT, IntT>(graph){};
774
776 ~ARMaxBaryDistanceOverRadius() override = default;
777
795 const IndexT i_fc,
796 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
797 const std::unordered_set<IndexT> &fc_of_cc,
798 // out
799 IntT &shared_faces,
800 RealT &aspect_ratio,
802 ) const override {
803 // Update
804 this->template update_basic_features<>(
805 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
806 );
807 const auto bary =
808 this->compute_and_update_barycenter(i_fc, cc_feats, fc_of_cc, new_feats);
809 // Compute AR
810 const auto dist_fc =
811 squared_euclidean_distance<RealT>(bary, this->_graph->_centers[i_fc]);
812 RealT max_dist = dist_fc;
813 for (const auto i_fc_cc : fc_of_cc) {
814 const auto dist = squared_euclidean_distance<RealT>(
815 bary, this->_graph->_centers[i_fc_cc]
816 );
817 if (dist > max_dist) max_dist = dist;
818 } // for i_fc_cc
819 aspect_ratio = this->template x_over_radius<dim>(max_dist, new_feats);
820 }
821};
822
831template<typename IndexT, typename RealT, typename IntT>
833public:
840 std::shared_ptr<Dual_Graph<IndexT, RealT, IntT>> graph,
841 const RealT tolerance
842 ) :
843 ARComputer<IndexT, RealT, IntT>(graph), _tolerance(tolerance){};
844
846 ~ARMaxOverMinBaryDistance() override = default;
847
862 const IndexT i_fc,
863 const CellFeatures<IndexT, RealT, IntT> &cc_feats,
864 const std::unordered_set<IndexT> &fc_of_cc,
865 // out
866 IntT &shared_faces,
867 RealT &aspect_ratio,
869 ) const override {
870 // Update
871 this->template update_basic_features<false, true>(
872 i_fc, cc_feats, fc_of_cc, shared_faces, new_feats
873 );
874 const auto bary =
875 this->compute_and_update_barycenter(i_fc, cc_feats, fc_of_cc, new_feats);
876 // Compute AR
877 RealT min_dist = std::numeric_limits<RealT>::max(),
878 max_dist = std::numeric_limits<RealT>::min();
879 // Skipping if totally internal cell
880 if (new_feats._external_facets[i_fc] > 0) {
881 // Since we are comparing to a threshold, keep sqrt here
882 const auto dist = sqrt(
883 squared_euclidean_distance<RealT>(bary, this->_graph->_centers[i_fc])
884 );
885 // Skipping if barycenter is the center of the cell
886 if (dist > this->_tolerance) {
887 min_dist = max_dist = dist;
888 }
889 }
890 for (const auto i_fc_cc : fc_of_cc) {
891 if (new_feats._external_facets[i_fc_cc] > 0) {
892 const auto dist = sqrt(squared_euclidean_distance<RealT>(
893 bary, this->_graph->_centers[i_fc_cc]
894 ));
895 if (dist > this->_tolerance) {
896 if (dist > max_dist) max_dist = dist;
897 if (dist < min_dist) min_dist = dist;
898 }
899 }
900 } // for i_fc_cc
901 aspect_ratio = max_dist / min_dist;
902 }
903
904protected:
907};
908
909} // end namespace comma
910
911#endif // COMMA_PROJECT_ARCOMPUTER_H
Similar to a functor, the key point is the method that computes the AR and update the features of a c...
Definition: ARComputer.h:168
RealT constexpr x_over_radius(const RealT sqx, const CellFeatures< IndexT, RealT, IntT > &feats) const
Given a squared quantity and cell features, compute the ratio between the quantity and the radius of ...
Definition: ARComputer.h:337
void update_basic_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &n_shared_faces, CellFeatures< IndexT, RealT, IntT > &new_feats) const
Compute approximated geometric features (e.g., diameter)
Definition: ARComputer.h:299
virtual void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const =0
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
void compute_shared_faces(const IndexT i_fc, const std::unordered_set< IndexT > &fc_of_cc, RealT &shared_weights, std::unordered_set< IndexT > &shared_faces) const
Computes number of shared faces and features of the CC obtained by adding a given fine cell....
Definition: ARComputer.h:218
std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > _graph
Dual_Graph object determining Fine cells graph and hence the connectivity.
Definition: ARComputer.h:206
virtual ~ARComputer()=default
The destructor of the class.
void update_approximated_geometric_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, CellFeatures< IndexT, RealT, IntT > &new_feats) const
Compute approximated geometric features (e.g., diameter)
Definition: ARComputer.h:242
std::vector< RealT > compute_and_update_barycenter(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, CellFeatures< IndexT, RealT, IntT > &new_feats) const
Compute the barycenter and update the features accordingly.
Definition: ARComputer.h:269
ARComputer(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:173
ARComputer. Here, AR is the ratio of the diameter over the smallest edge.
Definition: ARComputer.h:466
ARDiamOverMinEdge(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:471
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:492
~ARDiamOverMinEdge() override=default
Destructor.
ARComputer. Here, AR is the ratio of the diameter over the estimated one (typically,...
Definition: ARComputer.h:361
ARDiamOverRadius(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:366
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:387
~ARDiamOverRadius() override=default
Destructor.
ARComputer. Here, AR is the approximated diameter.
Definition: ARComputer.h:606
~ARDiameter() override=default
Destructor.
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:630
ARDiameter(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:611
ARComputer. Here, AR is the ratio of the external weights over the measure. With dim equal to 2,...
Definition: ARComputer.h:529
RealT constexpr compute_AR(const CellFeatures< IndexT, RealT, IntT > &feats) const
Compute the aspect-ratio.
Definition: ARComputer.h:579
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:555
~ARExternalWeightOverRadius() override=default
Destructor.
ARExternalWeightOverRadius(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:534
ARComputer. Here, AR is the total external weights (that is, from a geometric point of view,...
Definition: ARComputer.h:659
ARExternalWeights(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:664
~ARExternalWeights() override=default
Destructor.
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:685
ARComputer. Here, AR is the ratio of the maximum over minimum distance of the cell centers from the b...
Definition: ARComputer.h:764
ARMaxBaryDistanceOverRadius(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:770
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:794
~ARMaxBaryDistanceOverRadius() override=default
Destructor.
ARComputer. Here, AR is the ratio of the maximum over minimum distance of the cell centers from the b...
Definition: ARComputer.h:832
ARMaxOverMinBaryDistance(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph, const RealT tolerance)
Constructor.
Definition: ARComputer.h:839
RealT _tolerance
Definition: ARComputer.h:906
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:861
~ARMaxOverMinBaryDistance() override=default
Destructor.
ARComputer. Here, AR is one over the internal weights (looking for the minimum leads to the maximizat...
Definition: ARComputer.h:710
~AROverInternalWeights() override=default
Destructor.
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:736
AROverInternalWeights(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:715
ARComputer. Here, AR is the reciprocal of the measure, hence the optimal solution should be the one w...
Definition: ARComputer.h:416
AROverMeasure(std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:421
~AROverMeasure() override=default
Destructor.
void compute_and_update_features(const IndexT i_fc, const CellFeatures< IndexT, RealT, IntT > &cc_feats, const std::unordered_set< IndexT > &fc_of_cc, IntT &shared_faces, RealT &aspect_ratio, CellFeatures< IndexT, RealT, IntT > &new_feats) const override
Computes features of the CC obtained by adding a given fine cell. The features are Aspect-Ratio,...
Definition: ARComputer.h:441
Convenient class containing salient features of a cell. According to to the chosen AR computation (se...
Definition: ARComputer.h:36
CellFeatures(const IndexT index, std::shared_ptr< Dual_Graph< IndexT, RealT, IntT > > graph)
Constructor.
Definition: ARComputer.h:104
RealT _internal_weights
Definition: ARComputer.h:45
IntT _n_internal_faces
Definition: ARComputer.h:48
std::unordered_map< IndexT, IntT > _external_facets
Definition: ARComputer.h:65
CellFeatures & operator=(CellFeatures< IndexT, RealT, IntT > &&other) noexcept=default
Move assignment.
RealT _external_weights
Definition: ARComputer.h:42
CellFeatures(const CellFeatures< IndexT, RealT, IntT > &other)=default
Copy constructor.
RealT _measure
Definition: ARComputer.h:39
CellFeatures & operator=(const CellFeatures< IndexT, RealT, IntT > &other)=default
Copy assignment.
CellFeatures(CellFeatures< IndexT, RealT, IntT > &&other) noexcept=default
Move constructor.
RealT _sq_diam
Definition: ARComputer.h:58
std::vector< RealT > _sum_centers
Definition: ARComputer.h:62
RealT constexpr get_radius() const
Compute the radius of a cell.
Definition: ARComputer.h:146
CellFeatures(const RealT measure=std::numeric_limits< RealT >::min(), const RealT external_weights=0.0, const RealT internal_weights=0.0, const IntT n_internal_faces=0, const RealT min_edge=std::numeric_limits< RealT >::max(), const RealT diam=std::numeric_limits< RealT >::min(), const std::vector< RealT > sum_centers=std::vector< RealT >{}, const std::unordered_map< IndexT, IntT > external_facets=std::unordered_map< IndexT, IntT >{})
Constructor.
Definition: ARComputer.h:82
RealT _sq_min_edge
Definition: ARComputer.h:53
A class implementing the CRS global graph representation of the global mesh.
Definition: Dual_Graph.h:548
Definition: Agglomerator.h:37
T constexpr _cb(const T x)
Cube.
Definition: Util.h:61
T constexpr _sq(const T x)
Square.
Definition: Util.h:51
T constexpr int_power(const T x)
Raise a quantity to an integer power.
Definition: Util.h:72