81AMRPatchPositionSignature(
const AMRPatchPosition& patch, ICartesianMesh* cmesh, Integer nb_cut)
98void AMRPatchPositionSignature::
107 if (m_sig_x[0] == 0) {
108 for (; reduce_x_min < m_sig_x.size(); ++reduce_x_min) {
109 if (m_sig_x[reduce_x_min] != 0) {
115 if (m_sig_y[0] == 0) {
116 for (; reduce_y_min < m_sig_y.size(); ++reduce_y_min) {
117 if (m_sig_y[reduce_y_min] != 0) {
123 if (m_sig_z[0] == 0) {
124 for (; reduce_z_min < m_sig_z.size(); ++reduce_z_min) {
125 if (m_sig_z[reduce_z_min] != 0) {
133 CartCoord reduce_x_max = m_sig_x.size() - 1;
134 if (m_sig_x[reduce_x_max] == 0) {
135 for (; reduce_x_max >= 0; --reduce_x_max) {
136 if (m_sig_x[reduce_x_max] != 0) {
141 CartCoord reduce_y_max = m_sig_y.size() - 1;
142 if (m_sig_y[reduce_y_max] == 0) {
143 for (; reduce_y_max >= 0; --reduce_y_max) {
144 if (m_sig_y[reduce_y_max] != 0) {
149 CartCoord reduce_z_max = m_sig_z.size() - 1;
150 if (m_sig_z[reduce_z_max] == 0) {
151 for (; reduce_z_max >= 0; --reduce_z_max) {
152 if (m_sig_z[reduce_z_max] != 0) {
159 if (reduce_x_min != 0 || reduce_x_max != m_sig_x.size()-1) {
161 if (reduce_x_max < reduce_x_min) {
169 patch_min.x += reduce_x_min;
170 patch_max.x = patch_min.x + (reduce_x_max - reduce_x_min);
171 m_patch.setMinPoint(patch_min);
172 m_patch.setMaxPoint(patch_max);
175 if (reduce_y_min != 0 || reduce_y_max != m_sig_y.size()-1) {
176 if (reduce_y_max < reduce_y_min) {
184 patch_min.y += reduce_y_min;
185 patch_max.y = patch_min.y + (reduce_y_max - reduce_y_min);
186 m_patch.setMinPoint(patch_min);
187 m_patch.setMaxPoint(patch_max);
190 if (m_mesh->mesh()->dimension() == 3 && (reduce_z_min != 0 || reduce_z_max != m_sig_z.size() - 1)) {
191 if (reduce_z_max < reduce_z_min) {
199 patch_min.z += reduce_z_min;
200 patch_max.z = patch_min.z + (reduce_z_max - reduce_z_min);
201 m_patch.setMinPoint(patch_min);
202 m_patch.setMaxPoint(patch_max);
209void AMRPatchPositionSignature::
220 ENUMERATE_ (
Cell, icell, m_mesh->mesh()->ownLevelCells(m_patch.level())) {
225 const CartCoord3 pos = m_numbering->cellUniqueIdToCoord(*icell);
226 if (!m_patch.isIn(pos)) {
230 m_sig_x[pos.x - m_patch.minPoint().x]++;
231 m_sig_y[pos.y - m_patch.minPoint().y]++;
232 m_sig_z[pos.z - m_patch.minPoint().z]++;
316Real AMRPatchPositionSignature::
319 if (!m_is_computed) {
321 m_mesh->traceMng()->warning() <<
"Need to be computed";
330 for (
const Int32 elem : m_sig_x) {
334 Real eff =
static_cast<Real>(sum) / (m_sig_x.size() * m_sig_y.size() * m_sig_z.size());
336 if constexpr (TARGET_SIZE == -1 || TARGET_SIZE_WEIGHT_IN_EFFICACITY == 0) {
341 if (m_sig_x.size() <= TARGET_SIZE) {
342 eff_xy =
static_cast<Real>(m_sig_x.size()) / TARGET_SIZE;
344 else if (m_sig_x.size() < TARGET_SIZE*2) {
345 Real size_x = math::abs(m_sig_x.size() - TARGET_SIZE*2);
346 eff_xy = size_x / TARGET_SIZE;
349 if (m_sig_y.size() <= TARGET_SIZE) {
350 eff_xy +=
static_cast<Real>(m_sig_y.size()) / TARGET_SIZE;
352 else if (m_sig_y.size() < TARGET_SIZE * 2) {
353 Real size_y = math::abs(m_sig_y.size() - TARGET_SIZE * 2);
354 eff_xy += size_y / TARGET_SIZE;
357 if (m_mesh->mesh()->dimension() == 2) {
361 if (m_sig_z.size() <= TARGET_SIZE) {
362 eff_xy = (eff_xy + (
static_cast<Real>(m_sig_z.size()) / TARGET_SIZE)) / 3;
364 else if (m_sig_z.size() < TARGET_SIZE * 2) {
365 Real size_z = math::abs(m_sig_z.size() - TARGET_SIZE * 2);
366 eff_xy = (eff_xy + (size_z / TARGET_SIZE)) / 3;
372 eff_xy *= TARGET_SIZE_WEIGHT_IN_EFFICACITY;
374 return (eff+eff_xy)/(1+TARGET_SIZE_WEIGHT_IN_EFFICACITY);
380std::pair<AMRPatchPositionSignature, AMRPatchPositionSignature> AMRPatchPositionSignature::
383 auto [fst, snd] = m_patch.cut(cut_point, dim);
384 return { AMRPatchPositionSignature(fst, m_mesh, m_nb_cut + 1), AMRPatchPositionSignature(snd, m_mesh, m_nb_cut + 1) };