CoMMA 1.3.2
A geometric agglomerator for unstructured meshes
Loading...
Searching...
No Matches
Seeds_Pool.h
Go to the documentation of this file.
1#ifndef COMMA_PROJECT_SEEDS_POOL_H
2#define COMMA_PROJECT_SEEDS_POOL_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 <algorithm>
18#include <cassert>
19#include <deque>
20#include <limits>
21#include <list>
22#include <map>
23#include <memory>
24#include <optional>
25#include <queue>
26#include <set>
27#include <utility>
28#include <vector>
29
30#include "CoMMA/CoMMADefs.h"
31#include "CoMMA/Util.h"
32
33namespace comma {
34
41template<
42 typename CoMMAIndexType,
43 typename CoMMAWeightType,
44 typename CoMMAIntType>
47 using CoMMAPairType = std::pair<CoMMAIndexType, CoMMAWeightType>;
49 using CoMMAQueueType = std::deque<CoMMAIndexType>;
52 std::set<CoMMAPairType, CustomPairGreaterFunctor<CoMMAPairType>>;
53
55 SPInitializator() = default;
56
58 virtual ~SPInitializator() = default;
59
69 virtual void operator()(
70 const std::vector<CoMMAWeightType> &priority_weights,
71 const std::vector<CoMMAIntType> &n_bnd_faces,
72 const CoMMAIntType max_bnd,
73 CoMMAQueueType &queue
74 ) = 0;
75};
76
83template<
84 typename CoMMAIndexType,
85 typename CoMMAWeightType,
86 typename CoMMAIntType>
88 public SPInitializator<CoMMAIndexType, CoMMAWeightType, CoMMAIntType> {
90 using BaseClass =
93 using typename BaseClass::CoMMAQueueType;
95 using typename BaseClass::CoMMASetOfPairType;
96
99 BaseClass() {}
100
102 ~SPFullInitializator() override = default;
103
114 const std::vector<CoMMAWeightType> &priority_weights,
115 const std::vector<CoMMAIntType> &n_bnd_faces,
116 const CoMMAIntType max_bnd,
117 CoMMAQueueType &queue
118 ) override {
119 // Similar to function build_queue but without is_agglomerated
120 // Using set to force order
121 CoMMASetOfPairType tmp_set{};
122 for (auto i_fc = decltype(n_bnd_faces.size()){0}; i_fc < n_bnd_faces.size();
123 ++i_fc) {
124 if (n_bnd_faces[i_fc] >= max_bnd)
125 tmp_set.emplace(i_fc, priority_weights[i_fc]);
126 }
127 for (const auto &idx : tmp_set)
128 queue.push_back(idx.first);
129 }
130};
131
138template<
139 typename CoMMAIndexType,
140 typename CoMMAWeightType,
141 typename CoMMAIntType>
143 public SPInitializator<CoMMAIndexType, CoMMAWeightType, CoMMAIntType> {
145 using BaseClass =
148 using typename BaseClass::CoMMAPairType;
150 using typename BaseClass::CoMMAQueueType;
151
154 BaseClass() {}
155
157 ~SPOnePointInitializator() override = default;
158
169 const std::vector<CoMMAWeightType> &priority_weights,
170 const std::vector<CoMMAIntType> &n_bnd_faces,
171 const CoMMAIntType max_bnd,
172 CoMMAQueueType &queue
173 ) override {
174 CoMMAPairType cur_max{
175 std::numeric_limits<CoMMAIndexType>::max(),
176 std::numeric_limits<CoMMAWeightType>::min()
177 };
179 for (auto i_fc = decltype(n_bnd_faces.size()){0}; i_fc < n_bnd_faces.size();
180 ++i_fc) {
181 const CoMMAPairType cur_pair{i_fc, priority_weights[i_fc]};
182 if (n_bnd_faces[i_fc] >= max_bnd && comp_op(cur_pair, cur_max))
183 cur_max = std::move(cur_pair);
184 }
185 queue.push_back(cur_max.first);
186 }
187};
188
196template<
197 typename CoMMAIndexType,
198 typename CoMMAWeightType,
199 typename CoMMAIntType>
201public:
203 using CoMMAPairType = std::pair<CoMMAIndexType, CoMMAWeightType>;
204#if 0
206 // Better to use a deque (rather than the default vector) because it has nice
207 // insert / remove performances, and it's more closer to the philosophy we would
208 // like to obtain
209 using CoMMAContainerPairType = std::deque<CoMMAPairType>;
211 // A drawback of priority_queue to be aware of: it cannot be looped through
212 // A workaround is explained on https://stackoverflow.com/questions/4484767/how-to-iterate-over-a-priority-queue
213 // TODO: Maybe change to the advised make_heap (with vector or deque)
214 using CoMMAPriorityQueueType = priority_queue<CoMMAPairType,
215 CoMMAContainerPairType,
217#endif
219 using CoMMAQueueType = std::deque<CoMMAIndexType>;
222 std::set<CoMMAPairType, CustomPairGreaterFunctor<CoMMAPairType>>;
223
224protected:
229 std::vector<CoMMAQueueType> _l_of_seeds;
230
232 const std::vector<CoMMAWeightType> &_priority_weights;
233
237 std::optional<CoMMAIntType> _cur_top_queue;
238
240 std::shared_ptr<
243
244public:
246 const std::vector<CoMMAIntType> &_n_bnd_faces;
247
257 const std::vector<CoMMAIntType> &n_bnd_faces,
258 const std::vector<CoMMAWeightType> &priority_weights,
259 const bool one_point_init
260 ) :
261 _priority_weights(priority_weights),
262 _cur_top_queue(std::nullopt),
263 _n_bnd_faces(n_bnd_faces) {
264 // The size 4 corresponds to 0 : interior, 1 : valley, 2 : ridge, 3 : corner
265 _l_of_seeds = std::vector<CoMMAQueueType>(CoMMACellT::N_CELL_TYPES);
266
267 _initializator = nullptr;
268 if (one_point_init)
269 _initializator = std::make_shared<
271 );
272 else
273 _initializator = std::make_shared<
275 }
276
278 virtual ~Seeds_Pool() = default;
279
286 inline std::optional<CoMMAIndexType> spoil_queue(
287 const std::vector<bool> &is_fc_agglomerated, CoMMAQueueType &queue
288 ) {
289 // If there still is something and it's already agglomerated, then keep on
290 // searching
291 for (; !queue.empty() && is_fc_agglomerated[queue.front()];
292 queue.pop_front()) {}
293 if (!queue.empty()) {
294 const auto seed = queue.front();
295 queue.pop_front();
296 return seed;
297 }
298 return std::nullopt;
299 }
300
306 virtual std::optional<CoMMAIndexType> choose_new_seed(
307 const std::vector<bool> &is_agglomerated
308 ) = 0;
309
316 virtual void update(const std::deque<CoMMAIndexType> &new_seeds) = 0;
317
324 const std::unordered_set<CoMMAIndexType> &new_seeds
325 ) = 0;
326
335 inline void build_queue(
336 const std::vector<bool> &is_fc_agglomerated, const CoMMAIntType target
337 ) {
338 // Using set to force order
339 CoMMASetOfPairType tmp_set{};
340 for (auto i_fc = decltype(_n_bnd_faces.size()){0};
341 i_fc < _n_bnd_faces.size();
342 ++i_fc) {
343 if (!is_fc_agglomerated[i_fc] && _n_bnd_faces[i_fc] == target)
344 tmp_set.emplace(i_fc, _priority_weights[i_fc]);
345 }
346 for (const auto &idx : tmp_set)
347 _l_of_seeds[target].push_back(idx.first);
348 }
349
359 inline std::optional<CoMMAIntType> get_highest_n_bnd_yet_to_agglomerate(
360 const std::vector<bool> &is_fc_agglomerated,
361 const CoMMAIntType expected_max = CoMMACellT::CORNER
362 ) const {
363 std::optional<CoMMAIntType> max_bnd = std::nullopt;
364 for (auto i_fc = decltype(_n_bnd_faces.size()){0};
365 i_fc < _n_bnd_faces.size();
366 ++i_fc) {
367 if (!is_fc_agglomerated[i_fc]) {
368 const auto i_fc_bnd = _n_bnd_faces[i_fc];
369 if (!max_bnd.has_value()) max_bnd = i_fc_bnd;
370 if (i_fc_bnd >= expected_max) {
371 return i_fc_bnd;
372 }
373 if (i_fc_bnd > max_bnd) {
374 max_bnd = i_fc_bnd;
375 }
376 }
377 }
378 return max_bnd;
379 }
380
385 bool is_empty(CoMMAIntType i_level = CoMMACellT::N_CELL_TYPES) const {
386 assert(CoMMACellT::INTERIOR <= i_level);
387 assert(i_level <= CoMMACellT::N_CELL_TYPES);
388 if (!_l_of_seeds.empty()) {
389 switch (i_level) {
391 return _l_of_seeds[CoMMACellT::INTERIOR].empty();
393 return _l_of_seeds[CoMMACellT::VALLEY].empty();
395 return _l_of_seeds[CoMMACellT::RIDGE].empty();
397 return _l_of_seeds[CoMMACellT::CORNER].empty();
399 default:
400 return _l_of_seeds[CoMMACellT::INTERIOR].empty()
404 } /* Switch */
405 }
406 return true;
407 }
408
414 virtual bool need_initialization(const std::vector<bool> &is_agglomerated
415 ) = 0;
416
418 inline void initialize() {
419 if (!_cur_top_queue.has_value())
420 // Computing the max number of boundary faces. Only the related seed queue
421 // will be filled at this initial stage
422 _cur_top_queue = *(max_element(_n_bnd_faces.begin(), _n_bnd_faces.end()));
423 (*this->_initializator)(
424 this->_priority_weights,
425 this->_n_bnd_faces,
426 this->_cur_top_queue.value(),
427 this->_l_of_seeds[this->_cur_top_queue.value()]
428 );
429 }
430
434 inline void set_top_queue(const CoMMAIntType q_lvl) {
435 this->_cur_top_queue = q_lvl;
436 }
437};
438
447template<
448 typename CoMMAIndexType,
449 typename CoMMAWeightType,
450 typename CoMMAIntType>
452 public Seeds_Pool<CoMMAIndexType, CoMMAWeightType, CoMMAIntType> {
453public:
461
471 const std::vector<CoMMAIntType> &n_bnd_faces,
472 const std::vector<CoMMAWeightType> &priority_weights,
473 const bool one_point_init
474 ) :
475 Seeds_Pool<CoMMAIndexType, CoMMAWeightType, CoMMAIntType>(
476 n_bnd_faces, priority_weights, one_point_init
477 ) {}
478
480 ~Seeds_Pool_Boundary_Priority() override = default;
481
487 std::optional<CoMMAIndexType> choose_new_seed(
488 const std::vector<bool> &is_agglomerated
489 ) override {
490 // Choose a correct seed from the fc pool list_of_seeds beyond not
491 // agglomerated fc.
492 // We choose preferably the corners, then the ridges, then the valley, and
493 // finally interior cells:
494 // see NIA (Mavriplis uses Wall and farfield only)
495 // Exactly the inverse of the order of the list. For this reason we proceed
496 // from the back
497 if (this->_cur_top_queue.has_value()) {
498 auto opt_seed = this->spoil_queue(
499 is_agglomerated, this->_l_of_seeds[this->_cur_top_queue.value()]
500 );
501 if (opt_seed.has_value()) return opt_seed.value();
502 auto opt_top = this->get_highest_n_bnd_yet_to_agglomerate(
503 is_agglomerated, this->_cur_top_queue.value()
504 );
505 if (opt_top.has_value()) {
506 const auto cur_queue = opt_top.value();
507 this->_cur_top_queue = cur_queue;
508 // Could be the same top queue, but that's OK
509 opt_seed =
510 this->spoil_queue(is_agglomerated, this->_l_of_seeds[cur_queue]);
511 if (opt_seed.has_value()) return opt_seed.value();
512 // If here, we already used everything that we had in the seeds pool but
513 // there are still cells to agglomerate of the same type, hence we need
514 // to rebuild the queue from scratch
515 this->build_queue(is_agglomerated, cur_queue);
516
517 const auto seed = this->_l_of_seeds[cur_queue].front();
518 this->_l_of_seeds[cur_queue].pop_front();
519 return seed;
520 }
521 // If everything failed, set to null
522 this->_cur_top_queue = std::nullopt;
523 }
524 return std::nullopt;
525 }
526
533 inline void update(const std::deque<CoMMAIndexType> &new_seeds) override {
534 if (!new_seeds.empty()) {
535 CoMMAIntType max_bnd{0};
536 for (const auto &seed : new_seeds) {
537 const auto n_bnd = this->_n_bnd_faces[seed];
538 if (n_bnd > max_bnd) max_bnd = n_bnd;
539 // We add even if already present. Worst case scenario, a check if
540 // agglomerated is done when choosing new seed
541 this->_l_of_seeds[n_bnd].push_back(seed);
542 }
543 if (!this->_cur_top_queue.has_value()
544 || max_bnd > this->_cur_top_queue.value())
545 this->_cur_top_queue = max_bnd;
546 }
547 }
548
555 const std::unordered_set<CoMMAIndexType> &new_seeds
556 ) override {
557 std::map<CoMMAIntType, CoMMASetOfPairType, std::greater<>> new_seeds_by_bnd;
558 if (!new_seeds.empty()) {
559 for (const auto seed : new_seeds) {
560 new_seeds_by_bnd[this->_n_bnd_faces[seed]].emplace(
561 seed, this->_priority_weights[seed]
562 );
563 }
564 const auto max_bnd = new_seeds_by_bnd.begin()->first;
565 if (!this->_cur_top_queue.has_value()
566 || max_bnd > this->_cur_top_queue.value())
567 this->_cur_top_queue = max_bnd;
568 for (const auto &[n_bnd, seeds] : new_seeds_by_bnd) {
569 // We add even if already present. Worst case scenario, a check if
570 // agglomerated is done when choosing new seed
571 std::transform(
572 seeds.cbegin(),
573 seeds.cend(),
574 std::back_inserter(this->_l_of_seeds[n_bnd]),
575 [](const auto &pr) { return pr.first; }
576 );
577 }
578 }
579 }
580
587 bool need_initialization(const std::vector<bool> &is_agglomerated) override {
588 if (this->is_empty() || (!this->_cur_top_queue.has_value())) return true;
589 const auto max_bnd =
590 this->get_highest_n_bnd_yet_to_agglomerate(is_agglomerated);
591 if (max_bnd.has_value() && max_bnd.value() > this->_cur_top_queue.value()) {
592 this->_cur_top_queue = max_bnd.value();
593 return true;
594 }
595 return false;
596 }
597};
598
607template<
608 typename CoMMAIndexType,
609 typename CoMMAWeightType,
610 typename CoMMAIntType>
612 public Seeds_Pool<CoMMAIndexType, CoMMAWeightType, CoMMAIntType> {
613public:
621
631 const std::vector<CoMMAIntType> &n_bnd_faces,
632 const std::vector<CoMMAWeightType> &priority_weights,
633 const bool one_point_init
634 ) :
635 Seeds_Pool<CoMMAIndexType, CoMMAWeightType, CoMMAIntType>(
636 n_bnd_faces, priority_weights, one_point_init
637 ) {}
638
641
647 std::optional<CoMMAIndexType> choose_new_seed(
648 const std::vector<bool> &is_agglomerated
649 ) override {
650 // Choose a correct seed from the fc pool list_of_seeds beyond not
651 // agglomerated fc.
652 // We choose preferably the corners, then the ridges, then the valley, and
653 // finally interior cells:
654 // see NIA (Mavriplis uses Wall and farfield only)
655 // Exactly the inverse of the order of the list. For this reason we proceed
656 // from the back
657 if (this->_cur_top_queue.has_value()) {
658 for (auto queue = this->_l_of_seeds.rbegin()
659 + (this->_l_of_seeds.size() - (this->_cur_top_queue.value() + 1));
660 queue != this->_l_of_seeds.rend();
661 ++queue) {
662 const auto opt_seed = this->spoil_queue(is_agglomerated, *queue);
663 if (opt_seed.has_value()) {
664 this->_cur_top_queue = distance(queue, this->_l_of_seeds.rend()) - 1;
665 return opt_seed.value();
666 }
667 }
668
669 // If not found, see which is the highest unfinished level
670 const auto opt_top = this->get_highest_n_bnd_yet_to_agglomerate(
671 is_agglomerated, this->_cur_top_queue.value()
672 );
673 if (opt_top.has_value()) {
674 const auto cur_queue = opt_top.value();
675 this->_cur_top_queue = cur_queue;
676 // Could be the same top queue, but that's OK
677 const auto opt_seed =
678 this->spoil_queue(is_agglomerated, this->_l_of_seeds[cur_queue]);
679 if (opt_seed.has_value()) return opt_seed.value();
680 // If here, we already used everything that we had in the seeds pool but
681 // there are still cells to agglomerate of the same type, hence we need
682 // to rebuild the queue from scratch
683 this->build_queue(is_agglomerated, cur_queue);
684
685 const auto seed = this->_l_of_seeds[cur_queue].front();
686 this->_l_of_seeds[cur_queue].pop_front();
687 return seed;
688 }
689 // If everything failed, set to null
690 this->_cur_top_queue = std::nullopt;
691 }
692 return std::nullopt;
693 }
694
701 inline void update(const std::deque<CoMMAIndexType> &new_seeds) override {
702 for (const auto &seed : new_seeds) {
703 // In order to the neighbourhood priority, we choose to append to the
704 // current top queue, rather than switching queue
705 const auto q_lvl = this->_cur_top_queue.has_value()
706 ? std::min(this->_n_bnd_faces[seed], this->_cur_top_queue.value())
707 : this->_n_bnd_faces[seed];
708 // We add even if already present. Worst case scenario, a check if
709 // agglomerated is done when choosing new seed
710 this->_l_of_seeds[q_lvl].push_back(seed);
711 }
712 }
713
720 const std::unordered_set<CoMMAIndexType> &new_seeds
721 ) override {
722 std::map<CoMMAIntType, CoMMASetOfPairType, std::greater<>> new_seeds_by_bnd;
723 for (const auto &seed : new_seeds) {
724 new_seeds_by_bnd[this->_n_bnd_faces[seed]].emplace(
725 seed, this->_priority_weights[seed]
726 );
727 }
728 for (auto &[n_bnd, seeds] : new_seeds_by_bnd) {
729 // In order to the neighbourhood priority, we choose to append to the
730 // current top queue, rather than switching queue
731 const auto q_lvl = this->_cur_top_queue.has_value()
732 ? std::min(n_bnd, this->_cur_top_queue.value())
733 : n_bnd;
734 // We add even if already present. Worst case scenario, a check if
735 // agglomerated is done when choosing new seed
736 std::transform(
737 seeds.cbegin(),
738 seeds.cend(),
739 std::back_inserter(this->_l_of_seeds[q_lvl]),
740 [](const auto &pr) { return pr.first; }
741 );
742 }
743 }
744
749 bool need_initialization(const std::vector<bool> &is_agglomerated) override {
750 CoMMAUnused(is_agglomerated);
751 return this->is_empty() || (!this->_cur_top_queue.has_value());
752 }
753};
754
755} // end namespace comma
756
757#endif // COMMA_PROJECT_SEEDS_POOL_H
#define CoMMAUnused(var)
Convenient function to avoid unused warnings.
Definition: Util.h:38
Class representing the pool of all the seeds for creating a coarse cell. This derived class gives hig...
Definition: Seeds_Pool.h:452
void order_new_seeds_and_update(const std::unordered_set< CoMMAIndexType > &new_seeds) override
Add the provided seeds to a seeds pool queue according to the number of boundary faces....
Definition: Seeds_Pool.h:554
bool need_initialization(const std::vector< bool > &is_agglomerated) override
Whether the seeds pool need to be initialized. It updates the top queue if necessary.
Definition: Seeds_Pool.h:587
Seeds_Pool_Boundary_Priority(const std::vector< CoMMAIntType > &n_bnd_faces, const std::vector< CoMMAWeightType > &priority_weights, const bool one_point_init)
Constructor.
Definition: Seeds_Pool.h:470
~Seeds_Pool_Boundary_Priority() override=default
Destructor.
void update(const std::deque< CoMMAIndexType > &new_seeds) override
Add the provided seeds to a seeds pool queue according to the number of boundary faces....
Definition: Seeds_Pool.h:533
std::optional< CoMMAIndexType > choose_new_seed(const std::vector< bool > &is_agglomerated) override
Choose a new seed in the pool.
Definition: Seeds_Pool.h:487
Class representing the pool of all the seeds for creating a coarse cell. This derived class gives hig...
Definition: Seeds_Pool.h:612
std::optional< CoMMAIndexType > choose_new_seed(const std::vector< bool > &is_agglomerated) override
Choose a new seed in the pool.
Definition: Seeds_Pool.h:647
bool need_initialization(const std::vector< bool > &is_agglomerated) override
Whether the seeds pool need to be initialized.
Definition: Seeds_Pool.h:749
Seeds_Pool_Neighbourhood_Priority(const std::vector< CoMMAIntType > &n_bnd_faces, const std::vector< CoMMAWeightType > &priority_weights, const bool one_point_init)
Constructor.
Definition: Seeds_Pool.h:630
~Seeds_Pool_Neighbourhood_Priority() override=default
Destructor.
void order_new_seeds_and_update(const std::unordered_set< CoMMAIndexType > &new_seeds) override
Add the provided seeds to a seeds pool queue according to the number of boundary faces....
Definition: Seeds_Pool.h:719
void update(const std::deque< CoMMAIndexType > &new_seeds) override
Add the provided seeds to a seeds pool queue according to the number of boundary faces.
Definition: Seeds_Pool.h:701
Class representing the pool of all the seeds for creating a coarse cell.
Definition: Seeds_Pool.h:200
virtual bool need_initialization(const std::vector< bool > &is_agglomerated)=0
Whether the seeds pool need to be initialized.
std::vector< CoMMAQueueType > _l_of_seeds
List of deque of seeds. For each identifier we have the available seeds. We want the seed to be chose...
Definition: Seeds_Pool.h:229
std::optional< CoMMAIntType > get_highest_n_bnd_yet_to_agglomerate(const std::vector< bool > &is_fc_agglomerated, const CoMMAIntType expected_max=CoMMACellT::CORNER) const
Compute the highest number of boundary faces of cells which are not agglomerated yet.
Definition: Seeds_Pool.h:359
const std::vector< CoMMAWeightType > & _priority_weights
Weights used to set the order of the seed to choose.
Definition: Seeds_Pool.h:232
Seeds_Pool(const std::vector< CoMMAIntType > &n_bnd_faces, const std::vector< CoMMAWeightType > &priority_weights, const bool one_point_init)
Constructor.
Definition: Seeds_Pool.h:256
virtual std::optional< CoMMAIndexType > choose_new_seed(const std::vector< bool > &is_agglomerated)=0
Choose a new seed in the pool.
bool is_empty(CoMMAIntType i_level=CoMMACellT::N_CELL_TYPES) const
Given the default levels we define if the list of the targeted level is empty.
Definition: Seeds_Pool.h:385
std::pair< CoMMAIndexType, CoMMAWeightType > CoMMAPairType
Type of pair.
Definition: Seeds_Pool.h:203
virtual ~Seeds_Pool()=default
Destructor.
void initialize()
Initialize the seeds pool via a call to its initializator.
Definition: Seeds_Pool.h:418
virtual void update(const std::deque< CoMMAIndexType > &new_seeds)=0
Add the provided seeds to a seeds pool queue according to the number of boundary faces.
std::set< CoMMAPairType, CustomPairGreaterFunctor< CoMMAPairType > > CoMMASetOfPairType
Type of set of pairs.
Definition: Seeds_Pool.h:222
std::optional< CoMMAIntType > _cur_top_queue
Optional possibly containing the level (0,1,2,3, see Seeds_Pool::_l_of_seeds) of the queue currently ...
Definition: Seeds_Pool.h:237
std::optional< CoMMAIndexType > spoil_queue(const std::vector< bool > &is_fc_agglomerated, CoMMAQueueType &queue)
Spoil a queue looking for an not-yet-agglomerated seed.
Definition: Seeds_Pool.h:286
void set_top_queue(const CoMMAIntType q_lvl)
Setter for the top queue member.
Definition: Seeds_Pool.h:434
std::deque< CoMMAIndexType > CoMMAQueueType
Type of queue which holds seeds.
Definition: Seeds_Pool.h:219
std::shared_ptr< SPInitializator< CoMMAIndexType, CoMMAWeightType, CoMMAIntType > > _initializator
Pointer to a SPInitializator.
Definition: Seeds_Pool.h:242
virtual void order_new_seeds_and_update(const std::unordered_set< CoMMAIndexType > &new_seeds)=0
Add the provided seeds to a seeds pool queue according to the number of boundary faces....
void build_queue(const std::vector< bool > &is_fc_agglomerated, const CoMMAIntType target)
Build the weight-ordered queue of seed for a given target level. A set of (index, weight) pair with s...
Definition: Seeds_Pool.h:335
const std::vector< CoMMAIntType > & _n_bnd_faces
Vector of number of faces on boundary per cell.
Definition: Seeds_Pool.h:246
Definition: Agglomerator.h:37
@ N_CELL_TYPES
Total number of values.
Definition: CoMMADefs.h:31
@ CORNER
Corners, three boundary faces.
Definition: CoMMADefs.h:28
@ VALLEY
Valley, one boundary face.
Definition: CoMMADefs.h:26
@ RIDGE
Ridge, two boundary faces.
Definition: CoMMADefs.h:27
@ INTERIOR
Interior cell, no boundary faces.
Definition: CoMMADefs.h:25
Functor for pairs implementing a custom 'greater than'. It relies on the 'greater than' operator for ...
Definition: Util.h:201
Functor for pairs implementing a custom 'less than'. It relies on the 'less than' operator for the se...
Definition: Util.h:178
Functor performing the full initialization of a seeds pool.
Definition: Seeds_Pool.h:88
SPFullInitializator()
Constructor.
Definition: Seeds_Pool.h:98
~SPFullInitializator() override=default
Destructor.
void operator()(const std::vector< CoMMAWeightType > &priority_weights, const std::vector< CoMMAIntType > &n_bnd_faces, const CoMMAIntType max_bnd, CoMMAQueueType &queue) override
Initialize a queue of a seeds pool.
Definition: Seeds_Pool.h:113
std::set< CoMMAPairType, CustomPairGreaterFunctor< CoMMAPairType > > CoMMASetOfPairType
Type of set of pairs.
Definition: Seeds_Pool.h:52
std::deque< CoMMAIndexType > CoMMAQueueType
Type of queue which holds seeds.
Definition: Seeds_Pool.h:49
Functor performing the initialization of a seeds pool.
Definition: Seeds_Pool.h:45
std::pair< CoMMAIndexType, CoMMAWeightType > CoMMAPairType
Type of pair.
Definition: Seeds_Pool.h:47
virtual ~SPInitializator()=default
Destructor.
SPInitializator()=default
Constructor.
virtual void operator()(const std::vector< CoMMAWeightType > &priority_weights, const std::vector< CoMMAIntType > &n_bnd_faces, const CoMMAIntType max_bnd, CoMMAQueueType &queue)=0
Initialize a queue of a seeds pool.
std::set< CoMMAPairType, CustomPairGreaterFunctor< CoMMAPairType > > CoMMASetOfPairType
Type of set of pairs.
Definition: Seeds_Pool.h:52
std::deque< CoMMAIndexType > CoMMAQueueType
Type of queue which holds seeds.
Definition: Seeds_Pool.h:49
Functor performing the one-point initialization of a seeds pool.
Definition: Seeds_Pool.h:143
std::pair< CoMMAIndexType, CoMMAWeightType > CoMMAPairType
Type of pair.
Definition: Seeds_Pool.h:47
void operator()(const std::vector< CoMMAWeightType > &priority_weights, const std::vector< CoMMAIntType > &n_bnd_faces, const CoMMAIntType max_bnd, CoMMAQueueType &queue) override
Initialize a queue of a seeds pool.
Definition: Seeds_Pool.h:168
~SPOnePointInitializator() override=default
Destructor.
SPOnePointInitializator()
Constructor.
Definition: Seeds_Pool.h:153
std::deque< CoMMAIndexType > CoMMAQueueType
Type of queue which holds seeds.
Definition: Seeds_Pool.h:49