14#include "arcane/cartesianmesh/internal/AMRPatchPositionSignatureCut.h"
16#include "arcane/utils/FatalErrorException.h"
17#include "arcane/utils/Math.h"
19#include "arcane/core/IMesh.h"
21#include "arcane/cartesianmesh/ICartesianMesh.h"
23#include "arcane/cartesianmesh/internal/AMRPatchPositionSignature.h"
39AMRPatchPositionSignatureCut::
40AMRPatchPositionSignatureCut()
46AMRPatchPositionSignatureCut::
47~AMRPatchPositionSignatureCut() =
default;
56 if (sig.
size() < MIN_SIZE * 2) {
76 ARCANE_FATAL(
"Call AMRPatchPositionSignature::compress() before");
78 if (cut_point != -1 && cut_point >= MIN_SIZE && sig.
size() - cut_point >= MIN_SIZE) {
92 dsec_sig[i] = sig[i + 1] - 2 * sig[i] + sig[i - 1];
93 CartCoord dif = math::abs(dsec_sig[i - 1] - dsec_sig[i]);
98 else if (dif == max && math::abs(cut_point - mid) > math::abs(i - mid)) {
103 if (cut_point != -1 && cut_point >= MIN_SIZE && sig.
size() - cut_point >= MIN_SIZE) {
113 if (cut_point != -1 && cut_point >= MIN_SIZE && sig.
size() - cut_point >= MIN_SIZE) {
133 if (cut_point_x == -1 && cut_point_y == -1 && cut_point_z == -1) {
139 if (cut_point_x != -1) {
142 if (cut_point_y != -1) {
145 if (cut_point_z != -1) {
150 if (cut_point_x != -1 && cut_point_y != -1 && cut_point_z != -1) {
157 Real x_efficacity = 0;
158 auto [fst_x, snd_x] = sig.
cut(
MD_DirX, cut_point_x);
164 if (fst_x.isValid() && snd_x.isValid()) {
175 x_efficacity = (fst_x.efficacity() + snd_x.efficacity()) / 2;
183 Real y_efficacity = 0;
184 auto [fst_y, snd_y] = sig.
cut(
MD_DirY, cut_point_y);
190 if (fst_y.isValid() && snd_y.isValid()) {
201 y_efficacity = (fst_y.efficacity() + snd_y.efficacity()) / 2;
209 Real z_efficacity = 0;
210 auto [fst_z, snd_z] = sig.
cut(
MD_DirZ, cut_point_z);
216 if (fst_z.isValid() && snd_z.isValid()) {
227 z_efficacity = (fst_z.efficacity() + snd_z.efficacity()) / 2;
238 if (sig_efficacity > x_efficacity && sig_efficacity > y_efficacity && sig_efficacity > z_efficacity) {
244 if (x_efficacity >= y_efficacity && x_efficacity >= z_efficacity && x_efficacity != 0) {
245 return { fst_x, snd_x };
247 if (y_efficacity >= x_efficacity && y_efficacity >= z_efficacity && y_efficacity != 0) {
248 return { fst_y, snd_y };
250 if (z_efficacity == 0) {
253 return { fst_z, snd_z };
257 if (cut_point_x != -1 && cut_point_y != -1) {
258 Real x_efficacity = 0;
259 auto [fst_x, snd_x] = sig.
cut(
MD_DirX, cut_point_x);
265 if (fst_x.isValid() && snd_x.isValid()) {
276 x_efficacity = (fst_x.efficacity() + snd_x.efficacity()) / 2;
284 Real y_efficacity = 0;
285 auto [fst_y, snd_y] = sig.
cut(
MD_DirY, cut_point_y);
291 if (fst_y.isValid() && snd_y.isValid()) {
302 y_efficacity = (fst_y.efficacity() + snd_y.efficacity()) / 2;
311 if (sig_efficacity > x_efficacity && sig_efficacity > y_efficacity) {
316 if (x_efficacity >= y_efficacity && x_efficacity != 0) {
317 return { fst_x, snd_x };
319 if (y_efficacity == 0) {
322 return { fst_y, snd_y };
325 if (cut_point_x != -1) {
326 Real x_efficacity = 0;
327 auto [fst_x, snd_x] = sig.
cut(
MD_DirX, cut_point_x);
333 if (fst_x.isValid() && snd_x.isValid()) {
337 x_efficacity = (fst_x.efficacity() + snd_x.efficacity()) / 2;
346 return { fst_x, snd_x };
349 if (cut_point_y != -1) {
350 Real y_efficacity = 0;
351 auto [fst_y, snd_y] = sig.
cut(
MD_DirY, cut_point_y);
357 if (fst_y.isValid() && snd_y.isValid()) {
361 y_efficacity = (fst_y.efficacity() + snd_y.efficacity()) / 2;
370 return { fst_y, snd_y };
372 if (cut_point_z != -1) {
373 Real z_efficacity = 0;
374 auto [fst_z, snd_z] = sig.
cut(
MD_DirZ, cut_point_z);
380 if (fst_z.isValid() && snd_z.isValid()) {
384 z_efficacity = (fst_z.efficacity() + snd_z.efficacity()) / 2;
393 return { fst_z, snd_z };
403 bool a_a_b_b =
false;
406 bool need_cut =
true;
414 for (
auto& sig : array_in) {
418 if (!sig.stopCut()) {
419 if (!sig.isComputed()) {
422 if (sig.canBeCut()) {
423 auto [fst, snd] =
cut(sig);
439 sig.setStopCut(
true);
445 sig.setStopCut(
true);
462 sig_array_a = sig_array_b;
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
static CartCoord _cutDim(ConstArrayView< CartCoord > sig)
Méthode permettant de chercher le meilleur point pour effectuer une découpe.
static std::pair< AMRPatchPositionSignature, AMRPatchPositionSignature > cut(const AMRPatchPositionSignature &sig)
Méthode permettant de découper un patch en deux.
Classe permettant de gérer les signatures d'un patch.
ConstArrayView< CartCoord > sigX() const
Méthode permettant de récupérer la signature X.
ConstArrayView< CartCoord > sigZ() const
Méthode permettant de récupérer la signature Z.
Real efficacity() const
Méthode permettant de connaitre l'efficacité du patch.
std::pair< AMRPatchPositionSignature, AMRPatchPositionSignature > cut(Integer dim, CartCoord cut_point) const
Méthode permettant de découper le patch. Le patch n'est pas modifié.
AMRPatchPosition patch() const
Méthode permettant de récupérer une copie du patch.
ConstArrayView< CartCoord > sigY() const
Méthode permettant de récupérer la signature Y.
CartCoord3 minPoint() const
Méthode permettant de récupérer la position min de la boite englobante.
Integer size() const
Nombre d'éléments du vecteur.
void clear()
Supprime les éléments du tableau.
void add(ConstReferenceType val)
Ajoute l'élément val à la fin du tableau.
Vue constante d'un tableau de type T.
constexpr Integer size() const noexcept
Nombre d'éléments du tableau.
Vecteur 1D de données avec sémantique par valeur (style STL).
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
Int32 CartCoord
Représente une coordonnée d'un élément dans la grille cartésienne (en X ou en Y ou en Z).
Int32 Integer
Type représentant un entier.
double Real
Type représentant un réel.